I am using unity inbuild tool Editor Tests Runner and trying to run test cases in game play mode

I am using unity inbuild tool Editor Tests Runner and trying to execute test cases when game is in play mode. Getting below error:

InvalidOperationException: This cannot be used during play mode, please use SceneManager.CreateNewScene() instead.

UnityEditor.SceneManagement.EditorSceneManager.NewScene (NewSceneSetup setup, NewSceneMode mode) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorSceneManagerBindings.gen.cs:47)

UnityEditor.EditorTestsRunner.EditorTestsRunnerWindow.OpenNewScene () (at C:/buildslave/unity/build/Extensions/EditorTestsRunner/UnityEditor.EditorTestsRunner/TestRunner/EditorTestsRunnerWindow.cs:392)

UnityEditor.EditorTestsRunner.EditorTestsRunnerWindow.RunTests (UnityEditor.EditorTestsRunner.TestRunnerFilter filter) (at C:/buildslave/unity/build/Extensions/EditorTestsRunner/UnityEditor.EditorTestsRunner/TestRunner/EditorTestsRunnerWindow.cs:368)

UnityEditor.EditorTestsRunner.EditorTestsRunnerWindow.RunTests (NUnit.Core.TestName[ ] tests) (at C:/buildslave/unity/build/Extensions/EditorTestsRunner/UnityEditor.EditorTestsRunner/TestRunner/EditorTestsRunnerWindow.cs:357)

UnityEditor.EditorTestsRunner.EditorTestsRunnerWindow+c*AnonStorey1.<>m*7 (System.Object data) (at C:/buildslave/unity/build/Extensions/EditorTestsRunner/UnityEditor.EditorTestsRunner/TestRunner/EditorTestsRunnerWindow.cs:232)

UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[ ] options, Int32 selected) (at C:/buildslave/unity/build/artifacts/generated/common/editor/GenericMenuBindings.gen.cs:122)

Can you provide me solution of this.

By default, the test runner runs all tests in a new scene.
The scene it runs on is a temporary one, generated before running the tests (judging by the stack trace you posted).

This cannot work while in play mode. Is there any particular reason you have to run your tests in play mode ?

1 Like

Hi,
I wanted to do game testing so actual testing will be in Game Play mode right? like if m script runs on game play mode then it should be real environment testing. Game Play means in unity we have run button at the top right. On pressing it should game home screen. on that i wanted to run my script.

code is copied at https://drive.google.com/file/d/0B3TIRYVY5uBkNi1jTm5wSmVzZWc/view. please have a look.