diff --git a/src/main/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoader.java b/src/main/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoader.java index 740368e..b4cd269 100644 --- a/src/main/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoader.java +++ b/src/main/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoader.java @@ -19,6 +19,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.IntStream; +import java.util.stream.Stream; import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; @@ -97,7 +98,9 @@ private List scenarioTags(ScenarioDefinition scenario) { if (Scenario.class.isAssignableFrom(scenario.getClass())) { return ((Scenario) scenario).getTags(); } else { - return ((ScenarioOutline) scenario).getTags(); + return Stream.of(((ScenarioOutline) scenario).getTags(), ((ScenarioOutline) scenario).getExamples() + .stream().flatMap(e -> e.getTags().stream()).collect(toList())).flatMap(Collection::stream) + .collect(Collectors.toList()); } } diff --git a/src/test/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoaderTest.java b/src/test/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoaderTest.java index 9212325..f3f47a3 100644 --- a/src/test/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoaderTest.java +++ b/src/test/java/net/serenitybdd/cucumber/suiteslicing/CucumberScenarioLoaderTest.java @@ -49,5 +49,14 @@ public void shouldLoadFeatureAndScenarioTagsOntoCorrectScenarios() throws Except .tags())); } + @Test + public void shouldIncludeExamplesTagsOntoScenarios() throws Exception { + WeightedCucumberScenarios weightedCucumberScenarios = new CucumberScenarioLoader(newArrayList(new URI("classpath:samples/tagged_example_tables.feature")), testStatistics).load(); + assertThat(weightedCucumberScenarios.scenarios, contains(MatchingCucumberScenario.with() + .featurePath("tagged_example_tables.feature") + .feature("Tagged Tables") + .scenario("This scenario should have two tables") + .tags("@small", "@big"))); + } }