Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented junit 5 batching #3569

Merged
merged 1 commit into from
Nov 8, 2024
Merged

Conversation

nbarrett
Copy link
Contributor

@nbarrett nbarrett commented Nov 7, 2024

Note that this is a resubmission of #3568 with a fix to the version of cucumber tag expressions.


  • 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!

@nbarrett nbarrett marked this pull request as draft November 7, 2024 17:05
@nbarrett
Copy link
Contributor Author

nbarrett commented Nov 7, 2024

Sorry, just realised I wasn't against latest HEAD - resubmitting in a moment

@nbarrett nbarrett changed the title - fixed cucumber tag expressions dependency in support of recent junit 5 batching change Implemented junit 5 batching Nov 7, 2024
@nbarrett nbarrett marked this pull request as ready for review November 7, 2024 17:22
Comment on lines 42 to 48
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit5.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is needed since it is available in the ParentPom to avoid to define junit5 artifacts version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right @DanielFran - I removed that and all maven targets still ran okay 👍 - repushed and also added in some missing files that mysteriously were missing on last push 🤦

Copy link
Contributor

@DanielFran DanielFran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is needed since it is available in the ParentPom to avoid to define junit5 artifacts version?

- Includes fixed cucumber tag expressions dependency
@wakaleo wakaleo merged commit f0ee557 into serenity-bdd:main Nov 8, 2024
2 checks passed
@wakaleo
Copy link
Member

wakaleo commented Jan 13, 2025

@nbarrett I need to roll this change back as the new dependency between serenity-cucumber and serenity-junit5 causes issues in existing projects. The serenity-junit5 and serenity-cucumber modules need to be independent of each other.

wakaleo added a commit that referenced this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants