Beispiel #1
0
        public virtual TestRunState Run(IReadOnlyList <ITestCase> testCases = null, TestRunState initialRunState = TestRunState.NoTests)
        {
            try
            {
                if (testCases == null)
                {
                    testCases = Discover();
                }

                var resultSink = new ResultSink(testListener, testCases.Count)
                {
                    TestRunState = initialRunState
                };
                toDispose.Push(resultSink);

                var executionOptions = TestFrameworkOptions.ForExecution(configuration);
                xunit.RunTests(testCases, resultSink, executionOptions);

                resultSink.Finished.WaitOne();

                return(resultSink.TestRunState);
            }
            catch (Exception ex)
            {
                testListener.WriteLine("Error during test execution:\r\n" + ex, Category.Error);
                return(TestRunState.Error);
            }
        }
        public virtual TestRunState Run(IReadOnlyList<ITestCase> testCases = null, TestRunState initialRunState = TestRunState.NoTests)
        {
            try
            {
                if (testCases == null)
                    testCases = Discover();

                var resultSink = new ResultSink(testListener, testCases.Count) { TestRunState = initialRunState };
                toDispose.Push(resultSink);

                var executionOptions = TestFrameworkOptions.ForExecution(configuration);
                xunit.RunTests(testCases, resultSink, executionOptions);

                resultSink.Finished.WaitOne();

                return resultSink.TestRunState;
            }
            catch (Exception ex)
            {
                testListener.WriteLine("Error during test execution:\r\n" + ex, Category.Error);
                return TestRunState.Error;
            }
        }
        public virtual TestRunState Run(
            IReadOnlyList <_TestCaseDiscovered>?testCases = null,
            TestRunState initialRunState = TestRunState.NoTests)
        {
            Guard.NotNull($"Attempted to use an uninitialized {GetType().FullName}", testListener);
            Guard.NotNull($"Attempted to use an uninitialized {GetType().FullName}", frontController);

            try
            {
                // TODO: This should be able to be converted to FindAndRun, but we need test case
                // count for the results sink...?
                if (testCases == null)
                {
                    testCases = Discover();
                }

                var resultSink = new ResultSink(testListener, testCases.Count)
                {
                    TestRunState = initialRunState
                };
                disposalTracker.Add(resultSink);

                var executionOptions = _TestFrameworkOptions.ForExecution(projectAssembly.Configuration);
                var settings         = new FrontControllerRunSettings(executionOptions, testCases.Select(tc => tc.Serialization));
                frontController.Run(resultSink, settings);

                resultSink.Finished.WaitOne();

                return(resultSink.TestRunState);
            }
            catch (Exception ex)
            {
                testListener.WriteLine("Error during test execution:\r\n" + ex, Category.Error);
                return(TestRunState.Error);
            }
        }