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.

Adding secondary module with Kotest as dependency to primary module leads to primary module JUnit4 tests not being run when running them from Android Studio folder

See original GitHub issue

Kotest version: 4.2.5

Given

  1. An Android project with the next modules structure: ±primary ±secondary
  2. The secondary module has Kotest configured like this (gradle.kts with correct kotest dependencies, here as constants):
android {
    tasks.withType<Test>().all {
        useJUnitPlatform()
    }
}
...
testImplementation(kotestJunit5Runner)
testImplementation(kotestAssertions)
testImplementation(kotestProperty)
testRuntimeOnly(junitVintage)
  1. the primary module has the secondary module added as a dependency like this (gradle.kts): implementation(project(secondary))
  2. the primary module has neither Kotest dependencies nor tests written using Kotest

When

running tests using Android Studio via right-click on a primary module package with tests -> select Run ‘Tests in ‘primary’’

Then

The tests are built but complete with error: No tests were found And the error message:

~~~ Kotest Configuration ~~~
-> Parallelization factor: 1
-> Default test timeout: 600000ms
-> Default test order: Sequential
-> Default isolation mode: SingleInstance
-> Global soft assertations: False
-> Write spec failure file: False
-> Fail on ignored tests: False
-> Spec execution order: SpecExecutionOrder
-> Extensions
  - io.kotest.engine.extensions.SystemPropertyTagExtension
  - io.kotest.core.extensions.RuntimeTagExtension
  - io.kotest.engine.extensions.RuntimeTagExpressionExtension


Process finished with exit code 0

Expected result

The tests should work without error, there shouldn’t be any mentions of Kotest in the primary module during running

Additional info

  1. The issues don’t depend on the state of Kotest IIntelliJ IDEA plugin (installed, not installed, installed but not enabled)
  2. If running tests using Gradle it works without issues
  3. Adding to the primary gradle.kts next configuration fixes the issue (given the plugin is unistalled) testRuntimeOnly(junitVintage)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sksamuelcommented, Feb 8, 2022

I don’t know why it’s not picking the deps up, but that’s the error. JUnit platform is saying it can’t find an engine implementation.

On Mon, 7 Feb 2022 at 15:03, Yaroslav Shlapak @.***> wrote:

The error in that stack is because it can’t find either jupiter or kotest.

So why does it happen when the tests are run for a module which doesn’t have any dependency neither from jupiter or kotest. This primary module does have a dependency on another module that has the dependency from jupiter or kotest, but I wouldn’t expect that this affect the primary module.

— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest/issues/1912#issuecomment-1031918632, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGVC5QZJAO5RCVNHIYDU2AXQ5ANCNFSM4U4II2WA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

1reaction
sksamuelcommented, Feb 7, 2022

The error in that stack is because it can’t find either jupiter or kotest.

On Sun, 6 Feb 2022 at 03:07, Yaroslav Shlapak @.***> wrote:

Still have an issue with no Junit4 tests being run in primary module (see the issue description). The only workaround is to add testRuntimeOnly “org.junit.vintage:junit-vintage-engine:5.7.2” to the primary module. Kotest version is “5.1.0”. Android gradle plugin version is “7.0.2”.

However, the error is different this time

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 13. at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy5.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:135) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.junit.platform.commons.PreconditionViolationException: Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:296) at org.junit.platform.launcher.core.DefaultLauncher.<init>(DefaultLauncher.java:48) at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:105) at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:75) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:97) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) … 25 more

— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest/issues/1912#issuecomment-1030781722, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGUYYIVGSMCG3VMWKA3UZY25PANCNFSM4U4II2WA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quick Start - Kotest
The Kotest test framework is supported on JVM, Javascript and Native. ... the tasks with type Test and then adding the Kotest junit5...
Read more >
Why is library module android.support.test not visible in add ...
I had the same issue and I found that the dependencies with the androidTestCompile are visible only by default in the debug build...
Read more >
Build local unit tests - Android Developers
A local test runs directly on your own workstation, rather than an Android device or emulator. As such, it uses your local Java...
Read more >
kotlintest - Bountysource
Adding secondary module with Kotest as dependency to primary module leads to primary module JUnit4 tests not being run when running them from...
Read more >
Best Practices for Unit Testing in Kotlin - Philipp Hauer's Blog
In JUnit4, a new instance of the test class is created for every test method. So the initial setup code (that is used...
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