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 RunTests(TestFilter filter, ITestRunnerCallback testRunnerEventListener) { try { if (testRunnerEventListener != null) { testRunnerEventListener.RunStarted(m_TestSuite.TestName.FullName, m_TestSuite.TestCount); } ExecuteTestSuite(m_TestSuite, testRunnerEventListener, filter); if (testRunnerEventListener != null) { testRunnerEventListener.RunFinished(); } } catch (Exception e) { Debug.LogException(e); if (testRunnerEventListener != null) { testRunnerEventListener.RunFinishedException(e); } } }
public void StartTestRun(TestFilter filter, ITestRunnerCallback eventListener) { var callbackList = new TestRunnerCallbackList(); if (eventListener != null) { callbackList.Add(eventListener); } testEngine.RunTests(filter, callbackList); }
private void ExecuteTestSuite(TestSuite suite, ITestRunnerCallback testRunnerEventListener, TestFilter filter) { EventListener eventListener; if (testRunnerEventListener == null) { eventListener = new NullListener(); } else { eventListener = new TestRunnerEventListener(testRunnerEventListener); } suite.Run(eventListener, GetFilter(filter)); }
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); } } }
/// <summary> /// <para>Execute editor tests run.</para> /// </summary> /// <param name="testRunnerCallback">Test runner callback.</param> /// <param name="nameFilter">Test names to run.</param> /// <param name="categoryFilter">Categories to run.</param> public static void RunTests(ITestRunnerCallback testRunnerCallback, string[] nameFilter, string[] categoryFilter) { TestRunnerFilter filter = new TestRunnerFilter { names = nameFilter, categories = categoryFilter }; NUnitTestEngine engine = new NUnitTestEngine(); if (engine.testSuite == null) { Debug.Log("No tests were found. Compilation error?"); EditorApplication.Exit(3); } new TestListBuilder().GetTests(engine.testSuite, null); engine.RunTests(filter, testRunnerCallback); }
private void ExecuteTestSuite(TestSuite suite, ITestRunnerCallback testRunnerEventListener, TestRunnerFilter filter) { EventListener listener; if (testRunnerEventListener == null) { listener = new NullListener(); } else { listener = new TestRunnerEventListener(testRunnerEventListener); } TestExecutionContext.get_CurrentContext().set_Out(new EventListenerTextWriter(listener, 0)); TestExecutionContext.get_CurrentContext().set_Error(new EventListenerTextWriter(listener, 1)); suite.Run(listener, this.GetFilter(filter)); }
private void ExecuteTestSuite(TestSuite suite, ITestRunnerCallback testRunnerEventListener, TestFilter filter) { EventListener eventListener; if (testRunnerEventListener == null) { eventListener = new NullListener(); } else { eventListener = new TestRunnerEventListener(testRunnerEventListener); } TestExecutionContext.CurrentContext.Out = new EventListenerTextWriter(eventListener, TestOutputType.Out); TestExecutionContext.CurrentContext.Error = new EventListenerTextWriter(eventListener, TestOutputType.Error); suite.Run(eventListener, GetFilter(filter)); }
public void RunTests(TestFilter filter, ITestRunnerCallback testRunnerEventListener) { try { if (testRunnerEventListener != null) testRunnerEventListener.RunStarted(m_TestSuite.TestName.FullName, m_TestSuite.TestCount); ExecuteTestSuite(m_TestSuite, testRunnerEventListener, filter); if (testRunnerEventListener != null) testRunnerEventListener.RunFinished(); } catch (Exception e) { Debug.LogException(e); if (testRunnerEventListener != null) testRunnerEventListener.RunFinishedException(e); } }
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); } }
/// <summary> /// <para>Execute editor tests run.</para> /// </summary> /// <param name="testRunnerCallback">Test runner callback.</param> /// <param name="nameFilter">Test names to run.</param> /// <param name="categoryFilter">Categories to run.</param> public static void RunTests(ITestRunnerCallback testRunnerCallback) { RunTests(testRunnerCallback, null, null); }
public TestRunnerEventListener(string resultFilePath, ITestRunnerCallback verboseTestLogger) { this.m_ResultFilePath = resultFilePath; this.m_Results = new List<EditorTestResult>(); this.m_VerboseTestLogger = verboseTestLogger; }
public void Add(ITestRunnerCallback callback) { m_CallbackList.Add(callback); }
public void Remove(ITestRunnerCallback callback) { m_CallbackList.Remove(callback); }
public TestRunnerEventListener(ITestRunnerCallback testRunnerEventListener) { m_TestRunnerEventListener = testRunnerEventListener; }
public void StartTestRun(TestFilter filter, ITestRunnerCallback eventListener) { var callbackList = new TestRunnerCallbackList(); if (eventListener != null) callbackList.Add(eventListener); k_TestEngine.RunTests(filter, callbackList); }
public void RunTests(ITestRunnerCallback testRunnerEventListener) { RunTests(TestFilter.Empty, testRunnerEventListener); }
private void ExecuteTestSuite(TestSuite suite, ITestRunnerCallback testRunnerEventListener, TestFilter filter) { EventListener eventListener; if (testRunnerEventListener == null) eventListener = new NullListener(); else eventListener = new TestRunnerEventListener(testRunnerEventListener); TestExecutionContext.CurrentContext.Out = new EventListenerTextWriter(eventListener, TestOutputType.Out); TestExecutionContext.CurrentContext.Error = new EventListenerTextWriter(eventListener, TestOutputType.Error); suite.Run(eventListener, GetFilter(filter)); }
public void Remove(ITestRunnerCallback callback) { this.m_CallbackList.Remove(callback); }
public void Add(ITestRunnerCallback callback) { this.m_CallbackList.Add(callback); }
public TestRunnerEventListener(string resultFilePath, ITestRunnerCallback verboseTestLogger) { this.m_ResultFilePath = resultFilePath; this.m_Results = new List <EditorTestResult>(); this.m_VerboseTestLogger = verboseTestLogger; }
private void ExecuteTestSuite(TestSuite suite, ITestRunnerCallback testRunnerEventListener, TestFilter filter) { EventListener eventListener; if (testRunnerEventListener == null) eventListener = new NullListener(); else eventListener = new TestRunnerEventListener(testRunnerEventListener); suite.Run(eventListener, GetFilter(filter)); }