Exemplo n.º 1
0
        private void StartNewTest()
        {
            m_TestMessages      = "";
            m_Stacktrace        = "";
            m_TestState         = TestState.Running;
            m_AssertionsToCheck = null;

            m_StartTime = Time.time;
            currentTest = m_TestsProvider.GetNextTest() as TestComponent;

            var testResult = m_ResultList.Single(result => result.TestComponent == currentTest);

            if (currentTest != null && currentTest.ShouldSucceedOnAssertions())
            {
                var assertionList = currentTest.gameObject.GetComponentsInChildren <AssertionComponent>().Where(a => a.enabled);
                if (assertionList.Any())
                {
                    m_AssertionsToCheck = assertionList.ToArray();
                }
            }

            if (currentTest != null && currentTest.IsExludedOnThisPlatform())
            {
                m_TestState = TestState.Ignored;
                Debug.Log(currentTest.gameObject.name + " is excluded on this platform");
            }

            // don't ignore test if user initiated it from the runner and it's the only test that is being run
            if (currentTest != null &&
                (currentTest.IsIgnored() &&
                 !(isInitializedByRunner && m_ResultList.Count == 1)))
            {
                m_TestState = TestState.Ignored;
            }

            LogMessage(k_StartedMessage);
            TestRunnerCallback.TestStarted(testResult);
        }
Exemplo n.º 2
0
        public IEnumerator StateMachine()
        {
            TestRunnerCallback.RunStarted(Application.platform.ToString(), m_TestComponents);
            while (true)
            {
                if (!m_TestsProvider.AnyTestsLeft() && currentTest == null)
                {
                    FinishTestRun();
                    yield break;
                }
                if (currentTest == null)
                {
                    StartNewTest();
                }
                if (currentTest != null)
                {
                    if (m_TestState == TestState.Running)
                    {
                        if (currentTest.ShouldSucceedOnAssertions())
                        {
                            var assertionsToCheck = currentTest.gameObject.GetComponentsInChildren <AssertionComponent>().Where(a => a.enabled).ToArray();
                            if (assertionsToCheck.Any() && assertionsToCheck.All(a => a.checksPerformed > 0))
                            {
                                IntegrationTest.Pass(currentTest.gameObject);
                                m_TestState = TestState.Success;
                            }
                        }
                        if (currentTest != null && Time.time > m_StartTime + currentTest.GetTimeout())
                        {
                            m_TestState = TestState.Timeout;
                        }
                    }

                    switch (m_TestState)
                    {
                    case TestState.Success:
                        LogMessage(k_FinishedMessage);
                        FinishTest(TestResult.ResultType.Success);
                        break;

                    case TestState.Failure:
                        LogMessage(k_FailedMessage);
                        FinishTest(TestResult.ResultType.Failed);
                        break;

                    case TestState.Exception:
                        LogMessage(k_FailedExceptionMessage);
                        FinishTest(TestResult.ResultType.FailedException);
                        break;

                    case TestState.Timeout:
                        LogMessage(k_TimeoutMessage);
                        FinishTest(TestResult.ResultType.Timeout);
                        break;

                    case TestState.Ignored:
                        LogMessage(k_IgnoredMessage);
                        FinishTest(TestResult.ResultType.Ignored);
                        break;
                    }
                }
                yield return(null);
            }
        }
Exemplo n.º 3
0
		private void StartNewTest ()
		{
			this.testMessages = "";
			this.stacktrace = "";
			testState = TestState.Running;
			assertionsToCheck = null;

			startTime = Time.time;
			currentTest = testsProvider.GetNextTest () as TestComponent;

			var testResult = resultList.Single (result => result.TestComponent == currentTest);
			
			if (currentTest.ShouldSucceedOnAssertions ())
			{
				var assertionList = currentTest.gameObject.GetComponentsInChildren<AssertionComponent> ().Where (a => a.enabled);
				if(assertionList.Any())
					assertionsToCheck = assertionList.ToArray();
			}

			if (currentTest.IsExludedOnThisPlatform ())
			{
				testState = TestState.Ignored;
				Debug.Log(currentTest.gameObject.name + " is excluded on this platform");
			}

			//don't ignore test if user initiated it from the runner and it's the only test that is being run
			if (currentTest.IsIgnored () && !(isInitializedByRunner && resultList.Count == 1)) testState = TestState.Ignored;

			LogMessage(startedMessage);
			TestRunnerCallback.TestStarted (testResult);
		}
Exemplo n.º 4
0
        public IEnumerator StateMachine()
        {
            TestRunnerCallback.RunStarted(Application.platform.ToString(), m_TestComponents);
            while (m_TestsProvider.AnyTestsLeft() || !(currentTest == null))
            {
                if (currentTest == null)
                {
                    StartNewTest();
                }
                if (currentTest != null)
                {
                    if (m_TestState == TestState.Running)
                    {
                        if (currentTest.ShouldSucceedOnAssertions())
                        {
                            AssertionComponent[] source = (from a in currentTest.gameObject.GetComponentsInChildren <AssertionComponent>()
                                                           where a.enabled
                                                           select a).ToArray();
                            if (source.Any() && source.All((AssertionComponent a) => a.checksPerformed > 0))
                            {
                                IntegrationTest.Pass(currentTest.gameObject);
                                m_TestState = TestState.Success;
                            }
                        }
                        if (currentTest != null && (double)Time.time > m_StartTime + currentTest.GetTimeout())
                        {
                            m_TestState = TestState.Timeout;
                        }
                    }
                    switch (m_TestState)
                    {
                    case TestState.Success:
                        LogMessage("IntegrationTest Finished");
                        FinishTest(TestResult.ResultType.Success);
                        break;

                    case TestState.Failure:
                        LogMessage("IntegrationTest Failed");
                        FinishTest(TestResult.ResultType.Failed);
                        break;

                    case TestState.Exception:
                        LogMessage("IntegrationTest Failed with exception");
                        FinishTest(TestResult.ResultType.FailedException);
                        break;

                    case TestState.Timeout:
                        LogMessage("IntegrationTest Timeout");
                        FinishTest(TestResult.ResultType.Timeout);
                        break;

                    case TestState.Ignored:
                        LogMessage("IntegrationTest Ignored");
                        FinishTest(TestResult.ResultType.Ignored);
                        break;
                    }
                }
                yield return(null);
            }
            FinishTestRun();
        }