0

I am testing a Springboot application using cucumber (v7.2.3). I have a feature file to test application using @SpringBootTest and @Suite (from junit-platform) I am using @ConfigurationParameter to refer the package where I have my step definition class.

I also have @DataTableType annotations to convert feature data into java objects, which are in the same package as my step-definitions.

Now I want to have another set of step definitions (in a separate file) which will connect to the application running in dev environment (over REST). I want to re-use my feature files as testing exactly same feature but on a running application.

I tried to create a new step definition java class in a different package and placed existing step definition java class in another package, but feature data to java object creation failed. Probably cucumber is expecting to have class which has @DataTableType annotations in the same package as step definition class.

Any idea how can I achieve 2 different step definitions using same feature file.

Note: I want to run local step definitions to run as part of maven build and remote step definitions as post deployment task. Please also guide how can I achieve that (probably using tags).

Versions used junit-platform - 1.8.2 junit-jupiter - 5.8.2 springboot - 2.7.4

1 Answer 1

2

Suppose you organize your code into three packages com.example.local, com.example.remote, com.example.shared. Then you would put the step definitions for the local tests in .local, those for remote in .remote and the data table types and other shared code in the .shared package.

Then you can create multiple suites with different configurations for the glue.

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/example")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example.local, com.example.shared")
public class RunLocalCucumberTest {
}

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/example")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example.remote, com.example.shared")
public class RunRemoteCucumberTest {
}
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your answer. I managed to get that on the same line before I saw this answer. How can I get pretty report generated in 2 different html output files?
You add a ConfigurationParameter annotation for the plugin property to the suite.github.com/cucumber/cucumber-jvm/tree/main/…
That I have. But the generation of the input data file if happening through default behavior. Can you update your given example showing ConfigurationParameter so that both test suites are generating different reports please?
Can you show me what you have, it will be easier to explain that way.
hat I solve, now I want to run Local steps as part of build (using maven surefire or failsafe plugin) and other one as post deploy process through Jenkins. Any guidance?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.