Exemplo n.º 1
0
        private static async void ExecuteTests(CommandLineOptions options)
        {
            var logger = LogManager.LogFactory.GetLogger("Logger");

            try
            {
                SetUpLogging(options);

                if (options.SingleRun)
                {
                    logger.Log(LogLevel.Info, "Executing single run...");
                    var result = await new SingleTestExecutor(logger).Execute(options.RunCommand);
                    logger.Log(result.IsCompletedSuccessfully ? LogLevel.Info : LogLevel.Error, $"{result.Type} {result.Error}");
                    return;
                }

                logger.Log(LogLevel.Info, "Executing full test...");

                var aggregated = new ResultsAggregator().Aggregate(await Task.WhenAll(Enumerable.Range(1, 100)
                                                                                      .Select(index =>
                {
                    logger.Log(LogLevel.Info, $"----------------------");
                    logger.Log(LogLevel.Info, $"Executing run #{index}");
                    return(new SingleTestExecutor(logger).Execute(options.RunCommand));
                })));

                Console.WriteLine(aggregated);
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                throw;
            }
        }
 public void BeforeEach()
 {
     ResultsAggregator.Execute(Path.Combine(Environment.CurrentDirectory, Destination), _result1, _result2);
     _document        = XDocument.Load(Destination);
     _resultDocument1 = XDocument.Load(_result1.ResultsFilepath);
     _resultDocument2 = XDocument.Load(_result2.ResultsFilepath);
 }
Exemplo n.º 3
0
        public void Run()
        {
            // TODO: Check mode
            // Right now environment-level parallelization is only supported,
            // though with the process starter we could do more granular assembly-level parallelization as well
            var tasks   = new List <Task>();
            var results = new List <TestRunResult>();
            var runs    = GetRuns();

            if (runs.Count() < 1)
            {
                Console.WriteLine("No tests were found using the provided options!");
            }

            foreach (var run in GetRuns())
            {
                // Start the process
                var starter = new NUnitProcessStarter(
                    Path.Combine(Path.GetFullPath(run.Environment.Path),
                                 Options.AssemblyFileName),
                    run.Environment.Name);
                _processes.Add(starter);

                // Get the full type name (including namespace) for each type, join into comma-separated string
                var testNames = run.Tests.Select(x => string.Format("{0}.{1}", x.ReflectedType, x.Name));
                tasks.Add(Task.Run(
                              async() => results.Add(
                                  new TestRunResult
                {
                    ResultsFilepath = "nunit-runner\\" + await starter.RunAsync(testNames),
                    Environment     = run.Environment
                }
                                  )
                              ));
            }

            Task.WaitAll(tasks.ToArray());

            if (Options.AggregateResults)
            {
                ResultsAggregator.Execute(Options.ResultsFilepath, results.ToArray());
            }
        }