Example #1
0
        }         // TestPerformance

        // ----------------------------------------------------------------------
        private static bool TestPackage(string packageName)
        {
            bool success = true;

            SimpleTestRunner runner  = new SimpleTestRunner();
            TestPackage      package = new TestPackage(packageName);

            if (runner.Load(package))
            {
                TestResult result = runner.Run(new NullListener());

                if (result.IsSuccess)
                {
                    Console.WriteLine("tests finished successfully");
                }
                else
                {
                    success = false;
                    TestResultReport testReport = new TestResultReport(result);
                    foreach (string failedTest in testReport.FailedTests)
                    {
                        Console.WriteLine("failed test: {0}", failedTest);
                    }
                    foreach (string errorTests in testReport.ErrorTests)
                    {
                        Console.WriteLine("error test: {0}", errorTests);
                    }
                }
            }
            return(success);
        }         // TestPackage
Example #2
0
        public static int RunMain(string [] args)
        {
            var runOptions = RunOptions.Parse(args);

            if (runOptions.ShouldShowHelp)
            {
                runOptions.ShowHelp();
                return(0);
            }

            CoreExtensions.Host.InitializeService();

            var assembly = Assembly.GetExecutingAssembly();

            var         runner  = new SimpleTestRunner();
            TestPackage package = new TestPackage(assembly.GetName().Name);

            package.Assemblies.Add(assembly.Location);
            if (!runner.Load(package))
            {
                Console.WriteLine("Could not find the tests.");
                return(-1);
            }

            var listener = new CommandLineTestEventListener(runOptions);
            var filter   = new AggregateTestFilter(runOptions.Filters);
            var results  = runner.Run(listener, filter, false, LoggingThreshold.Off);

            return(results.IsFailure ? 1 : 0);
        }
        public static int Main(String[] args)
        {
            CoreExtensions.Host.InitializeService();
            SimpleTestRunner runner  = new SimpleTestRunner();
            TestPackage      package = new TestPackage("Test");

            string loc = Assembly.GetAssembly(typeof(UnpickleStackTest)).Location;

            Console.WriteLine("assembly=" + loc);
            package.Assemblies.Add(loc);

            bool fail = true;

            if (runner.Load(package))
            {
                Console.WriteLine("running tests");
                TestResult results = runner.Run(new MyListener());
                fail = results.IsFailure;
            }

            Console.WriteLine("press enter to exit");
            Console.ReadLine();

            if (fail)
            {
                return(10);
            }
            else
            {
                return(0);
            }
        }
Example #4
0
        public static void Main()
        {
            // Set common application locale, check 'app.config' for this property
            SetLocale(ConfigurationManager.AppSettings["Locale"]);

            // Get test data from scenario file
            Scenario       scenario    = GetScenario(ConfigurationManager.AppSettings["Nunit.Runner.Scenario"]);
            string         suite       = scenario.Name;
            IList <string> testClasses = scenario.Tests;

            // Start tests
            CoreExtensions.Host.InitializeService();
            SimpleTestRunner runner  = new SimpleTestRunner();
            TestPackage      package = new TestPackage(suite);
            string           loc     = Assembly.GetExecutingAssembly().Location;

            package.Assemblies.Add(loc);
            try
            {
                if (runner.Load(package))
                {
                    TestResult result = runner.Run(new RunnerListener(), new ClassTestFilter(testClasses), true, LoggingThreshold.Debug);
                }
            }
            catch (Exception e)
            {
                _log.Error(e.Message, e);
            }
        }
Example #5
0
        public void RunAllAcceptanceTests()
        {
            //Define the name of itself
            var assemblyName = @"NBi.Testing.dll";

            //Instantiate a SimpleTestRunner
            CoreExtensions.Host.InitializeService();
            SimpleTestRunner runner = new SimpleTestRunner();

            //Define the test package as all the tests of this assembly in the class RuntimeOverrider
            //The assembly (and so the tests) will be filtered based on TestName
            TestPackage package = new TestPackage("Test");

            package.TestName = "NBi.Testing.Acceptance.RuntimeOverrider"; //Filter
            package.Assemblies.Add(assemblyName);

            //Load the tests from the filtered package (so we don't need to filter again!)
            if (runner.Load(package))
            {
                //Run all the tests (Have I said I've previsously filtered ? ... No seriously you read this kind of comment?)
                TestResult result = runner.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off);
                //Ensure the acceptance test suite is fully positive!
                Assert.That(result.IsSuccess, Is.True);
            }
            else
            {
                Assert.Fail("Unable to load the TestPackage from assembly '{0}'", assemblyName);
            }
        }
