private List<ChorusScenario> createChildren() { List<ChorusScenario> l = new ArrayList<>(); for (ScenarioToken s : featureToken.getScenarios()) { l.add(new ChorusScenario(featureToken, s, uniqueScenarioNames)); } return l; }
private void removeFeatureIfNoScenariosMatchTags(String filterExpression, Iterator<FeatureToken> fi) { //remove all filtered scenarios from this feature FeatureToken feature = fi.next(); int startOrEndCount = 0; for (Iterator<ScenarioToken> si = feature.getScenarios().iterator(); si.hasNext(); ) { ScenarioToken scenario = si.next(); if ( scenario.isFeatureStartScenario() || scenario.isFeatureEndScenario() ) { log.trace("Not removing since this is a start or end feature scenario"); startOrEndCount ++; } else if (! tagExpressionEvaluator.shouldRunScenarioWithTags(filterExpression, scenario.getTags())) { log.debug("Removing scenario " + scenario + " which does not match tag " + filterExpression); si.remove(); } } //if there are no scenarios left (apart from special start or end feature scenarios which are never tagged), //then remove this feature from the list to run if (feature.getScenarios().size() == startOrEndCount) { log.debug("Will not run feature " + fi + " which does not have any scenarios which " + "passed the tag filter " + filterExpression); fi.remove(); } }
@Override public void featureCompleted(ExecutionToken testExecutionToken, FeatureToken feature) { pauseForJUnitOutput(); for ( ScenarioToken s : feature.getScenarios()) { if ( ! completedScenarios.contains(s)) { //The feature terminated early and this scenario did not get run //usually this happens when we can't find feature-level resources such as a //handler class. // Since junit is waiting on the scenario we need to send a start and complete scenarioStarted(testExecutionToken, s); scenarioCompleted(testExecutionToken, s); } } awaitFeatureEnd(); pauseForJUnitOutput(); }
@Test public void outlineScenarioInheritsTagsFromFeatureAndAddsOwn() throws Exception { File f = getFileResourceWithName(TEST_FEATURE_FILE); FeatureFileParser p = new FeatureFileParser(); List<FeatureToken> features = p.parse(new FileReaderSupplier(f)); FeatureToken feature = features.get(0); // remaining scenarios (created from an outline) should have 2 inherited tags from the parent feature and one of their own for (int i = 2; i < feature.getScenarios().size(); i++) { ScenarioToken scenario3 = feature.getScenarios().get(2); List<String> scenario3tags = scenario3.getTags(); assertEquals("Wrong number of tags found on scenario " + (i + 1), 3, scenario3tags.size()); assertTrue(scenario3tags.contains("@tagA")); assertTrue(scenario3tags.contains("@tagB")); assertTrue(scenario3tags.contains("@tagF")); } }
@Test public void scenarioInheritsTagsFromFeature() throws Exception { File f = getFileResourceWithName(TEST_FEATURE_FILE); FeatureFileParser p = new FeatureFileParser(); List<FeatureToken> features = p.parse(new FileReaderSupplier(f)); assertEquals("Wrong number of features loaded", 1, features.size()); FeatureToken feature = features.get(0); // the first scenario should inherit the two tags from the parent feature only ScenarioToken scenario = feature.getScenarios().get(0); List<String> scenarioTags = scenario.getTags(); assertEquals("Wrong number of tags found on scenario 1", 2, scenarioTags.size()); // check the two tag values assertTrue(scenarioTags.contains("@tagA")); assertTrue(scenarioTags.contains("@tagB")); }
@Test public void scenarioInheritsTagsFromFeatureAndAddsOwn() throws Exception { File f = getFileResourceWithName(TEST_FEATURE_FILE); FeatureFileParser p = new FeatureFileParser(); List<FeatureToken> features = p.parse(new FileReaderSupplier(f)); FeatureToken feature = features.get(0); // the second scenario should inherit the two tags from the parent feature and declare three of its own too ScenarioToken scenario = feature.getScenarios().get(1); List<String> scenarioTags = scenario.getTags(); assertEquals("Wrong number of tags found on scenario 2", 5, scenarioTags.size()); // check the tag values assertTrue(scenarioTags.contains("@tagA")); assertTrue(scenarioTags.contains("@tagB")); assertTrue(scenarioTags.contains("@tagC")); assertTrue(scenarioTags.contains("@tagD")); assertTrue(scenarioTags.contains("@tagE")); }
runScenarios(executionToken, feature, feature.getScenarios(), handlerManager, skipAllScenarios);
@Override public FeatureTokenBean marshal(FeatureToken f) throws Exception { FeatureTokenBean result = new FeatureTokenBean(); result.setTokenId(f.getTokenId()); result.setName(f.getName()); if (f.getUsesHandlers()!=null && f.getUsesHandlers().length>0) { String handlerCsv = FormattingUtils.getAsCsv(f.getUsesHandlers()); result.setUsesHandlers(handlerCsv); } result.setConfigurationName(f.getConfigurationName()); result.setDescription(f.getDescription()); result.setScenarios(f.getScenarios()); result.setEndState(f.getEndState()); return result; }