how to generate json file with feature file name ?

1,231 views
Skip to first unread message

sai krishna

unread,
Nov 8, 2015, 12:06:34 PM11/8/15
to Cukes
Hi Guys,

Is there any way in cucumber-jvm that i can generate json report with feature file name ?

Björn Rasmusson

unread,
Nov 8, 2015, 3:02:25 PM11/8/15
to Cukes
sai krishna wrote:
Hi Guys,

Is there any way in cucumber-jvm that i can generate json report with feature file name ?
Hi,

The json report name is controlled by the json formatter argument passed to Cucumber-JVM, either using the @CucumberOptions annotation:
@CucumberOptions(plugin = { "json:<path/filename>.json" })

or using command line arguments:
--plugin json:<path/filename>.json

So if you only execute one feature you can get a json report with the feature file name by passing that name to Cucumber-JVM, if you are executing several features in one invocation you only can get one json report (with the filename you choose).

Regards
Björn

 

sai krishna

unread,
Nov 8, 2015, 8:36:53 PM11/8/15
to Cukes
Thanks buddy,

This is how i run the tests currently, all i need is to know how do i pass a custom_file_name.json instead of cucumber.json as below

@RunWith(Cucumber.class)

@Cucumber.Options(features = "src/test/resources/cucumber/examples/",  format = {"pretty", "html:target/cucumber", "json:target/cucumber.json"})

public class AutoCorrectAT {

Björn Rasmusson

unread,
Nov 9, 2015, 6:59:25 AM11/9/15
to Cukes
sai krishna wrote:
Thanks buddy,

This is how i run the tests currently, all i need is to know how do i pass a custom_file_name.json instead of cucumber.json as below

@RunWith(Cucumber.class)

@Cucumber.Options(features = "src/test/resources/cucumber/examples/",  format = {"pretty", "html:target/cucumber", "json:target/cucumber.json"})

public class AutoCorrectAT {

}


Hi,

If you do not want to update your @CucumberOptions annotation, you can run a specific feature file and add a formatter from the command line using:
 -Dcucumber.options="--plugin json:<path/filename>.json <path/filename>.feature"

This will run only the <path/filename>.feature and create a json report <path/filename>.json (in addition to the reports specified in the @CucumberOptions annotation).

In Cucumber-JVM v1.2.0 the --format option was replaced by the --plugin option.

Regards
Björn

 
Reply all
Reply to author
Forward
0 new messages