예제 #1
0
        private async Task RunTests()
        {
            try
            {
                var assemblySuite = runner.Load(assembly, new Dictionary <string, object>
                {
                    [FrameworkPackageSettings.NumberOfTestWorkers] = 0,
                    [FrameworkPackageSettings.SynchronousEvents]   = true,
                    [FrameworkPackageSettings.RunOnMainThread]     = true
                });
                var textUI = new TextUI(writer, reader: null, options: new NUnitLiteOptions("--workers=0"));
                textUI.DisplayHeader();
                textUI.DisplayTestFiles(new string[] { assembly.FullName });

                var results = new List <ITestResult>();

                foreach (var test in assemblySuite.Tests.SelectManyRecursive(suite => suite.Tests))
                {
                    if (test.HasChildren)
                    {
                        continue;
                    }

                    await Task.Delay(1); // Allow UI to respond

                    results.Add(runner.Run(new TextUIAdapterListener(textUI), new SingleTestCaseFilter(test)));
                }

                var result  = MergeTestResults(results);
                var summary = new ResultSummary(result);

                if (summary.ExplicitCount + summary.SkipCount + summary.IgnoreCount > 0)
                {
                    textUI.DisplayNotRunReport(result);
                }

                textUI.DisplayErrorsFailuresAndWarningsReport(result);
                textUI.DisplayRunSettings();
                textUI.DisplaySummaryReport(summary);

                OnTestRunEnded();
            }
            catch (Exception ex)
            {
                writer.WriteLine(ColorStyle.Error, "Unhandled runner exception: ");
                writer.WriteLine(ColorStyle.Error, ex.ToString());
            }
        }