Search Unity

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:
    515
    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

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,184
    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:
    515
    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?