Create json object for each scenario

432 Views Asked by At

Tried with below command:

behave sample.feature --format json --out file_name.json

The above command provides a single json file containing all the scenarios results. But I need multiple json's for all the listed scenarios present in feature file instead of a single json. Is there any implemented logic to get this or anything to add here.

1

There are 1 best solutions below

1
On

This is not possible as is, but it can be done. There are two main options.

1) You could create your own formatter class to achieve this, or possibly expand the already existing JSON formatter. See this for more details on user defined formatters.

2) Post-processing the output. You basically could create your own little tool that post-processes the generated JSON file after your tests have finished executing.