private void InvokeStep(ITestRunStep step, TestRunExecutionContext context, TestRunResult result, ITestRunLogger logger) { context.Step = step; try { step.Run(context); } catch (TestRunAssertException) { result.AddStep(new TestRunStepResult(context.StepNumber, step.ToString(), false)); throw; } catch (Exception ex) { result.IsSuccess = false; if (context.FirstException == null) { result.FailException = ex; context.FirstException = ex; } else { context.LastException = ex; } } result.AddStep(new TestRunStepResult(context.StepNumber, step.ToString(), result.IsSuccess)); }
/// <summary> /// Throw exception and format it with current execution context. /// </summary> /// <param name="message">Message to display to user.</param> /// <param name="context">Current test execution context.</param> /// <param name="step">Test run step instance.</param> public static void ThrowWithExecutionContext(string message, TestRunExecutionContext context, ITestRunStep step) { throw new TestRunAssertException(message); }