Skip to content

Unable to run individual tests KMP tests #245

@kirillzh

Description

@kirillzh

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'.
Screenshot 2023-07-28 at 4 10 07 PM

Activity

Kantis

Kantis commented on Mar 6, 2023

@Kantis
Member

Can you provide a repro for this? It looks like a gradle error to me. The Kotest plugin never explicitly calls the compileJava task

kirillzh

kirillzh commented on Mar 11, 2023

@kirillzh
Author

@Kantis, I see this happening when trying to run/debug individual tests from IDE. Seems to work fine with the whole test suite though:
Screenshot 2023-03-10 at 6 04 51 PM

kirillzh

kirillzh commented on Apr 19, 2023

@kirillzh
Author

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:
Screenshot 2023-04-18 at 10 25 12 PM

stale

stale commented on Jun 18, 2023

@stale

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.

changed the title [-]Trying to debug jvm test throws `Task 'compileJava' not found in project`[/-] [+]Unable to run individual tests[/+] on Jul 28, 2023
changed the title [-]Unable to run individual tests[/-] [+]Unable to run individual tests KMP tests[/+] on Jul 28, 2023
kirillzh

kirillzh commented on Jul 28, 2023

@kirillzh
Author

@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?

Nek-12

Nek-12 commented on Aug 17, 2023

@Nek-12

I have the same problem. This should be reopened @kirillzh

kirillzh

kirillzh commented on Sep 28, 2023

@kirillzh
Author

@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!

kirillzh

kirillzh commented on Sep 28, 2023

@kirillzh
Author

The plugin does seem to generate the right configuration:

Screenshot 2023-09-28 at 7 48 47 PM

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'.
OSemenovBoyarka

OSemenovBoyarka commented on Nov 21, 2023

@OSemenovBoyarka

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.

TadeasKriz

TadeasKriz commented on Dec 8, 2023

@TadeasKriz

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!

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @TadeasKriz@Kantis@sksamuel@mvarnagiris@kirillzh

        Issue actions

          Unable to run individual tests KMP tests · Issue #245 · kotest/kotest-intellij-plugin