public void Run_AfterLoad_ReturnsRunnableSuite()
        {
            LoadMockAssembly();
            var result = _runner.Run(TestListener.NULL, TestFilter.Empty);

            Assert.That(result.Test.IsSuite);
            Assert.That(result.Test, Is.TypeOf <TestAssembly>());
            Assert.That(result.Test.RunState, Is.EqualTo(RunState.Runnable));
            Assert.That(result.Test.TestCaseCount, Is.EqualTo(MockAssembly.Tests));
            Assert.That(result.ResultState, Is.EqualTo(ResultState.ChildFailure));
            Assert.That(result.PassCount, Is.EqualTo(MockAssembly.Success));
            Assert.That(result.FailCount, Is.EqualTo(MockAssembly.ErrorsAndFailures));
            Assert.That(result.SkipCount, Is.EqualTo(MockAssembly.Skipped));
            Assert.That(result.InconclusiveCount, Is.EqualTo(MockAssembly.Inconclusive));
        }
Exemplo n.º 2
0
        private void RunTests(ITestFilter filter)
        {
            ITestResult result = runner.Run(this, filter);

            new ResultReporter(result, writer).ReportResults();
            string resultFile   = commandLineOptions.ResultFile;
            string resultFormat = commandLineOptions.ResultFormat;

            if (resultFile != null || commandLineOptions.ResultFormat != null)
            {
                if (resultFile == null)
                {
                    resultFile = "TestResult.xml";
                }

                if (resultFormat == "nunit2")
                {
                    new NUnit2XmlOutputWriter().WriteResultFile(result, resultFile);
                }
                else
                {
                    new NUnit3XmlOutputWriter().WriteResultFile(result, resultFile);
                }

                Console.WriteLine();
                Console.WriteLine("Results saved as {0}.", resultFile);
            }
        }
Exemplo n.º 3
0
            public void Execute(Assembly assembly)
            {
                try {
                    Randomizer.InitialSeed = 0;

                    if (!runner.Load(assembly, new Dictionary <string, string>()))
                    {
                        throw new Exception($"No tests found in assembly {AssemblyHelper.GetAssemblyName(assembly).Name}");
                    }

                    ITestFilter filter = (ITestFilter)formatter.Deserialize(stream);

                    AppDomain.CurrentDomain.UnhandledException += TopLevelHandler;

                    ITestResult result = (ITestResult)runner.Run(this, filter);
                    formatter.Serialize(stream, new Xamarin.ResultMessage {
                        TestResult = result
                    });

                    AppDomain.CurrentDomain.UnhandledException -= TopLevelHandler;
                }
                catch (Exception ex)
                {
                    formatter.Serialize(stream, new Xamarin.ExceptionMessage {
                        Exception = ex
                    });
                    throw;
                }
            }
Exemplo n.º 4
0
        public int RunTests(TestFilter filter, IDictionary <string, object> runSettings)
        {
            var startTime = DateTime.UtcNow;

            ITestResult result = _runner.Run(this, filter);

            ReportResults(result);

#if !PORTABLE
            if (_options.ResultOutputSpecifications.Count > 0)
            {
                var outputManager = new OutputManager(_options.WorkDirectory);

                foreach (var spec in _options.ResultOutputSpecifications)
                {
                    outputManager.WriteResultFile(result, spec, runSettings, filter);
                }
            }
#endif
            if (Summary.InvalidTestFixtures > 0)
            {
                return(INVALID_TEST_FIXTURE);
            }

            return(Summary.FailureCount + Summary.ErrorCount + Summary.InvalidCount);
        }
Exemplo n.º 5
0
        public int RunTests(TestFilter filter, IDictionary runSettings)
        {
            var startTime = DateTime.UtcNow;

            ITestResult result = _runner.Run(this, filter);

#if SILVERLIGHT
            // Silverlight can't display results while the test is running
            // so we do it afterwards.
            foreach (ITestResult testResult in _results)
            {
                _textUI.TestFinished(testResult);
            }
#endif
            ReportResults(result);

#if !SILVERLIGHT && !PORTABLE
            if (_options.ResultOutputSpecifications.Count > 0)
            {
                var outputManager = new OutputManager(_options.WorkDirectory);

                foreach (var spec in _options.ResultOutputSpecifications)
                {
                    outputManager.WriteResultFile(result, spec, runSettings, filter);
                }
            }
#endif

            return(Summary.FailureCount + Summary.ErrorCount + Summary.InvalidCount);
        }
