use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldFailIfMatchedParametersAreNotFound.
@Test(expected = ParameterNotFound.class)
public void shouldFailIfMatchedParametersAreNotFound() {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepMatcher stepMatcher = mock(StepMatcher.class);
MostUsefulConfiguration configuration = new MostUsefulConfiguration();
InjectableStepsFactory stepsFactory = new InstanceStepsFactory(configuration, stepsInstance);
StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory, stepsContext, configuration.parameterConverters(), new ParameterControls(), stepMatcher, new SilentStepMonitor());
// When
when(stepMatcher.parameterNames()).thenReturn(new String[] {});
stepCreator.matchedParameter("unknown");
// Then .. fail as expected
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldHandleObjectNotStoredFailure.
@Test
public void shouldHandleObjectNotStoredFailure() throws IntrospectionException {
// Given
setupContext();
SomeSteps stepsInstance = new SomeSteps();
InjectableStepsFactory stepsFactory = new InstanceStepsFactory(new MostUsefulConfiguration(), stepsInstance);
StepMatcher stepMatcher = new RegexStepMatcher(StepType.WHEN, "I read from context", Pattern.compile("I read from context"), new String[] {});
StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory, stepsContext, null, new ParameterControls(), stepMatcher, new SilentStepMonitor());
// When
Method method = SomeSteps.methodFor("aMethodReadingFromContext");
StepResult stepResult = stepCreator.createParametrisedStep(method, "When I read from context", "I read from context", new HashMap<String, String>()).perform(null);
// Then
assertThat(stepResult, instanceOf(Failed.class));
Throwable cause = stepResult.getFailure().getCause();
assertThat(cause, instanceOf(ObjectNotStoredException.class));
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepFinderBehaviour method shouldFindStepdocs.
@Test
public void shouldFindStepdocs() throws Exception {
MySteps mySteps = new MySteps();
List<Stepdoc> stepdocs = finder.stepdocs(new InstanceStepsFactory(new MostUsefulConfiguration(), mySteps).createCandidateSteps());
Collections.sort(stepdocs);
assertThat(stepdocs.size(), equalTo(3));
assertThatStepdocIs(stepdocs.get(0), "givenFoo", "givenFoo(java.lang.String)", "foo named $name", "Given", GIVEN, mySteps);
assertThatStepdocIs(stepdocs.get(1), "whenFoo", "whenFoo(java.lang.String)", "foo named $name", "When", WHEN, mySteps);
assertThatStepdocIs(stepdocs.get(2), "thenFoo", "thenFoo(java.lang.String)", "foo named $name", "Then", THEN, mySteps);
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepsBehaviour method shouldListCandidateStepsFromAnnotatedMethodsInPojo.
@Test
public void shouldListCandidateStepsFromAnnotatedMethodsInPojo() {
PojoSteps steps = new PojoSteps();
Configuration configuration = new MostUsefulConfiguration();
List<StepCandidate> candidates = new InstanceStepsFactory(configuration, steps).createCandidateSteps().get(0).listCandidates();
assertThat(candidates.size(), equalTo(6));
findCandidate(candidates, "GIVEN a given").createMatchedStep("Given a given", tableRow).perform(null);
findCandidate(candidates, "GIVEN a given alias").createMatchedStep("Given a given alias", tableRow).perform(null);
findCandidate(candidates, "WHEN a when").createMatchedStep("When a when", tableRow).perform(null);
findCandidate(candidates, "WHEN a when alias").createMatchedStep("When a when alias", tableRow).perform(null);
findCandidate(candidates, "THEN a then").createMatchedStep("Then a then", tableRow).perform(null);
findCandidate(candidates, "THEN a then alias").createMatchedStep("Then a then alias", tableRow).perform(null);
assertThat(steps.givens, equalTo(2));
assertThat(steps.whens, equalTo(2));
assertThat(steps.thens, equalTo(2));
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class StepsBehaviour method shouldNotCreateStepIfStartingWordNotFound.
@Test(expected = StartingWordNotFound.class)
public void shouldNotCreateStepIfStartingWordNotFound() {
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));
// misspelled starting word
candidates.get(0).createMatchedStep("Dado che un dato che", tableRow);
}
Aggregations