question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot run single test when using with Kotest 4.2.0.RC2

See original GitHub issue

When I run a single test (“first test” in my code example) withing a test class using the green Run test in the gutter, the test fails with “java.lang.NoClassDefFoundError: io/kotest/core/filters/TestCaseFilter” exception. Running all tests withing test class (using the double Run button in the gutter at the class declaration line) works fine.

Code example:

import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe

class TestMyClass : StringSpec({
    "first test" {
        2 * 2 shouldBe 4
    }
})

Stack trace:

Exception in thread "main" java.lang.NoClassDefFoundError: io/kotest/core/filters/TestCaseFilter
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at io.kotest.launcher.ExecuteTestsKt.executeTests(executeTests.kt:37)
	at io.kotest.launcher.Execute.run(launcher.kt:71)
	at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:168)
	at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:16)
	at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:258)
	at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:255)
	at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:273)
	at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:298)
	at io.kotest.launcher.LauncherKt.main(launcher.kt:14)
Caused by: java.lang.ClassNotFoundException: io.kotest.core.filters.TestCaseFilter
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 18 more

Environment:

  • Plugin version: 1.1.9-IC-2020.1
  • IntelliJ IDEA 2020.2 Ultimate Edition
  • Kotest 4.2.0.RC2
  • OpenJDK 14.0.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Ultraniumcommented, Aug 20, 2020

Kotest 4.2.0 final has been released so upgrade to that. And there is a kotest plugin update pending approval at jetbrains which will fix this issue, so once that gets released (today hopefully), you should be all set.

Today I got the plugin update (not it’s v. 1.1.11-IC-2020.1), switched to the final version 4.2.0 Things got even worse - now I can’t run even all tests in the class using the gutter button - I get this error message:

Error: Unable to initialize main class io.kotest.launcher.LauncherKt
Caused by: java.lang.NoClassDefFoundError: io/kotest/core/engine/TestEngineListener

After reverting the Kotest version back to 4.2.0.RC2 with the latest plugin, it works as before - running all tests cases withing a class works, running a single test does not.

I created a repo with a minimal project to demonstrate this behavior - https://github.com/Ultranium/kotest-idea-plugin-bug It contains only a single test class in the file src/test/kotlin/TestMyClass.kt.

1reaction
rkim-branchcommented, Sep 25, 2020

I am having similar variation of problem.

Exception in thread "main" java.lang.NoSuchMethodError: com.github.ajalt.clikt.parameters.options.OptionWithValuesKt.option$default(Lcom/github/ajalt/clikt/core/ParameterHolder;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;Lkotlin/text/Regex;Ljava/util/Map;Lcom/github/ajalt/clikt/completion/CompletionCandidates;ILjava/lang/Object;)Lcom/github/ajalt/clikt/parameters/options/OptionWithValues;
	at io.kotest.engine.launcher.Execute.<init>(main.kt:34)
	at io.kotest.engine.launcher.MainKt.main(main.kt:24)

It used to work fine, until I have upgrade clikt to 3.x from 2.x. As kotest-framework depends on clikt@2.x, IntelliJ plugin was not able to find matching bytecode symbol from 3.x jar.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pulling Kotest 4.2.0-RC2 from Central complains ... - GitHub
I confirm the issue is gone. Contextually, I want to amend my previous post, in fact there is a way in Gradle to...
Read more >
Hi we ve noticed that when we run a single junit test or sin | Kotest ...
(Kotest version 4.1.3 and 4.2.0.RC2). https://linen-assets.s3.amazonaws.com/attachments/. if I run the kotest file, this doesn't trigger the junit tests.
Read more >
Cannot run single test when using with Kotest 4.2.0.RC2 - Codesti
When I run a single test ("first test" in my code example) withing a test class using the green Run test in the...
Read more >
WooCommerce - Version 6.6.0
Analyze changes between open-source plugin releases.
Read more >
Best-of-breed OpenTracing utilities, instrumentations and ...
My Intention is to have multiple Traces of the same name running at the same time. Basically I get a call through HTTP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found