Search in sources :

Example 21 with SingleScenario

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

the class GherkinDocumentParserTest method validFeatureWithScenarioOutlineTest.

@Test
public void validFeatureWithScenarioOutlineTest() throws Exception {
    String featureContent = "Feature: test feature 3\n" + "\n" + "  Scenario Outline: This is a scenario outline\n" + "    When I search for key <key>\n" + "    Then I see the value '<value>'\n" + "\n" + "    Examples:\n" + "      | key | value |\n" + "      | 1   | one   |\n" + "      | 2   | two   |";
    List<SingleScenario> singleScenariosFromFeature = gherkinDocumentParser.getSingleScenariosFromFeature(featureContent, "", null);
    assertThat(singleScenariosFromFeature.size(), is(2));
    SingleScenario scenario = singleScenariosFromFeature.get(0);
    assertThat(scenario.getScenarioName(), is("Scenario: This is a scenario outline"));
    assertThat(scenario.getSteps().size(), is(2));
    assertThat(scenario.getBackgroundSteps().size(), is(0));
    assertThat(scenario.getSteps().get(0).getDataTable(), is(nullValue()));
    assertThat(scenario.getSteps().get(0).getName(), is("When I search for key 1"));
    assertThat(scenario.getSteps().get(1).getName(), is("Then I see the value 'one'"));
    scenario = singleScenariosFromFeature.get(1);
    assertThat(scenario.getScenarioName(), is("Scenario: This is a scenario outline"));
    assertThat(scenario.getSteps().size(), is(2));
    assertThat(scenario.getBackgroundSteps().size(), is(0));
    assertThat(scenario.getSteps().get(0).getDataTable(), is(nullValue()));
    assertThat(scenario.getSteps().get(0).getName(), is("When I search for key 2"));
    assertThat(scenario.getSteps().get(1).getName(), is("Then I see the value 'two'"));
}
Also used : SingleScenario(com.trivago.vo.SingleScenario) Test(org.junit.Test)

Example 22 with SingleScenario

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

the class GherkinDocumentParserTest method replaceDataTableExamplePlaceholderTest.

@Test
public void replaceDataTableExamplePlaceholderTest() throws Exception {
    String featureContent = "Feature: test feature 3\n" + "\n" + "  Scenario Outline: This is a scenario outline\n" + "    When I search for key <key>\n" + "    | test | <key> | <value> |" + "\n" + "    Examples:\n" + "      | key | value |\n" + "      | 1   | one   |\n";
    List<SingleScenario> singleScenariosFromFeature = gherkinDocumentParser.getSingleScenariosFromFeature(featureContent, "", null);
    assertThat(singleScenariosFromFeature.size(), is(1));
    assertThat(singleScenariosFromFeature.get(0).getSteps().size(), is(1));
    DataTable dataTable = singleScenariosFromFeature.get(0).getSteps().get(0).getDataTable();
    assertThat(dataTable.getRows().size(), is(1));
    List<String> firstRow = dataTable.getRows().get(0);
    assertThat(firstRow.get(0), is("test"));
    assertThat(firstRow.get(1), is("1"));
    assertThat(firstRow.get(2), is("one"));
}
Also used : DataTable(com.trivago.vo.DataTable) SingleScenario(com.trivago.vo.SingleScenario) Test(org.junit.Test)

Example 23 with SingleScenario

use of com.trivago.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);
    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.vo.SingleScenario) Test(org.junit.Test)

Aggregations

SingleScenario (com.trivago.vo.SingleScenario)23 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)10 CucableFeature (com.trivago.vo.CucableFeature)7 FeatureRunner (com.trivago.vo.FeatureRunner)7 Step (com.trivago.vo.Step)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 DataTable (com.trivago.vo.DataTable)2 CucablePluginException (com.trivago.exceptions.CucablePluginException)1 FeatureFileParseException (com.trivago.exceptions.filesystem.FeatureFileParseException)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 List (java.util.List)1