[cucumber-jvm] configure several reports via command line argument

2,988 views
Skip to first unread message

Christian

unread,
Jun 27, 2014, 9:07:46 AM6/27/14
to cu...@googlegroups.com
Hi,

Is there a way to get different report formats when running cucumber-jvm via command line?

I'm looking to an equivalent for 
@CucumberOptions(format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" })

Do I need to pass in several --format arguments in, or do I comma-separate the values?

-Dcucumber.options="--format pretty, html:target/cucumber"

Or do I need to separate using spaces?

Regards,

Christian

Christian

unread,
Jun 27, 2014, 9:21:56 AM6/27/14
to cu...@googlegroups.com

On Friday, June 27, 2014 2:07:46 PM UTC+1, Christian wrote:
Is there a way to get different report formats when running cucumber-jvm via command line?

I'm looking to an equivalent for 
@CucumberOptions(format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" })

Do I need to pass in several --format arguments in, or do I comma-separate the values?

-Dcucumber.options="--format pretty, html:target/cucumber"


I just tried to pass the following in via Build > Invoke Top-level Maven Targets > Advanced > Properties:
cucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json

When I run that, it gets passed in as
 "-Dcucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json"

and I get the following error:
cucumber.runtime.CucumberException: Only one formatter can use STDOUT. If you use more than one formatter you must specify output path with FORMAT:PATH_OR_URL

I'm probably overlooking something really simple and obvious here, but I thought I had only specified "pretty" as a STDOUT formatter?

Do I have to create the target folder first, maybe?

Christian

unread,
Jun 27, 2014, 9:27:27 AM6/27/14
to cu...@googlegroups.com
cucumber.options=src/test/resources/features --tags @a --format pretty:STDOUT --format html:target/cucumber-a --format json:target/cucumber-a.json
seems to work... 

Is that a bug?

Björn Rasmusson

unread,
Jun 27, 2014, 1:45:49 PM6/27/14
to cu...@googlegroups.com
Christian wrote:

On Friday, June 27, 2014 2:21:56 PM UTC+1, Christian wrote:

On Friday, June 27, 2014 2:07:46 PM UTC+1, Christian wrote:
Is there a way to get different report formats when running cucumber-jvm via command line?

I'm looking to an equivalent for 
@CucumberOptions(format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" })

Do I need to pass in several --format arguments in, or do I comma-separate the values?

-Dcucumber.options="--format pretty, html:target/cucumber"


I just tried to pass the following in via Build > Invoke Top-level Maven Targets > Advanced > Properties:
cucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json

When I run that, it gets passed in as
 "-Dcucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json"

and I get the following error:
cucumber.runtime.CucumberException: Only one formatter can use STDOUT. If you use more than one formatter you must specify output path with FORMAT:PATH_OR_URL

I'm probably overlooking something really simple and obvious here, but I thought I had only specified "pretty" as a STDOUT formatter?

Hi,

You need to be aware of the "--format" option when used in -Dcucumber.options works differently than the other options, it adds the formatters specified in -Dcucumber.options to the ones specified in @CucumberOptions, so when you get the error you are likely to have two formatters wanting to write to standard out, the pretty formatter instance from @CucumberOptions and the pretty formatter instance from -Dcucumber.options.
 
Do I have to create the target folder first, maybe?

cucumber.options=src/test/resources/features --tags @a --format pretty:STDOUT --format html:target/cucumber-a --format json:target/cucumber-a.json
seems to work... 

Yes, now the pretty formatter instance from -Dcucumber.options writes to the regular file STDOUT (check the file system, you will find it there), so then there is only the pretty formatter instance from @CucumberOptions writing to standard out.

Is that a bug?

Is it a bug or a feature?
Well, it is actually used as a feature in some instance, see #643.

Best Regards
Björn

Christian

unread,
Jul 1, 2014, 10:55:45 AM7/1/14
to cu...@googlegroups.com

On Friday, June 27, 2014 6:45:49 PM UTC+1, Björn Rasmusson wrote:
Christian wrote:

On Friday, June 27, 2014 2:21:56 PM UTC+1, Christian wrote:

On Friday, June 27, 2014 2:07:46 PM UTC+1, Christian wrote:
Is there a way to get different report formats when running cucumber-jvm via command line?

I'm looking to an equivalent for 
@CucumberOptions(format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" })

Do I need to pass in several --format arguments in, or do I comma-separate the values?

-Dcucumber.options="--format pretty, html:target/cucumber"


I just tried to pass the following in via Build > Invoke Top-level Maven Targets > Advanced > Properties:
cucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json

When I run that, it gets passed in as
 "-Dcucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json"

and I get the following error:
cucumber.runtime.CucumberException: Only one formatter can use STDOUT. If you use more than one formatter you must specify output path with FORMAT:PATH_OR_URL

I'm probably overlooking something really simple and obvious here, but I thought I had only specified "pretty" as a STDOUT formatter?

You need to be aware of the "--format" option when used in -Dcucumber.options works differently than the other options, it adds the formatters specified in -Dcucumber.options to the ones specified in @CucumberOptions, so when you get the error you are likely to have two formatters wanting to write to standard out, the pretty formatter instance from @CucumberOptions and the pretty formatter instance from -Dcucumber.options.

Hi Björn,

Now, that contrasts slightly with what you told me the other day... ;-)
 
Cucumber-JVM will use the options from @CucumberOptions that aren't overridden by the -Dcucumber.options statement.

Good to know, though...


cucumber.options=src/test/resources/features --tags @a --format pretty:STDOUT --format html:target/cucumber-a --format json:target/cucumber-a.json
seems to work... 

Yes, now the pretty formatter instance from -Dcucumber.options writes to the regular file STDOUT (check the file system, you will find it there), so then there is only the pretty formatter instance from @CucumberOptions writing to standard out.

Is that a bug?

Is it a bug or a feature?
Well, it is actually used as a feature in some instance, see #643.


Well, let me rephrase, then: how do I force a format for the Jenkins console on Continuous Integration when users have specified something else in the annotation? 
Please don't say "you can't"... ;-)

Regards,

Christian

Björn Rasmusson

unread,
Jul 1, 2014, 1:05:47 PM7/1/14
to cu...@googlegroups.com
Christian wrote:

On Friday, June 27, 2014 6:45:49 PM UTC+1, Björn Rasmusson wrote:
Christian wrote:

On Friday, June 27, 2014 2:21:56 PM UTC+1, Christian wrote:

On Friday, June 27, 2014 2:07:46 PM UTC+1, Christian wrote:
Is there a way to get different report formats when running cucumber-jvm via command line?

I'm looking to an equivalent for 
@CucumberOptions(format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" })

Do I need to pass in several --format arguments in, or do I comma-separate the values?

-Dcucumber.options="--format pretty, html:target/cucumber"


I just tried to pass the following in via Build > Invoke Top-level Maven Targets > Advanced > Properties:
cucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json

When I run that, it gets passed in as
 "-Dcucumber.options=src/test/resources/features --tags @a --format pretty --format html:target/cucumber-a --format json:target/cucumber-a.json"

and I get the following error:
cucumber.runtime.CucumberException: Only one formatter can use STDOUT. If you use more than one formatter you must specify output path with FORMAT:PATH_OR_URL

I'm probably overlooking something really simple and obvious here, but I thought I had only specified "pretty" as a STDOUT formatter?


You need to be aware of the "--format" option when used in -Dcucumber.options works differently than the other options, it adds the formatters specified in -Dcucumber.options to the ones specified in @CucumberOptions, so when you get the error you are likely to have two formatters wanting to write to standard out, the pretty formatter instance from @CucumberOptions and the pretty formatter instance from -Dcucumber.options.

Hi Björn,

Now, that contrasts slightly with what you told me the other day... ;-)
 
Cucumber-JVM will use the options from @CucumberOptions that aren't overridden by the -Dcucumber.options statement.

Good to know, though...

Hi,

I think that when I wrote that, #643 had not been rejected yet, so I had some reasons to believe that even though it was not true with respect to the formatters then, it was something that would be fixed.

 

cucumber.options=src/test/resources/features --tags @a --format pretty:STDOUT --format html:target/cucumber-a --format json:target/cucumber-a.json
seems to work... 

Yes, now the pretty formatter instance from -Dcucumber.options writes to the regular file STDOUT (check the file system, you will find it there), so then there is only the pretty formatter instance from @CucumberOptions writing to standard out.

Is that a bug?

Is it a bug or a feature?
Well, it is actually used as a feature in some instance, see #643.


Well, let me rephrase, then: how do I force a format for the Jenkins console on Continuous Integration when users have specified something else in the annotation? 
Please don't say "you can't"... ;-)

I don't know how (which is hardly a better answer the "you can't").

Regards
Björn
 

Regards,

Christian

Jason Smiley

unread,
Jul 1, 2014, 3:09:17 PM7/1/14
to cu...@googlegroups.com
you need --format for each.

Note: Format gets ADDED to, not overwritten.

the equivalent for the above is as follows:

-Dcucumber.options="--format pretty --format html:target/cucumber --format json:target/cucumber.json"
Reply all
Reply to author
Forward
0 new messages