Don't ignore coverage of methods without assertions#3348
Don't ignore coverage of methods without assertions#3348lcobucci wants to merge 1 commit intosebastianbergmann:7.4from
Conversation
Codecov Report
@@ Coverage Diff @@
## 7.4 #3348 +/- ##
============================================
+ Coverage 82.59% 82.83% +0.23%
- Complexity 3533 3534 +1
============================================
Files 143 143
Lines 9331 9332 +1
============================================
+ Hits 7707 7730 +23
+ Misses 1624 1602 -22
Continue to review full report at Codecov.
|
|
I was able to agree to adding Thank you for your contribution. I appreciate the time you invested in preparing this pull request. However, I have decided not to merge it. |
|
@sebastianbergmann so do you expect people to rely on public function assert(): void
{
if (/** condition */) {
throw new Exception();
}
} I respect your decision but I find it hard to agree that setting the test to not expect an assertion is not an assertion, since it actually sets the intention of the test. I would even argue that it is similar to setting the test to expect an exception - IMO this mindset plays nicely with @localheinz's contribution to fail the test if any assertion happened. |
|
It's important to mention that I don't really care about having 100% of coverage but the coverage affects my mutation tests and msi and covered msi are relevant to me. |
|
@sebastianbergmann the issue #2484 and all related PRs/issues shows how people are using |
|
@lcobucci Sounds like a documentation issue to me. |
|
@sebastianbergmann alright, I can send a PR to the doc repo to solve that issue. Could you please confirm that the expected ways to assert that no exception has been thrown are: using Even though I might not agree with either it's important to make things clear on the docs 👍 |
PHPUnit was not adding the coverage of tests with
@doesNotPerformAssertionsor$this->expectNotToPerformAssertions();to the report, leading to wrong coverage results.