- Home /
Application.isPlaying in Test Runner - Check if running Test Runner
I've been using Application.isPlaying
in some of my scripts to check whether the game is running or unit tests are. (This allows me to execute alternative behaviours and return dummy values for Unity API stuff, like FindObjectsOfType
.)
However, while batch testing, the Test Runner might move away from the main thread, making Application.isPlaying
calls illegal. This leaves me with tests that succeed if run on their own, but that might fail if run in a batch.
What's the simplest way to check whether I'm running a unit test ?
Same here! I need to know if there is a built-in way to check if a UnityTest is running / App is playing from Test Runner. Now you can have a static boolean workaround so that your [UnityTest] or [SetUp] function will set the boolean to true and you must check that from your App scripts in runtime to know whether a UnityTest is running.
Your answer
Follow this Question
Related Questions
How to mock or skip execution of Awake in playmode unit tests? 2 Answers
Unit Testing Rigidbody2D without polluting scene with gameobjects 1 Answer
Load scene/prefab when running a test through the test runner 1 Answer
Monobehaviour.Start() is called when Playmode tests are executed 0 Answers
MSTools instead of NUnit 0 Answers