Exemplo n.º 1
0
        /// <summary>
        /// Gets the matching test member 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 TestMember GetTestMember(string fullyQualifiedName)
        {
            string className = TestMember.GetQualifiedClassName(fullyQualifiedName);

            if (className != null)
            {
                if (Contains(className))
                {
                    TestClass testClass  = this[className];
                    string    memberName = TestMember.GetMemberName(fullyQualifiedName);
                    if (memberName != null)
                    {
                        return(testClass.GetTestMember(memberName));
                    }
                }
                else
                {
                    LoggingService.Debug("TestClass not found: " + className);
                }
            }
            else
            {
                LoggingService.Debug("Invalid test member name: " + fullyQualifiedName);
            }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function adds the base class as a prefix and tries to find
        /// the corresponding test member.
        ///
        /// 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>
        TestMember GetPrefixedTestMember(string testResultName)
        {
            IClass baseClass = c.BaseClass;

            while (baseClass != null)
            {
                string     memberName       = TestMember.GetMemberName(testResultName);
                string     actualMemberName = String.Concat(baseClass.Name, ".", memberName);
                TestMember member           = GetTestMember(actualMemberName);
                if (member != null)
                {
                    return(member);
                }
                baseClass = baseClass.BaseClass;
            }
            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the test member with the specified test result.
        /// </summary>
        public void UpdateTestResult(TestResult testResult)
        {
            TestMember member     = null;
            string     memberName = TestMember.GetMemberName(testResult.Name);

            if (memberName != null)
            {
                member = GetTestMember(memberName);
                if (member == null)
                {
                    member = GetPrefixedTestMember(testResult.Name);
                }
            }
            if (member != null)
            {
                member.Result = testResult.ResultType;
            }
        }