// ToDo: this method does not really belong to this class public StepExecutionResult ExecuteStep(ExecutionStep executionStep) { try { executionStep.Execute(TestObject); executionStep.Result = StepExecutionResult.Passed; } catch (Exception ex) { // ToDo: more thought should be put into this. Is it safe to get the exception? var exception = ex; if (exception is TargetInvocationException) { exception = ex.InnerException ?? ex; } if (exception is NotImplementedException) { executionStep.Result = StepExecutionResult.NotImplemented; executionStep.Exception = exception; } else if (IsInconclusive(exception)) { executionStep.Result = StepExecutionResult.Inconclusive; executionStep.Exception = exception; } else { executionStep.Exception = exception; executionStep.Result = StepExecutionResult.Failed; } } return executionStep.Result; }
private static void AssertStep(ExecutionStep step, string stepTitle, ExecutionOrder order, bool asserts = false, bool shouldReport = true) { Assert.That(step.StepTitle.Trim(), Is.EqualTo(stepTitle)); Assert.That(step.Asserts, Is.EqualTo(asserts)); Assert.That(step.ExecutionOrder, Is.EqualTo(order)); Assert.That(step.ShouldReport, Is.EqualTo(shouldReport)); }
void ReportOnStep(Scenario scenario, ExecutionStep step) { var message = string.Format ("\t{0} [{1}] ", PrefixWithSpaceIfRequired(step).PadRight(_longestStepSentence + 5), Configurator.Scanners.Humanize(step.Result.ToString())); // if all the steps have passed, there is no reason to make noise if (scenario.Result == StepExecutionResult.Passed) message = "\t" + PrefixWithSpaceIfRequired(step); if (step.Exception != null) { _exceptions.Add(step.Exception); var exceptionReference = string.Format("[Details at {0} below]", _exceptions.Count); if (!string.IsNullOrEmpty(step.Exception.Message)) message += string.Format("[{0}] {1}", FlattenExceptionMessage(step.Exception.Message), exceptionReference); else message += string.Format("{0}", exceptionReference); } if (step.Result == StepExecutionResult.Inconclusive || step.Result == StepExecutionResult.NotImplemented) Console.ForegroundColor = ConsoleColor.Yellow; else if (step.Result == StepExecutionResult.Failed) Console.ForegroundColor = ConsoleColor.Red; else if (step.Result == StepExecutionResult.NotExecuted) Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(message); Console.ForegroundColor = ConsoleColor.White; }
// ToDo: this method does not really belong to this class public StepExecutionResult ExecuteStep(ExecutionStep executionStep) { try { executionStep.Execute(TestObject); executionStep.Result = StepExecutionResult.Passed; } catch (Exception ex) { // ToDo: more thought should be put into this. Is it safe to get the exception? var exception = ex; if (exception is TargetInvocationException) { exception = ex.InnerException ?? ex; } if (exception is NotImplementedException) { executionStep.Result = StepExecutionResult.NotImplemented; executionStep.Exception = exception; } else if (IsInconclusive(exception)) { executionStep.Result = StepExecutionResult.Inconclusive; executionStep.Exception = exception; } else { executionStep.Exception = exception; executionStep.Result = StepExecutionResult.Failed; } } return(executionStep.Result); }
static string PrefixWithSpaceIfRequired(ExecutionStep step) { var stepTitle = step.StepTitle; var executionOrder = step.ExecutionOrder; if (executionOrder == ExecutionOrder.ConsecutiveAssertion || executionOrder == ExecutionOrder.ConsecutiveSetupState || executionOrder == ExecutionOrder.ConsecutiveTransition) stepTitle = " " + stepTitle; // add two spaces in the front for indentation. return stepTitle.Replace(Environment.NewLine, Environment.NewLine + "\t\t"); }