use of org.jbehave.core.configuration.Configuration in project jbehave-core by jbehave.
the class ConfigurableEmbedderBehaviour method shouldRunASingleStory.
@Test
public void shouldRunASingleStory() throws Throwable {
// Given
Embedder embedder = mock(Embedder.class);
Configuration configuration = mock(Configuration.class);
StoryPathResolver pathResolver = mock(StoryPathResolver.class);
when(embedder.configuration()).thenReturn(configuration);
when(configuration.storyPathResolver()).thenReturn(pathResolver);
Class<MyStory> storyClass = MyStory.class;
String storyPath = "/path/to/story";
when(pathResolver.resolve(storyClass)).thenReturn(storyPath);
CandidateSteps steps = mock(CandidateSteps.class);
// When
MyStory story = new MyStory(configuration, steps);
story.useEmbedder(embedder);
story.run();
// Then
verify(embedder).useConfiguration(configuration);
verify(embedder).useCandidateSteps(eq(asList(steps)));
verify(embedder).runStoriesAsPaths(asList(storyPath));
}
use of org.jbehave.core.configuration.Configuration 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.Configuration 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);
}
use of org.jbehave.core.configuration.Configuration in project jbehave-core by jbehave.
the class StepCandidateBehaviour method shouldPerformStepsInDryRunMode.
@Test
public void shouldPerformStepsInDryRunMode() {
Configuration configuration = new MostUsefulConfiguration();
configuration.storyControls().doDryRun(true);
NamedTypeSteps steps = new NamedTypeSteps(configuration);
List<StepCandidate> candidates = steps.listCandidates();
assertThat(candidates.size(), equalTo(2));
StepCandidate step0 = candidateMatchingStep(candidates, "Given foo named $name");
step0.createMatchedStep("Given foo named xyz", namedParameters).perform(null);
step0.createMatchedStep("And foo named xyz", namedParameters).perform(null);
StepCandidate step1 = candidateMatchingStep(candidates, "When foo named $name");
step1.createMatchedStep("When foo named Bar", namedParameters).perform(null);
step1.createMatchedStep("And foo named Bar", namedParameters).perform(null);
assertThat(steps.givenName, nullValue());
assertThat(steps.givenTimes, equalTo(0));
assertThat(steps.whenName, nullValue());
assertThat(steps.whenTimes, equalTo(0));
}
use of org.jbehave.core.configuration.Configuration in project jbehave-core by jbehave.
the class GroovyAnnotationBuilderBehaviour method shouldBuildCandidateStepsFromAnnotationsUsingGroovy.
@Test
public void shouldBuildCandidateStepsFromAnnotationsUsingGroovy() {
GroovyAnnotationBuilder builderAnnotated = new GroovyAnnotationBuilder(AnnotatedUsingGroovy.class);
Configuration configuration = builderAnnotated.buildConfiguration();
assertThatStepsInstancesAre(builderAnnotated.buildCandidateSteps(configuration), "FooSteps");
}
Aggregations