예제 #1
0
        public NUnitResults Run(ITestEventListener listener, TestFilter filter)
        {
            var timing  = new TimingLogger(settings, logger);
            var results = new NUnitResults(Runner.Run(listener, filter));

            timing.LogTime("Execution engine run time ");
            return(results);
        }
예제 #2
0
        public NUnitResults Explore(TestFilter filter)
        {
            var timing  = new TimingLogger(settings, logger);
            var results = new NUnitResults(Runner.Explore(filter));

            timing.LogTime("Execution engine discovery time ");
            return(results);
        }
        public NUnitDiscoveryTestRun ConvertXml(NUnitResults discovery)
        {
            var doc          = XDocument.Load(new XmlNodeReader(discovery.FullTopNode));
            var testrun      = ExtractTestRun(doc);
            var anode        = doc.Root.Elements("test-suite");
            var assemblyNode = anode.Single(o => o.Attribute(NUnitXmlAttributeNames.Type).Value == "Assembly");
            var testassembly = ExtractTestAssembly(assemblyNode, testrun);

            ExtractAllFixtures(testassembly, assemblyNode);
            return(testrun);
        }
예제 #4
0
        public NUnitResults Run(ITestEventListener listener, TestFilter filter)
        {
            var timing  = new TimingLogger(settings, logger);
            var results = new NUnitResults(Runner.Run(listener, filter));

            timing.LogTime($"Execution engine run time with filter length {filter.Text.Length}");
            if (filter.Text.Length < 300)
            {
                logger.Debug($"Filter: {filter.Text}");
            }
            return(results);
        }
예제 #5
0
        public NUnitResults Explore(TestFilter filter)
        {
            var timing  = new TimingLogger(settings, logger);
            var results = new NUnitResults(Runner.Explore(filter));

            timing.LogTime($"Execution engine discovery time with filter length {filter.Text.Length}");
            if (filter.Text.Length < 300)
            {
                logger.Debug($"Filter: {filter.Text}");
            }

            return(results);
        }
예제 #6
0
        public void GenerateTestOutput(NUnitResults testResults, string assemblyPath, string testOutputXmlFolder)
        {
            if (!settings.UseTestOutputXml)
            {
                return;
            }

            string path          = GetXmlFilePath(testOutputXmlFolder, Path.GetFileNameWithoutExtension(assemblyPath), "xml");
            var    resultService = GetService <IResultService>();

            // Following null argument should work for nunit3 format. Empty array is OK as well.
            // If you decide to handle other formats in the runsettings, it needs more work.
            var resultWriter = resultService.GetResultWriter("nunit3", null);

            resultWriter.WriteResultFile(testResults.FullTopNode, path);
            logger.Info($"   Test results written to {path}");
        }
예제 #7
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 IList <TestCase> Convert(NUnitResults discoveryResults, string assemblyPath)
        {
            if (discoveryResults == null)
            {
                return(new List <TestCase>());
            }
            AssemblyPath = assemblyPath;
            var timing = new TimingLogger(Settings, TestLog);

            if (Settings.DiscoveryMethod != DiscoveryMethod.Legacy)
            {
                TestRun = ConvertXml(discoveryResults);
            }

            var nunitTestCases = discoveryResults.TestCases();

            // 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.

            if (Settings.DiscoveryMethod == DiscoveryMethod.Legacy)
            {
                converterForXml = new TestConverterForXml(TestLog, AssemblyPath, Settings);
                foreach (XmlNode testNode in nunitTestCases)
                {
                    loadedTestCases.Add(converterForXml.ConvertTestCase(new NUnitEventTestCase(testNode)));
                }
                TestLog.Info(
                    $"   NUnit3TestExecutor discovered {loadedTestCases.Count} of {nunitTestCases.Count} NUnit test cases using Legacy discovery mode");
            }
            else
            {
                converter = new TestConverter(TestLog, AssemblyPath, Settings, this);
                var isExplicit = TestRun.IsExplicit;
                var testCases  = RunnableTestCases(isExplicit);
                foreach (var testNode in testCases)
                {
                    loadedTestCases.Add(converter.ConvertTestCase(testNode));
                }
                var msg = isExplicit ? "Explicit run" : "Non-Explicit run";
                TestLog.Info(
                    $"   NUnit3TestExecutor discovered {loadedTestCases.Count} of {nunitTestCases.Count} NUnit test cases using Current Discovery mode, {msg}");
            }

            timing.LogTime("Converting test cases ");
            return(loadedTestCases);

            IEnumerable <NUnitDiscoveryTestCase> RunnableTestCases(bool isExplicit)
            {
                IEnumerable <NUnitDiscoveryTestCase> result;

                if (isExplicit || !Settings.DesignMode)
                {
                    result = TestRun.TestAssembly.AllTestCases;
                }
                else
                {
                    result = TestRun.TestAssembly.RunnableTestCases;
                }
                return(result);
            }
        }