Ejemplo n.º 1
0
        public void Start()
        {
            // Preventing OnDestroy call with invalid internal state
            currentTest = null;

            if (isInitializedByRunner)
            {
                return;
            }

            if (m_Configurator.sendResultsOverNetwork)
            {
                var nrs = m_Configurator.ResolveNetworkConnection();
                if (nrs != null)
                {
                    TestRunnerCallback.Add(nrs);
                }
            }

            TestComponent.DestroyAllDynamicTests();
            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name);

            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
Ejemplo n.º 2
0
        public void Start()
        {
            if (isInitializedByRunner)
            {
                return;
            }

            if (m_Configurator.sendResultsOverNetwork)
            {
                var nrs = m_Configurator.ResolveNetworkConnection();
                if (nrs != null)
                {
                    TestRunnerCallback.Add(nrs);
                }
            }

            TestComponent.DestroyAllDynamicTests();
            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName);

            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
Ejemplo n.º 3
0
        public void Start()
        {
            if (isInitializedByRunner)
            {
                return;
            }

            if (m_Configurator.sendResultsOverNetwork)
            {
                var nrs = m_Configurator.ResolveNetworkConnection();
                if (nrs != null)
                {
                    TestRunnerCallback.Add(nrs);
                }
            }

            TestComponent.DestroyAllDynamicTests();

#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            var loadedLevelName = Application.loadedLevelName;
#else
            var loadedLevelName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
#endif

            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(loadedLevelName);
            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
Ejemplo n.º 4
0
        public void Start()
        {
            Debug.Log("TestRunner.Start");
            if (isInitializedByRunner)
            {
                return;
            }
            if (m_Configurator.sendResultsOverNetwork)
            {
                ITestRunnerCallback testRunnerCallback = m_Configurator.ResolveNetworkConnection();
                if (testRunnerCallback != null)
                {
                    TestRunnerCallback.Add(testRunnerCallback);
                }
            }
            TestComponent.DestroyAllDynamicTests();
            IEnumerable <Type> typesWithHelpAttribute = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name);

            foreach (Type item in typesWithHelpAttribute)
            {
                TestComponent.CreateDynamicTest(item);
            }
            List <TestComponent> list = TestComponent.FindAllTestsOnScene();

            Debug.Log("Found tests in scene:\n" + string.Join("\n", list.Select((TestComponent t) => t.Name).ToArray()));
            InitRunner(list, typesWithHelpAttribute.Select((Type type) => type.AssemblyQualifiedName).ToList());
        }
        private void RebuildTestList()
        {
            testLines = null;
            if (!TestComponent.AnyTestsOnScene())
            {
                return;
            }

            if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                var dynamicTestsOnScene = TestComponent.FindAllDynamicTestsOnScene();
                var dynamicTestTypes    = TestComponent.GetTypesWithHelpAttribute(EditorApplication.currentScene);

                foreach (var dynamicTestType in dynamicTestTypes)
                {
                    var existingTests = dynamicTestsOnScene.Where(component => component.dynamicTypeName == dynamicTestType.AssemblyQualifiedName);
                    if (existingTests.Any())
                    {
                        dynamicTestsOnScene.Remove(existingTests.Single());
                        continue;
                    }
                    TestComponent.CreateDynamicTest(dynamicTestType);
                }

                foreach (var testComponent in dynamicTestsOnScene)
                {
                    DestroyImmediate(testComponent.gameObject);
                }
            }

            var topTestList = TestComponent.FindAllTopTestsOnScene();

            var newResultList = new List <TestResult> ();

            testLines = ParseTestList(topTestList, newResultList);

            var oldDynamicResults = resultList.Where(result => result.dynamicTest);

            foreach (var oldResult in resultList)
            {
                var result = newResultList.Find(r => r.Id == oldResult.Id);
                if (result == null)
                {
                    continue;
                }
                result.Update(oldResult);
            }
            newResultList.AddRange(oldDynamicResults.Where(r => !newResultList.Contains(r)));
            resultList = newResultList;

            IntegrationTestRendererBase.RunTest  = RunTests;
            IntegrationTestGroupLine.FoldMarkers = foldMarkers;
            IntegrationTestLine.Results          = resultList;

            foldMarkers.RemoveAll(o => o == null);

            selectedInHierarchy = true;
            Repaint();
        }
