Пример #1
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));
        }