Exemple #1
0
        Xunit1RunSummary RunTestCollection(ITestCollection testCollection, IEnumerable <ITestCase> testCases, IMessageSink messageSink)
        {
            var results = new Xunit1RunSummary();

            results.Continue = messageSink.OnMessage(new TestCollectionStarting(testCases, testCollection));

            try
            {
                if (results.Continue)
                {
                    foreach (var testClassGroup in testCases.GroupBy(tc => tc.TestMethod.TestClass, Comparer.Instance))
                    {
                        var classResults = RunTestClass(testClassGroup.Key, testClassGroup.ToList(), messageSink);
                        results.Aggregate(classResults);
                        if (!classResults.Continue)
                        {
                            break;
                        }
                    }
                }
            }
            finally
            {
                results.Continue = messageSink.OnMessage(new TestCollectionFinished(testCases, testCollection, results.Time, results.Total, results.Failed, results.Skipped)) && results.Continue;
            }

            return(results);
        }
Exemple #2
0
        void SendTestCaseMessagesWhenAppropriate(ITestCase current)
        {
            var results = TestClassResults;

            if (current != lastTestCase && lastTestCase != null)
            {
                results.Continue = messageSink.OnMessage(new TestCaseFinished(lastTestCase, testCaseResults.Time, testCaseResults.Total, testCaseResults.Failed, testCaseResults.Skipped)) && results.Continue;
                testMethodResults.Aggregate(testCaseResults);
                testCaseResults.Reset();

                if (current == null || lastTestCase.TestMethod.Method.Name != current.TestMethod.Method.Name)
                {
                    var testMethodTestCases = GetTestMethodTestCases(lastTestCase.TestMethod);

                    results.Continue = messageSink.OnMessage(new TestMethodFinished(testMethodTestCases,
                                                                                    lastTestCase.TestMethod,
                                                                                    testMethodResults.Time,
                                                                                    testMethodResults.Total,
                                                                                    testMethodResults.Failed,
                                                                                    testMethodResults.Skipped)) && results.Continue;
                    testMethodResults.Reset();
                }
            }

            if (current != lastTestCase && current != null)
            {
                if (lastTestCase == null || lastTestCase.TestMethod.Method.Name != current.TestMethod.Method.Name)
                {
                    var testMethodTestCases = GetTestMethodTestCases(current.TestMethod);
                    results.Continue = messageSink.OnMessage(new TestMethodStarting(testMethodTestCases, current.TestMethod)) && results.Continue;
                }

                results.Continue = messageSink.OnMessage(new TestCaseStarting(current)) && results.Continue;
            }

            lastTestCase = current;
        }