コード例 #1
0
ファイル: TestRunner.cs プロジェクト: smdx24/CPI-Source-Code
        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());
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        public void StartTestRun(TestFilter filter, ITestRunnerCallback eventListener)
        {
            var callbackList = new TestRunnerCallbackList();

            if (eventListener != null)
            {
                callbackList.Add(eventListener);
            }
            testEngine.RunTests(filter, callbackList);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
ファイル: Batch.cs プロジェクト: CarlosHBC/UnityDecompiled
 /// <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);
 }
コード例 #7
0
        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));
        }
コード例 #8
0
ファイル: Batch.cs プロジェクト: twenty0ne/UnityDecompiled
        /// <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);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
ファイル: NUnitTestEngine.cs プロジェクト: LostLT/TestTools
        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);
            }
        }
コード例 #11
0
		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);
			}
		}
コード例 #12
0
ファイル: Batch.cs プロジェクト: CarlosHBC/UnityDecompiled
 /// <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);
 }
コード例 #13
0
ファイル: Batch.cs プロジェクト: CarlosHBC/UnityDecompiled
 public TestRunnerEventListener(string resultFilePath, ITestRunnerCallback verboseTestLogger)
 {
     this.m_ResultFilePath = resultFilePath;
     this.m_Results = new List<EditorTestResult>();
     this.m_VerboseTestLogger = verboseTestLogger;
 }
コード例 #14
0
 public void Add(ITestRunnerCallback callback)
 {
     m_CallbackList.Add(callback);
 }
コード例 #15
0
 public void Remove(ITestRunnerCallback callback)
 {
     m_CallbackList.Remove(callback);
 }
コード例 #16
0
 public TestRunnerEventListener(ITestRunnerCallback testRunnerEventListener)
 {
     m_TestRunnerEventListener = testRunnerEventListener;
 }
コード例 #17
0
ファイル: TestRunner.cs プロジェクト: serenitii/jeisimple
 public void StartTestRun(TestFilter filter, ITestRunnerCallback eventListener)
 {
     var callbackList = new TestRunnerCallbackList();
     if (eventListener != null) callbackList.Add(eventListener);
     k_TestEngine.RunTests(filter, callbackList);
 }
コード例 #18
0
 public void RunTests(ITestRunnerCallback testRunnerEventListener)
 {
     RunTests(TestFilter.Empty, testRunnerEventListener);
 }
コード例 #19
0
ファイル: NUnitTestEngine.cs プロジェクト: LostLT/TestTools
        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));
        }
コード例 #20
0
 public void Remove(ITestRunnerCallback callback)
 {
     this.m_CallbackList.Remove(callback);
 }
コード例 #21
0
ファイル: NUnitTestEngine.cs プロジェクト: LostLT/TestTools
 public TestRunnerEventListener(ITestRunnerCallback testRunnerEventListener)
 {
     m_TestRunnerEventListener = testRunnerEventListener;
 }
コード例 #22
0
ファイル: NUnitTestEngine.cs プロジェクト: LostLT/TestTools
 public void RunTests(ITestRunnerCallback testRunnerEventListener)
 {
     RunTests(TestFilter.Empty, testRunnerEventListener);
 }
コード例 #23
0
 public void Add(ITestRunnerCallback callback)
 {
     this.m_CallbackList.Add(callback);
 }
コード例 #24
0
ファイル: Batch.cs プロジェクト: twenty0ne/UnityDecompiled
 public TestRunnerEventListener(string resultFilePath, ITestRunnerCallback verboseTestLogger)
 {
     this.m_ResultFilePath    = resultFilePath;
     this.m_Results           = new List <EditorTestResult>();
     this.m_VerboseTestLogger = verboseTestLogger;
 }
コード例 #25
0
ファイル: Batch.cs プロジェクト: twenty0ne/UnityDecompiled
 /// <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);
 }
コード例 #26
0
 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));
 }