Test runner errors InvalidOperationException and TreeView root item is null
Hi
I'm trying to use tests in my project. I'm working on newest Unity version - 2017.2.0f3. I've encountered some errors that I have no idea how to resolve. If someone could help me it would be really great. Basically every time I open Test Runner I get two errors:
InvalidOperationException: Operation is not valid due to the current state of the object
System.Linq.Enumerable.Single[PrecompiledAssembly] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback)
System.Linq.Enumerable.SingleOrDefault[PrecompiledAssembly] (IEnumerable`1 source, System.Func`2 predicate)
UnityEditor.TestTools.TestRunner.TestInEditorTestAssemblyProvider.AssemblySelector (System.String assemblyPath) (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEditor.TestRunner/TestRunner/Utils/TestInEditorTestAssemblyProvider.cs:41)
System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[System.String].MoveNext ()
System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[System.String,System.String].MoveNext ()
System.Collections.Generic.List`1[System.String].AddEnumerable (IEnumerable`1 enumerable) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:128)
System.Collections.Generic.List`1[System.String]..ctor (IEnumerable`1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:65)
System.Linq.Enumerable.ToList[String] (IEnumerable`1 source)
UnityEngine.TestTools.Utils.TestAssemblyProviderHelper.GetUserAssemblies (System.Func`2 assemblySelector, System.Func`2 selector) (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEngine.TestRunner/Utils/TestAssemblyProviderHelper.cs:45)
UnityEditor.TestTools.TestRunner.TestInEditorTestAssemblyProvider.GetUserAssemblies () (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEditor.TestRunner/TestRunner/Utils/TestInEditorTestAssemblyProvider.cs:30)
UnityEditor.TestTools.TestRunner.TestInEditorTestAssemblyProvider.GetTestsWithNUnit () (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEditor.TestRunner/TestRunner/Utils/TestInEditorTestAssemblyProvider.cs:23)
UnityEditor.TestTools.TestRunner.GUI.PlayModeTestListGUI.GetTestListNUnit () (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEditor.TestRunner/GUI/Views/PlayModeTestListGUI.cs:86)
UnityEditor.TestTools.TestRunner.GUI.TestListTreeViewDataSource.FetchData () (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEditor.TestRunner/GUI/TestListTreeView/TestListTreeViewDataSource.cs:27)
UnityEditor.IMGUI.Controls.TreeViewDataSource.ReloadData () (at C:/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewDataSource.cs:53)
UnityEditor.IMGUI.Controls.TreeViewController.ReloadData () (at C:/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewController.cs:266)
UnityEditor.TestTools.TestRunner.GUI.TestListGUI.Reload () (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEditor.TestRunner/GUI/Views/TestListGUIBase.cs:147)
UnityEditor.TestTools.TestRunner.TestRunnerWindow.OnEnable () (at C:/buildslave/unity/build/Extensions/TestRunner/UnityEditor.TestRunner/TestRunnerWindow.cs:113)
and the second one:
TreeView root item is null. Ensure that your TreeViewDataSource sets up at least a root item.
UnityEditor.TestTools.TestRunner.TestRunnerWindow:CompilationCallback()
I get these errors with or without any written tests in project. For the record the project is new and clean, I'm using some third party libraries: Entitas, FMOD, Firebase and Crashlytics.
If you can help me in any way I will really appreciate it, thanks!,
Hey. I have tried to reproduce the issue using Unity 2017.2.0f3 on a clean project, without any luck. Do you still get the error if you try to run without the mentioned third party libraries?
Hi, thanks for an idea! I tried to remove libs from project and indeed - Entitas was the problem. I also tried to add Entitas to clean project and the same thing happened. So i guess I'm doing something wrong with Entitas config or there is a bug in latest release - i will report it on Entitas forum.
Thanks again for help
Answer by ericksson · Nov 27, 2017 at 11:23 AM
Unity Test Tools are not officially supported anymore. Since Unity 5.6 or so, you can write unit tests in Unity directly using the Test Runner: https://docs.unity3d.com/Manual/testing-editortestsrunner.html
I suggest you stick with that. The tools have much improved in subsequent Unity versions, so going to the latest Unity release is probably best.
Sorry, my mistake, I was talking about Test Runner from newest Unity, that's where I get my errors.
Your answer
Follow this Question
Related Questions
Unity-iPhone has Conflicting Provisioning Settings? 4 Answers
Black Screen when I click to run the game project 0 Answers
Simulate InputSystem mouse events 0 Answers
PlayMode tests stop Unity Cloud Builds from working 1 Answer
Terrible Unity testing graphics quality,Terrible Graphics Quality When Testing Project 0 Answers