inor
inor

Reputation: 2846

how to specify cucumber tags as invocation param in eclipse debug configuration?

I have a Spring Boot project. In it I have a java class BookTests which contains:

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {
                "pretty",
                "html:target/acceptance-test-report",
                "json:target/cucumber/cucumber.json"
        },
        glue = {
                "com.my.sdk.test",
                "com.my.book.test"
        }
        ,tags = {"@findConsideringGrants"}
        )
public class BookTests {
    // No implementation required.  The Cucumber annotations drive the test execution.

}

I'm using Junit 4. when I "Debug As JUnit Test" this class it only runs the feature file which is annotated with "@findConsideringGrants (as it should)

Is there a way i don't have to hard-code this tags annotation in the java class but instead specify the tags as Program argumnents or VM arguuments?

I tried configuring it with Program argumnents, but with all the following attempts it ignored the argument and ran the tests on all my features/tags:

--tags findConsideringGrants 
-tags findConsideringGrants
--tags @findConsideringGrants 
-tags @findConsideringGrants

So to summerize, i'm looking for a way to
1) debug in eclipse a certain feature
2) without hardcoding the name of the feature into the java source. Somehow by just configuring the debug configuration.

is this even possible?

Upvotes: 0

Views: 1994

Answers (1)

Grasshopper
Grasshopper

Reputation: 9058

If you are using maven you can use -- mvn test -Dcucumber.options="--tags @findConsideringGrants".

Or you can use the cucumber cli command to run -- Main.main(new String[]{"-g", "classpath to step definition file","-t", "tags to use", "-p", "plugins to use", "Full path to feature file"}). The feature file path has to be the last option.

Running from eclipse -- Go to the "Environment" tab of the "Debug Configurations" or "Run Configurations" window. Click on "New" button. For the "Name" add "cucumber.options" and "Value" add "--tags @findConsideringGrants". Apply and Run. If you want to add a specific feature file path add only the path to the end of this.

Upvotes: 1

Related Questions