STAMP-project / pitest-descartes

Descartes supports developers to improve their test suites by reporting weak spots in covered code
https://hal.archives-ouvertes.fr/hal-01870976/document
GNU Lesser General Public License v3.0
126 stars 21 forks source link

smarter stop method 'constant' #121

Open arnobl opened 4 years ago

arnobl commented 4 years ago

Characteristics

Description

The stop method 'constant' sometimes creates a mutant that returns the exact same value of the returned constant. I face this limitation in abstract classes that have some methods with default behavior (eg https://github.com/interacto/interacto-java-api/blob/master/src/main/java/io/github/interacto/binding/WidgetBindingImpl.java#L243). The method returns false and Descartes creates a mutant that returns true while it should just create a mutant that returns false.

Do you think that is possible to improve that?

Steps to reproduce

Create a method that returns true. Enable except[constant]

oscarlvp commented 4 years ago

Actually, no mutant should be created for this method. so this is indeed a bug.

arnobl commented 4 years ago

Really? (I activated the 'constant' mutation) I guess one mutant should be created: return true; when the method returns the constant false (and vise versa). No?

oscarlvp commented 4 years ago

With except you actually disable the constant stop method. So that's why these mutants are created. I understand now what you mean. With constant we disable all methods returning a constant value no matter the type or the value. But yes, maybe a smarter feature could be implemented.

arnobl commented 4 years ago

well this is what I though when I read to documentation but this actually activate the mutants: https://github.com/STAMP-project/pitest-descartes/blob/master/README.md#configuring-stop-methods

The doc says:

<features>
  <feature>
  <!-- This will allow descartes to mutate deprecated methods -->
    +STOP_METHODS(except[deprecated])
  </feature>
</features>

and indeed I activated several mutation operators this way.
oscarlvp commented 4 years ago

Yes, sure, you activate the mutants by disabling the stop methods. Sorry I might not have been clear enough. So having constant activated, which is the default configuration, you avoid these mutants. except[constant] allows the creation. so you are right.

arnobl commented 4 years ago

Yes, sure, you activate the mutants by disabling the stop methods.

ok! I think you can add this sentence in the readme file.