Search code examples
javatestingcucumbercucumber-jvmcucumber-java

How to specify source jar for Cucumber stepdef


I have some scenarios which call a stepdef from a jar included as a dependency.

Now, I want to maintain 2 separate versions for the same stepdef into 2 different jars. Since I need few scenarios to use version 1 and others to use version 2 of the stepdef.

How do I do this with @CucumberOptions, specifically mentioning jar source in the glue?


Solution

  • I solved this problem using the following approach:

    1. Created 2 separate JUnit runners for running version 1 and 2.
    2. Supported both versions of step definition by maintaining 2 packages.
    3. Mentioned respective package name using step.provider.pkg property in @CucumberOptions glue specification for both the runners.

    Note regarding maven:

    I had to include both the runners in maven failsafe plugin to run tests during integration-test phase. Also had to provide 2 separate executions in failsafe plugin to enable ordered execution of mentioned runners.