com.github.mkolisnyk.cucumber.runner.ExtendedScenarioOutlineRunner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cucumber-runner Show documentation
Show all versions of cucumber-runner Show documentation
The part of Cucumber Reports library which contains extended Cucumber-JVM runners and all relevant functionality.
The newest version!
package com.github.mkolisnyk.cucumber.runner;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.junit.runner.Description;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.Suite;
import org.junit.runners.model.InitializationError;
import cucumber.runtime.Runtime;
import cucumber.runtime.junit.JUnitReporter;
import cucumber.runtime.model.CucumberExamples;
import cucumber.runtime.model.CucumberScenarioOutline;
public class ExtendedScenarioOutlineRunner extends
Suite {
private final CucumberScenarioOutline cucumberScenarioOutline;
private final JUnitReporter jUnitReporter;
private Description description;
public ExtendedScenarioOutlineRunner(
Runtime runtimeValue,
CucumberScenarioOutline cucumberScenarioOutlineValue,
JUnitReporter jUnitReporterValue,
int retryCountValue,
Method[] retryMethodsValue) throws InitializationError {
super(null, buildRunners(
runtimeValue, cucumberScenarioOutlineValue,
jUnitReporterValue, retryCountValue, retryMethodsValue));
this.cucumberScenarioOutline = cucumberScenarioOutlineValue;
this.jUnitReporter = jUnitReporterValue;
}
private static List buildRunners(
Runtime runtime,
CucumberScenarioOutline cucumberScenarioOutline,
JUnitReporter jUnitReporter,
int retryCount,
Method[] retryMethodsValue) throws InitializationError {
List runners = new ArrayList();
for (CucumberExamples cucumberExamples : cucumberScenarioOutline.getCucumberExamplesList()) {
runners.add(new ExtendedExamplesRunner(
runtime, cucumberExamples, jUnitReporter, retryCount, retryMethodsValue));
}
return runners;
}
@Override
public String getName() {
return cucumberScenarioOutline.getVisualName();
}
@Override
public Description getDescription() {
if (description == null) {
description = Description.createSuiteDescription(getName(), cucumberScenarioOutline.getGherkinModel());
for (Runner child : getChildren()) {
description.addChild(describeChild(child));
}
}
return description;
}
@Override
public void run(final RunNotifier notifier) {
cucumberScenarioOutline.formatOutlineScenario(jUnitReporter);
super.run(notifier);
}
@Override
protected void runChild(Runner runner, final RunNotifier notifier) {
super.runChild(runner, notifier);
}
}