You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DEVELOPMENT-SNAPSHOT: 2012-08-17 (after fixes for issue #59)
The JSONFormatter has currently several problems
(using it "behave --format=json ...").
PROBLEM 1:
Last feature is outputted twice.
REASON:
formatter.eof() is called twice for last feature:
once at end of Feature.run() and
once at end of Runner.run()
JSONFormatter currently detects not that no additional data was entered in between these 2 calls. NOTE:
These 2 calls are not bad. They allow the Formatter class a finalize-output feature that is sometimes needed (as long as no other method exists for this).
Unformatted JSON output is unreadable.
Prettify output with json.dumps(x, indent=2) or json.dumps(x, indent=2, sort_keys=True)
Summary formatter output is mingled with JSON data, even when --output option is used.
This leads again to invalid JSON output that must be seperated from JSON data. DESIRED-CHANGE: Only JSON output is written into output file (or more general: Only from one formatter)
IMHO, this will not work to solve the JSON output problem described in issue #60.
I looked into this problem after I wrote the trouble-ticket.
behave.runner.Runner.run_with_path() creates a new formatter object for each iteration in the feature processing loop. Therefore, exactly one feature is processed by each JSONFormatter instance. Maybe it would be better to have a JSON reporter !?!
It seems just like another output format, like the junit (XML) reporter.
After retesting
After testing it with release-1.2.2, my worries, stated above, are confirmed.
PROBLEM 1 is fixed.
PROBLEM 2 is not fixed.
Therefore, non-JSON compliant output is generated.
Problem 2 is now finally fixed.
Formatters are now created only once (was: once for each feature).
JSON formatter writes now feature data triggered by formatter.eof() and final JSON footer when formatter is closed.
Well-formed JSON output is now generated.
FUTURE:
Provide *.jsonschema to validate generated JSON output (and detect implementation problems early on)
Activity
jenisys commentedon Aug 21, 2012
Before retesting (after inspecting the changes)
IMHO, this will not work to solve the JSON output problem described in issue #60.
I looked into this problem after I wrote the trouble-ticket.
behave.runner.Runner.run_with_path() creates a new formatter object for each iteration in the feature processing loop. Therefore, exactly one feature is processed by each JSONFormatter instance. Maybe it would be better to have a JSON reporter !?!
It seems just like another output format, like the junit (XML) reporter.
After retesting
After testing it with release-1.2.2, my worries, stated above, are confirmed.
PROBLEM 1 is fixed.
PROBLEM 2 is not fixed.
Therefore, non-JSON compliant output is generated.
FIX behave#60: behave --format=json, Background steps are missing.
jenisys commentedon Apr 27, 2013
Problem 2 is now finally fixed.
Formatters are now created only once (was: once for each feature).
JSON formatter writes now feature data triggered by formatter.eof() and final JSON footer when formatter is closed.
Well-formed JSON output is now generated.
FUTURE:
Provide *.jsonschema to validate generated JSON output (and detect implementation problems early on)
Add final remark to issue #60. Last problem is finally fixed.
Add final remark to issue behave#60. Last problem is finally fixed.