hcoles / pitest

State of the art mutation testing system for the JVM
Apache License 2.0
1.67k stars 357 forks source link

Custom 3rd party mutators #563

Open rnveach opened 5 years ago

rnveach commented 5 years ago

I am interested in knowing what it takes to create a mutator, what are the limitations, and knowing if it is possible for pitest to allow users to add their own 3rd party custom mutators without being added to pitest repo.

I haven't seen any documentation on this on the website so I don't think it was a consideration. Looking at Mutator.java, it seems the method to add mutators is hidden behind a private method and pitest doesn't have any options that I saw to allow users to specify a custom mutator by classpath. I know mutations work on the byte code, but I don't know how complex the search algorithm can be.

Looking at https://github.com/LaurentTho3/ExtendedPitest , it seems the extended mutators could only be used by replacing the original pitest jar before it was integrated into pitest directly.

For our project checkstyle, we have an integer array that says what tokens checks are allowed to stop on for static processing in the check. Example: https://github.com/checkstyle/checkstyle/blob/63afcb8a76cb73ae198afe87bcf01765e84fc713/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java#L147-L154 It would be interesting to try and write a mutator that modified these integer arrays under these methods and replace each token with a dummy token to see if the specific token is actually needed.

szpak commented 1 year ago

@rnveach I've accidentally bumped into this question and I wonder in the pluggable mutators mechanism, introduced in PIT 1.7.0 (on 2021-09-01, so some time after your initial question) wouldn't be useful for you?

I don't know if the procedure is described anywhere, but looking at the mechanism's own tests, it should be possible to provide mutator(s) in the external JAR and they should be discovered by the Gregor engine.

szpak commented 1 year ago

Btw, accidentally again, I have crashed into https://github.com/pitest/pitest-rv-plugin which clearly show an external plugin with extra mutators :-).