public void GivenTestIsSkippedWhenFlagIsSet()
 {
     if (Settings.UseCookieOverride)
     {
         RuntimeProvider.TestIgnore("Test skipped because it cannot be performed using cookie override for authentication.");
     }
 }
Exemple #2
0
 public void SkipWindowsOnlyScenarioIfNotOnWindows()
 {
     if (!_runtimeInformationProvider.IsOperatingSystemWindows())
     {
         _unitTestRuntimeProvider.TestIgnore("Test must be run on a Windows host system.");
     }
 }
        public virtual void OnAfterLastStep()
        {
            HandleBlockSwitch(ScenarioBlock.None);

            if (_specFlowConfiguration.TraceTimings)
            {
                _contextManager.ScenarioContext.Stopwatch.Stop();
                var duration = _contextManager.ScenarioContext.Stopwatch.Elapsed;
                _testTracer.TraceDuration(duration, "Scenario: " + _contextManager.ScenarioContext.ScenarioInfo.Title);
            }

            var testResultResult = _testResultFactory.BuildFromContext(_contextManager.ScenarioContext, _contextManager.FeatureContext);

            switch (testResultResult)
            {
            case ISuccess <TestResult> success:
                _cucumberMessageSender.SendTestCaseFinished(_contextManager.ScenarioContext.ScenarioInfo, success.Result);
                _testRunResultCollector.CollectTestResultForScenario(_contextManager.ScenarioContext.ScenarioInfo, success.Result);
                break;

            case IFailure failure:
                _testTracer.TraceWarning(failure.ToString());
                break;
            }

            if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.OK)
            {
                return;
            }

            if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.Skipped)
            {
                _unitTestRuntimeProvider.TestIgnore("Scenario ignored using @Ignore tag");
                return;
            }

            if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.StepDefinitionPending)
            {
                string pendingStepExceptionMessage = _testPendingMessageFactory.BuildFromScenarioContext(_contextManager.ScenarioContext);
                _errorProvider.ThrowPendingError(_contextManager.ScenarioContext.ScenarioExecutionStatus, pendingStepExceptionMessage);
                return;
            }

            if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.UndefinedStep)
            {
                string undefinedStepExceptionMessage = _testUndefinedMessageFactory.BuildFromContext(_contextManager.ScenarioContext, _contextManager.FeatureContext);
                _errorProvider.ThrowPendingError(_contextManager.ScenarioContext.ScenarioExecutionStatus, undefinedStepExceptionMessage);
                return;
            }

            if (_contextManager.ScenarioContext.TestError == null)
            {
                throw new InvalidOperationException("test failed with an unknown error");
            }

            _contextManager.ScenarioContext.TestError.PreserveStackTrace();
            throw _contextManager.ScenarioContext.TestError;
        }
Exemple #4
0
        public void ThrowPendingError(TestStatus testStatus, string message)
        {
            switch (RuntimeConfiguration.Current.MissingOrPendingStepsOutcome)
            {
            case MissingOrPendingStepsOutcome.Inconclusive:
                unitTestRuntimeProvider.TestInconclusive(message);
                break;

            case MissingOrPendingStepsOutcome.Ignore:
                unitTestRuntimeProvider.TestIgnore(message);
                break;

            default:
                if (testStatus == TestStatus.MissingStepDefinition)
                {
                    throw GetMissingStepDefinitionError();
                }
                throw GetPendingStepDefinitionError();
            }
        }
Exemple #5
0
        public void ThrowPendingError(ScenarioExecutionStatus testStatus, string message)
        {
            switch (specFlowConfiguration.MissingOrPendingStepsOutcome)
            {
            case MissingOrPendingStepsOutcome.Pending:
                unitTestRuntimeProvider.TestPending(message);
                break;

            case MissingOrPendingStepsOutcome.Inconclusive:
                unitTestRuntimeProvider.TestInconclusive(message);
                break;

            case MissingOrPendingStepsOutcome.Ignore:
                unitTestRuntimeProvider.TestIgnore(message);
                break;

            default:
                if (testStatus == ScenarioExecutionStatus.UndefinedStep)
                {
                    throw GetMissingStepDefinitionError();
                }
                throw GetPendingStepDefinitionError();
            }
        }