Exemplo n.º 6
0
        public ITestResult Execute()
        {
            IDictionary loadOptions = new System.Collections.Generic.Dictionary <string, string>();

            if (!runner.Load(this.testAssembly, loadOptions))
            {
                AssemblyName assemblyName = AssemblyHelper.GetAssemblyName(this.testAssembly);
                throw new Exception(string.Format("No tests found in assembly {0}", assemblyName.Name));
            }

            return(runner.Run(this.listener, TestFilter.Empty));
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Run selected tests synchronously or asynchronously, notifying the listener interface as it progresses.
        /// </summary>
        /// <param name="assemblies">The list of test assembly runners to run.</param>
        /// <param name="listener">Interface to receive EventListener notifications.</param>
        /// <param name="filter">A test filter used to select tests to be run.</param>
        /// <param name="runAsync"><c>true</c> to run tests asynchronously, otherwise <c>false</c> to run synchronously.</param>
        /// <param name="results">The <see cref="ITestResult" /> object to add the test results to.</param>
        private static void RunTests(IList <ITestAssemblyRunner> assemblies,
                                     ITestListener listener, ITestFilter filter, bool runAsync, ref TestSuiteResult results)
        {
            filter = ValidateFilter(filter);
            Queue <ITestAssemblyRunner> testQueue = new Queue <ITestAssemblyRunner>(assemblies);

            // Check each test not ran when first encountered to see if it is ready to be run
            while (testQueue.Count > 0)
            {
                // Run test if not currently running, otherwise queue up to be checked again later
                ITestAssemblyRunner test = testQueue.Dequeue();
                if (!test.IsTestRunning)
                {
                    if (runAsync)
                    {
                        test.RunAsync(listener, filter);
                    }
                    else
                    {
                        test.Run(listener, filter);
                    }
                }
                else
                {
                    // Test not ready to run so re-enqueue
                    testQueue.Enqueue(test);
                }

                // Slow down the polling loop to give time for tests to complete
                if (runAsync)
                {
                    Thread.Sleep(10);
                }
            }

            // Wait for tests to complete
            while (assemblies.Any(test => test.IsTestRunning || !test.IsTestComplete))
            // Slow down the polling loop to give time for tests to complete
            {
                Thread.Sleep(10);
            }

            // Add individual test runner results to overall result
            foreach (ITestAssemblyRunner test in assemblies)
            {
                if (test.Result != null)
                {
                    results.AddResult(test.Result);
                }
            }
        }
Exemplo n.º 8
0
        private void RunTests()
        {
            NUnit.Framework.Api.ITestResult testResult = runner.Run(TestListener.NULL, TestFilter.Empty);
            ReportResults(testResult);
            string resultFile = commandLineOptions.ResultFile;

            if (resultFile != null)
            {
                XmlTextWriter xmlTextWriter = new XmlTextWriter(resultFile, Encoding.UTF8);
                xmlTextWriter.Formatting = Formatting.Indented;
                testResult.ToXml(recursive: true).WriteTo(xmlTextWriter);
                xmlTextWriter.Close();
            }
        }
Exemplo n.º 9
0
        private void RunTests(ITestFilter filter)
        {
            ITestResult result = runner.Run(this, filter);

            ExitCode = result.FailCount > 0 ? 1 : 0;
            new ResultReporter(result, writer).ReportResults();
            if (commandLineOptions.ResultFile != null)
            {
                new NUnit2XmlOutputWriter().WriteResultFile(result, commandLineOptions.ResultFile);

                Console.WriteLine();
                Console.WriteLine("Results saved as {0}.", commandLineOptions.ResultFile);
            }
        }
Exemplo n.º 10
0
    private void RunTests()
    {
        ITestResult result = runner.Run(TestListener.NULL, TestFilter.Empty);

        ReportResults(result);
        string resultFile = commandLineOptions.ResultFile;

        if (resultFile != null)
        {
            XmlTextWriter resultWriter = new XmlTextWriter(resultFile, System.Text.Encoding.UTF8);
            resultWriter.Formatting = Formatting.Indented;
            result.ToXml(true).WriteTo(resultWriter);
            resultWriter.Close();
        }
    }
Exemplo n.º 11
0
        private void RunTests(ITestFilter filter)
        {
            DateTime startTime = DateTime.Now;

            var crashHandler = new UnhandledExceptionEventHandler(TopLevelHandler);

            AppDomain.CurrentDomain.UnhandledException += crashHandler;

            ITestResult result = runner.Run(this, filter);

            new ResultReporter(result, writer).ReportResults();
            string resultFile   = commandLineOptions.ResultFile;
            string resultFormat = commandLineOptions.ResultFormat;

            this.Failure = (result.ResultState.Equals(ResultState.Failure) || result.ResultState.Equals(ResultState.Error));

            if (resultFile != null || commandLineOptions.ResultFormat != null)
            {
                if (resultFile == null)
                {
                    resultFile = "TestResult.xml";
                }

                if (resultFormat == "nunit2")
                {
                    new NUnit2XmlOutputWriter(startTime).WriteResultFile(result, resultFile);
                }
                else if (resultFormat == "nunit3")
                {
                    new NUnit3XmlOutputWriter(startTime).WriteResultFile(result, resultFile);
                }
#if MONO
                else if (resultFormat == "xunit")
                {
                    new XunitXmlOutputWriter(startTime).WriteResultFile(result, resultFile);
                }
#endif
                else
                {
                    throw new Exception("Unknown resultFormat.");
                }

                Console.WriteLine();
                Console.WriteLine("Results saved as {0}.", resultFile);
            }

            AppDomain.CurrentDomain.UnhandledException -= crashHandler;
        }
Exemplo n.º 12
0
        private ITestResult runTests(string nameSpace, TestFilter filter)
        {
            IDictionary options = new Hashtable();

            if (nameSpace != null)
            {
                options["LOAD"] = new string[] { nameSpace }
            }
            ;

            if (runner.Load(testAssembly, options))
            {
                return(runner.Run(TestListener.NULL, filter));
            }

            return(null);
        }
Exemplo n.º 13
0
        private void RunTests(ITestFilter filter)
        {
            var startTime = DateTime.UtcNow;

            ITestResult result = _runner.Run(this, filter);

            new ResultReporter(result, _outWriter).ReportResults();

            if (_options.ResultOutputSpecifications.Count > 0)
            {
                var outputManager = new OutputManager(_workDirectory);

                foreach (var spec in _options.ResultOutputSpecifications)
                {
                    outputManager.WriteResultFile(result, spec);
                }
            }
        }
Exemplo n.º 14
0
        private void ExecuteTests()
        {
            ITestResult    result   = runner.Run(TestListener.NULL, TestFilter.Empty);
            ResultReporter reporter = new ResultReporter(result, writer);

            reporter.ReportResults();

            ResultSummary summary = reporter.Summary;

            this.Total.Text        = summary.TestCount.ToString();
            this.Failures.Text     = summary.FailureCount.ToString();
            this.Errors.Text       = summary.ErrorCount.ToString();
            this.NotRun.Text       = summary.NotRunCount.ToString();
            this.Passed.Text       = summary.PassCount.ToString();
            this.Inconclusive.Text = summary.InconclusiveCount.ToString();

            this.Notice.Visibility = Visibility.Collapsed;
        }
Exemplo n.º 15
0
        private ITestResult runTests(string nameSpace, TestFilter filter)
        {
            IDictionary <string, object> options = new Dictionary <string, object>();

            if (nameSpace != null)
            {
                options["LOAD"] = new string[] { nameSpace }
            }
            ;
            // No need for the overhead of parallel execution here
            options["NumberOfTestWorkers"] = 0;

            if (runner.Load(testAssembly, options) != null)
            {
                return(runner.Run(TestListener.NULL, filter));
            }

            return(null);
        }
Exemplo n.º 16
0
        private int RunTests(ITestFilter filter)
        {
            var startTime = DateTime.UtcNow;

            ITestResult result   = _runner.Run(this, filter);
            var         reporter = new ResultReporter(result, _outWriter, _options.StopOnError);

            reporter.ReportResults();

            if (_options.ResultOutputSpecifications.Count > 0)
            {
                var outputManager = new OutputManager(_workDirectory);

                foreach (var spec in _options.ResultOutputSpecifications)
                {
                    outputManager.WriteResultFile(result, spec);
                }
            }

            var summary = reporter.Summary;

            return(summary.FailureCount + summary.ErrorCount + summary.InvalidCount);
        }
Exemplo n.º 17
0
        private void RunTests(ITestFilter filter)
        {
            DateTime startTime = DateTime.Now;

            ITestResult result = runner.Run(this, filter);

            new ResultReporter(result, writer).ReportResults();
            string resultFile   = commandLineOptions.ResultFile;
            string resultFormat = commandLineOptions.ResultFormat;

            if (resultFile != null || commandLineOptions.ResultFormat != null)
            {
                if (resultFile == null)
                {
                    resultFile = "TestResult.xml";
                }

                if (resultFormat == "nunit2")
                {
                    new NUnit2XmlOutputWriter(startTime).WriteResultFile(result, resultFile);

                    /*XslTransform xslt = new XslTransform();
                     * xslt.Load("XslTransform_2_6_3.xlst");
                     * xslt.Transform(xPathNav, null, fileStream, null);
                     * XslTransform transform = new XslTransform();
                     * transform.Transform(resultFile,"XslTransform.xlst");
                     * XmlTextWriter myWriter = new XmlTextWriter("result.html",null);*/
                }
                else
                {
                    new NUnit3XmlOutputWriter(startTime).WriteResultFile(result, resultFile);
                }

                Console.WriteLine();
                Console.WriteLine("Results saved as {0}.", resultFile);
            }
        }
Exemplo n.º 18
0
 private void RunTests()
 {
     NUnit.Framework.Api.ITestResult result = runner.Run(TestListener.NULL, TestFilter.Empty);
     ReportResults(result);
 }
        private static ITestResult RunTests(ITestAssemblyRunner testRunner, Type testsType)
        {
            var testFilter = new ClassNameFilter(testsType.FullName);

            return(testRunner.Run(TestListener.NULL, testFilter));
        }
Exemplo n.º 20
0
        private void RunTests()
        {
            ITestResult result = runner.Run(TestListener.NULL, TestFilter.Empty);

            ReportResults(result);
        }
 /// <inheritdoc />
 public ITestResult Run(ITestListener listener, ITestFilter filter)
 {
     v_IsTestCompleteOverride = false;
     v_IsTestRunningOverride  = false;
     return(v_Runner.Run(listener, filter));
 }