kotest-intellij-plugin
kotest-intellij-plugin copied to clipboard
Unable to run individual tests KMP tests
When trying to run an individual KMP test in IJ/AS, getting this error:
Cannot locate tasks that match ':shared:money:impl:compileJava' as task 'compileJava' is ambiguous in project ':shared:money:impl'. Candidates are: 'compileDebugAndroidTestJavaWithJavac', 'compileDebugJavaWithJavac', 'compileDebugUnitTestJavaWithJavac', 'compileReleaseJavaWithJavac', 'compileReleaseUnitTestJavaWithJavac'.
Can you provide a repro for this? It looks like a gradle error to me. The Kotest plugin never explicitly calls the compileJava
task
@Kantis, I see this happening when trying to run/debug individual tests from IDE. Seems to work fine with the whole test suite though:
I see this in modules that don't have JVM target (eg Android or iOS), without debugger as well. The only way that I was able to make unit tests run from IDE is by right clicking on a spec file and running from there:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@Kantis, I update the title and description of the ticket. The real issue that I'm seeing is that we are not able to run individual tests from IDE (clicking green arrow next to a test
), whereas running the whole spec works (clicking green arrow next to a spec). Is there anything I can do to help debug this issue?
I have the same problem. This should be reopened @kirillzh
@Kantis, do you have any pointers for how this issue could be resolved? Happy to attempt fixing this in the plugin itself but not sure where to look. Would appreciate your help here, thanks!
The plugin does seem to generate the right configuration:
However when executing it for a KMP module it fails, here are the IDE logs:
2023-09-28 19:48:05,470 [2566302] INFO - #com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker - About to execute Gradle tasks: [:shared:money:impl:compileJava, :shared:money:impl:testClasses]
2023-09-28 19:48:05,472 [2566304] INFO - #o.j.p.g.GradleManager - Instructing gradle to use java from /Users/zhukov/Library/Java/JavaVirtualMachines/corretto-17.0.8.8.1.jdk/Contents/Home
2023-09-28 19:48:05,472 [2566304] INFO - #com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker - Build command line options: [--continue, -Pandroid.injected.invoked.from.ide=true, -Pandroid.studio.version=231.9392.1.2311.10809438, -Pandroid.injected.attribution.file.location=/Users/zhukov/Development/wallet/app/.gradle]
2023-09-28 19:48:05,473 [2566305] INFO - #o.j.p.g.s.e.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: --stacktrace --continue -Pandroid.injected.invoked.from.ide=true -Pandroid.studio.version=231.9392.1.2311.10809438 -Pandroid.injected.attribution.file.location=/Users/zhukov/Development/wallet/app/.gradle
2023-09-28 19:48:05,695 [2566527] INFO - #com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker - Gradle build failed in 222 ms
Gradle output error:
Cannot locate tasks that match ':shared:money:impl:compileJava' as task 'compileJava' is ambiguous in project ':shared:money:impl'. Candidates are: 'compileDebugAndroidTestJavaWithJavac', 'compileDebugJavaWithJavac', 'compileDebugUnitTestJavaWithJavac', 'compileReleaseJavaWithJavac', 'compileReleaseUnitTestJavaWithJavac'.
The same issue here, just creating blank KMP project with Android and iOS targets (no JVM). and adding Kotest following official docs reproduces this. If I add JVM target - plugin works well.
I've been debugging and prodding IntelliJ IDEA and the Android plugin's source code and found that there's actually a registry setting for IntelliJ IDEA. When you set the Registry...
setting called android.task.runner.restricted
to true (checking the box), it will make sure that Android task runner is only used for modules with the Android facet. Thanks to this it will correctly use the Gradle task runner and compile the underlying module correctly.
We still need to see if this can be enabled long-term and I'll be reaching out to JB to see if there's a reason not to use it and what's the plan for it. But being able to run Kotest from the gutter icons again is sweet!
Thank you for figuring this out!
On Thu, 7 Dec 2023 at 20:37, Tadeas Kriz @.***> wrote:
I've been debugging and prodding IntelliJ IDEA and the Android plugin's source code and found that there's actually a registry setting for IntelliJ IDEA. When you set the Registry... setting called android.task.runner.restricted to true (checking the box), it will make sure that Android task runner is only used for modules with the Android facet. Thanks to this it will correctly use the Gradle task runner and compile the underlying module correctly.
We still need to see if this can be enabled long-term and I'll be reaching out to JB to see if there's a reason not to use it and what's the plan for it. But being able to run Kotest from the gutter icons again is sweet!
— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-intellij-plugin/issues/245#issuecomment-1846464053, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGXMEVM2LBBVDTXY7O3YIJ4NNAVCNFSM6AAAAAAVARO3KCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBWGQ3DIMBVGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Any updates on this? I run into the same issue when running tests from IDE. Works fine when running via gradle. For us at the moment it would be quite painful to add jvm target to the modules as we do have a lot of modules.
@TadeasKriz, correct me if I'm wrong but this is blocked by https://youtrack.jetbrains.com/issue/KT-65131/Incorrect-compilation-name-for-custom-test-runs-KotlinJvmTest-tasks-in-KMP-modules, right?