SharpUnit.UnityTestCase.Run C# (CSharp) Method

Run() public method

public Run ( TestResult result ) : IEnumerator
result TestResult
return IEnumerator
        public IEnumerator Run(TestResult result)
        {
            // If test method invalid
            if (null == m_testMethod)
            {
                // Error
                throw new Exception("Invalid test method encountered, be sure to call " +
                                    "TestCase::SetTestMethod()");
            }

            // If the test method does not exist
            Type type = GetType();
            MethodInfo method = type.GetMethod(m_testMethod);
            if (null == method)
            {
                // Error
                throw new Exception("Test method: " + m_testMethod + " does not exist in class: " +
                                    type.ToString());
            }

            // If result invalid
            if (null == result)
            {
                // Create result
                result = new TestResult();
            }

            // Pre-test setup
            SetUp();
            result.TestStarted();

            yield return StartCoroutine((IEnumerator)method.Invoke(this, null));

            if (_Exception != null) {
                result.TestFailed(_Exception);
                UnityEngine.Debug.LogWarning("[SharpUnit] " + type.Name + "." + method.Name + " failed");

            } else if (_Failed) {
                result.TestFailed(new TestException("DoneTesting for " + type.Name + "." + method.Name +
                                                    " not called."));
                UnityEngine.Debug.LogWarning("[SharpUnit] " + type.Name + "." + method.Name +
                                             " might be failed");
            } else {
                UnityEngine.Debug.Log("[SharpUnit] " + type.Name + "." + method.Name + " runs ok");
            }

            // Clear expected exception
            Assert.Exception = null;

            // Post-test cleanup
            TearDown();

            _TestResult = result;
        }