Example #6
0
        private object RunTests(ITestFilter filter)
        {
            if (runner != null && runner.Running)
            {
                while (runner.Running) /*do nothing*/ } {
                return(GetTestResult(testResults));
        }

        using (runner = new SimpleTestRunner())
        {
            runner.Load(package);
            if (runner.Test == null)
            {
                runner.Unload();
                return(new { text = "Unable to load the tests", status = "warning" });
            }

            TestResult result;
            try
            {
                result = runner.Run(this, filter, true, LoggingThreshold.All);
            }
            catch (Exception e)
            {
                return(new { text = e.Message, status = "error" });
            }

            return(result == null
                    ? new { text = "No results", status = "warning" }
                    : GetTestResult(testResults));
        }
    }
Example #7
0
            public void DoTest(string testLibraryPath)
            {
                Console.SetOut(new StubWriter());
                var listener = new Listener();

                CoreExtensions.Host.InitializeService();
                var package = new TestPackage(testLibraryPath);
                //package.AutoBinPath = true;
                //package.BasePath = Path.GetDirectoryName(TestLibraryPath);
                //package.ConfigurationFile = TestLibraryPath + ".config";
                TestRunner runner = new SimpleTestRunner();

                if (runner.Load(package))
                {
                    runner.Run(listener, TestFilter.Empty, true, LoggingThreshold.All);
                }
                //DebugTestResult(Console.Out, result);

                if (!listener.Messages.Any())
                {
                    listener.Messages.Add(Message.CreateError("No messages from listener"));
                }

                AppDomain.CurrentDomain.SetData(DATA_TEST_RESULTS_KEY, new Response(listener.Messages));
            }
Example #8
0
        public static void Main(string[] args)
        {
            CoreExtensions.Host.InitializeService();
            TestPackage package = new TestPackage("Test");

            package.Assemblies.Add(System.Reflection.Assembly.GetExecutingAssembly().Location);
            SimpleTestRunner runner = new SimpleTestRunner();

            if (runner.Load(package))
            {
                runner.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Error);
            }
        }
Example #9
0
        public static void Main(string[] args)
        {
            CoreExtensions.Host.InitializeService();
            TestPackage package = new TestPackage("Test");

            package.Assemblies.Add(System.Reflection.Assembly.GetExecutingAssembly().Location);
            SimpleTestRunner runner = new SimpleTestRunner();

            if (runner.Load(package))
            {
                TestResult result = runner.Run(new NullListener(), TestFilter.Empty, true, LoggingThreshold.Debug);
                if (!result.IsSuccess)
                {
                    throw new Exception(result.Message);
                }
            }
        }
Example #10
0
        protected void Run()
        {
            var filter = ConstructFilter();

            var runner = new SimpleTestRunner();

            runner.Load(_testPackage);

            var result = runner.Run(this, filter, true, LoggingThreshold.All);

            var outputFormatRaw = Request.QueryString["output"];

            if (outputFormatRaw == "xml")
            {
                OutputXml(result);
            }
            else
            {
                OutputVisual(result);
            }
        }
Example #11
0
        protected void RunClick(object sender, EventArgs args)
        {
            var filter = ConstructFilter();

            var runner = new SimpleTestRunner();

            runner.Load(_testPackage);

            var result = runner.Run(this, filter, true, LoggingThreshold.All);

            // Bind results to presentation
            gvResults.DataSource = _results;
            gvResults.DataBind();

            // Display statistics
            ltlStats.Text = string.Format("{0} out of {1} tests run in {2} seconds.", _executedCount, result.Test.TestCount, result.Time);

            if (_failedCount > 0)
            {
                ltlStats.Text += string.Format("<br/>{0} {1} failed", _failedCount, _failedCount == 1 ? "test" : "tests");
            }

            var skipped = result.Test.TestCount - _executedCount;

            if (skipped > 0)
            {
                ltlStats.Text += string.Format("<br/>{0} {1} skipped", skipped, skipped == 1 ? "test" : "tests");
            }

            lblResult.Text = "Suite " + (result.IsSuccess ? "Passed" : "Failed");
            if (result.IsSuccess)
            {
                lblResult.CssClass = "passLabel";
            }
            else
            {
                lblResult.CssClass = "failLabel";
            }
        }