mutmut icon indicating copy to clipboard operation
mutmut copied to clipboard

List mutants with mutation_type?

Open AGeekInside opened this issue 6 years ago • 4 comments

Hi,

Is there anyone way to list the mutations by the mutation_type? I looked init and noticed that it looks like Mutants can be made of up multiple mutations. I am trying to figure out the best way to get a listing of mutants with the types of mutations in a given Mutant.

It looks like the cache code that refers to the Mutant class doesn't have any field showing the mutations involved in a given mutant, so I wasn't sure how to reconstruct the mutations involved in creating a specific mutant.

The context is that we'd like to be able to prioritize what mutants we examine first, as we start fleshing our tests to address issues found with mutmut.

Marc

AGeekInside avatar Apr 19 '19 14:04 AGeekInside

A mutant In mutmut is a single mutation point and a single possible mutant. One could imagine having multiple mutants for one mutation point (e.g. changing literal 0 to 1 and -1), but I haven't implemented that and no one has reported a case where the lack of this feature would be a problem. It's already slow enough as is so there must be a strong reason to introduce many more mutants to try!

Do you have some idea of what types of mutants you think are more valuable to kill? Because I would love to hear your logic, I haven't come up with such a scenario myself. In my experience the most scary sounding mutant that changes assignment from "a = b" to "a = None" mostly just means there is some dead code in practice. So it's hard to know how to prioritize!

boxed avatar Apr 19 '19 15:04 boxed

It's probably more of examples that are not as interesting. I ran mutmut on some code we are looking to test better/more, and some of the mutants were permutations of string constants in logging messages. That's a less interesting than mutations that change the boundary conditions of if statements and such.

Given the large number of surviving mutants in our codebase, I was trying to get my arms around how to prioritize what mutants to look at/work on first. I'm not 100% sure that the mutation types would be the right way to build that prioritized list, but it seemed like mutations of operators, and/or, and numbers might be higher priority than string (for instance).

AGeekInside avatar Apr 19 '19 16:04 AGeekInside

If I understand it well, mutmut has per statement one mutant. And one mutant has 1 change in the statement. That means that a complex statement is mutated only once however multiple or possible. ie the next statement:

value2 = value + (possible_non_value or 1)

will only mutate the or in a and, but will not mutate the + or the 1.

Is that the current behaviour indeed?

mrijken avatar Oct 21 '22 17:10 mrijken

No, that's not correct. It will mutate that line in 4 ways I believe.

boxed avatar Oct 21 '22 17:10 boxed