use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldHandleFailureInParametrisedStep.
@Test
public void shouldHandleFailureInParametrisedStep() {
// Given
SomeSteps stepsInstance = new SomeSteps();
InjectableStepsFactory stepsFactory = new InstanceStepsFactory(new MostUsefulConfiguration(), stepsInstance);
StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory, stepsContext, null, new ParameterControls(), null, new SilentStepMonitor());
// When
Method method = null;
StepResult stepResult = stepCreator.createParametrisedStep(method, "When I fail", "I fail", null).perform(null);
// Then
assertThat(stepResult, instanceOf(Failed.class));
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldHandleTargetInvocationFailureInParametrisedStep.
@Test
public void shouldHandleTargetInvocationFailureInParametrisedStep() throws IntrospectionException {
// Given
SomeSteps stepsInstance = new SomeSteps();
InjectableStepsFactory stepsFactory = new InstanceStepsFactory(new MostUsefulConfiguration(), stepsInstance);
StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory, stepsContext, null, new ParameterControls(), null, new SilentStepMonitor());
// When
Method method = SomeSteps.methodFor("aFailingMethod");
StepResult stepResult = stepCreator.createParametrisedStep(method, "When I fail", "I fail", null).perform(null);
// Then
assertThat(stepResult, instanceOf(Failed.class));
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldHandleObjectAlreadyStoredFailure.
private void shouldHandleObjectAlreadyStoredFailure(Method duplicateStoreMethod) throws IntrospectionException {
// Given
setupContext();
SomeSteps stepsInstance = new SomeSteps();
InjectableStepsFactory stepsFactory = new InstanceStepsFactory(new MostUsefulConfiguration(), stepsInstance);
StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory, stepsContext, null, new ParameterControls(), mock(StepMatcher.class), new SilentStepMonitor());
// When
Method method = SomeSteps.methodFor("aMethodStoringAString");
StepResult stepResult = stepCreator.createParametrisedStep(method, "When I store in context", "I store in context", new HashMap<String, String>()).perform(null);
StepResult stepResultSecondWrite = stepCreator.createParametrisedStep(duplicateStoreMethod, "And I store in context", "I store in context", new HashMap<String, String>()).perform(null);
// Then
assertThat(stepResult, instanceOf(Successful.class));
assertThat(stepResultSecondWrite, instanceOf(Failed.class));
Throwable cause = stepResultSecondWrite.getFailure().getCause();
assertThat(cause, instanceOf(ObjectAlreadyStoredException.class));
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepsBehaviour method shouldAllowLocalizationOfSteps.
@Test
public void shouldAllowLocalizationOfSteps() {
Configuration configuration = new MostUsefulConfiguration();
configuration.useKeywords(new LocalizedKeywords(new Locale("it")));
LocalizedSteps steps = new LocalizedSteps(configuration);
List<StepCandidate> candidates = steps.listCandidates();
assertThat(candidates.size(), equalTo(3));
findCandidate(candidates, "GIVEN un dato che").createMatchedStep("Dato che un dato che", tableRow).perform(null);
findCandidate(candidates, "WHEN un quando").createMatchedStep("Quando un quando", tableRow).perform(null);
findCandidate(candidates, "THEN un allora").createMatchedStep("Allora un allora", tableRow).perform(null);
assertThat(steps.givens, equalTo(1));
assertThat(steps.whens, equalTo(1));
assertThat(steps.thens, equalTo(1));
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class InstanceStepsFactoryBehaviour method shouldDetermineIfStepsInstanceHasAnnotatedMethods.
@Test
public void shouldDetermineIfStepsInstanceHasAnnotatedMethods() {
InstanceStepsFactory factory = new InstanceStepsFactory(new MostUsefulConfiguration());
assertThat(factory.hasAnnotatedMethods(MySteps.class), is(true));
assertThat(factory.hasAnnotatedMethods(NoAnnotatedMethods.class), is(false));
}
Aggregations