Search in sources :

Example 6 with SingleScenario

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

the class FeatureFileContentRendererTest method getRenderedFeatureFileContentTest.

@Test
public void getRenderedFeatureFileContentTest() {
    String expectedOutput = "@featureTag1\n" + "@featureTag2\n" + "Feature: featureName\n" + "featureDescription\n" + "\n" + "Background:\n" + "Background Step 1\n" + "Background Step 2\n" + "\n" + "@scenarioTag1\n" + "@scenarioTag2\n" + "Scenario: scenarioName\n" + "scenarioDescription\n" + "Step 1\n" + "Step 2\n" + "\n# Source feature: TESTPATH\n" + "# Generated by Cucable\n";
    String featureName = "Feature: featureName";
    String featureDescription = "featureDescription";
    String featureLanguage = "";
    List<String> featureTags = Arrays.asList("@featureTag1", "@featureTag2");
    String scenarioName = "Scenario: scenarioName";
    String scenarioDescription = "scenarioDescription";
    List<Step> backgroundSteps = Arrays.asList(new Step("Background Step 1", null, null), new Step("Background Step 2", null, null));
    List<Step> steps = Arrays.asList(new Step("Step 1", null, null), new Step("Step 2", null, null));
    List<String> scenarioTags = Arrays.asList("@scenarioTag1", "@scenarioTag2");
    String featureFilePath = "TESTPATH";
    SingleScenario singleScenario = new SingleScenario(featureName, featureFilePath, featureLanguage, featureDescription, scenarioName, scenarioDescription, featureTags, backgroundSteps);
    singleScenario.setScenarioTags(scenarioTags);
    singleScenario.setSteps(steps);
    String renderedFeatureFileContent = featureFileContentRenderer.getRenderedFeatureFileContent(singleScenario);
    // In a windows system, replace line separator "\r\n" with "\n".
    renderedFeatureFileContent = renderedFeatureFileContent.replaceAll("\\r\\n", "\n");
    assertThat(renderedFeatureFileContent, is(expectedOutput));
}
Also used : SingleScenario(com.trivago.vo.SingleScenario) Step(com.trivago.vo.Step) Test(org.junit.Test)

Example 7 with SingleScenario

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

the class FeatureFileContentRendererTest method getRenderedFeatureFileContentNonEnglishTest.

@Test
public void getRenderedFeatureFileContentNonEnglishTest() {
    String expectedOutput = "# language: de\n\n" + "@featureTag1\n" + "@featureTag2\n" + "Feature: featureName\n" + "featureDescription\n" + "\n" + "Background:\n" + "Background Step 1\n" + "Background Step 2\n" + "\n" + "@scenarioTag1\n" + "@scenarioTag2\n" + "Scenario: scenarioName\n" + "scenarioDescription\n" + "Step 1\n" + "Step 2\n" + "\n# Source feature: TESTPATH\n" + "# Generated by Cucable\n";
    String featureName = "Feature: featureName";
    String featureDescription = "featureDescription";
    String featureLanguage = "de";
    List<String> featureTags = Arrays.asList("@featureTag1", "@featureTag2");
    String scenarioName = "Scenario: scenarioName";
    String scenarioDescription = "scenarioDescription";
    List<Step> backgroundSteps = Arrays.asList(new Step("Background Step 1", null, null), new Step("Background Step 2", null, null));
    List<Step> steps = Arrays.asList(new Step("Step 1", null, null), new Step("Step 2", null, null));
    List<String> scenarioTags = Arrays.asList("@scenarioTag1", "@scenarioTag2");
    String featureFilePath = "TESTPATH";
    SingleScenario singleScenario = new SingleScenario(featureName, featureFilePath, featureLanguage, featureDescription, scenarioName, scenarioDescription, featureTags, backgroundSteps);
    singleScenario.setScenarioTags(scenarioTags);
    singleScenario.setSteps(steps);
    String renderedFeatureFileContent = featureFileContentRenderer.getRenderedFeatureFileContent(singleScenario);
    // In a windows system, replace line separator "\r\n" with "\n".
    renderedFeatureFileContent = renderedFeatureFileContent.replaceAll("\\r\\n", "\n");
    assertThat(renderedFeatureFileContent, is(expectedOutput));
}
Also used : SingleScenario(com.trivago.vo.SingleScenario) Step(com.trivago.vo.Step) Test(org.junit.Test)

Example 8 with SingleScenario

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

the class FeatureFileContentRendererTest method formatDataTableStringTest.

@Test
public void formatDataTableStringTest() {
    String expectedOutput = "Feature: featureName\n" + "featureDescription\n" + "\n" + "Scenario: scenarioName\n" + "scenarioDescription\n" + "Step 1\n" + "|cell11|cell12|cell13|\n" + "|cell21|cell22|cell23|\n" + "\n# Source feature: TESTPATH\n" + "# Generated by Cucable\n";
    String featureName = "Feature: featureName";
    String featureLanguage = "";
    String featureDescription = "featureDescription";
    String scenarioName = "Scenario: scenarioName";
    String scenarioDescription = "scenarioDescription";
    DataTable dataTable = new DataTable();
    dataTable.addRow(Arrays.asList("cell11", "cell12", "cell13"));
    dataTable.addRow(Arrays.asList("cell21", "cell22", "cell23"));
    List<Step> steps = Collections.singletonList(new Step("Step 1", dataTable, null));
    String featureFilePath = "TESTPATH";
    SingleScenario singleScenario = new SingleScenario(featureName, featureFilePath, featureLanguage, featureDescription, scenarioName, scenarioDescription, new ArrayList<>(), new ArrayList<>());
    singleScenario.setSteps(steps);
    String renderedFeatureFileContent = featureFileContentRenderer.getRenderedFeatureFileContent(singleScenario);
    // In a windows system, replace line separator "\r\n" with "\n".
    renderedFeatureFileContent = renderedFeatureFileContent.replaceAll("\\r\\n", "\n");
    assertThat(renderedFeatureFileContent, is(expectedOutput));
}
Also used : DataTable(com.trivago.vo.DataTable) SingleScenario(com.trivago.vo.SingleScenario) Step(com.trivago.vo.Step) Test(org.junit.Test)

Example 9 with SingleScenario

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

Example 10 with SingleScenario

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

the class GherkinDocumentParserTest method validFeatureWithScenarioOutlineAndTwoExampleTablesTest.

@Test
public void validFeatureWithScenarioOutlineAndTwoExampleTablesTest() 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   |\n" + "\n" + "    Examples:\n" + "      | key | value |\n" + "      | 1   | uno   |\n" + "      | 2   | dos   |";
    List<SingleScenario> singleScenariosFromFeature = gherkinDocumentParser.getSingleScenariosFromFeature(featureContent, "", null);
    assertThat(singleScenariosFromFeature.size(), is(4));
    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'"));
    scenario = singleScenariosFromFeature.get(2);
    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 'uno'"));
    scenario = singleScenariosFromFeature.get(3);
    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 'dos'"));
}
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