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));
}
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));
}
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));
}
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()));
}
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'"));
}
Aggregations