private int ProcessTestCases(XmlNode topNode, ITestCaseDiscoverySink discoverySink, TestConverter testConverter)
        {
            int cases = 0;

            foreach (XmlNode testNode in topNode.SelectNodes("//test-case"))
            {
                try
                {
#if LAUNCHDEBUGGER
                    if (!Debugger.IsAttached)
                    {
                        Debugger.Launch();
                    }
#endif
                    TestCase testCase = testConverter.ConvertTestCase(testNode);
                    discoverySink.SendTestCase(testCase);
                    cases += 1;
                }
                catch (Exception ex)
                {
                    TestLog.Warning("Exception converting " + testNode.GetAttribute("fullname"), ex);
                }
            }

            return(cases);
        }
Пример #2
0
 private void ProcessXml2TestCase(XmlNode xml)
 {
     foreach (XmlNode node in xml.SelectNodes("//test-case"))
     {
         var testcase = testconverter.ConvertTestCase(node);
         testcaselist.Add(testcase);
     }
 }
Пример #3
0
        public void SetUp()
        {
            testLog       = new FakeFrameworkHandle();
            testConverter = new TestConverter(new TestLogger(new MessageLoggerStub(), 0), FakeTestData.AssemblyPath);
            fakeTestNode  = FakeTestData.GetTestNode();

            // Ensure that the converted testcase is cached
            testConverter.ConvertTestCase(fakeTestNode);
            Assert.NotNull(testConverter.GetCachedTestCase("123"));

            listener = new NUnitEventListener(testLog, testConverter);
        }
        public void SetUp()
        {
            testLog = new FakeFrameworkHandle();
            testConverter = new TestConverter(new TestLogger(new MessageLoggerStub(), 0), FakeTestData.AssemblyPath);
            fakeTestNode = FakeTestData.GetTestNode();

            // Ensure that the converted testcase is cached
            testConverter.ConvertTestCase(fakeTestNode);
            Assert.NotNull(testConverter.GetCachedTestCase("123"));
            
            listener = new NUnitEventListener(testLog, testConverter);
        }
        public void SetUp()
        {
            testLog = new FakeFrameworkHandle();

            using (var testConverter = new TestConverter(new TestLogger(new MessageLoggerStub()), FakeTestData.AssemblyPath, collectSourceInformation: true))
            {
                fakeTestNode = FakeTestData.GetTestNode();

                // Ensure that the converted testcase is cached
                testConverter.ConvertTestCase(fakeTestNode);
                Assert.NotNull(testConverter.GetCachedTestCase("123"));

                listener = new NUnitEventListener(testLog, testConverter, null);
            }
        }
        public void SetUp()
        {
            MethodInfo fakeTestMethod = GetType().GetMethod("FakeTestMethod", BindingFlags.Instance | BindingFlags.NonPublic);
            fakeNUnitTest = new NUnitTestMethod(fakeTestMethod);

            fakeNUnitResult = new NUnitTestResult(fakeNUnitTest);
            fakeNUnitResult.SetResult(ResultState.Success, "It passed!", null);
            fakeNUnitResult.Time = 1.234;

            testLog = new FakeFrameworkHandle();

            testConverter = new TestConverter(new TestLogger(), ThisAssemblyPath);

            testConverter.ConvertTestCase(fakeNUnitTest);
            Assert.NotNull(testConverter.GetCachedTestCase(fakeNUnitTest.TestName.UniqueName));

            listener = new NUnitEventListener(testLog, testConverter);
        }
        public void SetUp()
        {
            testLog  = new FakeFrameworkHandle();
            settings = Substitute.For <IAdapterSettings>();
            executor = Substitute.For <INUnit3TestExecutor>();
            executor.Settings.Returns(settings);
            settings.CollectSourceInformation.Returns(true);
            using (var testConverter = new TestConverter(new TestLogger(new MessageLoggerStub()), FakeTestData.AssemblyPath, settings))
            {
                fakeTestNode = new NUnitTestCase(FakeTestData.GetTestNode());

                // Ensure that the converted testcase is cached
                testConverter.ConvertTestCase(fakeTestNode);
                Assert.NotNull(testConverter.GetCachedTestCase("123"));

                listener = new NUnitEventListener(testLog, testConverter, executor);
            }
        }
Пример #8
0
        public IList <TestCase> Convert(NUnitResults discoveryResults, ITestLogger logger, string assemblyPath, IAdapterSettings settings)
        {
            var nunitTestCases = discoveryResults.TestCases();

            TestConverter = new TestConverter(logger, assemblyPath, settings);
            var loadedTestCases = new List <TestCase>();

            // As a side effect of calling TestConverter.ConvertTestCase,
            // the converter's cache of all test cases is populated as well.
            // All future calls to convert a test case may now use the cache.
            foreach (XmlNode testNode in nunitTestCases)
            {
                loadedTestCases.Add(TestConverter.ConvertTestCase(new NUnitTestCase(testNode)));
            }
            logger.Info($"   NUnit3TestExecutor discovered {loadedTestCases.Count} of {nunitTestCases.Count} NUnit test cases");

            return(loadedTestCases);
        }
        public void SetUp()
        {
            MethodInfo fakeTestMethod = GetType().GetMethod("FakeTestMethod", BindingFlags.Instance | BindingFlags.NonPublic);

            fakeNUnitTest = new NUnitTestMethod(fakeTestMethod);

            fakeNUnitResult = new NUnitTestResult(fakeNUnitTest);
            fakeNUnitResult.SetResult(ResultState.Success, "It passed!", null);
            fakeNUnitResult.Time = 1.234;

            testLog = new FakeFrameworkHandle();

            testConverter = new TestConverter(new TestLogger(), ThisAssemblyPath);

            testConverter.ConvertTestCase(fakeNUnitTest);
            Assert.NotNull(testConverter.GetCachedTestCase(fakeNUnitTest.TestName.UniqueName));

            listener = new NUnitEventListener(testLog, testConverter);
        }
Пример #10
0
        /// <summary>
        /// Knows how to convert an entire XML fragment.
        /// </summary>
        public static IReadOnlyList <TestCase> ConvertTestCases(this TestConverter testConverter, string xml)
        {
            if (testConverter == null)
            {
                throw new ArgumentNullException(nameof(testConverter));
            }

            var fragment = new XmlDocument().CreateDocumentFragment();

            fragment.InnerXml = xml;
            var testCaseNodes = fragment.SelectNodes("//test-case");

            var testCases = new TestCase[testCaseNodes.Count];

            for (var i = 0; i < testCases.Length; i++)
            {
                testCases[i] = testConverter.ConvertTestCase(testCaseNodes[i]);
            }

            return(testCases);
        }
Пример #11
0
        public void CanMakeTestCaseFromTest()
        {
            var testCase = testConverter.ConvertTestCase(fakeTestNode);

            CheckTestCase(testCase);
        }