This PR utilises the suite slicing that was originally implemented in serenity cucumber and now implements it with new CucumberBatchTestEngine which is an implementation of HierarchicalTestEngine<CucumberEngineExecutionContext>.
Example runner class is shown below:
package net.serenitybdd.cucumber.suiteslicing;
import io.cucumber.junit.platform.engine.Constants;
import io.cucumber.plugin.ConcurrentEventListener;
import io.cucumber.plugin.event.EventPublisher;
import io.cucumber.plugin.event.TestRunFinished;
import io.cucumber.plugin.event.TestRunStarted;
import org.junit.platform.suite.api.*;
@Suite(failIfNoTests = false)
@IncludeEngines("cucumber-batch")
@SelectClasspathResources({@SelectClasspathResource("path-1"), @SelectClasspathResource("path-2")})
@ConfigurationParameters({
@ConfigurationParameter(key = Constants.EXECUTION_DRY_RUN_PROPERTY_NAME, value = "false"),
@ConfigurationParameter(key = Constants.GLUE_PROPERTY_NAME, value = "com.example.support,com.example.steps,com.example.hooks,com.example.types"),
@ConfigurationParameter(key = Constants.OBJECT_FACTORY_PROPERTY_NAME, value = "cucumber.runtime.SerenityObjectFactory"),
@ConfigurationParameter(key = Constants.PLUGIN_PUBLISH_QUIET_PROPERTY_NAME, value = "true"),
@ConfigurationParameter(key = Constants.PLUGIN_PUBLISH_ENABLED_PROPERTY_NAME, value = "false"),
@ConfigurationParameter(key = Constants.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME, value = "false"),
@ConfigurationParameter(key = Constants.PLUGIN_PROPERTY_NAME, value = "SlicedTestRunner,io.cucumber.core.plugin.SerenityReporter,pretty"),
@ConfigurationParameter(key = Constants.FILTER_TAGS_PROPERTY_NAME, value = "@my-tag")})
public class SlicedTestRunner implements ConcurrentEventListener {
@Override
public void setEventPublisher(EventPublisher eventPublisher) {
eventPublisher.registerHandlerFor(TestRunStarted.class, event -> {
setUp();
});
eventPublisher.registerHandlerFor(TestRunFinished.class, event -> {
tearDown();
});
}
public static void setUp() {
// setup code here
}
public static void tearDown() {
// tearDown code here
}
}
CucumberBatchTestEngine depends on objects that were originally in the cucumber-serenity module, but as part of this PR, these were moved out of that module into the serenity-junit5 module as it's not possible for serenity-junit5 to depend on cucumber-serenity, given that there is an existing dependency the other way. So this was done to avoid a circular dependency. This moving of concerns may not be approved by @wakaleo - so I'll let him review and decide. Sorry, I didn't have too much time to work on this as I have work commitments!
Final disclaimer is that we don't use the junit 5 batching much on the client project given that bazel is used for the bulk of the test parallelism - so try it and see!
This PR utilises the suite slicing that was originally implemented in serenity cucumber and now implements it with new
CucumberBatchTestEngine
which is an implementation ofHierarchicalTestEngine<CucumberEngineExecutionContext>
.Example runner class is shown below:
CucumberBatchTestEngine
depends on objects that were originally in thecucumber-serenity
module, but as part of this PR, these were moved out of that module into theserenity-junit5
module as it's not possible forserenity-junit5
to depend oncucumber-serenity
, given that there is an existing dependency the other way. So this was done to avoid a circular dependency. This moving of concerns may not be approved by @wakaleo - so I'll let him review and decide. Sorry, I didn't have too much time to work on this as I have work commitments!