Example #1
0
        /// <summary>
        /// Gets the matching test method from this set of classes.
        /// </summary>
        /// <param name="fullyQualifiedName">The fully qualified
        /// method name (e.g. Namespace.ClassName.MethodName).</param>
        /// <returns>Null if the method cannot be found.</returns>
        public TestMethod GetTestMethod(string fullyQualifiedName)
        {
            string className = TestMethod.GetQualifiedClassName(fullyQualifiedName);

            if (className != null)
            {
                if (Contains(className))
                {
                    TestClass testClass  = this[className];
                    string    methodName = TestMethod.GetMethodName(fullyQualifiedName);
                    if (methodName != null)
                    {
                        return(testClass.GetTestMethod(methodName));
                    }
                }
                else
                {
                    LoggingService.Debug("TestClass not found: " + className);
                }
            }
            else
            {
                LoggingService.Debug("Invalid test method name: " + fullyQualifiedName);
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// This function adds the base class as a prefix and tries to find
        /// the corresponding test method.
        ///
        /// Actual method name:
        ///
        /// RootNamespace.TestFixture.TestFixtureBaseClass.TestMethod
        /// </summary>
        /// <remarks>
        /// NUnit 2.4 uses the correct test method name when a test
        /// class uses a base class with test methods. It does
        /// not prefix the test method name with the base class name
        /// in the test results returned from nunit-console. It still
        /// displays the name in the NUnit GUI with the base class
        /// name prefixed. Older versions of NUnit-console (2.2.9) returned
        /// the test result with the test method name as follows:
        ///
        /// RootNamespace.TestFixture.BaseTestFixture.TestMethod
        ///
        /// The test method name would have the base class name prefixed
        /// to it.
        /// </remarks>
        TestMethod GetPrefixedTestMethod(string testResultName)
        {
            IClass baseClass = c.BaseClass;

            while (baseClass != null)
            {
                string     methodName       = TestMethod.GetMethodName(testResultName);
                string     actualMethodName = String.Concat(baseClass.Name, ".", methodName);
                TestMethod method           = GetTestMethod(actualMethodName);
                if (method != null)
                {
                    return(method);
                }
                baseClass = baseClass.BaseClass;
            }
            return(null);
        }
Example #3
0
        /// <summary>
        /// Updates the test method with the specified test result.
        /// </summary>
        public void UpdateTestResult(TestResult testResult)
        {
            TestMethod method     = null;
            string     methodName = TestMethod.GetMethodName(testResult.Name);

            if (methodName != null)
            {
                method = GetTestMethod(methodName);
                if (method == null)
                {
                    method = GetPrefixedTestMethod(testResult.Name);
                }
            }
            if (method != null)
            {
                method.Result = testResult.ResultType;
            }
        }