use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldInvokeBeforeOrAfterStepMethodWithExpectedConvertedParametersFromMeta.
@Test
public void shouldInvokeBeforeOrAfterStepMethodWithExpectedConvertedParametersFromMeta() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
stepCreator.useParanamer(new CachingParanamer(new BytecodeReadingParanamer()));
// When
Date aDate = new Date();
when(parameterConverters.convert(anyString(), eq(Date.class))).thenReturn(aDate);
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithDate"), new Meta());
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Silent.class));
assertThat((Date) stepsInstance.args, is(aDate));
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldInvokeBeforeOrAfterStepMethodWithMetaUsingParanamer.
@Test
public void shouldInvokeBeforeOrAfterStepMethodWithMetaUsingParanamer() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
stepCreator.useParanamer(new CachingParanamer(new BytecodeReadingParanamer()));
Properties properties = new Properties();
properties.put("theme", "shopping cart");
// When
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithoutNamedAnnotation"), new Meta(properties));
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Silent.class));
assertThat((String) stepsInstance.args, is("shopping cart"));
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldInvokeAfterStepUponFailureOutcomeMethodIfFailureOccurred.
@Test
public void shouldInvokeAfterStepUponFailureOutcomeMethodIfFailureOccurred() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
Properties properties = new Properties();
properties.put("theme", "shopping cart");
properties.put("variant", "book");
// When
Step stepWithMeta = stepCreator.createAfterStepUponOutcome(SomeSteps.methodFor("aMethodWithANamedParameter"), AfterScenario.Outcome.FAILURE, new Meta(properties));
StepResult stepResult = stepWithMeta.doNotPerform(null);
// Then
assertThat(stepResult, instanceOf(Silent.class));
assertThat(stepsInstance.args, instanceOf(Map.class));
@SuppressWarnings("unchecked") Map<String, String> methodArgs = (Map<String, String>) stepsInstance.args;
assertThat(methodArgs.get("variant"), is("book"));
assertThat(methodArgs.get("theme"), is("shopping cart"));
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class StepCreatorBehaviour method shouldInvokeBeforeOrAfterStepMethodWithExpectedParametersFromMeta.
@Test
public void shouldInvokeBeforeOrAfterStepMethodWithExpectedParametersFromMeta() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
Properties properties = new Properties();
properties.put("theme", "shopping cart");
properties.put("variant", "book");
// When
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithANamedParameter"), new Meta(properties));
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Silent.class));
assertThat(stepsInstance.args, instanceOf(Map.class));
@SuppressWarnings("unchecked") Map<String, String> methodArgs = (Map<String, String>) stepsInstance.args;
assertThat(methodArgs.get("variant"), is("book"));
assertThat(methodArgs.get("theme"), is("shopping cart"));
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class StepsBehaviour method shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithNoFailureOccuring.
@Test
public void shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithNoFailureOccuring() {
MultipleAliasesSteps steps = new MultipleAliasesSteps();
ScenarioType scenarioType = ScenarioType.NORMAL;
List<BeforeOrAfterStep> beforeAfterScenario = steps.listBeforeOrAfterScenario(scenarioType);
assertThat(beforeAfterScenario.size(), equalTo(4));
beforeAfterScenario.get(0).createStep().perform(null);
assertThat(steps.beforeNormalScenario, is(true));
Meta storyAndScenarioMeta = null;
// uponOutcome=ANY
beforeAfterScenario.get(1).createStepUponOutcome(storyAndScenarioMeta).perform(null);
assertThat(steps.afterNormalScenario, is(true));
// uponOutcome=SUCCESS
beforeAfterScenario.get(2).createStepUponOutcome(storyAndScenarioMeta).perform(null);
assertThat(steps.afterSuccessfulScenario, is(true));
// uponOutcome=FAILURE
beforeAfterScenario.get(3).createStepUponOutcome(storyAndScenarioMeta).perform(null);
assertThat(steps.afterFailedScenario, is(false));
}
Aggregations