Search in sources :

Example 1 with Scenario

use of cucumber.api.Scenario in project cucumber-jvm by cucumber.

the class RuntimeTest method should_make_scenario_id_available_to_hooks.

@Test
public void should_make_scenario_id_available_to_hooks() throws Throwable {
    CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n" + "    When second step\n" + "    Then third step\n");
    HookDefinition beforeHook = mock(HookDefinition.class);
    when(beforeHook.matches(anyCollectionOf(Tag.class))).thenReturn(true);
    Runtime runtime = createRuntimeWithMockedGlue(mock(StepDefinitionMatch.class), beforeHook, true);
    feature.run(mock(Formatter.class), mock(Reporter.class), runtime);
    ArgumentCaptor<Scenario> capturedScenario = ArgumentCaptor.forClass(Scenario.class);
    verify(beforeHook).execute(capturedScenario.capture());
    assertEquals("feature-name;scenario-name", capturedScenario.getValue().getId());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) JSONFormatter(gherkin.formatter.JSONFormatter) Formatter(gherkin.formatter.Formatter) CucumberJSONFormatter(cucumber.runtime.formatter.CucumberJSONFormatter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Scenario(cucumber.api.Scenario) Test(org.junit.Test)

Example 2 with Scenario

use of cucumber.api.Scenario in project cucumber-jvm by cucumber.

the class RuntimeTest method should_make_scenario_name_available_to_hooks.

@Test
public void should_make_scenario_name_available_to_hooks() throws Throwable {
    CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n" + "    When second step\n" + "    Then third step\n");
    HookDefinition beforeHook = mock(HookDefinition.class);
    when(beforeHook.matches(anyCollectionOf(Tag.class))).thenReturn(true);
    Runtime runtime = createRuntimeWithMockedGlue(mock(StepDefinitionMatch.class), beforeHook, true);
    feature.run(mock(Formatter.class), mock(Reporter.class), runtime);
    ArgumentCaptor<Scenario> capturedScenario = ArgumentCaptor.forClass(Scenario.class);
    verify(beforeHook).execute(capturedScenario.capture());
    assertEquals("scenario name", capturedScenario.getValue().getName());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) JSONFormatter(gherkin.formatter.JSONFormatter) Formatter(gherkin.formatter.Formatter) CucumberJSONFormatter(cucumber.runtime.formatter.CucumberJSONFormatter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Scenario(cucumber.api.Scenario) Test(org.junit.Test)

Aggregations

Scenario (cucumber.api.Scenario)2 StepDefinitionReporter (cucumber.api.StepDefinitionReporter)2 CucumberJSONFormatter (cucumber.runtime.formatter.CucumberJSONFormatter)2 CucumberFeature (cucumber.runtime.model.CucumberFeature)2 Formatter (gherkin.formatter.Formatter)2 JSONFormatter (gherkin.formatter.JSONFormatter)2 Reporter (gherkin.formatter.Reporter)2 Tag (gherkin.formatter.model.Tag)2 Test (org.junit.Test)2