Let’s clarify a bit what Play Mode and Edit Mode test means from the Unity Test Framework perspective:
Edit Mode tests (also known as Editor tests) are only run in the Unity Editor and have access to the Editor code in addition to the game code.
With Edit Mode tests it is possible to test any of your Editor extensions using the UnityTest attribute. For Edit Mode tests, your test code runs in the EditorApplication.update callback loop.
Note: You can also control entering and exiting Play Mode from your Edit Mode test. This allow your test to make changes before entering Play Mode.
Edit Mode tests should meet one of the following conditions:
"includePlatforms": [
"Editor"
],
You can run Play Mode tests as a standalone in a Player or inside the Editor. Play Mode tests allow you to exercise your game code, as the tests run as coroutines if marked with the UnityTest
attribute.
Play Mode tests should correspond to the following conditions:
"references": [
"NewAssembly"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [],
Use the NUnit Test
attribute instead of the UnityTest
attribute, unless you need to yield special instructions, in Edit Mode, or if you need to skip a frame or wait for a certain amount of time in Play Mode.
It is possible for your Test Assemblies to reference the test tools in UnityEngine.TestRunner
and UnityEditor.TestRunner
. The latter is only available in Edit Mode. You can specify these references in the Assembly Definition References
on the Assembly Definition.