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()); }
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()); }
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()); }
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()); }
public void StartTestRun(TestFilter filter, ITestRunnerCallback eventListener) { var callbackList = new TestRunnerCallbackList(); if (eventListener != null) { callbackList.Add(eventListener); } testEngine.RunTests(filter, callbackList); }
public static void StartTestRun(string[] testsToRunList, ITestRunnerCallback eventListener, bool performUndo) { #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if (performUndo) { Undo.RegisterSceneUndo("UnitTestRunSceneSave"); } #else var undoGroup = Undo.GetCurrentGroup(); #endif var callbackList = new TestRunnerCallbackList(); if (eventListener != null) { callbackList.Add(eventListener); } try { foreach (var unitTestEngine in TestEngines) { unitTestEngine.RunTests(testsToRunList, callbackList); } } catch (Exception e) { Debug.LogException(e); callbackList.RunFinishedException(e); } finally { if (performUndo) { var undoStartTime = DateTime.Now; #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 Undo.PerformUndo(); #else Undo.RevertAllDownToGroup(undoGroup); #endif if ((DateTime.Now - undoStartTime).Seconds > 1) { Debug.LogWarning("Undo after unit test run took " + (DateTime.Now - undoStartTime).Seconds + " seconds. Consider running unit tests on a new scene for better performance."); } } EditorUtility.ClearProgressBar(); if (UnityEditorInternal.InternalEditorUtility.inBatchMode) { EditorApplication.Exit(0); } } }
private void StartTestRun() { var okToRun = true; if (runTestOnANewScene && !UnityEditorInternal.InternalEditorUtility.inBatchMode) { if (autoSaveSceneBeforeRun) { EditorApplication.SaveScene(); } okToRun = EditorApplication.SaveCurrentSceneIfUserWantsTo(); } if (okToRun) { var currentScene = EditorApplication.currentScene; if (runTestOnANewScene || UnityEditorInternal.InternalEditorUtility.inBatchMode) { EditorApplication.NewScene(); } var callbackList = new TestRunnerCallbackList(); callbackList.Add(new TestRunnerEventListener(this)); try { foreach (var unitTestEngine in testEngines) { unitTestEngine.RunTests(testsToRunList, callbackList); } } catch (Exception e) { Debug.LogException(e); callbackList.RunFinishedException(e); } finally { EditorUtility.ClearProgressBar(); if (runTestOnANewScene && !UnityEditorInternal.InternalEditorUtility.inBatchMode) { EditorApplication.OpenScene(currentScene); } if (UnityEditorInternal.InternalEditorUtility.inBatchMode) { EditorApplication.Exit(0); } shouldUpdateTestList = true; } } }