Ejemplo n.º 6
0
        public static bool AnyDynamicTestForCurrentScene()
        {
#if UNITY_EDITOR
            return(TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name).Any());
#else
            return(TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name).Any());
#endif
        }
Ejemplo n.º 7
0
        public static bool AnyDynamicTestForCurrentScene()
        {
#if UNITY_EDITOR
            return(TestComponent.GetTypesWithHelpAttribute(EditorApplication.currentScene).Any());
#else
            return(TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName).Any());
#endif
        }
Ejemplo n.º 8
0
        public static bool AnyDynamicTestForCurrentScene()
        {
#if UNITY_5_3_OR_NEWER
            return(TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name).Any());
#else
            return(TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName).Any());
#endif
        }
Ejemplo n.º 9
0
        public static bool AnyDynamicTestForCurrentScene()
        {
#if UNITY_EDITOR
#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            var currentScene = EditorApplication.currentScene;
#else
            var currentScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
#endif

            return(TestComponent.GetTypesWithHelpAttribute(currentScene).Any());
#else
            return(TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName).Any());
#endif
        }
Ejemplo n.º 10
0
        public void Start()
        {
#if UNITY_EDITOR && !IMITATE_BATCH_MODE
            if (!UnityEditorInternal.InternalEditorUtility.inBatchMode)
            {
                return;
            }
#endif
            TestComponent.DestroyAllDynamicTests();
            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName);
            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
        private void RebuildTestList()
        {
            m_TestLines = null;
            if (!TestComponent.AnyTestsOnScene() &&
                !TestComponent.AnyDynamicTestForCurrentScene())
            {
                return;
            }

            if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                var dynamicTestsOnScene = TestComponent.FindAllDynamicTestsOnScene();
                var dynamicTestTypes    = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().path);

                foreach (var dynamicTestType in dynamicTestTypes)
                {
                    var existingTests = dynamicTestsOnScene.Where(component => component.dynamicTypeName == dynamicTestType.AssemblyQualifiedName);
                    if (existingTests.Any())
                    {
                        var testComponent = existingTests.Single();
                        foreach (var c in testComponent.gameObject.GetComponents <Component>())
                        {
                            var type = Type.GetType(testComponent.dynamicTypeName);
                            if (c is TestComponent || c is Transform || type.IsInstanceOfType(c))
                            {
                                continue;
                            }
                            DestroyImmediate(c);
                        }
                        dynamicTestsOnScene.Remove(existingTests.Single());
                        continue;
                    }
                    TestComponent.CreateDynamicTest(dynamicTestType);
                }

                foreach (var testComponent in dynamicTestsOnScene)
                {
                    DestroyImmediate(testComponent.gameObject);
                }
            }

            var topTestList = TestComponent.FindAllTopTestsOnScene();

            var newResultList = new List <TestResult>();

            m_TestLines = ParseTestList(topTestList, newResultList);

            var oldDynamicResults = m_ResultList.Where(result => result.dynamicTest);

            foreach (var oldResult in m_ResultList)
            {
                var result = newResultList.Find(r => r.Id == oldResult.Id);
                if (result == null)
                {
                    continue;
                }
                result.Update(oldResult);
            }
            newResultList.AddRange(oldDynamicResults.Where(r => !newResultList.Contains(r)));
            m_ResultList = newResultList;

            IntegrationTestRendererBase.RunTest  = RunTests;
            IntegrationTestGroupLine.FoldMarkers = m_FoldMarkers;
            IntegrationTestLine.Results          = m_ResultList;

            m_FilterSettings.UpdateCounters(m_ResultList.Cast <ITestResult>());

            m_FoldMarkers.RemoveAll(o => o == null);

            selectedInHierarchy = true;
            Repaint();
        }