TestResult TestMode is always 0 even for PlayMode tests

I’m registering a class that implements ICallbacks to receive RunsTarted, TestStarted and RunFinished. Within those callbacks I would like to differentiate between EditMode and PlayMode tests. Conveniently, all of the Adaptor classes have the Test.TestMode property which seems like an easy way to retrieve the information.

However, in my tests, the test mode is always reported as the value “0” (number zero), even when running PlayMode tests. The enum declaration defines value 0 for EditMode and value 2 for PlayMode. But no matter how I start the test run (via the test runner window or scripting), the value is always 0.

Is this a bug or some limitation or is there some special setup I need to consider?

I am not sure about the value you’re getting (did you try checking the UTF source code ?)

Are you starting your tests using the scripting API? in this case you are specifying which Filter you want to use (E.g: which tests to run - EditMode or PlayMode), did you try to reuse this information and pass it on to your ICallbacks implementation ?

Thanks anyway! I’ve reported this internally and it was deemed a bug that will be fixed in the future, sorry no issue id to share at the moment.

Another possible workaround, in case anyone needs it: it’s possible to traverse the entire hierarchy of tests and search for any test mode which is “PlayMode”. If at least one is found, the entire suite was a PlayMode run, if none are found in children and parents, then it was EditMode.