pytest-cov
pytest-cov copied to clipboard
Add JSON format to --cov-report
Before proposing please consider:
- the maintenance cost of the feature → probably not much if
coverage.pyis used - implementing it externally (like a shell/python script,
pytest plugin or something else) → it is already implemented in
coverage.pyso it should not be too difficult to add
Summary
These questions should be answered:
- why is the feature needed? User convenience
- what problem does it solve? User friendly
- how it is better compared to past solutions to the problem? JSON is easier to read than XML and more common
There's a suggestion in https://github.com/pytest-dev/pytest-cov/issues/337 that pytest-cov should do less, to simplify pytest-cov, and that coverage.py should be used for more things.
I like what I read @hugovk, thanks for the heads-up!
Given that issue has been open for three and a half years with no traction, I think support for JSON should be implemented in this plugin. What kind of overhead is there? I'd be happy to do the work to contribute it.
Turns out the implementation wasn't very complicated, so I went ahead and did it: https://github.com/pytest-dev/pytest-cov/pull/582
I appreciate the points made in #337, but I think the consensus there is that the maintainers should build a new library that does less, rather than releasing a new major version of this library that's essentially a totally different project anyway. Therefore I think it's appropriate that straightforward modifications to expose additional trivial functionality in coverage.py should still be added to this project.
Thansk a lot @mwgamble!
I agree with your assessment, especially after looking at your implementation (which is simple enough).
Help me understand why running coverage json is difficult? You can already get a JSON report that way.
Help me understand why running coverage json is difficult?
- It's an additional step. Having pytest just generate the JSON file automatically is much more convenient, for the same reasons anyone would already be using any of the other reporters by way of
--cov-report. - It's not obvious to inexperienced developers why they can't run
--cov-report=jsonwhen the coverage.py documentation is telling them JSON reporting is fully supported.