Exemplo n.º 1
0
 protected override Task <RunSummary> RunTestCasesAsync()
 {
     return(TaskExecutor.RunAsync(
                CancellationTokenSource.Token,
                TestCases.Select(c => (Func <Task <RunSummary> >)(() => RunTestCaseAsync(c))).ToArray(),
                _testClass));
 }
Exemplo n.º 2
0
        protected override async Task <RunSummary> RunTestAsync()
        {
            if (_dataDiscoveryException != null)
            {
                return(RunTest_DataDiscoveryException());
            }

            var runSummary = await TaskExecutor.RunAsync(
                CancellationTokenSource.Token,
                _testRunners.Select(r => (Func <Task <RunSummary> >)r.RunScenarioAsync).ToArray(),
                TestCase.TestMethod.TestClass);

            // Run the cleanup here so we can include cleanup time in the run summary,
            // but save any exceptions so we can surface them during the cleanup phase,
            // so they get properly reported as test case cleanup failures.
            var timer = new ExecutionTimer();

            foreach (var disposable in _toDispose)
            {
                timer.Aggregate(() => _cleanupAggregator.Run(disposable.Dispose));
            }

            runSummary.Time += timer.Total;
            return(runSummary);
        }
Exemplo n.º 3
0
        protected override async Task <RunSummary> RunTestMethodsAsync()
        {
            IEnumerable <IXunitTestCase> orderedTestCases;

            try
            {
                orderedTestCases = TestCaseOrderer.OrderTestCases(TestCases);
            }
            catch (Exception ex)
            {
                var innerEx = ex.Unwrap();
                DiagnosticMessageSink.OnMessage(new DiagnosticMessage($"Test case orderer '{TestCaseOrderer.GetType().FullName}' threw '{innerEx.GetType().FullName}' during ordering: {innerEx.Message}{Environment.NewLine}{innerEx.StackTrace}"));
                orderedTestCases = TestCases.ToList();
            }

            var constructorArguments = CreateTestClassConstructorArguments();
            var tasks = orderedTestCases
                        .GroupBy(tc => tc.TestMethod, TestMethodComparer.Instance)
                        .Select(method => (Func <Task <RunSummary> >)(() => RunTestMethodAsync(method.Key, (IReflectionMethodInfo)method.Key.Method, method, constructorArguments)))
                        .ToArray();

            return(await TaskExecutor.RunAsync(CancellationTokenSource.Token, tasks, TestClass));
        }