Spek: Fails to find tests with Kotlin version 1.1.4

Created on 15 Aug 2017  路  34Comments  路  Source: spekframework/spek

Spek is unable to find any of the tests when run with the newly released Kotlin 1.1.4 but works with 1.1.3-2. Spek version is 1.1.2, Gradle version is 4.1

When run with 1.1.3-2

Test run finished after 5478 ms
[        31 containers found      ]
[         0 containers skipped    ]
[        31 containers started    ]
[         0 containers aborted    ]
[        31 containers successful ]
[         0 containers failed     ]
[        20 tests found           ]
[         0 tests skipped         ]
[        20 tests started         ]
[         0 tests aborted         ]
[        20 tests successful      ]
[         0 tests failed          ]

When run with 1.1.4

Test run finished after 5049 ms
[         1 containers found      ]
[         0 containers skipped    ]
[         1 containers started    ]
[         0 containers aborted    ]
[         1 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]

Most helpful comment

It seems related to changes in Gradle 4.0, which JUnit 5 fixed in 1.0.0-M5. This didn't happen before because the kotlin plugin pre 1.1.4 was still using $buildDir/classes/main as an output directory.

As a workaround, in your buildscript or plugin block. Pull in Junit Platform 1.0.0-M5 then in the junitPlatform block set platformVersion to 1.0.0-M4.

buildscript {
    ...
    dependencies {
        classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0-M5"
    }
}

...


junitPlatform {
    platformVersion '1.0.0-M4'

    ...
}

All 34 comments

This is the repo using it: https://github.com/lispyclouds/bob

Can you please make sure all Kotlin dependencies use same version? Especially kotlin-reflect which Spek depends on.

Yes, I parameterized it as kotlin_version. All the deps are using this parameter.

Here is my build.gradle file: https://github.com/lispyclouds/bob/blob/master/build.gradle

I don't see kotlin-reflect explicitly specified there though.

Maybe it's pulled by kotlin-test, but I'm not sure, please check that with gradlew :module-name:dependencies and specify if it doesn't match common Kotlin version.

Yes, kotlin-reflect is still at 1.1.3-2
Should an explicit dependency be added?

Yes, please try that and report back :)

Added
testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
kotlin_version being 1.1.4
Still no luck. gradle does show that the version for reflect has changed.

I am also seeing this exact issue.

@lispyclouds I cloned the repo and did the following changes:

