-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
test: Introduce Infection for mutation tests #7874
Conversation
Hello, I'm glad you decided to try it :)
you can start with another approach first: instead of mutating all the files and running all the tests, you can mutate only those lines of code that actually changed (added, updated) in the Pull Request. Basically, we do exactly that on Infection itself: https://github.com/infection/infection/blob/873cd3335774a114bef9ca93388e623bf362d820/.github/workflows/mt-annotations.yaml#L55 Infection automatically shows github annotations on the lines that were mutated by mutant wasn't killed, so it's quite convenient (example). This is the fastest approach. Does it make sense?
Regarding Regarding freeze:
you can exclude any files from mutation process, please see here ( I'm happy to help with any issues you may face with integrating Infection, let me know please. |
I tried it out for Fixer already few years ago (2019-06), yet it was too many hours to run on CI back then. Eager to see how fast it can be on CI nowadays ! |
Of course, I saw it in the docs but wanted to start with full check anyway, just to check how the MSI looks like for our tests 🙂. But it seems like full check is a no-go, so I will take a look at the diff approach. My only doubt is how to approach MSI, because some files may have lower, some may have higher indicator. How should it be done properly? In your case you don't use
Yeah, I saw that. I think I'll try to figure out the exact mutator which causes this, I just did not have time for it yet. For now I was only able to ensure that Thanks for great feedback @maks-rafalko, I'll improve this PR soon and if I have any more doubts, I'll let you know. |
Let me clarify it with more details just to be sure we are on the same page about all the aspects of Infection. I think we have 2 goals here to use Infection:
How can we control the quality (MSI)? Only by forcing all the new code to be merged with MSI >= 80%. And from time to time increase this value (to 80.1%, then to 80.2% and so on). How can we force minimum MSI? Only by failing the build, thanks to What value we should set This depends on many factors. Good approach is to start with the baseline and continuously increase it as I described above, failing the builds if MSI < %baseline%. Another approach is to set it to 100% and do not allow any Why do I suggest to start with at least
I would also start with In short,
|
Thank you @maks-rafalko for the great explanation, I believe we're on the same page here as my vision was more or less as you described 😁. I am just a little afraid about the practice part 😅. In the end, the goal is to provide more tests and raise MSI, but as the baseline MSI (80) is only an average value, some contributions may hit the problem described by you - too low MSI just because of historically not-tested-enough code. In this project only @keradus have rights to merge PRs with failures, but really often in practice most of the reviews and merges are done by me, so without the ability to ignore MSI while merging I can see myself getting stuck with PRs 🤔. I could be forced to help people with achieving proper MSI, guide them or maybe even add tests / change Infection config by myself. It's doable, but far from ideal. From this perspective, the best initial introduction of mutation tests would be if we had inline hints for escaped mutants (to point people and maintainers what can/should be improved), but without failed CI. What do you think about it? |
Sounds good. You can always add |
019b6c9
to
a7c205c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Unfortunately there's the same error on v0.27.10 😟. Currently on mobile, so can't dig much, will take a look later. |
The current failure is because of the old PHPUnit xml configuration file format that needs to be migrated.
After it, Infection will run (just tried locally). If we look into other actions, there is always different version of But when we run Infection with PHPUnit on PHP 8.3, Since Infection doesn't have an option to turn off validation, we do it intentionally to make sure project's PHPUnit configuration is in the correct format to make sure coverage and all other features work properly. |
Guys, it's working 😁 In this run you can see warnings related to escaped mutants because I've made one indentation to a random file causing "change" of 1 whole class. I'll revert that change and I believe PR is ready 🥳. Thank you @maks-rafalko for your assistance 🍻! |
Looks good from my side. Great start! |
b9d60d1
to
6c463d8
Compare
@maks-rafalko 2m27s vs 8s 🥳! Awesome improvement! 🍻 |
This is really awesome 😮🥳 |
|
7d9db94
to
e32734d
Compare
We don't run Infection in regular development QA process because full analysis takes too long, so make it an opt-in check.
`line 1` was changed to `line 0|0` which was causing failures.
- Install coverage extension for Infection too - Remove Infection requirement if not needed in CI - Run Infection only for PR's diff
These are too resource greedy, should be opt-in only via local config (that's why `.gitignore` rule was added).
e32734d
to
9f5143c
Compare
@Wirone , this failed on master, mind to take a look? Perhaps it's a matter of using |
Yeah, Infection job should be triggered only for PRs at this point. |
After recent discussion I decided to verify what is our mutation score 😁. It does look good to be honest with initial setup:
Concerns to address
S
at the beginning, then it freezes for significant amount of time, then it runs further (why?).src/Runner/Runner.php
causes some fixture files to be modified, which causes regular test failures and may lead to committing changes that should not be committed.CC: @maks-rafalko, any suggestion are welcome 😃.