When upgrading from 6.1.7 to 6.1.9 I get: ```* Wha...
# kotest-contributors
c
When upgrading from 6.1.7 to 6.1.9 I get:
Copy code
* What went wrong:
Execution failed for task ':gradle:templates:template-app:jvmTest'.
> Test process encountered an unexpected problem.
   > Could not complete execution for Gradle Test Executor 2.
Copy code
Caused by: org.junit.platform.commons.JUnitException: TestEngine with ID 'kotest' failed to discover tests
        at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:208)
        at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:174)
        at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:119)
        at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:84)
        at app//org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:104)
        at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:91)
        at app//org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
        at app//org.junit.platform.launcher.core.InterceptingLauncher.lambda$execute$1(InterceptingLauncher.java:39)
        at app//org.junit.platform.launcher.core.ClasspathAlignmentCheckingLauncherInterceptor.intercept(ClasspathAlignmentCheckingLauncherInterceptor.java:25)
        at app//org.junit.platform.launcher.core.InterceptingLauncher.execute(InterceptingLauncher.java:38)
        at app//org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
        at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestDefinitionProcessor$CollectThenExecuteTestDefinitionConsumer.processAllTestClasses(JUnitPlatformTestDefinitionProcessor.java:172)
        at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestDefinitionProcessor$CollectThenExecuteTestDefinitionConsumer.access$000(JUnitPlatformTestDefinitionProcessor.java:121)
        at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestDefinitionProcessor.stop(JUnitPlatformTestDefinitionProcessor.java:114)
        at org.gradle.api.internal.tasks.testing.SuiteTestDefinitionProcessor.stop(SuiteTestDefinitionProcessor.java:64)
        ... 15 more
Caused by: java.lang.NoSuchMethodError: 'void io.kotest.core.LoggerKt.log(kotlin.jvm.functions.Function0)'
        at io.kotest.runner.junit.platform.discovery.Discovery.discover(Discovery.kt:34)
        at io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.discover(KotestJunitPlatformTestEngine.kt:109)
        at io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.discover(KotestJunitPlatformTestEngine.kt:29)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:195)
        ... 29 more
Repository: https://gitlab.com/opensavvy/playgrounds/gradle
✅ 1
s
Looks like a version mismatch. Something is still bringing in an earlier version
👀 1
c
Copy code
./gradlew :gradle:templates:template-app:dependencyInsight --dependency 'io.kotest:kotest-assertions-core' --configuration jvmTestRuntimeClasspath

io.kotest:kotest-assertions-core:6.1.9
\--- jvmTestRuntimeClasspath

io.kotest:kotest-assertions-core:6.1.4 -> 6.1.9
\--- io.kotest:kotest-runner-junit-platform-jvm:6.1.4
     \--- io.kotest:kotest-runner-junit-platform:6.1.4
          \--- io.kotest:kotest-runner-junit5-jvm:6.1.4
               \--- io.kotest:kotest-runner-junit5:6.1.4
                    \--- dev.opensavvy.prepared:runner-kotest-jvm:2.5.0
                         \--- dev.opensavvy.prepared:runner-kotest:2.5.0
                              \--- jvmTestRuntimeClasspath
and same output with
kotest-framework
Prepared is pulling the old version but Gradle correctly upgrades it so it shouldn't be a problem?
s
Copy code
Caused by: java.lang.NoSuchMethodError: 'void io.kotest.core.LoggerKt.log(kotlin.jvm.functions.Function0)'
this was added in 6.1.8, so somewhere in the stack its using a version that doesn't have it
c
🤔
Which module is that?
Copy code
Caused by: java.lang.NoSuchMethodError: 'void io.kotest.core.LoggerKt.log(kotlin.jvm.functions.Function0)'
        at io.kotest.runner.junit.platform.discovery.Discovery.discover(Discovery.kt:34)
        at io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.discover(KotestJunitPlatformTestEngine.kt:109)
kotest-framework I guess?
s
its in kotest-commons that's pulled in transitively
you bumped assertions to 6.1.9, what about junit runner ?
c
it's kotest-runner-junit5 that's out of date
It'd be nice if all modules could declare dependency constraints on each other so this doesn't happen
tbf I need to do that on my own libs as well
s
what do you mean?
each module has a dependency on the others it needs in gradle, is that not enough?
c
Here's the dependencies I had (simplified):
Copy code
jvmTestRuntimeClasspath - Runtime classpath of 'jvm/test'.
+--- dev.opensavvy.prepared:runner-kotest:2.5.0
|    \--- dev.opensavvy.prepared:runner-kotest-jvm:2.5.0
|         +--- io.kotest:kotest-runner-junit5:6.1.4
|         |    \--- io.kotest:kotest-runner-junit5-jvm:6.1.4
|         |         +--- io.kotest:kotest-common:6.1.4 -> 6.1.9
|         |         |    \--- io.kotest:kotest-common-jvm:6.1.9
|         |         +--- io.kotest:kotest-framework-engine:6.1.4 -> 6.1.9
|         |         |    \--- io.kotest:kotest-framework-engine-jvm:6.1.9
|         |         |         +--- io.kotest:kotest-common:6.1.9 (*)
|         |         +--- io.kotest:kotest-runner-junit-platform:6.1.4
|         |         |    \--- io.kotest:kotest-runner-junit-platform-jvm:6.1.4
|         |         |         +--- io.kotest:kotest-common:6.1.4 -> 6.1.9 (*)
|         |         |         +--- io.kotest:kotest-framework-engine:6.1.4 -> 6.1.9 (*)
|         |         +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 (*)
|         +--- io.kotest:kotest-framework-engine:6.1.4 -> 6.1.9 (*)
+--- io.kotest:kotest-framework-engine:6.1.9 (*)
+--- io.kotest:kotest-assertions-core:6.1.9 (*)
+--- org.jetbrains.kotlin:kotlin-test:2.3.10 (*)
\--- org.jetbrains.kotlin:kotlin-test:2.3.10 (*)
Prepared is pulling
io.kotest:kotest-runner-junit5-jvm:6.1.4
, but the module explicitly specifies
io.kotest:kotest-framework-engine:6.1.9
and
io.kotest:kotest-assertions-core:6.1.9
. Because of that, both get upgraded, but the module doesn't explicitly specify
kotest-runner-junit5
so that one is out of date.
I'm a bit confused because that should only cause issues if something is removed, not when something is added
s
for jvm you need to specify the runner5, for non-jvm, just engine + ksp is sufficient, and assertions of course if you use those
if you specify all 4, then the rest should all be set to 6.1.9 automatically
I think what you were suggesting, is why doesn't engine bring in junit runner, but that's because that's only required for JVM, and you might not want it at all, or you might want junit4 or junit5.
c
So you don't plan to support users that have an older
runner-junit5
and a newer
framework
? (not a critique, just making sure)
s
it wouldn't be supported no, but i don't know why that would be desired, all the
io.kotest
modules should be bumped in lockstep. I think we can add a spring style dependency plugin that does it all for you actually. What do you think ?
c
why doesn't engine bring in junit runner
No, dependencies and dependencies constraints are different. What I'm suggesting is that
kotest-framework:x.y
should declare a constraint that it is only compatible with
kotest-runner-junit5:x.y
. If the user has an older version of
kotest-runner-junit5
, Gradle will align it with the version of
kotest-framework
automatically
s
gotcha, I didn't know that exists
is that something we can do as the library authors?
c
i don't know why that would be desired, all the
io.kotest
modules should be bumped in lockstep.
It's not desired, it happened by accident here because I'm pulling Prepared which has a transitive dependency on all modules, but I only declare some of them explicitly in user modules. However in the same reason, users of any test framework other than Kotest that decide to use one Kotest module (e.g. kotest-property) would have the same issue and would need to explicitly specify all Kotest modules
It is, but I've never tried it on a Multiplatform project, so I have no idea if that works… KGP is weird… https://docs.gradle.org/current/userguide/dependency_constraints.html
s
if you're only using kotest-property for example, you wouldn't need engine/framework at all
I just read that page but it seems to be about consumiing libraries, rather than publishing them
c
In theory, you should have something like
Copy code
// kotest-framework/build.gradle.kts

kotlin {
    jvm()
    …

    sourceSets.commonMain.dependencies {
        constraints {
            api(projects.kotlinRunnerJunit5)
            // …and all other modules which don't support forward compatibility
        }
    }
}
but I think KGP doesn't expose the
constraints {}
block in multiplatform source sets 😕
(and also, this is something all library authors with multiple modules should probably do, but no one really does it)
I'll add that to my blog post TODO-list and I'll prototype something then
👍🏻 1
s
and back to your original issue, did bumping runner to 6.1.9 fix it ?
c
it's kind of the same idea as a BOM, but without needing an extra artifact
yes
s
cool