-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Smaller-than-function mutations #73
Comments
Hey, thanks again for the idea. I think there is interesting potential to generate smaller-than-function mutations. That's likely to greatly increase the number of mutations, which makes parallelization (#39) more important, and perhaps means people want to sample mutants rather than run them exhaustively. So, I would probably not tend to add this right yet, and maybe even then not turn it on by default. So in your example, it seems to me that your problem is that you don't have very good tests for The mutation that you're proposing in this bug is in fact the exact same mutation that we already generate: hollowing out Assuming you wanted to keep the application logic the same, you could write a test that catches stdout and checks for the expected output, much like the CLI tests in cargo-mutants. That test could potentially catch changes to both these functions. So I think a more actionable definition of this bug would be: here is a tree that is actually not very well tested, but cargo-mutants doesn't say so, but deleting individual statements would potentially catch it. I think one could write an example that does this and that doesn't look too contrived. |
In general this will help when the tests evaluate some, but not all, important behavior of the function. For example:
|
Great additions to the topic, I like them! Also agree with the point we should give the users the options to opt-in/opt-out specific mutants. On the other hand, I would like to challenge my delete-statement idea further. Sorry, but my previous code example was not trivial to demonstrate the problem. The updated code can be found here. But let me first explain it: Let's say we have some logic we want to use it in multiple parts of our program. In this case just a simple data
Now let's say we use this logic in two places in our program. For example in
Now let's say I totally cover my For this code, the hollowing-out mutation generated by Next to that, there are situations where we have no control over the code we use (fe.: 3th party library), so we can not mutate it, so not possible to hollow it out. I left in some On the other hand, this mutagen library can generate a mutation which deletes the abovementioned method call. In the current workplace I work, we have multiple projects each containing dozens of packages. We found this delete-statement mutation as literally the most useful one, it helped us a lot in finding the gaping holes in our test suites. That's why I am pushing for this feature! x) Let me know your thoughts! Thank you! |
Yeah, exactly. That's a more realistic example of the second category in my post. I'm in favor of adding this, but I think it will need some mitigations for the likely effect on run time, e.g.
|
https://stryker-mutator.io/docs/mutation-testing-elements/supported-mutators/ has a good list of ideas. |
The upcoming 23.12 release can represent smaller-than-function mutants, and adds a few modifications of Deleting single statements seems to have a lot of potential too, although it would make a lot of mutants, and I have some concern it might produce too much noise. Perhaps if we exclude patterns like trace lines it will be OK. |
There could be categorical mutations like “delete all statements that aren't (It might also be good to do this while keeping |
Feature request
It would be handy to have a mutation to remove statements that call a single function or method. I see many times in bigger projects (written without TDD) that such things are not covered by tests.
For example, let's say I have the following code:
It would be nice to have a mutation of this code where we would delete the following line in the
do_logic
method:What do you think, it is feasible to do such a thing?
Note
If I run cargo mutants, the following mutant is generated
It rules out many cases, but does not rule out the situation where we have tests for public API
deposit_event
, but not for calling it within other public APIdo_logic
Reproduction
Steps
cargo mutants
Expected behaviour:
There is a mutant generated for removing a statement calling a specific function, something like:
Actual behaviour:
No such mutation is supported by command
cargo mutants
The text was updated successfully, but these errors were encountered: