Adding custom elements in json output #1105
-
We are having the scenario's test status as "passed" in the json output in console or the exported json
I want to add a new element "logs_captured" below the "status" element which holds trace of logs captured using logging library for a particular scenario. Note: I have the captured traces in "after_scenario" added behave context. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The existing JSON schema has no attribute that you can use to add this information. NOTE: SEE ALSO:
|
Beta Was this translation helpful? Give feedback.
The existing JSON schema has no attribute that you can use to add this information.
You need to extend the existing JSON output format/schema to add the additional information.
You need to provide an own JSON formatter to add this additional data to the JSON output.
NOTE:
Formatters
are an extension-point inbehave
.Therefore, you are able to add your own format(ter) class and use it.
You probably need to override
JSONFormatter.finish_current_scenario()
for what you are trying to do.SEE ALSO:
behave.formatters
: Formatter aliases inbehave
config-file to simplify use and/or override existing formatters)