本文整理汇总了Java中org.jbehave.core.steps.CandidateSteps类的典型用法代码示例。如果您正苦于以下问题:Java CandidateSteps类的具体用法?Java CandidateSteps怎么用?Java CandidateSteps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CandidateSteps类属于org.jbehave.core.steps包,在下文中一共展示了CandidateSteps类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertThatStepsCanBeCreated
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void assertThatStepsCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
// Given
Injector parent = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(FooSteps.class).in(Scopes.SINGLETON);
}
});
AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
// When
List<CandidateSteps> steps = factory.createCandidateSteps();
// Then
assertFooStepsFound(steps);
}
示例2: assertThatStepsWithStepsWithDependencyCanBeCreated
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void assertThatStepsWithStepsWithDependencyCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
Injector parent = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(Integer.class).toInstance(42);
bind(FooStepsWithDependency.class).in(Scopes.SINGLETON);
}
});
// When
AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
List<CandidateSteps> steps = factory.createCandidateSteps();
// Then
assertFooStepsFound(steps);
assertEquals(42, (int) ((FooStepsWithDependency) stepsInstance(steps.get(0))).integer);
}
示例3: reportStepdocsAsEmbeddables
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
public void reportStepdocsAsEmbeddables(List<String> classNames) {
EmbedderControls embedderControls = embedderControls();
if (embedderControls.skip()) {
embedderMonitor.embeddablesSkipped(classNames);
return;
}
for (Embeddable embeddable : embeddables(classNames, classLoader())) {
if (embeddable instanceof ConfigurableEmbedder) {
ConfigurableEmbedder configurableEmbedder = (ConfigurableEmbedder) embeddable;
List<CandidateSteps> steps = configurableEmbedder.candidateSteps();
if (steps.isEmpty()) {
steps = configurableEmbedder.stepsFactory().createCandidateSteps();
}
reportStepdocs(configurableEmbedder.configuration(), steps);
} else {
embedderMonitor.embeddableNotConfigurable(embeddable.getClass().getName());
}
}
}
示例4: shouldRunASingleStory
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@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));
}
示例5: shouldAllowOverrideOfDefaultConfiguration
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldAllowOverrideOfDefaultConfiguration() 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(new MostUsefulConfiguration(), steps);
assertThat(story.configuration(), is(not(sameInstance(configuration))));
story.useConfiguration(configuration);
assertThat(story.configuration(), is(sameInstance(configuration)));
story.useEmbedder(embedder);
story.run();
// Then
verify(embedder).useConfiguration(configuration);
verify(embedder).useCandidateSteps(Mockito.eq(Arrays.asList(steps)));
verify(embedder).runStoriesAsPaths(asList(storyPath));
}
示例6: shouldAllowAdditionOfSteps
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldAllowAdditionOfSteps() 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).runStoriesAsPaths(asList(storyPath));
}
示例7: shouldRunStepsBeforeAndAfterStories
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldRunStepsBeforeAndAfterStories() throws Throwable {
// Given
Step beforeStep = mock(Step.class, "beforeStep");
StepResult beforeResult = mock(StepResult.class);
when(beforeStep.perform(null)).thenReturn(beforeResult);
Step afterStep = mock(Step.class, "afterStep");
StepResult afterResult = mock(StepResult.class);
when(afterStep.perform(null)).thenReturn(afterResult);
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
StoryReporter reporter = mock(StoryReporter.class);
FailureStrategy failureStrategy = mock(FailureStrategy.class);
// When
StoryRunner runner = new StoryRunner();
when(collector.collectBeforeOrAfterStoriesSteps(asList(mySteps), Stage.BEFORE)).thenReturn(asList(beforeStep));
runner.runBeforeOrAfterStories(configurationWith(reporter, collector, failureStrategy), asList(mySteps), Stage.BEFORE);
when(collector.collectBeforeOrAfterStoriesSteps(asList(mySteps), Stage.AFTER)).thenReturn(asList(afterStep));
runner.runBeforeOrAfterStories(configurationWith(reporter, collector, failureStrategy), asList(mySteps), Stage.AFTER);
// Then
verify(beforeStep).perform(null);
verify(afterStep).perform(null);
}
示例8: shouldRunBeforeAndAfterStorySteps
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldRunBeforeAndAfterStorySteps() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step beforeStep = mockSuccessfulStep("beforeStep");
Step afterStep = mockSuccessfulStep("secondStep");
StepCollector collector = mock(StepCollector.class);
FailureStrategy strategy = mock(FailureStrategy.class);
CandidateSteps mySteps = new Steps();
Story story = new Story();
boolean givenStory = false;
when(collector.collectBeforeOrAfterStorySteps(asList(mySteps), story, Stage.BEFORE, givenStory)).thenReturn(asList(beforeStep));
when(collector.collectBeforeOrAfterStorySteps(asList(mySteps), story, Stage.AFTER, givenStory)).thenReturn(asList(afterStep));
// When
StoryRunner runner = new StoryRunner();
runner.run(configurationWith(reporter, collector, strategy),asList(mySteps), story);
// Then
verify(beforeStep).perform(null);
verify(afterStep).perform(null);
}
示例9: shouldHandlePendingStepsAccordingToStrategy
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldHandlePendingStepsAccordingToStrategy() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step pendingStep = mock(Step.class);
StepResult pendingResult = pending("My step isn't defined!");
when(pendingStep.perform(null)).thenReturn(pendingResult);
PendingStepStrategy strategy = mock(PendingStepStrategy.class);
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
when(collector.collectScenarioSteps(eq(asList(mySteps)), (Scenario) anyObject(), eq(parameters))).thenReturn(
asList(pendingStep));
Story story = new Story(asList(new Scenario()));
givenStoryWithNoBeforeOrAfterSteps(story, false, collector, mySteps);
// When
StoryRunner runner = new StoryRunner();
runner.run(configurationWithPendingStrategy(collector, reporter,
strategy), asList(mySteps), story);
// Then
verify(strategy).handleFailure(pendingResult.getFailure());
}
示例10: shouldFailWithFailingUpongPendingStepsStrategy
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test(expected = PendingStepFound.class)
public void shouldFailWithFailingUpongPendingStepsStrategy() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step pendingStep = mock(Step.class);
StepResult pendingResult = pending("My step isn't defined!");
when(pendingStep.perform(null)).thenReturn(pendingResult);
PendingStepStrategy strategy = new FailingUponPendingStep();
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
when(collector.collectScenarioSteps(eq(asList(mySteps)), (Scenario) anyObject(), eq(parameters))).thenReturn(
asList(pendingStep));
Story story = new Story(asList(new Scenario()));
givenStoryWithNoBeforeOrAfterSteps(story, false, collector, mySteps);
// When
StoryRunner runner = new StoryRunner();
runner.run(configurationWithPendingStrategy(collector, reporter,
strategy), asList(mySteps), story);
// Then ... fail as expected
}
示例11: shouldNotRunStoriesNotAllowedByFilter
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldNotRunStoriesNotAllowedByFilter() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
StepCollector collector = mock(StepCollector.class);
FailureStrategy strategy = mock(FailureStrategy.class);
CandidateSteps mySteps = new Steps();
when(collector.collectScenarioSteps(eq(asList(mySteps)), (Scenario) anyObject(), eq(parameters))).thenReturn(
Arrays.<Step>asList());
Meta meta = new Meta(asList("some property"));
Story story = new Story("", Description.EMPTY, meta, Narrative.EMPTY, asList(new Scenario()));
boolean givenStory = false;
givenStoryWithNoBeforeOrAfterSteps(story, givenStory, collector, mySteps);
String filterAsString = "-some property";
MetaFilter filter = new MetaFilter(filterAsString);
// When
StoryRunner runner = new StoryRunner();
runner.run(configurationWith(reporter, collector, strategy), asList(mySteps), story, filter);
// Then
verify(reporter).beforeStory(story, givenStory);
verify(reporter).storyNotAllowed(story, filterAsString);
verify(reporter).afterStory(givenStory);
}
示例12: shouldNotRunStoriesNotAllowedByFilterOnStoryElement
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldNotRunStoriesNotAllowedByFilterOnStoryElement() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
StepCollector collector = mock(StepCollector.class);
FailureStrategy strategy = mock(FailureStrategy.class);
CandidateSteps mySteps = new Steps();
when(collector.collectScenarioSteps(eq(asList(mySteps)), (Scenario) anyObject(), eq(parameters))).thenReturn(
Arrays.<Step>asList());
Story story = new Story("excluded_path", Description.EMPTY, Meta.EMPTY, Narrative.EMPTY, asList(new Scenario()));
boolean givenStory = false;
givenStoryWithNoBeforeOrAfterSteps(story, givenStory, collector, mySteps);
String filterAsString = "-story_path excluded_path";
MetaFilter filter = new MetaFilter(filterAsString);
// When
StoryRunner runner = new StoryRunner();
Configuration configuration = configurationWith(reporter, collector, strategy);
configuration.storyControls().useStoryMetaPrefix("story_");
runner.run(configuration, asList(mySteps), story, filter);
// Then
verify(reporter).beforeStory(story, givenStory);
verify(reporter).storyNotAllowed(story, filterAsString);
verify(reporter).afterStory(givenStory);
}
示例13: shouldNotRunScenariosNotAllowedByFilter
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldNotRunScenariosNotAllowedByFilter() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
StepCollector collector = mock(StepCollector.class);
FailureStrategy strategy = mock(FailureStrategy.class);
CandidateSteps mySteps = new Steps();
when(collector.collectScenarioSteps(eq(asList(mySteps)), (Scenario) anyObject(), eq(parameters))).thenReturn(
Arrays.<Step>asList());
Meta meta = new Meta(asList("some property"));
Story story = new Story("", Description.EMPTY, Meta.EMPTY, Narrative.EMPTY, asList(new Scenario("", meta, GivenStories.EMPTY, ExamplesTable.EMPTY, asList(""))));
boolean givenStory = false;
givenStoryWithNoBeforeOrAfterSteps(story, givenStory, collector, mySteps);
String filterAsString = "-some property";
MetaFilter filter = new MetaFilter(filterAsString);
// When
StoryRunner runner = new StoryRunner();
runner.run(configurationWith(reporter, collector, strategy), asList(mySteps), story, filter);
// Then
verify(reporter).beforeStory(story, givenStory);
verify(reporter).beforeScenario("");
verify(reporter).scenarioNotAllowed(story.getScenarios().get(0), filterAsString);
verify(reporter).afterScenario();
}
示例14: shouldFindAndReportMatchingSteps
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldFindAndReportMatchingSteps() {
// Given
Embedder embedder = new Embedder();
embedder.useCandidateSteps(asList((CandidateSteps) new MySteps()));
embedder.configuration().useStepFinder(new StepFinder());
OutputStream out = new ByteArrayOutputStream();
embedder.configuration().useStepdocReporter(new PrintStreamStepdocReporter(new PrintStream(out)));
// When
embedder.reportMatchingStepdocs("Given a given");
// Then
String expected = "Step 'Given a given' is matched by annotated patterns:\n" + "'Given a given'\n"
+ "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.given()\n" + "from steps instances:\n"
+ "org.jbehave.core.embedder.EmbedderBehaviour$MySteps\n";
assertThat(dos2unix(out.toString()), equalTo(expected));
}
示例15: shouldReportAllStepdocs
import org.jbehave.core.steps.CandidateSteps; //导入依赖的package包/类
@Test
public void shouldReportAllStepdocs() {
// Given
Embedder embedder = new Embedder();
embedder.useCandidateSteps(asList((CandidateSteps) new MySteps()));
embedder.configuration().useStepFinder(new StepFinder());
OutputStream out = new ByteArrayOutputStream();
embedder.configuration().useStepdocReporter(new PrintStreamStepdocReporter(new PrintStream(out)));
// When
embedder.reportStepdocs();
// Then
String output = dos2unix(out.toString());
assertThat(output, containsString("'Given a given'\n"
+ "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.given()\n"));
assertThat(output, containsString("'When a when'\n"
+ "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.when()\n"));
assertThat(output, containsString("'Then a then'\n"
+ "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.then()\n"));
assertThat(output,
containsString("from steps instances:\norg.jbehave.core.embedder.EmbedderBehaviour$MySteps\n"));
}