Exemple #1
0
        /// <summary>
        /// Makes a TestCase from an NUnit test, adding
        /// navigation data if it can be found.
        /// </summary>
        private TestCase MakeTestCaseFromNUnitTest(ITest nunitTest)
        {
            //var testCase = MakeTestCaseFromTestName(nunitTest.TestName);
            var testCase = new TestCase(
                nunitTest.TestName.FullName,
                new Uri(NUnitTestExecutor.ExecutorUri),
                this._sourceAssembly)
            {
                DisplayName  = nunitTest.TestName.Name,
                CodeFilePath = null,
                LineNumber   = 0
            };

            var navData = _navigationDataProvider.GetNavigationData(nunitTest.ClassName, nunitTest.MethodName);

            if (navData.IsValid)
            {
                testCase.CodeFilePath = navData.FilePath;
                testCase.LineNumber   = navData.LineNumber;
            }

            testCase.AddTraitsFromNUnitTest(nunitTest);

            return(testCase);
        }
        /// <summary>
        /// Makes a TestCase from an NUnit test, adding
        /// navigation data if it can be found.
        /// </summary>
        private TestCase MakeTestCaseFromNUnitTest(ITest nunitTest)
        {
            //var testCase = MakeTestCaseFromTestName(nunitTest.TestName);
            var testCase = new TestCase(Regex.Replace(nunitTest.TestName.FullName, @" ?\(.*?\)", string.Empty),
                                        new Uri(NUnitTestExecutor.ExecutorUri),
                                        this._sourceAssembly)
            {
                DisplayName  = Regex.Replace(nunitTest.TestName.Name, @" ?\(.*?\)", string.Empty),
                CodeFilePath = null,
                LineNumber   = 0
            };

            if (_collectSourceInformation && _navigationDataProvider != null)
            {
                var navData = _navigationDataProvider.GetNavigationData(nunitTest.ClassName, nunitTest.MethodName);
                if (navData.IsValid)
                {
                    testCase.CodeFilePath = navData.FilePath;
                    testCase.LineNumber   = navData.LineNumber;
                }
            }

            testCase.AddTraitsFromNUnitTest(nunitTest);

            return(testCase);
        }