コード例 #1
0
        public static void Main(string[] args)
        {
            RunnerOptions opts = null;

            try
            {
                opts = ParseOptions(args);
            }
            catch (OptionException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Try running with '--help' for more information.");
                Environment.Exit(1);
            }

            RecordingListener listener = new RecordingListener(opts.reportFile);

            ITestEngine engine  = TestEngineActivator.CreateInstance();
            TestPackage package = new TestPackage(opts.targetAssembly);
            ITestRunner runner  = engine.GetRunner(package);

            int testCount = runner.CountTestCases(TestFilter.Empty);

            if (testCount < 1)
            {
                throw new ArgumentException("Nothing to run, no tests were loaded");
            }

            try
            {
                DateTime startTime = DateTime.Now;
                for (int i = 0; i < opts.iterations; i++)
                {
                    runner.Run(listener, TestFilter.Empty);
                    TimeSpan offset = DateTime.Now - startTime;
                    if (opts.durationLimit > 0 && offset.TotalSeconds > opts.durationLimit)
                    {
                        break;
                    }
                }
            }
            finally
            {
                listener.CloseFile();
            }
            Environment.Exit(0);
        }
コード例 #2
0
        public static XmlNode FullRun(List <string> projectAssemblies, string category)
        {
            XmlNode node = null;

            foreach (string assemblyPath in projectAssemblies)
            {
                if (engine == null)
                {
                    engine = TestEngineActivator.CreateInstance();
                }
                TestPackage testPackage   = new TestPackage(assemblyPath);
                var         filterService = engine.Services.GetService <ITestFilterService>();
                var         builder       = filterService.GetTestFilterBuilder();
                builder.SelectWhere(category);
                TestFilter filter = builder.GetFilter();

                ITestRunner runner = engine.GetRunner(testPackage);
                var         y      = runner.CountTestCases(filter);
                node = runner.Run(testEventListner, filter);
                //TestRun testRun = RunManagerNunit.DeserializeTestRun(node);
            }
            return(node);
        }
コード例 #3
0
 /// <summary>
 /// Count the test cases that would be run under
 /// the specified filter.
 /// </summary>
 /// <param name="filter">A TestFilter</param>
 /// <returns>The count of test cases</returns>
 public int CountTestCases(TestFilter filter)
 {
     return(runner.CountTestCases(filter));
 }