Output option for Mutation coverage #19
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On a similar note as pestphp/pest-plugin-type-coverage#19, I would like to add an output option for mutation coverage.
The format follows more or less the same as for the type coverage and usage is the same as well:
--mutate-output-json=[path]This will output a computer-readable file which can be used for reporting and tracking historical changes (especially relevant for repositories that does not have full coverage).
Based on comments from the type coverage PR, I have followed a very similar pattern with a NullLogger as default that can then be overwritten, which also would let us extend this to other formats than JSON. I did an unset of the arg after usage because the configuration class did not like me passing the arg to it.
Notes
src/Plugins/Mutate.phpcode to use as inspiration, so I just wrote a test for the JsonLoggerPlease do provide with feedback. Hope you'll consider support for this 🙏🏻 I will commit to keeping the output code maintained (tag me for related issues I'll be on it asap!)
Output example
{ "format": "pest", "results": [ { "path": "\/Users\/lasserafn\/Downloads\/php-example-pestphp-mutation-coverage\/src\/User.php", "count_total": 9, "count_not_run": 0, "count_timed_out": 0, "count_uncovered": 0, "count_untested": 2, "tests": [ { "id": "6d3549fc8e6a1f96", "duration": 0.1179, "result": "tested", "mutation": { "id": "6d3549fc8e6a1f96", "mutator": "Pest\\Mutate\\Mutators\\ControlStructures\\IfNegated", "start_line": 20, "end_line": 25 } }, { "id": "70dfd45e38c4631e", "duration": 0.1071, "result": "tested", "mutation": { "id": "70dfd45e38c4631e", "mutator": "Pest\\Mutate\\Mutators\\Equality\\IdenticalToNotIdentical", "start_line": 20, "end_line": 20 } }, { "id": "75e38a7740a0415a", "duration": 0.1078, "result": "tested", "mutation": { "id": "75e38a7740a0415a", "mutator": "Pest\\Mutate\\Mutators\\Number\\DecrementInteger", "start_line": 20, "end_line": 20 } }, { "id": "8e91b931bd0908bb", "duration": 0.1051, "result": "tested", "mutation": { "id": "8e91b931bd0908bb", "mutator": "Pest\\Mutate\\Mutators\\Number\\IncrementInteger", "start_line": 20, "end_line": 20 } }, { "id": "aa7a76fbc9a8d0a9", "duration": 0.0999, "result": "untested", "mutation": { "id": "aa7a76fbc9a8d0a9", "mutator": "Pest\\Mutate\\Mutators\\Number\\DecrementInteger", "start_line": 21, "end_line": 21 } }, { "id": "12f7cc5502bddaf3", "duration": 0.0982, "result": "untested", "mutation": { "id": "12f7cc5502bddaf3", "mutator": "Pest\\Mutate\\Mutators\\Number\\IncrementInteger", "start_line": 21, "end_line": 21 } }, { "id": "07ad61bc7838a59c", "duration": 0.1061, "result": "tested", "mutation": { "id": "07ad61bc7838a59c", "mutator": "Pest\\Mutate\\Mutators\\Logical\\TrueToFalse", "start_line": 24, "end_line": 24 } }, { "id": "c8d4ddcec1589bbe", "duration": 0.1176, "result": "tested", "mutation": { "id": "c8d4ddcec1589bbe", "mutator": "Pest\\Mutate\\Mutators\\Removal\\RemoveEarlyReturn", "start_line": 24, "end_line": 24 } }, { "id": "ba3ed65695679b63", "duration": 0.1112, "result": "tested", "mutation": { "id": "ba3ed65695679b63", "mutator": "Pest\\Mutate\\Mutators\\Logical\\FalseToTrue", "start_line": 27, "end_line": 27 } } ] } ], "stats": { "duration": 0.9737, "score": 77.77777777777779, "tests": { "count_total": 1, "count_not_run": 0, "count_timed_out": 0, "count_uncovered": 0, "count_untested": 2 } } }