Search in sources :

Example 11 with SingleScenario

use of com.trivago.rta.vo.SingleScenario in project cucable-plugin by trivago.

the class GherkinDocumentParserTest method validFeatureWithDataTableTest.

@Test
public void validFeatureWithDataTableTest() throws Exception {
    String featureContent = "@featureTag\n" + "Feature: test feature\n" + "\n" + "@scenario1Tag1\n" + "@scenario1Tag2\n" + "Scenario: This is a scenario with two steps\n" + "Given this is step 1\n" + "|value1|value2|\n" + "Then this is step 2\n";
    List<SingleScenario> singleScenariosFromFeature = gherkinDocumentParser.getSingleScenariosFromFeature(featureContent, "", null, null, null);
    assertThat(singleScenariosFromFeature.size(), is(1));
    SingleScenario scenario = singleScenariosFromFeature.get(0);
    assertThat(scenario.getScenarioName(), is("Scenario: This is a scenario with two steps"));
    assertThat(scenario.getSteps().size(), is(2));
    assertThat(scenario.getBackgroundSteps().size(), is(0));
    assertThat(scenario.getSteps().get(0).getDataTable(), is(notNullValue()));
    assertThat(scenario.getSteps().get(0).getDataTable().getRows().size(), is(1));
    assertThat(scenario.getSteps().get(0).getDataTable().getRows().get(0).size(), is(2));
}
Also used : SingleScenario(com.trivago.rta.vo.SingleScenario) Test(org.junit.Test)

Example 12 with SingleScenario

use of com.trivago.rta.vo.SingleScenario in project cucable-plugin by trivago.

the class GherkinDocumentParserTest method validScenarioNamesWithScenarioOutlineTest.

@Test
public void validScenarioNamesWithScenarioOutlineTest() throws Exception {
    String featureContent = "Feature: test feature 3\n" + "\n" + "  Scenario Outline: This is a scenario outline, key = <key>, value = <value>\n" + "    This is a step\n" + "    How about another step\n" + "\n" + "    Examples:\n" + "      | key | value |\n" + "      | 1   | one   |\n" + "      | 2   | two   |";
    List<SingleScenario> singleScenariosFromFeature = gherkinDocumentParser.getSingleScenariosFromFeature(featureContent, "", null, null, null);
    assertThat(singleScenariosFromFeature.size(), is(2));
    SingleScenario scenario = singleScenariosFromFeature.get(0);
    assertThat(scenario.getScenarioName(), is("Scenario: This is a scenario outline, key = 1, value = one"));
    scenario = singleScenariosFromFeature.get(1);
    assertThat(scenario.getScenarioName(), is("Scenario: This is a scenario outline, key = 2, value = two"));
}
Also used : SingleScenario(com.trivago.rta.vo.SingleScenario) Test(org.junit.Test)

Example 13 with SingleScenario

use of com.trivago.rta.vo.SingleScenario in project cucable-plugin by trivago.

the class GherkinDocumentParserTest method validFeatureWithBackgroundScenarioTest.

@Test
public void validFeatureWithBackgroundScenarioTest() throws Exception {
    String featureContent = "Feature: FeatureName\n" + "\n" + "  Background:\n" + "    Given BackgroundGivenStep\n" + "    And BackgroundGivenStep2\n" + "\n" + "  @tag1\n" + "  @tag2\n" + "  Scenario: This is a scenario with background\n" + "    Then ThenStep";
    List<SingleScenario> singleScenariosFromFeature = gherkinDocumentParser.getSingleScenariosFromFeature(featureContent, "", null, null, null);
    assertThat(singleScenariosFromFeature.size(), is(1));
    SingleScenario scenario = singleScenariosFromFeature.get(0);
    assertThat(scenario.getScenarioName(), is("Scenario: This is a scenario with background"));
    assertThat(scenario.getSteps().size(), is(1));
    assertThat(scenario.getBackgroundSteps().size(), is(2));
    assertThat(scenario.getSteps().get(0).getDataTable(), is(nullValue()));
}
Also used : SingleScenario(com.trivago.rta.vo.SingleScenario) Test(org.junit.Test)

Aggregations

SingleScenario (com.trivago.rta.vo.SingleScenario)13 Test (org.junit.Test)10 Step (com.trivago.rta.vo.Step)5 SingleScenarioRunner (com.trivago.rta.vo.SingleScenarioRunner)3 ArrayList (java.util.ArrayList)3 CucablePluginException (com.trivago.rta.exceptions.CucablePluginException)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 FeatureFileParseException (com.trivago.rta.exceptions.filesystem.FeatureFileParseException)1 MissingFileException (com.trivago.rta.exceptions.filesystem.MissingFileException)1 DataTable (com.trivago.rta.vo.DataTable)1 Background (gherkin.ast.Background)1 Examples (gherkin.ast.Examples)1 Feature (gherkin.ast.Feature)1 GherkinDocument (gherkin.ast.GherkinDocument)1 Scenario (gherkin.ast.Scenario)1 ScenarioDefinition (gherkin.ast.ScenarioDefinition)1 ScenarioOutline (gherkin.ast.ScenarioOutline)1 Path (java.nio.file.Path)1 List (java.util.List)1