-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Mutation testing is used to design new tests and evaluate the quality of an existing test suite. In other words, it can tell you about the quality of your tests, where coverage only tells you about how much code you have not yet written a test for.
It works by changing the behavior of a program by changing parts of the code ("mutating it"), running the test suite with this new mutation and checking if the test suite passed. If the test suite passed, the mutation is considered to have survived - if not, it is considered to have died.
If dead / total
is below some threshold, then there is room for improvement in the test suite. In other words, the more dead mutations you have, the better.
I think this would be a pretty cool tool to have in Foundry - and I think it is somewhat trivial to implement as well (simplified strategy):
- Have a list of mutations we can do
- Parse the source contracts
- Insert mutation somewhere
- Run tests
- Repeat until we're satisfied
Here's a paper on mutation testing for Solidity that I found interesting: https://arxiv.org/pdf/2105.03626.pdf
Metadata
Metadata
Assignees
Labels
Type
Projects
Status