本文整理汇总了Java中org.jbehave.core.steps.Steps类的典型用法代码示例。如果您正苦于以下问题:Java Steps类的具体用法?Java Steps怎么用?Java Steps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Steps类属于org.jbehave.core.steps包,在下文中一共展示了Steps类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldRunStepsBeforeAndAfterStories
import org.jbehave.core.steps.Steps; //导入依赖的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);
}
示例2: shouldRunBeforeAndAfterStorySteps
import org.jbehave.core.steps.Steps; //导入依赖的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);
}
示例3: shouldHandlePendingStepsAccordingToStrategy
import org.jbehave.core.steps.Steps; //导入依赖的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());
}
示例4: shouldFailWithFailingUpongPendingStepsStrategy
import org.jbehave.core.steps.Steps; //导入依赖的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
}
示例5: shouldNotRunStoriesNotAllowedByFilter
import org.jbehave.core.steps.Steps; //导入依赖的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);
}
示例6: shouldNotRunStoriesNotAllowedByFilterOnStoryElement
import org.jbehave.core.steps.Steps; //导入依赖的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);
}
示例7: shouldNotRunScenariosNotAllowedByFilter
import org.jbehave.core.steps.Steps; //导入依赖的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();
}
示例8: stepsFactory
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Override
public InjectableStepsFactory stepsFactory() {
ArrayList<Steps> stepFileList = new ArrayList<Steps>();
stepFileList.add(new LoadByteSteps());
return new InstanceStepsFactory(configuration(), stepFileList);
}
示例9: stepsFactory
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Override
public InjectableStepsFactory stepsFactory() {
ArrayList<Steps> stepFileList = new ArrayList<Steps>();
stepFileList.add(new JBehaveTest());
return new InstanceStepsFactory(configuration(), stepFileList);
}
示例10: shouldReportFailuresInStepsBeforeAndAfterStories
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Test
public void shouldReportFailuresInStepsBeforeAndAfterStories() throws Throwable {
// Given
Step beforeStep = mock(Step.class, "beforeStep");
StepResult beforeResult = mock(StepResult.class, "beforeStep");
when(beforeStep.perform(null)).thenReturn(beforeResult);
UUIDExceptionWrapper failure = new UUIDExceptionWrapper("failed");
when(beforeResult.getFailure()).thenReturn(failure);
Step afterStep = mock(Step.class, "afterStep");
StepResult afterResult = mock(StepResult.class);
when(afterStep.doNotPerform(failure)).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).doNotPerform(failure);
}
示例11: shouldNotPerformStepsAfterFailedOrPendingSteps
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Test
public void shouldNotPerformStepsAfterFailedOrPendingSteps() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step firstStepNormal = mockSuccessfulStep("Given I succeed");
Step secondStepPending = mock(Step.class, "secondStepPending");
Step thirdStepNormal = mock(Step.class, "thirdStepNormal");
Step fourthStepAlsoPending = mock(Step.class, "fourthStepAlsoPending");
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
Scenario scenario = new Scenario();
when(collector.collectScenarioSteps(eq(asList(mySteps)), eq(scenario), eq(parameters))).thenReturn(
asList(firstStepNormal, secondStepPending, thirdStepNormal, fourthStepAlsoPending));
when(secondStepPending.perform(null)).thenReturn(pending("When I am pending"));
when(thirdStepNormal.doNotPerform(Matchers.<UUIDExceptionWrapper>any())).thenReturn(notPerformed("Then I should not be performed"));
when(fourthStepAlsoPending.doNotPerform(Matchers.<UUIDExceptionWrapper>any())).thenReturn(
notPerformed("Then I should not be performed either"));
Story story = new Story(asList(scenario));
givenStoryWithNoBeforeOrAfterSteps(story, false, collector, mySteps);
// When
StoryRunner runner = new StoryRunner();
runner.run(configurationWith(reporter, collector), asList(mySteps), story);
// Then
verify(firstStepNormal).perform(null);
verify(secondStepPending).perform(null);
verify(thirdStepNormal).doNotPerform(Matchers.<UUIDExceptionWrapper>any());
verify(fourthStepAlsoPending).doNotPerform(Matchers.<UUIDExceptionWrapper>any());
verify(reporter).successful("Given I succeed");
verify(reporter).pending("When I am pending");
verify(reporter).notPerformed("Then I should not be performed");
verify(reporter).notPerformed("Then I should not be performed either");
}
示例12: shouldReportAnyFailuresAndHandleThemAfterStory
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Test
public void shouldReportAnyFailuresAndHandleThemAfterStory() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step firstStepExceptional = mock(Step.class);
Step secondStepNotPerformed = mock(Step.class);
StepResult failed = failed("When I fail", new UUIDExceptionWrapper(new IllegalStateException()));
StepResult notPerformed = notPerformed("Then I should not be performed");
when(firstStepExceptional.perform(null)).thenReturn(failed);
when(secondStepNotPerformed.doNotPerform(Matchers.<UUIDExceptionWrapper>any())).thenReturn(notPerformed);
FailureStrategy failureStrategy = mock(FailureStrategy.class);
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
Scenario scenario = new Scenario();
when(collector.collectScenarioSteps(eq(asList(mySteps)), eq(scenario), eq(parameters))).thenReturn(
asList(firstStepExceptional, secondStepNotPerformed));
Story story = new Story(asList(scenario));
boolean givenStory = false;
givenStoryWithNoBeforeOrAfterSteps(story, givenStory, collector, mySteps);
// When
StoryRunner runner = new StoryRunner();
runner.run(configurationWith(reporter, collector, failureStrategy), asList(mySteps), story);
// Then
verify(firstStepExceptional).perform(null);
verify(secondStepNotPerformed).doNotPerform(Matchers.<UUIDExceptionWrapper>any());
InOrder inOrder = inOrder(reporter, failureStrategy);
inOrder.verify(reporter).beforeStory((Story) anyObject(), eq(givenStory));
inOrder.verify(reporter).beforeScenario((String) anyObject());
inOrder.verify(reporter).failed("When I fail", failed.getFailure());
inOrder.verify(reporter).notPerformed("Then I should not be performed");
inOrder.verify(reporter).afterScenario();
inOrder.verify(reporter).afterStory(givenStory);
inOrder.verify(failureStrategy).handleFailure(failed.getFailure());
}
示例13: shouldAllowToSkipScenariosAfterFailedScenario
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Test
public void shouldAllowToSkipScenariosAfterFailedScenario() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step failedStep = mock(Step.class);
Step neverExecutedStep = mock(Step.class);
StepResult failed = failed("When I fail", new UUIDExceptionWrapper(new IllegalStateException()));
when(failedStep.perform(null)).thenReturn(failed);
FailureStrategy failureStrategy = mock(FailureStrategy.class);
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
Scenario scenario1 = new Scenario();
when(collector.collectScenarioSteps(eq(asList(mySteps)), eq(scenario1), eq(parameters))).thenReturn(
asList(failedStep));
Scenario scenario2 = new Scenario();
when(collector.collectScenarioSteps(eq(asList(mySteps)), eq(scenario2), eq(parameters))).thenReturn(
asList(neverExecutedStep));
Story story = new Story(asList(scenario1, scenario2));
givenStoryWithNoBeforeOrAfterSteps(story, false, collector, mySteps);
// When
StoryRunner runner = new StoryRunner();
Configuration configuration = configurationWith(reporter, collector, failureStrategy);
configuration.storyControls().doSkipScenariosAfterFailure(true);
runner.run(configuration, asList(mySteps), story);
// Then
verify(failedStep).perform(null);
verify(neverExecutedStep, never()).perform(null);
}
示例14: shouldResetStateBeforeScenario
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Test
public void shouldResetStateBeforeScenario() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step pendingStep = mock(Step.class);
when(pendingStep.perform(null)).thenReturn(pending("pendingStep"));
Step secondStep = mockSuccessfulStep("secondStep");
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
Scenario scenario1 = new Scenario();
Scenario scenario2 = new Scenario();
when(collector.collectScenarioSteps(asList(mySteps), scenario1, parameters)).thenReturn(asList(pendingStep));
when(collector.collectScenarioSteps(asList(mySteps), scenario2, parameters)).thenReturn(asList(secondStep));
Story story = new Story(asList(scenario1, scenario2));
givenStoryWithNoBeforeOrAfterSteps(story, false, collector, mySteps);
// When
StoryRunner runner = new StoryRunner();
Configuration configuration = configurationWith(reporter, collector);
configuration.storyControls().doResetStateBeforeScenario(true);
runner.run(configuration, asList(mySteps), story);
// Then
verify(pendingStep).perform(Matchers.<UUIDExceptionWrapper>any());
verify(secondStep).perform(Matchers.<UUIDExceptionWrapper>any());
verify(secondStep, never()).doNotPerform(Matchers.<UUIDExceptionWrapper>any());
}
示例15: shouldAllowToNotResetStateBeforeScenario
import org.jbehave.core.steps.Steps; //导入依赖的package包/类
@Test
public void shouldAllowToNotResetStateBeforeScenario() throws Throwable {
// Given
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
Step pendingStep = mock(Step.class);
when(pendingStep.perform(null)).thenReturn(pending("pendingStep"));
Step secondStep = mockSuccessfulStep("secondStep");
StepCollector collector = mock(StepCollector.class);
CandidateSteps mySteps = new Steps();
Scenario scenario1 = new Scenario();
Scenario scenario2 = new Scenario();
when(collector.collectScenarioSteps(asList(mySteps), scenario1, parameters)).thenReturn(asList(pendingStep));
when(collector.collectScenarioSteps(asList(mySteps), scenario2, parameters)).thenReturn(asList(secondStep));
Story story = new Story(asList(scenario1, scenario2));
givenStoryWithNoBeforeOrAfterSteps(story, false, collector, mySteps);
// When
StoryRunner runner = new StoryRunner();
Configuration configuration = configurationWith(reporter, collector);
configuration.storyControls().doResetStateBeforeScenario(false);
runner.run(configuration, asList(mySteps), story);
// Then
verify(pendingStep).perform(Matchers.<UUIDExceptionWrapper>any());
verify(secondStep).doNotPerform(Matchers.<UUIDExceptionWrapper>any());
verify(secondStep, never()).perform(Matchers.<UUIDExceptionWrapper>any());
}