pitest icon indicating copy to clipboard operation
pitest copied to clipboard

Cant find mutation on multi module project

Open mcarabolante opened this issue 9 years ago • 7 comments

My maven based project has the current structure: A - root containing (B-production code, C-Tests)

Pitest is not finding any mutations( Failed to execute goal org.pitest:pitest-maven:1.1.10:mutationCoverage (default-cli) on project unit-tests: Execution default-cli of goal org.pitest:pitest-maven:1.1.10:mutationCoverage failed: No mutations found. This probably means there is an issue with either the supplied classpath or filters.). In the log it seems it is trying to find the mutations before running the tests.

15:26:39 PIT >> FINE : According to coverage no tests hit the mutation MutationDetails [id=MutationIdentifier [location=Location [clazz=com.gradussoftwares.AClass, method=getQuantity, methodDesc=()Ljava/math/BigDecimal;], indexes=[5], mutator=org.pitest.mutationtest.engine.gregor.mutators.ReturnValsMutator], filename=AClass.java, block=4, lineNumber=17, description=mutated return of Object value for com/gradussoftwares/APath/

later ..

15:28:58 PIT >> INFO : MINION : 15:28:58 PIT >> FINE : Gathering coverage for test Description [testClass=com.gradussoftwares.ATest, name=shouldBeBlocked(com.gradussoftwares.ATest

I have added pitest on unit-test pom plugin with the config :

<configuration>
 <targetTests>
  <param>com.*</param>
  </targetTests>
 <targetClasses>
  <param>com.*</param>
 </targetClasses>
</configuration>

mcarabolante avatar Dec 13 '16 17:12 mcarabolante

It is definitely possible with Gradle. Maybe similar approach with mainSourceSets and additionalMutableCodePaths can be also adapted to the Maven project.

szpak avatar Dec 13 '16 18:12 szpak

The maven configuration is similar, but after runing the tests, it keeps not finding any mutation.

10:31:26 PIT >> WARNING : No mutations found. This probably means there is an issue with either the supplied classpath or filters.

What I really find weird is that it seems to be trying to generate the mutations before getting coverave from the tests

mcarabolante avatar Dec 14 '16 12:12 mcarabolante

@mcarabolante-gradus The maven module does not currently support placing unit tests in a different module than the code under test.

It is also not currently possible to manually configure the mutable code path for maven (the output classes directories are used).

It would be possible to allow the mutable code paths to be overridden so your structure code be supported (at the expense of fiddly config).

Out of interest, why do you not place your unit tests in the same module as the code?

hcoles avatar Dec 14 '16 13:12 hcoles

We have 3 types of tests, unit, integration and functional, each one tests different layers of our code.

Leaving them separated from production code and each other made it easier to run one layer at a time and made our test code more organized, and faster to fix failing tests since we can rule out layers.

mcarabolante avatar Dec 14 '16 15:12 mcarabolante

Same issue here. Are there any ways to get reports for a Module A with Tests in Module B?

FrankR85 avatar Jun 16 '17 17:06 FrankR85

You can try this maven plugin for running PIT in multi-module projects. It would be nice to have some feedback.

oscarlvp avatar Dec 12 '17 11:12 oscarlvp

The referenced plugin doesn't seem to be actively maintained, it would be nice to have that feature as a part of PIT (or Arcmutate).

ul avatar Sep 10 '24 05:09 ul