Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive: Throw_ mutant not covered by tests #1778

Closed
ghostwriter opened this issue Dec 16, 2022 · 10 comments
Closed

False positive: Throw_ mutant not covered by tests #1778

ghostwriter opened this issue Dec 16, 2022 · 10 comments

Comments

@ghostwriter
Copy link

Question Answer
Infection version 0.26.16
Test Framework version PHPUnit 9.5.27
PHP version 8.1.13
Platform MacOS & Ubuntu
Github Repo ghostwriter/option ghostwriter/result
  1. ghostwriter/option/src/Traits/OptionTrait.php:70 [M] Throw_
--- Original
+++ New
@@ @@
     public function expect(Throwable $throwable) : mixed
     {
         if ($this instanceof NoneInterface) {
-            throw $throwable;
+            $throwable;
         }
         return $this->value;
     }

This test explicitly checks that the method throws a specific exception with a specific exception message, but that doesn’t satisfy infection. ghostwriter/option/tests/Unit/NoneTest.php:102

I keep seeing multiple instances of this same error in many repositories.

I believe it is a false positive or bug because, in each instance, I have 100% test coverage.

eg. :
https://github.com/ghostwriter/option/actions/runs/3710778536/jobs/6290589145
https://github.com/ghostwriter/result/actions/runs/3710486045/jobs/6290051681

@sanmai
Copy link
Member

sanmai commented Dec 16, 2022

Please try:

composer require --dev phpunit/php-code-coverage:^9.2.21

And report if you still have the issue.

@ghostwriter
Copy link
Author

I still have the same issue.

@sanmai
Copy link
Member

sanmai commented Dec 16, 2022

Here's what I did.

I generated a coverage report with php vendor/bin/phpunit --coverage-html=coverage and saw:


Then I downgraded the package to the earliest known working version as per #1773:

composer require --dev phpunit/php-code-coverage:=9.2.16

And saw:

@Slamdunk
Copy link
Contributor

Yup, an easy fix is needed in phpunit/php-code-coverage indeed, hope to propose it today

@romm
Copy link
Contributor

romm commented Dec 16, 2022

@Slamdunk
Copy link
Contributor

Fix proposed in sebastianbergmann/php-code-coverage#969

@ghostwriter
Copy link
Author

@sanmai Thanks for your help pinpointing the main issue and @Slamdunk Thanks for providing the solution.

@sanmai
Copy link
Member

sanmai commented Dec 16, 2022

Shall we close this as completed?

@ghostwriter
Copy link
Author

Personally, I’d wait until there’s a new tag released for sebastianbergmann/php-code-coverage, but ultimately the issue has been addressed so I’m okay with your decision.

@sanmai
Copy link
Member

sanmai commented Dec 18, 2022

Thanks for raising this issue. I don't see we can do anything more here.

If there is more to the issue, please inspect the coverage report and open any issues with the packages where they appear. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants