Ejemplo n.º 1
0
        private void FinalizeTestRun()
        {
            IsRunning = false;
            EndTime   = DateTime.Now;

            _console?.WriteLine($"Finalizing test run...");
            var anyFailures = RunReports.SelectMany(x => x.Report.TestReports).Any(x => x.TestStatus == TestStatus.Fail);

            if (anyFailures)
            {
                TestStatus = TestStatus.Fail;
            }
            else
            {
                TestStatus = TestStatus.Pass;
            }
            if (_console?.IsOutputRedirected != true)
            {
                _console?.ClearAtRange(0, BeginY, 0, BeginY + 1 + _lastNumberOfLinesDrawn);
                _console?.SetCursorPosition(0, BeginY);
            }
        }
Ejemplo n.º 2
0
        private void ProcessActiveTests(EventEntry e)
        {
            // Debug.WriteLine($"EVENT: {e.Event.Event}");
            switch (e.Event.Event)
            {
            case EventNames.StartRun:
                _totalTestsQueued += e.Event.TestCount;
                break;

            case EventNames.StartAssembly:
                _activeAssemblies.Add(new EventEntry(e));
                break;

            case EventNames.EndAssembly:
                var matchingActiveAssembly = _activeAssemblies.FirstOrDefault(x => x.Event.TestSuite == e.Event.TestSuite && x.Event.Event == EventNames.StartAssembly);
                UpdateEventEntry(matchingActiveAssembly, e);
                break;

            case EventNames.StartSuite:
                if (!string.IsNullOrEmpty(e.Event.TestSuite) && e.Event.TestSuite.EndsWith(".dll"))
                {
                    // fix for older versions of nunit
                    e.Event.Event = EventNames.StartAssembly;
                    _activeAssemblies.Add(new EventEntry(e));
                }
                else
                {
                    _activeTestSuites.Add(new EventEntry(e));
                }
                break;

            case EventNames.EndSuite:
                var matchingActiveTestSuite = _activeTestSuites.FirstOrDefault(x => x.Event.TestSuite == e.Event.TestSuite && x.Event.Event == EventNames.StartSuite);
                UpdateEventEntry(matchingActiveTestSuite, e);
                break;

            case EventNames.StartTestFixture:
                _activeTestFixtures.Add(new EventEntry(e));
                break;

            case EventNames.EndTestFixture:
                var matchingActiveTestFixture = _activeTestFixtures.FirstOrDefault(x => x.Event.FullName == e.Event.FullName && x.Event.Event == EventNames.StartTestFixture);
                UpdateEventEntry(matchingActiveTestFixture, e);
                break;

            case EventNames.StartTest:
                // clone the event object
                _activeTests.Add(new EventEntry(e));
                break;

            case EventNames.EndTest:
                var matchingActiveTest = _activeTests.FirstOrDefault(x => x.Event.FullName == e.Event.FullName && x.Event.Event == EventNames.StartTest);
                UpdateEventEntry(matchingActiveTest, e);
                break;

            case EventNames.Report:
                RunReports.Add(e.Event);
                break;

            default:
                // unknown event type
                break;
            }
        }