vishalbha
vishalbha

Reputation: 49

How to pass cucumber tag as parameter and update in test runner file before perform execution in jenkins?

i am new for Jenkins and want to pass a parameter like cucumber tag from jenkins and it should update in test runner file dynamically and then should start execution. Please share me code or screenshots.

Upvotes: 3

Views: 11577

Answers (2)

M.P. Korstanje
M.P. Korstanje

Reputation: 12039

In addition to UnknownBeast, with Cucumber v6 and onwards you can no longer use cucumber.options with a command line like string. Instead you'll have to use individual properties.

mvn test -Dcucumber.filter.tags="(@cucumber or @gherkin) and not @salad"

Supported properties are:

cucumber.ansi-colors.disabled=  # true or false. default: false                     
cucumber.execution.dry-run=     # true or false. default: false 
cucumber.execution.limit=       # number of scenarios to execute (CLI only).  
cucumber.execution.order=       # lexical, reverse, random or random:[seed] (CLI only). default: lexical
cucumber.execution.strict=      # true or false. default: false.
cucumber.execution.wip=         # true or false. default: false.
cucumber.features=              # command separated paths to feature files. example: path/to/example.feature, path/to/other.feature  
cucumber.filter.name=           # regex. example: .*Hello.*
cucumber.filter.tags=           # tag expression. example: @smoke and not @slow 
cucumber.glue=                  # comma separated package names. example: com.example.glue  
cucumber.plugin=                # comma separated plugin strings. example: pretty, json:path/to/report.json
cucumber.object-factory=        # object factory class name. example: com.example.MyObjectFactory
cucumber.snippet-type=          # underscore or camelcase. default: underscore

From https://github.com/cucumber/cucumber-jvm/tree/master/core#properties-environment-variables-system-options

Upvotes: 5

UnknownBeast
UnknownBeast

Reputation: 979

If you want to run the test cases associated to Tags, this is how we specify : mvn test -Dcucumber.options=”–tags @tag Name”

So what you can do, set the parameters in the Jenkins job and then you can execute the test script with the above maven command. So the tag name will come from the parameter that you have set in the Jenkins job.

Upvotes: 1

Related Questions