Search in sources :

Example 1 with ScenarioType

use of org.jbehave.core.annotations.ScenarioType in project jbehave-core by jbehave.

the class StepsBehaviour method shouldProvideStepsToBePerformedBeforeAndAfterScenariosParametrisedByExample.

@Test
public void shouldProvideStepsToBePerformedBeforeAndAfterScenariosParametrisedByExample() {
    MultipleAliasesSteps steps = new MultipleAliasesSteps();
    ScenarioType scenarioType = ScenarioType.EXAMPLE;
    List<BeforeOrAfterStep> beforeAfterScenario = steps.listBeforeOrAfterScenario(scenarioType);
    assertThat(beforeAfterScenario.size(), equalTo(2));
    beforeAfterScenario.get(0).createStep().perform(null);
    assertThat(steps.beforeExampleScenario, is(true));
    beforeAfterScenario.get(1).createStep().perform(null);
    assertThat(steps.afterExampleScenario, is(true));
}
Also used : ScenarioType(org.jbehave.core.annotations.ScenarioType) Test(org.junit.Test)

Example 2 with ScenarioType

use of org.jbehave.core.annotations.ScenarioType in project jbehave-core by jbehave.

the class StepsBehaviour method shouldProvideStepsToBeNotPerformedAfterScenarioUponOutcome.

@Test
public void shouldProvideStepsToBeNotPerformedAfterScenarioUponOutcome() {
    MultipleAliasesSteps steps = new MultipleAliasesSteps();
    ScenarioType scenarioType = ScenarioType.NORMAL;
    List<BeforeOrAfterStep> beforeAfterScenario = steps.listBeforeOrAfterScenario(scenarioType);
    assertThat(beforeAfterScenario.size(), equalTo(4));
    beforeAfterScenario.get(0).createStep().doNotPerform(null);
    assertThat(steps.beforeNormalScenario, is(true));
    Meta storyAndScenarioMeta = null;
    UUIDExceptionWrapper failure = new UUIDExceptionWrapper();
    // uponOutcome=ANY
    beforeAfterScenario.get(1).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(failure);
    assertThat(steps.afterNormalScenario, is(true));
    // uponOutcome=SUCCESS
    beforeAfterScenario.get(2).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(failure);
    assertThat(steps.afterSuccessfulScenario, is(false));
    // uponOutcome=FAILURE
    beforeAfterScenario.get(3).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(failure);
    assertThat(steps.afterFailedScenario, is(true));
}
Also used : Meta(org.jbehave.core.model.Meta) ScenarioType(org.jbehave.core.annotations.ScenarioType) UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper) Test(org.junit.Test)

Example 3 with ScenarioType

use of org.jbehave.core.annotations.ScenarioType in project jbehave-core by jbehave.

the class StepsBehaviour method shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithFailureOccuring.

@Test
public void shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithFailureOccuring() {
    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).doNotPerform(null);
    assertThat(steps.afterSuccessfulScenario, is(false));
    // uponOutcome=FAILURE
    beforeAfterScenario.get(3).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(null);
    assertThat(steps.afterFailedScenario, is(true));
}
Also used : Meta(org.jbehave.core.model.Meta) ScenarioType(org.jbehave.core.annotations.ScenarioType) Test(org.junit.Test)

Example 4 with ScenarioType

use of org.jbehave.core.annotations.ScenarioType in project jbehave-core by jbehave.

the class StepsBehaviour method shouldProvideStepsToBePerformedBeforeAndAfterAnyScenario.

@Test
public void shouldProvideStepsToBePerformedBeforeAndAfterAnyScenario() {
    MultipleAliasesSteps steps = new MultipleAliasesSteps();
    ScenarioType scenarioType = ScenarioType.ANY;
    List<BeforeOrAfterStep> beforeAfterScenario = steps.listBeforeOrAfterScenario(scenarioType);
    assertThat(beforeAfterScenario.size(), equalTo(2));
    beforeAfterScenario.get(0).createStep().perform(null);
    assertThat(steps.beforeAnyScenario, is(true));
    beforeAfterScenario.get(1).createStep().perform(null);
    assertThat(steps.afterAnyScenario, is(true));
}
Also used : ScenarioType(org.jbehave.core.annotations.ScenarioType) Test(org.junit.Test)

Example 5 with ScenarioType

use of org.jbehave.core.annotations.ScenarioType 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));
}
Also used : Meta(org.jbehave.core.model.Meta) ScenarioType(org.jbehave.core.annotations.ScenarioType) Test(org.junit.Test)

Aggregations

ScenarioType (org.jbehave.core.annotations.ScenarioType)6 Test (org.junit.Test)5 Meta (org.jbehave.core.model.Meta)3 UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)2 BeforeOrAfterFailed (org.jbehave.core.failures.BeforeOrAfterFailed)1 Failed (org.jbehave.core.steps.AbstractStepResult.Failed)1