szpak / gradle-pitest-plugin

Gradle plugin for PIT Mutation Testing
http://gradle-pitest-plugin.solidsoft.info/
214 stars 58 forks source link

Automatically add junit-platform-launcher for JUnit Platform projects #353

Closed szpak closed 1 year ago

szpak commented 1 year ago

Automatically add junit-platform-launcher to testRuntimeOnly for JUnit Platform projects to avoid "UNKNOWN_ERROR" or: "NoClassDefFoundError: org.junit.platform.launcher.core.LauncherFactory" with PIT 1.14.0+ (with pitest-junit-plugin 1.2.0+).

That dependency is no longer shaded. More details in #337.

The implementation was more complicated than in the Maven plugin and help provided by @Vampire was very helpful!

I keep it as draft, maybe @Vampire (or someone else) has an idea how to simplify the implementation (or sees any important not supported corner cases)?

Also bumped PIT to 1.14 to ensure the aforementioned changes there are properly supported.

Closes #337.

szpak commented 1 year ago

I've just uploaded 1.14.0-SNAPSHOT for people facing this problem in real projects to give it a try:

buildscript {
    repositories {
        mavenCentral()
        //Needed only for SNAPSHOT versions
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    }
    dependencies {
        classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.14.0-SNAPSHOT'
    }
}
szpak commented 1 year ago

Verified in the real project - https://github.com/szpak/gradle-pitest-plugin/issues/352#issuecomment-1734591601 (in addition to functional tests).