domohuhn / mutation-test

Automated mutation testing for any programming language
BSD 3-Clause "New" or "Revised" License
21 stars 3 forks source link

`Replaces arithmetic operators` should not mutate if within a String #21

Closed marandaneto closed 1 year ago

marandaneto commented 1 year ago

For the given String 'a+b' the Regex will be a match and it will be executed, it's a false positive since it's not an arithmetic operation.

For String templates, only mutates if it's using variables such as '$a+$b', '${a + b}', etc.

domohuhn commented 1 year ago

The program does not parse the code, that way it is agnostic to the programming language. You can provide your own rules in an xml configuration and ignore the built in rule set. The consequence of this design is that it is not possible to exclude a certain pattern for strings, but not for string interpolation. A general exclusion for all strings can be added to the default rules, but i am not sure if that is needed. You can always add your own exclusion rules by adding --rules <file.xml> to the call of the executable. See also https://github.com/domohuhn/mutation-test#exclude

I will have to think about that a bit more.

marandaneto commented 1 year ago

A general exclusion for all strings can be added to the default rules, but i am not sure if that is needed

That is the problem, for languages that have String interpolation, this rule which is useful has to be disabled, I understand the need of being agnostic but this is a side effect and consequently a bug.

domohuhn commented 1 year ago

I added a command line flag in version 1.6 that should exclude most strings without interpolation.

marandaneto commented 1 year ago

That should help, thanks for doing this.