private boolean matchesParameters(Scenario scenario, Map<String, String> parameters) { Meta meta = scenario.getMeta(); for (String name : parameters.keySet()) { if (meta.hasProperty(name)) { return meta.getProperty(name).equals(parameters.get(name)); } } return false; }
private Meta parameterMeta(Keywords keywords, Map<String, String> scenarioParameters) { String meta = keywords.meta(); if (scenarioParameters.containsKey(meta)) { return Meta.createMeta(scenarioParameters.get(meta), keywords); } return Meta.EMPTY; }
private boolean match(Properties properties, Meta meta) { for (Object key : properties.keySet()) { String property = (String) properties.get(key); for (String metaName : meta.getPropertyNames()) { if (key.equals(metaName)) { String value = meta.getProperty(metaName); if (StringUtils.isBlank(value)) { return true; } else if (property.contains("*")) { return value.matches(property.replace("*", ".*")); } return properties.get(key).equals(value); } } } return false; }
private void runScenariosParametrisedByExamples( RunContext context, Scenario scenario, Lifecycle lifecycle, Meta storyAndScenarioMeta) throws Throwable { ExamplesTable table = scenario.getExamplesTable(); reporter.get().beforeExamples(scenario.getSteps(), table); Keywords keywords = context.configuration().keywords(); for (Map<String, String> scenarioParameters : table.getRows()) { Meta parameterMeta = parameterMeta(keywords, scenarioParameters); if (!parameterMeta.isEmpty() && !context.filter.allow(parameterMeta)) { continue; } reporter.get().example(scenarioParameters); if (context.configuration().storyControls().resetStateBeforeScenario()) { context.resetState(); } runBeforeOrAfterScenarioSteps( context, scenario, storyAndScenarioMeta, Stage.BEFORE, ScenarioType.EXAMPLE); runStepWithLifecycle(context, lifecycle, scenarioParameters, scenario, storyAndScenarioMeta); runBeforeOrAfterScenarioSteps( context, scenario, storyAndScenarioMeta, Stage.AFTER, ScenarioType.EXAMPLE); } reporter.get().afterExamples(); }
private void addMetaParameters(Map<String, String> storyParameters, Meta meta) { for (String name : meta.getPropertyNames()) { storyParameters.put(name, meta.getProperty(name)); } }