diff --git a/build.gradle b/build.gradle
index fb335d1..ea58f0f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,7 +24,7 @@ version "0.1.0"

 buildscript {
     ext {
-        kotlin_version = "1.1.3-2"
+        kotlin_version = "1.1.4"
         ktor_version = "0.3.3"
         spek_version = "1.1.2"
     }

Running ./gradlew test yields:

$ ./gradlew test
Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.1.4/kotlin-compiler-embeddable-1.1.4.jar

> Configure project :
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0

Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.1.4/kotlin-stdlib-jre8-1.1.4.pom
Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.4/kotlin-stdlib-jre7-1.1.4.pom
Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.4/kotlin-stdlib-jre7-1.1.4.jar
Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.1.4/kotlin-stdlib-jre8-1.1.4.jar

> Task :compileKotlin
Using kotlin incremental compilation

Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-test-junit/1.1.4/kotlin-test-junit-1.1.4.pom
Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-test/1.1.4/kotlin-test-1.1.4.pom
Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-test-junit/1.1.4/kotlin-test-junit-1.1.4.jar
Download https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-test/1.1.4/kotlin-test-1.1.4.jar

> Task :compileTestKotlin
Using kotlin incremental compilation

> Task :junitPlatformTest

Test run finished after 1177 ms
[        31 containers found      ]
[         0 containers skipped    ]
[        31 containers started    ]
[         0 containers aborted    ]
[        31 containers successful ]
[         0 containers failed     ]
[        20 tests found           ]
[         0 tests skipped         ]
[        20 tests started         ]
[         0 tests aborted         ]
[        20 tests successful      ]
[         0 tests failed          ]



BUILD SUCCESSFUL in 5m 36s

./gradlew dependencies --configuration testCompile tells that a different version of kotlin-reflect is being pulled

> Configure project :
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0

> Task :dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

testCompile - Dependencies for source set 'test' (deprecated, use 'testImplementation ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.4
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 (*)
+--- org.jetbrains.ktor:ktor-netty:0.3.3
|    +--- org.jetbrains.ktor:ktor-hosts-common:0.3.3
|    |    +--- org.jetbrains.ktor:ktor-core:0.3.3
|    |    |    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5
|    |    |    |    \--- org.jetbrains:annotations:13.0
|    |    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.3-2
|    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2 -> 1.1.4 (*)
|    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16
|    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2 -> 1.1.4 (*)
|    |    |    +--- org.slf4j:slf4j-api:1.7.25
|    |    |    \--- com.typesafe:config:1.3.1
|    |    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5 (*)
|    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.3-2 (*)
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16 (*)
|    |    +--- org.slf4j:slf4j-api:1.7.25
|    |    \--- com.typesafe:config:1.3.1
|    +--- io.netty:netty-codec-http2:4.1.9.Final
|    |    +--- io.netty:netty-codec-http:4.1.9.Final
|    |    |    \--- io.netty:netty-codec:4.1.9.Final
|    |    |         \--- io.netty:netty-transport:4.1.9.Final
|    |    |              +--- io.netty:netty-buffer:4.1.9.Final
|    |    |              |    \--- io.netty:netty-common:4.1.9.Final
|    |    |              \--- io.netty:netty-resolver:4.1.9.Final
|    |    |                   \--- io.netty:netty-common:4.1.9.Final
|    |    \--- io.netty:netty-handler:4.1.9.Final
|    |         +--- io.netty:netty-buffer:4.1.9.Final (*)
|    |         +--- io.netty:netty-transport:4.1.9.Final (*)
|    |         \--- io.netty:netty-codec:4.1.9.Final (*)
|    +--- org.eclipse.jetty.alpn:alpn-api:1.1.3.v20160715
|    +--- org.jetbrains.ktor:ktor-core:0.3.3 (*)
|    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5 (*)
|    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.3-2 (*)
|    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16 (*)
|    +--- org.slf4j:slf4j-api:1.7.25
|    \--- com.typesafe:config:1.3.1
+--- org.jetbrains.kotlinx:kotlinx-collections-immutable:0.1
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.4 (*)
+--- com.google.code.gson:gson:2.8.1
+--- ch.qos.logback:logback-classic:1.2.3
|    +--- ch.qos.logback:logback-core:1.2.3
|    \--- org.slf4j:slf4j-api:1.7.25
+--- org.jetbrains.exposed:exposed:0.8.5
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.3-2 (*)
|    +--- joda-time:joda-time:2.9.9
|    \--- org.slf4j:slf4j-api:1.7.25
+--- com.h2database:h2:1.4.196
+--- org.jetbrains.kotlin:kotlin-test:1.1.4
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 (*)
+--- org.jetbrains.kotlin:kotlin-test-junit:1.1.4
|    +--- org.jetbrains.kotlin:kotlin-test:1.1.4 (*)
|    \--- junit:junit:4.12
|         \--- org.hamcrest:hamcrest-core:1.3
+--- org.jetbrains.ktor:ktor-test-host:0.3.3
|    +--- org.jetbrains.ktor:ktor-hosts-common:0.3.3 (*)
|    +--- junit:junit:4.12 (*)
|    +--- org.jetbrains.kotlin:kotlin-test-junit:1.1.2-5 -> 1.1.4 (*)
|    +--- ch.qos.logback:logback-classic:1.2.1 -> 1.2.3 (*)
|    +--- org.jetbrains.ktor:ktor-core:0.3.3 (*)
|    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5 (*)
|    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.3-2 (*)
|    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16 (*)
|    +--- org.slf4j:slf4j-api:1.7.25
|    \--- com.typesafe:config:1.3.1
\--- org.jetbrains.spek:spek-api:1.1.2
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.6 -> 1.1.4 (*)
     \--- org.jetbrains.kotlin:kotlin-reflect:1.0.6 -> 1.1.3-2 (*)

(*) - dependencies omitted (listed previously)

To fix it I did the following changes:

diff --git a/build.gradle b/build.gradle
index fb335d1..7e3c0cf 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,7 +24,7 @@ version "0.1.0"

 buildscript {
     ext {
-        kotlin_version = "1.1.3-2"
+        kotlin_version = "1.1.4"
         ktor_version = "0.3.3"
         spek_version = "1.1.2"
     }
@@ -68,6 +68,8 @@ dependencies {

     compile "com.h2database:h2:1.4.196"

+    testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
+
     testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
     testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

Which now pulls the correct version of kotlin-reflect.

> Configure project :
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0

> Task :dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

testCompile - Dependencies for source set 'test' (deprecated, use 'testImplementation ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.4
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 (*)
+--- org.jetbrains.ktor:ktor-netty:0.3.3
|    +--- org.jetbrains.ktor:ktor-hosts-common:0.3.3
|    |    +--- org.jetbrains.ktor:ktor-core:0.3.3
|    |    |    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5
|    |    |    |    \--- org.jetbrains:annotations:13.0
|    |    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.4
|    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 (*)
|    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16
|    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2 -> 1.1.4 (*)
|    |    |    +--- org.slf4j:slf4j-api:1.7.25
|    |    |    \--- com.typesafe:config:1.3.1
|    |    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5 (*)
|    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.4 (*)
|    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16 (*)
|    |    +--- org.slf4j:slf4j-api:1.7.25
|    |    \--- com.typesafe:config:1.3.1
|    +--- io.netty:netty-codec-http2:4.1.9.Final
|    |    +--- io.netty:netty-codec-http:4.1.9.Final
|    |    |    \--- io.netty:netty-codec:4.1.9.Final
|    |    |         \--- io.netty:netty-transport:4.1.9.Final
|    |    |              +--- io.netty:netty-buffer:4.1.9.Final
|    |    |              |    \--- io.netty:netty-common:4.1.9.Final
|    |    |              \--- io.netty:netty-resolver:4.1.9.Final
|    |    |                   \--- io.netty:netty-common:4.1.9.Final
|    |    \--- io.netty:netty-handler:4.1.9.Final
|    |         +--- io.netty:netty-buffer:4.1.9.Final (*)
|    |         +--- io.netty:netty-transport:4.1.9.Final (*)
|    |         \--- io.netty:netty-codec:4.1.9.Final (*)
|    +--- org.eclipse.jetty.alpn:alpn-api:1.1.3.v20160715
|    +--- org.jetbrains.ktor:ktor-core:0.3.3 (*)
|    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5 (*)
|    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16 (*)
|    +--- org.slf4j:slf4j-api:1.7.25
|    \--- com.typesafe:config:1.3.1
+--- org.jetbrains.kotlinx:kotlinx-collections-immutable:0.1
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.4 (*)
+--- com.google.code.gson:gson:2.8.1
+--- ch.qos.logback:logback-classic:1.2.3
|    +--- ch.qos.logback:logback-core:1.2.3
|    \--- org.slf4j:slf4j-api:1.7.25
+--- org.jetbrains.exposed:exposed:0.8.5
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.3-2 -> 1.1.4 (*)
|    +--- joda-time:joda-time:2.9.9
|    \--- org.slf4j:slf4j-api:1.7.25
+--- com.h2database:h2:1.4.196
+--- org.jetbrains.kotlin:kotlin-reflect:1.1.4 (*)
+--- org.jetbrains.kotlin:kotlin-test:1.1.4
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 (*)
+--- org.jetbrains.kotlin:kotlin-test-junit:1.1.4
|    +--- org.jetbrains.kotlin:kotlin-test:1.1.4 (*)
|    \--- junit:junit:4.12
|         \--- org.hamcrest:hamcrest-core:1.3
+--- org.jetbrains.ktor:ktor-test-host:0.3.3
|    +--- org.jetbrains.ktor:ktor-hosts-common:0.3.3 (*)
|    +--- junit:junit:4.12 (*)
|    +--- org.jetbrains.kotlin:kotlin-test-junit:1.1.2-5 -> 1.1.4 (*)
|    +--- ch.qos.logback:logback-classic:1.2.1 -> 1.2.3 (*)
|    +--- org.jetbrains.ktor:ktor-core:0.3.3 (*)
|    +--- org.jetbrains.kotlin:kotlin-runtime:1.1.2-5 (*)
|    +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-5 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-5 -> 1.1.4 (*)
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16 (*)
|    +--- org.slf4j:slf4j-api:1.7.25
|    \--- com.typesafe:config:1.3.1
\--- org.jetbrains.spek:spek-api:1.1.2
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.6 -> 1.1.4 (*)
     \--- org.jetbrains.kotlin:kotlin-reflect:1.0.6 -> 1.1.4 (*)

(*) - dependencies omitted (listed previously)

@raniejade Can you have a look at https://github.com/libktx/ktx/tree/develop ? It has the same issue after updating to 1.1.4 and running ./gradlew clean ashley:test

The test-runtime classpath has the correct version of kotlin-reflect:
testRuntime - Runtime dependencies for source set 'test' (deprecated, use 'testRuntimeOnly ' instead). +--- com.badlogicgames.gdx:gdx:1.9.6 +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 | \--- org.jetbrains:annotations:13.0 +--- org.jetbrains.kotlin:kotlin-reflect:1.1.4 | \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4 (*) +--- com.badlogicgames.ashley:ashley:1.7.3 | \--- com.badlogicgames.gdx:gdx:1.9.4 -> 1.9.6 +--- junit:junit:4.12 | \--- org.hamcrest:hamcrest-core:1.3 +--- io.kotlintest:kotlintest:2.0.3 | +--- com.google.guava:guava:18.0 | +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2-3 -> 1.1.4 (*) | +--- org.reflections:reflections:0.9.10 | | +--- com.google.guava:guava:18.0 | | +--- org.javassist:javassist:3.18.2-GA | | \--- com.google.code.findbugs:annotations:2.0.1 | +--- com.sksamuel.koors:koors:0.90.0 | | +--- junit:junit:4.12 (*) | | +--- com.google.guava:guava:18.0 | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.0.1 -> 1.1.4 (*) | +--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-3 -> 1.1.4 (*) | \--- org.mockito:mockito-core:2.7.11 -> 2.8.9 | +--- net.bytebuddy:byte-buddy:1.6.14 | +--- net.bytebuddy:byte-buddy-agent:1.6.14 | \--- org.objenesis:objenesis:2.5 +--- com.nhaarman:mockito-kotlin-kt1.1:1.5.0 | +--- com.nhaarman:mockito-kotlin:1.5.0 | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.7 -> 1.1.4 (*) | | +--- org.jetbrains.kotlin:kotlin-reflect:1.0.7 -> 1.1.4 (*) | | \--- org.mockito:mockito-core:2.8.9 (*) | +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2-4 -> 1.1.4 (*) | \--- org.jetbrains.kotlin:kotlin-reflect:1.1.2-4 -> 1.1.4 (*) +--- org.jetbrains.spek:spek-api:1.1.2 | +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.6 -> 1.1.4 (*) | \--- org.jetbrains.kotlin:kotlin-reflect:1.0.6 -> 1.1.4 (*) +--- org.assertj:assertj-core:3.8.0 +--- org.junit.platform:junit-platform-launcher:1.0.0-M4 | \--- org.junit.platform:junit-platform-engine:1.0.0-M4 | +--- org.junit.platform:junit-platform-commons:1.0.0-M4 | \--- org.opentest4j:opentest4j:1.0.0-M2 \--- org.jetbrains.spek:spek-junit-platform-engine:1.1.2 +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.6 -> 1.1.4 (*) +--- org.jetbrains.kotlin:kotlin-reflect:1.0.6 -> 1.1.4 (*) \--- org.jetbrains.spek:spek-api:1.1.2 (*)

@raniejade Kotlin version is set through gradle.properties. This branch was updated to Kotlin 1.1.4, but it was not merged yet due to issues with Spek and Mockito.

Seems like it fails with gradle check only. gradle test seems to work ok.
Not sure why.

But subsequent runs of gradle clean test still fails.

It seems that in case of KTX Spek finds 0 tests with both check and test tasks. We do however get the following 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.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)

Should we modify JUnit platform version?

@czyzby I think so. It gives this error if
org.junit.platform:junit-platform-gradle-plugin is greater than 1.0.0-M4

This is what I am using in my gradle file as well.

Changing JUnit platform version to 1.0.0-M4 fixed the error, but the tests are still not detected.

It seems related to changes in Gradle 4.0, which JUnit 5 fixed in 1.0.0-M5. This didn't happen before because the kotlin plugin pre 1.1.4 was still using $buildDir/classes/main as an output directory.

As a workaround, in your buildscript or plugin block. Pull in Junit Platform 1.0.0-M5 then in the junitPlatform block set platformVersion to 1.0.0-M4.

buildscript {
    ...
    dependencies {
        classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0-M5"
    }
}

...


junitPlatform {
    platformVersion '1.0.0-M4'

    ...
}

I think after your changes it just goes back to this error:

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.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:79)
        at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:69)
        at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:41)

Could you try checking out this branch and changing the library versions in gradle.properties, so that Spek works with Kotlin 1.1.4 in ashley subproject?

@czyzby this works: (just comment out testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion")

diff --git a/ashley/build.gradle b/ashley/build.gradle
index 23da24e..1ed1c25 100644
--- a/ashley/build.gradle
+++ b/ashley/build.gradle
@@ -7,11 +7,12 @@ dependencies {
   testCompile "org.jetbrains.spek:spek-api:$spekVersion"
   testCompile "org.assertj:assertj-core:$assertjVersion"

-  testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"
+  // testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"
   testRuntime "org.jetbrains.spek:spek-junit-platform-engine:$spekVersion"
 }

 junitPlatform {
+  platformVersion '1.0.0-M4'
   filters {
     engines {
       include 'spek'
diff --git a/gradle.properties b/gradle.properties
index f474cda..04e1fd6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,6 @@
 libGroup=io.github.libktx
 gdxVersion=1.9.6
-kotlinVersion=1.1.3-2
+kotlinVersion=1.1.4
 kotlinCoroutinesVersion=0.17

 ashleyVersion=1.7.3

Ah, I see, I haven't noticed that we override the JUnit platform setting with the test dependency. Anyway, are you planning on moving to the latest JUnit platform version?

Yes, it was planned only for 2.x but given the circumstances it needs to be done in 1.x. Good thing there's already a PR for it #247, expect it sometime next week.

Thanks @raniejade

Your workaround:

buildscript {
    ...
    dependencies {
        classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0-M5"
    }
}

...


junitPlatform {
    platformVersion '1.0.0-M4'

    ...
}

works for me 馃槃
I tried it with org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC2 which is the latest one and works fine.

Waiting for #247 馃憤

Fixed by #247, v1.1.3 will be out early this week.

After upgrading to v1.1.3, test cases still unable to find? any idea?

image

Yes, doesn't work even with an explicit mention of version:

junitPlatform {
    platformVersion "1.0.0-RC2"
    ...
}

and platformVersion "1.0.0-M4" isn't working too as it was with 1.1.2

Raises this error when run with 1.0.0-M4:

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.engine.support.descriptor.AbstractTestDescriptor.<init>(Lorg/junit/platform/engine/UniqueId;Ljava/lang/String;Lorg/junit/platform/engine/TestSource;)V
        at org.jetbrains.spek.engine.Scope.<init>(Scope.kt:21)
        at org.jetbrains.spek.engine.Scope.<init>(Scope.kt:19)
        at org.jetbrains.spek.engine.Scope$Group.<init>(Scope.kt:63)
        at org.jetbrains.spek.engine.SpekTestEngine.resolveSpec(SpekTestEngine.kt:114)
        at org.jetbrains.spek.engine.SpekTestEngine.resolveSpecs(SpekTestEngine.kt:68)
        at org.jetbrains.spek.engine.SpekTestEngine.discover(SpekTestEngine.kt:50)
        at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:115)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:87)
        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:79)
        at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:69)
        at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:41)

Hmmm.. I'll look into it.

It's working on my project, I'll go checkout @lispyclouds's repo.

Fix is here #251. Verified it locally with https://github.com/lispyclouds/bob.

Will this be a new release? If yes, when do we expect it?

Yes, expect it this week. Just waiting for it to be code reviewed.

Works fine now! 馃槃

Good job, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabiocarballo picture fabiocarballo  路  3Comments

yaroslav-shlapak picture yaroslav-shlapak  路  4Comments

dnowak picture dnowak  路  7Comments

svenjacobs picture svenjacobs  路  6Comments

ruigoncalo picture ruigoncalo  路  7Comments