use of org.jbehave.core.steps.AbstractStepResult.Failed in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldHandleTargetInvocationFailureInBeforeOrAfterStep.
@Test
public void shouldHandleTargetInvocationFailureInBeforeOrAfterStep() throws IntrospectionException {
// Given
SomeSteps stepsInstance = new SomeSteps();
MostUsefulConfiguration configuration = new MostUsefulConfiguration();
InjectableStepsFactory stepsFactory = new InstanceStepsFactory(configuration, stepsInstance);
StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory, stepsContext, configuration.parameterConverters(), new ParameterControls(), null, new SilentStepMonitor());
// When
Method method = SomeSteps.methodFor("aFailingBeforeScenarioMethod");
StepResult stepResult = stepCreator.createBeforeOrAfterStep(method, Meta.EMPTY).perform(null);
// Then
assertThat(stepResult, instanceOf(Failed.class));
assertThat(stepResult.getFailure(), instanceOf(UUIDExceptionWrapper.class));
Throwable cause = stepResult.getFailure().getCause();
assertThat(cause, instanceOf(BeforeOrAfterFailed.class));
assertThat(cause.getMessage(), org.hamcrest.Matchers.equalTo("Method aFailingBeforeScenarioMethod (annotated with @BeforeScenario in class org.jbehave.core.steps.SomeSteps) failed: java.lang.RuntimeException"));
}
Aggregations