pitest icon indicating copy to clipboard operation
pitest copied to clipboard

Inconsistent coverage when running JUnit tests in parallel

Open EPadronU opened this issue 5 years ago • 3 comments

After a single mvn clean install invocation, I get inconsistent coverage with subsequence calls to mvn org.pitest:pitest-maven:mutationCoverage

JDK target: 8

$ for x in (seq 1 10); mvn org.pitest:pitest-maven:mutationCoverage 2>/dev/null | grep 'Generated 7 mutations Killed'; sleep 2; end
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 3 (43%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)

JDK target: 14

$ for x in (seq 1 10); mvn org.pitest:pitest-maven:mutationCoverage 2>/dev/null | grep 'Generated 7 mutations Killed'; sleep 2; end
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 7 (100%)
>> Generated 7 mutations Killed 6 (86%)
>> Generated 7 mutations Killed 3 (43%)
>> Generated 7 mutations Killed 3 (43%)

Something to be noticed

It happens less setting up the target to JDK 8, it happens for JDK 11 as frequently as for JDK 14.

Work around (which is the default for JUnit5):

junit.jupiter.execution.parallel.enabled=false 

The source code: src.zip

EPadronU avatar Apr 22 '20 14:04 EPadronU

I have observed the same, and indeed it seems that PIT is not compatible with junit.jupiter.execution.parallel.enabled = true Eventually it would be nice that it turn off junit.jupiter.execution.parallel.enabled automatically if detected when using pitest-junit5-plugin.

tyge68 avatar Dec 15 '22 21:12 tyge68

It does so since version 1.1.1, but it would be nicer if parallel execution would be supported properly. Assuming the same problems will hit with Spock in parallel mode.

Vampire avatar May 07 '23 19:05 Vampire

While pitest/pitest-junit5-plugin#74 already worked-around this specifically for Jupiter engine, pitest/pitest-junit5-plugin#91 provides a generic fix that should work with all test engines and was also tested with Spock. So latest when pitest/pitest-junit5-plugin#91 gets merged, this issue can be closed.

Vampire avatar May 12 '23 17:05 Vampire