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

feat: register WireMockServer as a Spring Bean (refs #73) #77

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

tomasbjerre
Copy link
Collaborator

@tomasbjerre tomasbjerre commented Jan 18, 2025

@tomasbjerre tomasbjerre added the enhancement New feature or request label Jan 18, 2025
@tomasbjerre tomasbjerre force-pushed the feature/issue-73-register-spring-bean branch from f7f66f7 to 6943e46 Compare January 19, 2025 15:54
@tomasbjerre tomasbjerre force-pushed the feature/issue-73-register-spring-bean branch from 6943e46 to 13343c3 Compare January 19, 2025 15:58
@tomakehurst
Copy link
Member

Thanks for working on this @tomasbjerre!

It looks good to me, but would be great to get a quick eyeball from @Arc-E-Tect as well.

Copy link

@Arc-E-Tect Arc-E-Tect left a comment

Choose a reason for hiding this comment

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

Looks good to me, proof would be in eating the pudding though.

build.gradle Outdated
@@ -7,6 +7,7 @@ buildscript {
dependencies {
classpath "se.bjurr.gradle.java-convention:se.bjurr.gradle.java-convention.gradle.plugin:0.+"
classpath "org.wiremock.tools.gradle:gradle-wiremock-extension-plugins:0.4.0"
classpath "se.thinkcode.cucumber-runner:se.thinkcode.cucumber-runner.gradle.plugin:0.0.11"

Choose a reason for hiding this comment

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

Any specific reason for using this plugin? It's not been updated since a couple of years and that introduces the risk of not being compatible with future versions of Gradle.
There's a cucumber-junit platform runner that achieves the same and seamlessly integrates with the Gradle test suite features

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was googling for a while and this was the simplest version I found. But I can try your proposal also.

Choose a reason for hiding this comment

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

It's pretty straightforward, but requires the Cucumber configuration in its own class as part of the gluecode.

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/arc_e_tect")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty," +
        "html:build/reports/bdd-test/Cucumber.html")
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "not @ignore and not @wip")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.arc_e_tect.experiments")
public class RunBddTest {
}

https://github.com/Arc-E-Tect/sedr-wiremock-cucumber-experiment/blob/main/app/src/bdd-test/java/com/arc_e_tect/experiments/RunBddTest.java

and

@CucumberContextConfiguration
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = App.class)
@ActiveProfiles({"bddtest"})
@Import(WireMockConfig.class)
public class CucumberConfiguration {
    WireMockServer wireMockServer;

    protected CucumberConfiguration(WireMockServer wireMockServer) {
        this.wireMockServer = wireMockServer;
        wireMockServer.start();
    }

}

https://github.com/Arc-E-Tect/sedr-wiremock-cucumber-experiment/blob/main/app/src/bdd-test/java/com/arc_e_tect/experiments/CucumberConfiguration.java

Let me know when you need some help.

@tomasbjerre tomasbjerre merged commit 1b42d76 into main Jan 20, 2025
6 checks passed
@tomakehurst
Copy link
Member

Thanks both of you for getting this in there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants