pitest / pitest-junit5-plugin

JUnit 5 test framework support for Pitest
Apache License 2.0
74 stars 26 forks source link

Plugin is not compatible with junit5 junit.jupiter.execution.parallel.enabled true #73

Open tyge68 opened 1 year ago

tyge68 commented 1 year ago

If your project uses a junit-platform.properties which enable parallel execution, PIT will compute wrong coverage.

As a solution this plugin should disable parallel mode from junit via junit.jupiter.execution.parallel.enabled property.

I suppose in the JUnit5TestPluginFactory createTestFrameworkConfiguration could be a good place to set it (at least it worked for me)

    public Configuration createTestFrameworkConfiguration(TestGroupConfig config, 
        ClassByteArraySource source, 
        Collection<String> excludedRunners,
        Collection<String> includedTestMethods) {
        System.setProperty("junit.jupiter.execution.parallel.enabled", "false"); <--- enforce to disable parallel mode
        return new JUnit5Configuration(config, includedTestMethods);
    }
Vampire commented 1 year ago

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