Exemple #1
0
        public void HasFailedSteps_should_report_failed_if_at_least_one_step_failed()
        {
            var passed = new StepResult("Foo".AsStringStep(""), new Passed());

            _results.AddActionStepResult(passed);
            var failed = new StepResult("Foo".AsStringStep(""), new Failed(new Exception()));

            _results.AddActionStepResult(failed);
            Assert.IsTrue(_results.HasFailedSteps());
        }
Exemple #2
0
        public override void ScenarioFinished(ScenarioResult result)
        {
            var hasFailures = result.HasFailedSteps();
            var pending     = result.StepResults.Where(r => r.Result is Pending || r.Result is PendingNotImplemented);
            var hasPending  = pending.Any();

            var isSuccessful = !(hasFailures || hasPending);

            var failingStep    = "";
            var failureMessage = "";

            if (!isSuccessful)
            {
                if (hasFailures)
                {
                    var step = result.StepResults.First(r => r.Result is Failed);
                    failingStep    = step.StringStep.Step;
                    failureMessage = result.Message;
                }
                else if (hasPending)
                {
                    failingStep    = pending.First().StringStep.Step;
                    failureMessage = STEP_HAS_NOT_YET_BEEN_IMPLEMENTED;
                }
            }

            var resultType = isSuccessful ? SUCCESSFUL_RESULT : UN_SUCCESSFUL_RESULT;

            // var resultInt = isSuccessful ? passStatus :failStatus;

            var resultInt = 0;

            if (isSuccessful)
            {
                resultInt = passStatus;
            }
            else if (hasPending)
            {
                resultInt = wipStatus;
            }
            else if (hasFailures)
            {
                resultInt = failStatus;
            }


            var unexecuted = unexecutedStatus;

            var comment           = isSuccessful ? AUTOMATED_EXECUTION : string.Format(FAILURE_COMMENT_FORMAT, failingStep, failureMessage);
            var unexecutedComment = UNEXECUTED_MESSAGE;

            logger.InfoFormat("Writing {0} execution result to Jira for scenario: {1}", resultType, result.ScenarioTitle);


            zapi.UpdateTestExecution(executionId, unexecuted, unexecutedComment.Length > MAX_COMMENT_LENGTH ? unexecutedComment.Substring(0, MAX_COMMENT_LENGTH) : unexecutedComment).Wait();



            zapi.UpdateTestExecution(executionId, resultInt, comment.Length > MAX_COMMENT_LENGTH ? comment.Substring(0, MAX_COMMENT_LENGTH) : comment).Wait();
        }
        public override void ScenarioFinished(ScenarioResult result)
        {
            logger.InfoFormat("Scenario finished [{0}]", result.ScenarioTitle);

            var stepResults = result.StepResults.ToList();

            foreach (var stepResult in stepResults)
            {
                var stepName   = stepResult.StringStep;
                var message    = stepResult.Message;
                var resultType = stepResult.Result.GetType().Name.ToUpper();
                var logEntry   = string.Format("{0}: {1} - {2}", resultType, stepName, message);

                if (stepResult.Result is Passed)
                {
                    logger.Info(logEntry);
                }
                else
                {
                    logger.Warn(logEntry);
                }
            }

            if (result.HasFailedSteps())
            {
                logger.ErrorFormat("SCENARIO FAILED: {0}", result.ScenarioTitle);
            }
        }
Exemple #4
0
 private void AfterScenario(Scenario scenario, ScenarioResult scenarioResult)
 {
     if (scenario.Steps.Any())
     {
         try
         {
             stringStepRunner.AfterScenario();
         }
         catch (Exception e)
         {
             if (!scenarioResult.HasFailedSteps())
                 scenarioResult.Fail(new WrappedException(e));
         }
     }
 }
Exemple #5
0
 private void AfterScenario(Scenario scenario, ScenarioResult scenarioResult)
 {
     if (scenario.Steps.Any())
     {
         try
         {
             stringStepRunner.AfterScenario();
         }
         catch (Exception e)
         {
             if (!scenarioResult.HasFailedSteps())
             {
                 scenarioResult.Fail(new WrappedException(e));
             }
         }
     }
 }
Exemple #6
0
 public void Should_not_fail_any_steps()
 {
     Assert.IsFalse(scenarioResult.HasFailedSteps());
 }