예제 #1
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);
        }
예제 #2
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);
            }
        }
예제 #3
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.All);
         if (!result.IsSuccess)
             throw new Exception(result.Message);
     }
 }
예제 #4
0
        static void Main(string[] args)
        {
            CoreExtensions.Host.InitializeService();
            SimpleTestRunner runner = new SimpleTestRunner();
            TestPackage package = new TestPackage("GivenITGuys");
            string loc = Assembly.GetExecutingAssembly().Location;
            package.Assemblies.Add(loc);
            if (runner.Load(package))
            {
                TestResult result = runner.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off);

                new XmlResultWriter(@"ITGuysResult.xml").SaveTestResult(result);
            }
        }
예제 #5
0
        public List<TestResult> RunTests()
        {
            TestResultsEventListener eventListener = new TestResultsEventListener();
            CoreExtensions.Host.InitializeService();
            SimpleTestRunner runner = new SimpleTestRunner();

            TestPackage package = new TestPackage("TemplateTestClass");

            string loc = Assembly.GetExecutingAssembly().Location;
            package.Assemblies.Add(loc);

            if (runner.Load(package))
            {
                runner.Run(eventListener, TestFilter.Empty, true, LoggingThreshold.All);
            }
            return eventListener.ListResults;
        }
예제 #6
0
    protected void RunClick(object sender, EventArgs args)
    {
      var categories = from ListItem item in cblCategories.Items
                       where item.Selected
                       select item.Value;

      if(!categories.Any())
        categories = from ListItem item in cblCategories.Items
                       select item.Value;

      // Create a category filter
      var filter = new CategoryFilter(categories.ToArray());

      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";
    }
예제 #7
0
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            RevitCommandData = revit;

            // Run tests
            try
            {
                CoreExtensions.Host.InitializeService();
                var runner = new SimpleTestRunner();
                var package = new TestPackage("Test");
                string loc = Assembly.GetExecutingAssembly().Location;
                package.Assemblies.Add(loc);

                TestResult result;
                if (runner.Load(package))
                {
                    result = runner.Run(new NullListener(), TestFilter.Empty, true, LoggingThreshold.All);

                    MessageBox.Show(result.FullName);
                    MessageBox.Show(result.IsSuccess.ToString());
                    MessageBox.Show(result.Message);
                    MessageBox.Show(result.Results.Count.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                if (dynSettings.Writer != null)
                {
                    dynSettings.Writer.WriteLine(ex.Message);
                    dynSettings.Writer.WriteLine(ex.StackTrace);
                    dynSettings.Writer.WriteLine("Dynamo log ended " + DateTime.Now.ToString());
                }
            }

            return Result.Succeeded;
        }
예제 #8
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;
        }
예제 #9
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);
            }
        }
예제 #10
0
        // ----------------------------------------------------------------------
        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;
        }
예제 #11
0
		public static void RunMain (string [] args)
		{
			var runOptions = RunOptions.Parse (args);

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

			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;
			}

			var listener = new CommandLineTestEventListener(runOptions);
			var filter = new AggregateTestFilter (runOptions.Filters);
			runner.Run (listener, filter, false, LoggingThreshold.Off);
		}
        private TestResult GenerateTestResults()
        {
            CoreExtensions.Host.InitializeService();
            loggerProvider.GetLogger()
                .Debug("Running tests from {testLibraryPath}", configurationProvider.TestLibraryPath);
            var testPackage = new TestPackage(configurationProvider.TestLibraryPath);
            var simpleTestRunner = new SimpleTestRunner();
            simpleTestRunner.Load(testPackage);

            var currentOut = Console.Out;
            var testResult = simpleTestRunner.Run(new NullListener(), new CategoryFilter("Smoke"), true, LoggingThreshold.All);
            Console.SetOut(currentOut);
            return testResult;
        }
예제 #13
0
        public static void RunMain(string [] args)
        {
            bool launchResults = true;
            bool performXslTransform = true;
            bool showHelp = false;

            var directory = Directory.GetCurrentDirectory ();

            string xmlResultsFile = Path.Combine (directory, "test_results.xml");
            string transformedResultsFile = Path.Combine (directory, "test_results.html");
            string xslTransformPath = Path.Combine ("Resources", "tests.xsl");
            string stdoutFile = Path.Combine (directory, "stdout.txt");
            var filters = new List<RegexFilter> ();
            var optionSet = new OptionSet () {
                { "i|include=", x => filters.Add(RegexFilter.Parse(x, FilterAction.Include)) },
                { "x|exclude=", x => filters.Add(RegexFilter.Parse(x, FilterAction.Exclude)) },
                { "no-launch-results", x => launchResults = false },
                { "no-xsl-transform", x => performXslTransform = false },
                { "xml-results=", x => xmlResultsFile = x },
                { "xsl-transform=", x => xslTransformPath = x },
                { "transformed-results=", x => transformedResultsFile = x },
                { "stdout=", x => stdoutFile = x },
            //				{ "v|verbose",  x => ++verbose },
                { "h|?|help",   x => showHelp = true },
            };

            List<string> extra = optionSet.Parse (args);
            if (extra.Count > 0)
                Console.WriteLine (
                    "Ignoring {0} unrecognized argument(s): {1}",
                    extra.Count, string.Join (", ", extra));

            if (showHelp) {
                ShowHelp (optionSet);
                System.Threading.Thread.Sleep (3000);
                return;
            }

            CoreExtensions.Host.InitializeService ();

            var assembly = Assembly.GetExecutingAssembly ();

            var simpleTestRunner = new SimpleTestRunner ();
            TestPackage package = new TestPackage (assembly.GetName ().Name);
            package.Assemblies.Add (assembly.Location);
            if (!simpleTestRunner.Load (package)) {
                Console.WriteLine ("Could not find the tests.");
                return;
            }

            var cli = new CommandLineInterface (filters);

            var result = simpleTestRunner.Run (cli, cli);

            var resultWriter = new XmlResultWriter (xmlResultsFile);
            resultWriter.SaveTestResult (result);

            if (performXslTransform) {
                var transform = new XslTransform ();
                transform.Load (xslTransformPath);
                transform.Transform (xmlResultsFile, transformedResultsFile);
            }

            File.WriteAllText (stdoutFile, cli._stdoutStandin.ToString ());

            if (performXslTransform && launchResults)
                System.Diagnostics.Process.Start (transformedResultsFile);
        }
예제 #14
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));
            }