3

I'm getting a crash while spek is trying to find tests. I've tried many different versions and sample configs. I am running from the command line. Gradle 4.0, mac osx. Any help would be appreciated!

Here is the error:

WARNING: TestEngine with ID 'spek' failed to discover tests
java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.findAllClassesInClasspathRoot(Ljava/nio/file/Path;Ljava/util/function/Predicate;Ljava/util/function/Predicate;)Ljava/util/List;
        at org.jetbrains.spek.engine.SpekTestEngine.resolveSpecs(SpekTestEngine.kt:66)
        at org.jetbrains.spek.engine.SpekTestEngine.discover(SpekTestEngine.kt:50)
        at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130)
        at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
        at org.junit.platform.launcher.Launcher.execute(Launcher.java:96)
        at org.junit.platform.console.tasks.ConsoleTestExecutor.executeTests(ConsoleTestExecutor.java:65)
        at org.junit.platform.console.tasks.ConsoleTestExecutor.lambda$execute$0(ConsoleTestExecutor.java:57)
        at org.junit.platform.console.tasks.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:33)
        at org.junit.platform.console.tasks.ConsoleTestExecutor.execute(ConsoleTestExecutor.java:57)
        at org.junit.platform.console.ConsoleLauncher.executeTests(ConsoleLauncher.java:85)
        at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:75)
        at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:48)
        at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:40)

And here is my current build.gradle:

buildscript {

repositories {
    jcenter()
    maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
    classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M5'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$project.ext.kotlinVersion"
}
}

apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'idea'
apply plugin: 'kotlin'
apply plugin: 'java'

junitPlatform {
    filters {
        engines {
            include 'spek', 'junit-jupiter', 'junit-vintage'
        }
    }
}

dependencies {
    compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:$project.ext.kotlinVersion")


//    testCompile 'junit:junit:4.12'
    testCompile 'org.jetbrains.spek:spek-api:1.1.2'
    testRuntime 'org.jetbrains.spek:spek-junit-platform-engine:1.1.2'
    testCompile 'org.junit.platform:junit-platform-runner:1.0.0-M5'
    testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0-M5'
    testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
    testRuntime "org.junit.vintage:junit-vintage-engine:4.12.0-M5"
    testRuntime "org.junit.jupiter:junit-jupiter-engine:5.0.0-M5"
    testRuntime "org.junit.platform:junit-platform-console:1.0.0-M5"

    testCompile "com.google.code.gson:gson:$project.ext.gsonVersion"
}

repositories {
    mavenCentral()
}
Axifive
  • 1,159
  • 2
  • 19
  • 31
Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
  • With Gradle 4.0, the classes from different language compilers are placed in separate directories: https://docs.gradle.org/current/release-notes.html Seemingly, Spek expects the Kotlin classes to be located in the Java output directory, as with earlier versions. All the tools that use the classes directories should be updated to support this feature. Alternatively, try to use an earlier Gradle version. – hotkey Jul 10 '17 at 20:35
  • 2
    Try with junit platform version 1.0.0.M4 (as listed in the Spek docs http://spekframework.org/docs/latest/) - the new milestone versions of Junit platform sometimes introduce breaking API changes. – JK Ly Jul 10 '17 at 21:07
  • @JKLy . you nailed it. just had to follow the directions lol. Post that up as an answer and I will accepted. – Patrick Jackson Jul 11 '17 at 00:45

1 Answers1

7

With Spek 1.1.2 you have to use JUnit platform version 1.0.0-M4 as M5 has breaking API changes which makes them incompatible.

See this: https://github.com/JetBrains/spek/issues/225

JK Ly
  • 2,845
  • 2
  • 18
  • 13