Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Ignore UNITY_EDITOR when running edit mode tests

Discussion in 'Testing & Automation' started by firegate666, Jan 30, 2020.

  1. firegate666

    firegate666

    Joined:
    Nov 20, 2015
    Posts:
    17
    Hello,

    we recently run into an issue where code was accidentally wrapped in #if UNITY_EDITOR. This resulted on our builds failing because of missing declaration for variables. Took some time to track this down.

    On our pull requests we have edit mode tests running make sure nothing breaks before we merge. Unfortunately since these are running in editor, they didn't spot it.

    Is there any way to teach the edit mode tests (we are running them in directly from the console with -runTests) to ignore #if UNITY_EDITOR, so to behave as if they weren't editor?

    Or any other suggestion how to add a testing method to spot those errors?
     
  2. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,337
    It sounds like simply having your PRs actually do a build of your project (to whichever platform is fastest) would catch this kind of problem. You could potentially even temporarily wipe out the scene list in order to minimise the amount of time spent building content.
     
unityunity