1
votes

I have the following dependencies for my Kotlin Android project {

dependencies {
    ...
    testImplementation "org.junit.platform:junit-platform-engine:1.0.2"
    testImplementation "org.junit.platform:junit-platform-gradle-plugin:1.0.2"
    testImplementation "org.junit.platform:junit-platform-launcher:1.0.2"
    testImplementation "org.junit.platform:junit-platform-suite-api:1.0.2"
    testImplementation "org.junit.jupiter:junit-jupiter-api:5.0.2"
    testImplementation "org.junit.jupiter:junit-jupiter-engine:5.0.2"
    testImplementation "org.junit.jupiter:junit-jupiter-params:5.0.2"
}

The error I get when running my tests is:

org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-vintage' failed to discover tests
java.lang.NoClassDefFoundError: org/junit/runner/manipulation/Filter
...
Caused by: java.lang.ClassNotFoundException: org.junit.runner.manipulation.Filter
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.launcher.Launcher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;

If my test engine id is junit-vintage, then is it possible to change this? It seems like it's still using the junit 4 engine. How can I change this so it uses junit-jupiter? I removed junit-4.12 from my dependencies, so I wonder why it is using junit-vintage engine instead of junit-jupiter.

Currently using:

Android Studio 3.0
Build #AI-171.4408382, built on October 20, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

If I have to include the junit-vintage-engine, why do I need to if all my tests are written in JUnit5 style?

1
Did you happen to see the build support for Gradle in the docs?Naman
When I add the line apply plugin: 'org.junit.platform.gradle.plugin', I get the error Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.ShrimpCrackers

1 Answers

1
votes

If you're using Android with JUnit Jupiter (JUnit 5), you'll likely find it easier to configure your Gradle build using the android-junit5 plugin.