Search Unity

Resolved Is it possible to use the same tests in both Edit Mode and Play Mode?

Discussion in 'Testing & Automation' started by Kybernetik, Aug 25, 2019.

  1. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    I've made an animation system called Animancer which uses the Playables API and has the ability to play animations in both Edit Mode and Play Mode so I would like to make my tests runnable in both modes, but I can't figure out how to do so. Setting my assembly definition to "Any Platform" makes it only show up in the Play Mode tab of the Test Runner and setting it to "Editor" only makes it only show up in the Edit Mode tab, but never both.
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    We don't support having a single test available in both modes. What I suggest is that you create your tests as Playmode tests, and then create test classes in your Editor tests assembly which inherit from the test classes in your Playmode assembly.
     
  3. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    That seems to work well enough.

    Apparently it doesn't support WaitForSeconds in Edit Mode though, so I'm going to have to just yield null repeatedly and implement my own timer. Can you think of any better alternative or are there any plans to implement such a feature in the near future?
     
  4. leni8ec

    leni8ec

    Joined:
    May 23, 2013
    Posts:
    24
    `WaitForSecondsRealtime` - is worked for me