Spek: Spek doesn't work with JUnit platform 1.0.0-M5

Created on 11 Jul 2017  路  6Comments  路  Source: spekframework/spek

Recently (on July 4, 2017) JUnit 5 has released de Milestone 5, but Spek 1.1.2 doesn't work with it.

To reproduce it, use this Gradle build configuration (I think Maven has the same problem, see #224 that maybe is the same issue)

build.gradle

buildscript {
    ext {
        junitPlatformVersion = '1.0.0-M5'
        spekVersion = '1.1.2'
    }

    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "org.junit.platform:junit-platform-gradle-plugin:${junitPlatformVersion}"
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.1.3-2'
}

apply plugin: 'org.junit.platform.gradle.plugin'

junitPlatform {
    filters {
        engines {
            include 'spek'
        }
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8

    kotlinOptions {
        jvmTarget = '1.8'
    }
}

repositories {
    mavenCentral()
}

dependencies {
    // Kotlin
    compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8'
    compile 'org.jetbrains.kotlin:kotlin-reflect'

    testCompile 'org.jetbrains.kotlin:kotlin-test'
    testCompile 'org.jetbrains.kotlin:kotlin-test-junit'

    // Spek
    testCompile "org.jetbrains.spek:spek-api:${spekVersion}"
    testRuntime "org.jetbrains.spek:spek-junit-platform-engine:${spekVersion}"
}

If you build the project you get the error:

:testClasses UP-TO-DATE
Jul 11, 2017 10:01:05 AM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
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 no one Spek test was run.

If you change the value of the property junitPlatformVersion by '1.0.0-M4' all works fine.

Most helpful comment

The same issue is still true as of JUnit Platform 1.0.0-RC2, I think there's a good chance this issue will persist with the final version.

All 6 comments

I'm a bit hesitant to release a new version just to fix the issue with 1.0.0-M5. We don't get anything from using the new version since we only use it as a test runner.

I think that not worth the effort to release a new version just for this. Just take account it to fix it in the next normal release.

Anyway I see you have a branch to _Implement Spek JVM runtime (#222)_ and remove the JUnit 5 dependency. May be here is not the best site to talk about (I don't not where, please tell me if there is a better place, a list, forum, ... there are any guide to colaborate?) but, are you sure is a good idea?

I think you are sure because you are doing it, but I mean that JUnit 5 is a good engine, plugable and extensible, and is less code to maintain in Spek.

Now JUnit 5 is a little instable, but I think this situation should be temporal until they release the final version.

It's a POC and not final, we are going to do some internal discussions and eventually bring up our plans with the community.

The same issue is still true as of JUnit Platform 1.0.0-RC2, I think there's a good chance this issue will persist with the final version.

Anything new on that issue?
I have a following setup (which includes production dependencies) and it fails with the same error:

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta5'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.4-3"
        classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0"
    }
...
}
...

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4-3"

    testImplementation 'org.jetbrains.spek:spek-api:1.1.4'
    testImplementation 'org.jetbrains.spek:spek-junit-platform-engine:1.1.4'
    testImplementation 'org.junit.platform:junit-platform-runner:1.0.0'
    testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.0'

    testImplementation 'org.mockito:mockito-core:2.8.47'
    testImplementation 'com.nhaarman:mockito-kotlin-kt1.1:1.5.0'
   ...
}

This is already fixed. Please use Spek 1.1.4 and JUnit Platform 1.0.0-RC2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pilgr picture pilgr  路  3Comments

jcornaz picture jcornaz  路  4Comments

raosuj picture raosuj  路  3Comments

mtrewartha picture mtrewartha  路  5Comments

henrik242 picture henrik242  路  5Comments