private static async Task MainAsync(string[] args)
        {
            var options = new RunnerOptions();

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

            var engine  = TestEngineActivator.CreateInstance(true);
            var package = new TestPackage(options.TargetAssembly);

            var reportItems       = new ConcurrentQueue <ReportItem>();
            var testEventListener = new TestEventListener(engine, package, reportItems, string.Empty);

            var testCount = testEventListener.Runner.CountTestCases(TestFilter.Empty);

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

            var userStepTime     = options.RampUp / options.Concurrency;
            var reportWriter     = new ReportWriter(reportItems);
            var reportWriterTask = Task.Run(() => reportWriter.StartWriting(options.ReportFile));
            var startTime        = DateTime.UtcNow;
            var testTasks        = new Task[options.Concurrency];

            for (int i = 0; i < options.Concurrency; i++)
            {
                var threadName = "worker_" + (i + 1);
                testTasks[i] = Task.Run(() => Test.RunTest(
                                            startTime, options, new TestEventListener(engine, package, reportItems, threadName)));
                Thread.Sleep(userStepTime * 1000);
            }

            await Task.WhenAll(testTasks);

            reportWriter.TestsCompleted = true;
            await reportWriterTask;
        }
        public void Verify_AddPerformanceTestRunResults()
        {
            // Arrange
            var resultXmlFilePath = EnsureFullPath("results.xml");
            var args = new[] { string.Format("--testresultsxmlsource={0}", resultXmlFilePath) };

            optionsParser.ParseOptions(PerformanceBenchmark, args);

            // Act
            PerformanceBenchmark.AddPerformanceTestRunResults(testResultXmlParser, performanceTestRunResults, testResults, new List <TestResult>());

            // Assert
            Assert.IsTrue(PerformanceBenchmark.ResultFilesExist);
            AssertCorrectResultXmlFilePaths(new[] { resultXmlFilePath });
            Assert.NotNull(testResults);
            Assert.IsTrue(testResults.Count > 0);
            Assert.NotNull(performanceTestRunResults);
            Assert.IsTrue(performanceTestRunResults.Count > 0);
        }