stryker-mutator / stryker-js

Mutation testing for JavaScript and friends
https://stryker-mutator.io
Apache License 2.0
2.58k stars 249 forks source link

Excluding files with 100% coverage from the clearTextReporter #4690

Closed sebiniemann closed 2 months ago

sebiniemann commented 8 months ago

Is your feature request related to a problem? Please describe. We adhere to a test policy mandating that all modifications made by developers to the source code reach 100% test coverage. While deviations are permissible, they must be clearly denoted through explicit exceptions in the form of corresponding comment blocks, which the test system recognizes.

To enforce this policy, we set the coverage threshold to 100% (utilizing thresholds: { break: 100 }). This ensures that every change is accompanied by either a test or a formally acknowledged deviation, as indicated by comments like // Stryker disable ....

When assessing our progress using the score table from the clear-text reporter, numerous rows with a 100.00 value in the score column are displayed, which makes it more difficult to find the file that still need to be worked on, especially with a large code base.

-----------|---------|----------|-----------|------------|----------|----------|
File       | % score | # killed | # timeout | # survived | # no cov | # errors |
-----------|---------|----------|-----------|------------|----------|----------|
All files  |   99.70 |      987 |         0 |          3 |        0 |        0 |
 file1.js  |  100.00 |       10 |         0 |          0 |        0 |        0 |
 file2.js  |   90.00 |        9 |         0 |          1 |        0 |        0 |
 file3.js  |  100.00 |       10 |         0 |          0 |        0 |        0 |
 ...       |     ... |      ... |       ... |        ... |      ... |      ... |
 file33.js |  100.00 |       10 |         0 |          0 |        0 |        0 |
 file34.js |   90.00 |        9 |         0 |          1 |        0 |        0 |
 file35.js |  100.00 |       10 |         0 |          0 |        0 |        0 |
 ...       |     ... |      ... |       ... |        ... |      ... |      ... |
 file97.js |  100.00 |       10 |         0 |          0 |        0 |        0 |
 file98.js |   90.00 |        9 |         0 |          1 |        0 |        0 |
 file99.js |  100.00 |       10 |         0 |          0 |        0 |        0 |
-----------|---------|----------|-----------|------------|----------|----------|

Describe the solution you'd like Similar to the --skip-full option in https://github.com/bcoe/c8, an option to hide files with a perfect score in the clear-text reporter would be great.

Using this option should produce the following report compared to the example above:

-----------|---------|----------|-----------|------------|----------|----------|
File       | % score | # killed | # timeout | # survived | # no cov | # errors |
-----------|---------|----------|-----------|------------|----------|----------|
All files  |   90.00 |       27 |         0 |          3 |        0 |        0 |
 file2.js  |   90.00 |        9 |         0 |          1 |        0 |        0 |
 file34.js |   90.00 |        9 |         0 |          1 |        0 |        0 |
 file98.js |   90.00 |        9 |         0 |          1 |        0 |        0 |
-----------|---------|----------|-----------|------------|----------|----------|

We are open to contributing a merge request. 😃

An open question would be how you want to deal with the all files entry. Whether it should only refer to the displayed lines (as here), to all lines (as above), or not be displayed at all if the new option is used.

For us, each variant would be equally suitable, as this summary has no influence on our reviews.

nicojs commented 7 months ago

Hi @sebiniemann, and welcome. I'm sorry I didn't reply sooner. I've been quite busy and have yet to notice this issue sneaking in.

This sounds like an excellent new feature. It seems like a great addition to the clearTextReporter option. The name 'skip full' sounds good 👍.

An open question would be how you want to deal with the all files entry. Whether it should only refer to the displayed lines (as here), to all lines (as above), or not be displayed at all if the new option is used.

Ah yes. I would say the All files shouldn't be shown when all files result in a 100% score. And with that, we can also choose to not show the table at all in that case. What do you think?

sebiniemann commented 4 months ago

And with that, we can also choose to not show the table at all in that case. What do you think?

Sounds good to me.

I've created a pull request (#4875) to implement this feature. I wasn't sure where you wanted these changes, so I've tried to be minimally invasive while covering everything mentioned -- excluding files with a 100% score, skipping "All files" and omitting the entire table if all files achieve a 100% score.