Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. The Burst compiler has its own forum section now.
    Dismiss Notice
  3. 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


    Nov 20, 2015

    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


    Drink more water! Unity Technologies

    Jan 16, 2011
    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.