net.serenitybdd.cucumber.CucumberWithSerenity Maven / Gradle / Ivy
package net.serenitybdd.cucumber;
import cucumber.api.junit.Cucumber;
import cucumber.runtime.ClassFinder;
import cucumber.runtime.Runtime;
import cucumber.runtime.RuntimeOptions;
import cucumber.runtime.io.ResourceLoader;
import cucumber.runtime.io.ResourceLoaderClassFinder;
import net.thucydides.core.guice.Injectors;
import net.thucydides.core.webdriver.Configuration;
import org.junit.runners.model.InitializationError;
import java.io.IOException;
/**
* Glue code for running Cucumber via Thucydides.
* Sets the Thucydides reporter.
*
* @author L.Carausu ([email protected])
*/
public class CucumberWithSerenity extends Cucumber {
public CucumberWithSerenity(Class clazz) throws InitializationError, IOException
{
super(clazz);
}
/**
* Create the Runtime. Sets the Serenity runtime.
*/
protected cucumber.runtime.Runtime createRuntime(ResourceLoader resourceLoader, ClassLoader classLoader,
RuntimeOptions runtimeOptions) throws InitializationError, IOException {
return createSerenityEnabledRuntime(resourceLoader, classLoader, runtimeOptions);
}
private Runtime createSerenityEnabledRuntime(ResourceLoader resourceLoader, ClassLoader classLoader, RuntimeOptions runtimeOptions) {
Configuration systemConfiguration = Injectors.getInjector().getInstance(Configuration.class);
return createSerenityEnabledRuntime(resourceLoader, classLoader, runtimeOptions, systemConfiguration);
}
public static Runtime createSerenityEnabledRuntime(ResourceLoader resourceLoader, ClassLoader classLoader, RuntimeOptions runtimeOptions, Configuration systemConfiguration) {
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
SerenityReporter reporter = new SerenityReporter(systemConfiguration);
runtimeOptions.addPlugin(reporter);
return new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy