[cucumber-jvm] CucumberOptions annotation and cucumber.options (runtime) system property: precedence

599 views
Skip to first unread message

Christian

unread,
Jun 25, 2014, 9:49:43 AM6/25/14
to cu...@googlegroups.com
Hi!

If I've set several options via the annotation, e.g.
@CucumberOptions(
format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "@all", 
features = "target/test-classes/features")

If I then set the runtime option to
-Dcucumber.options="src/test/resources/features/abc --tags ~@xyz"

What will happen; what will the effective options look like?

format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "~@xyz", 
features = "src/test/resources/features/abc"

or just

tags = "~@xyz", 
features = "src/test/resources/features/abc"

In other words: if I use runtime options, will Cucumber only use those, or will it also use the annotation options that aren't overridden by the runtime options?

Kind regards,

Christian

Björn Rasmusson

unread,
Jun 25, 2014, 10:20:53 AM6/25/14
to cu...@googlegroups.com
Christian wrote:
Hi!

If I've set several options via the annotation, e.g.
@CucumberOptions(
format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "@all", 
features = "target/test-classes/features")

If I then set the runtime option to
-Dcucumber.options="src/test/resources/features/abc --tags ~@xyz"

What will happen; what will the effective options look like?

format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "~@xyz", 
features = "src/test/resources/features/abc"

Yes,
 
Cucumber-JVM will use the options from @CucumberOptions that aren't overridden by the -Dcucumber.options statement.
 
Regards
Björn

Christian

unread,
Jun 25, 2014, 1:00:17 PM6/25/14
to cu...@googlegroups.com


On Wednesday, June 25, 2014 3:20:53 PM UTC+1, Björn Rasmusson wrote:
Christian wrote:
If I've set several options via the annotation, e.g.
@CucumberOptions(
format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "@all", 
features = "target/test-classes/features")

If I then set the runtime option to
-Dcucumber.options="src/test/resources/features/abc --tags ~@xyz"

What will happen; what will the effective options look like?

format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "~@xyz", 
features = "src/test/resources/features/abc"

Yes,
 
Cucumber-JVM will use the options from @CucumberOptions that aren't overridden by the -Dcucumber.options statement.

Thanks! :) 

Christian

unread,
Jul 1, 2014, 10:58:18 AM7/1/14
to cu...@googlegroups.com
On Wednesday, June 25, 2014 3:20:53 PM UTC+1, Björn Rasmusson wrote:
Christian wrote:
Hi!

If I've set several options via the annotation, e.g.
@CucumberOptions(
format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "@all", 
features = "target/test-classes/features")

If I then set the runtime option to
-Dcucumber.options="src/test/resources/features/abc --tags ~@xyz"

What will happen; what will the effective options look like?

format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, 
tags = "~@xyz", 
features = "src/test/resources/features/abc"

Yes,
 
Cucumber-JVM will use the options from @CucumberOptions that aren't overridden by the -Dcucumber.options statement.
 

For anyone stumbling across this in the future: the --format parameter behaves differently; it doesn't override the annotation's value(s), but instead adds more formats: https://groups.google.com/d/msg/cukes/8bZd6dWnSwc/qqynbO65VXIJ
Trying to override one will result in an error message...
Reply all
Reply to author
Forward
0 new messages