kotest / kotest-intellij-plugin

The official Kotest plugin for Intellij and Android Studio
Apache License 2.0
179 stars 25 forks source link

IntelliJ Gradle Testing Support #96

Closed gchallen closed 4 years ago

gchallen commented 4 years ago

kotest version 4.2.3. Latest version of IntelliJ IDEA CE.

I just recently updated to kotest from kotlintest. In the past, IntelliJ was able to at least identify entire kotlintest StringSpec blocks as tests. You could then use f: focusing to pick out individual tests to run, even if (IIRC) IntelliJ couldn't identify individual tests within the spec.

Since the upgrade to kotest there is no option to run tests. I have tried the kotest plugin, but it doesn't seem to honor my settings to run tests with Gradle, which I'd like to continue doing so that I don't need to duplicate test configurations in two places.

Is this the expected behavior—or a bug with the kotest IntelliJ plugin, or something wonky about my environment? Unfortunately this represents a fairly serious regression for our use case, since our project has a large number of tests and the entire suite runs quite slowly.

sksamuel commented 4 years ago

Since the upgrade to kotest there is no option to run tests

Do you mean you don't see the individual green play icons for each test ?

gchallen commented 4 years ago

I don't see them for individual tests, no. But I don't remember if that ever worked. What I really miss is the green icon next to the suite, since individual tests could then be focused.

To try and be as specific as possible, in the past clicking the green play icon at the top of the test spec would create a temporary Gradle run configuration configured to run tests in that project and with something like arguments --tests "edu.illinois.cs.cs125.jeed.core.TestComplexity". (I still have a few of these lying around.)

sksamuel commented 4 years ago

Yes, it won't create a gradle configuration for you (that could be added since you need some gradle config applied?), but you should see a green icon for the spec (class) and every test (nested or otherwise). Then you don't even focus because you can just run the one you want directly.

This indicates to me the plugin is broken / not installed properly if you're not seeing any green icons.

On Tue, 8 Sep 2020 at 16:26, Geoffrey Challen notifications@github.com wrote:

I don't see them for individual tests, no. But I don't remember if that ever worked. What I really miss you is the green icon next to the suite, since individual tests could then be focused.

To try and be as specific as possible, in the past clicking the green play icon at the top of the test spec would create a temporary Gradle run configuration configured to run tests in that project and with something like arguments --tests "edu.illinois.cs.cs125.jeed.core.TestComplexity". (I still have a few of these lying around.)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest/issues/1708#issuecomment-689144948, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGVQYRQJTIPJENTWOFDSE2ORJANCNFSM4RAQWSFQ .

gchallen commented 4 years ago

Ah, sorry. I'm not using the plugin. When I installed it worked as you describe. But the tests aren't run using Gradle. That's a requirement for me, since a have test-specific configuration in the Gradle files and don't want to have to sync it with internal IntelliJ configuration.

gchallen commented 4 years ago

FWIW, I never used the plugin in the past. I tried it after upgrading to kotest to see if it would help, but again, it doesn't reproduce the prior behavior. That said, the plugin's behavior may not have changed, but rather the ability of IntelliJ to identify tests without the plugin installed.

sksamuel commented 4 years ago

Because of the existence of the plugin now, Kotest no longer has to piggy back on junit support in the IDE by pretending to be JUnit. I will see how quickly we can add the gradle run option that you're using from the junit plugin that ships with the IDE.

On Tue, 8 Sep 2020 at 16:40, Geoffrey Challen notifications@github.com wrote:

FWIW, I never used the plugin in the past. I tried it after upgrading to kotest to see if it would help, but again, it doesn't reproduce the prior behavior. That said, the plugin's behavior may not have changed, but rather the ability of IntelliJ to identify tests without the plugin installed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest/issues/1708#issuecomment-689150782, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGRPFG54F76ZQFVIXLLSE2QENANCNFSM4RAQWSFQ .

gchallen commented 4 years ago

Makes sense. Thanks! Alternatively, if Gradle support could be added to the plugin that would also be awesome. I have no objects to the plugin, it just doesn't do what I need it to do :-).

sksamuel commented 4 years ago

Yeah it would be in the plugin. It would show two options like it did previously (I assume you see the gradle icon and the junit icon)

On Tue, 8 Sep 2020 at 16:48, Geoffrey Challen notifications@github.com wrote:

Makes sense. Thanks! Alternatively, if Gradle support could be added to the plugin that would also be awesome. I have no objects to the plugin, it just doesn't do what I need it to do :-).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest/issues/1708#issuecomment-689154617, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGWQV6BZKRYLZ26A4ITSE2RCHANCNFSM4RAQWSFQ .

LeoColman commented 4 years ago

Perhaps moving this to https://github.com/kotest/kotest-intellij-plugin makes more sense?

sksamuel commented 4 years ago

Yep.

On Wed, 9 Sep 2020 at 13:38, Leonardo Colman notifications@github.com wrote:

Perhaps moving this to https://github.com/kotest/kotest-intellij-plugin makes more sense?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest/issues/1708#issuecomment-689743371, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGXD6E7CYBTFTUSNEXDSE7DQ5ANCNFSM4RAQWSFQ .

sksamuel commented 4 years ago

Gchallen I'm trying to get this to work but I can't get the gradle run icon to appear even for junit tests.

I think I've fixed the issue with kotest but can't confirm it.

sksamuel commented 4 years ago

Do you have a sample project I can use that gives me the gradle run icon on a test.

gchallen commented 4 years ago

Here's an example: https://github.com/gchallen/kotest-gradle-repo. Note that this is using kotlintest, not kotest. But this is the way that things used to work.

When I open this in IntelliJ here's what I see:

image

And, when I click on the run icon, it runs the test using Gradle:

image

Note that this is probably because I have some global setting that is configured to run tests with Gradle, rather than with IntelliJ.

I can confirm that this is still broken using the latest version of the kotest plugin, but perhaps you have not yet pushed this fix. Let me know how I can help. This is becoming a big usability problem at this point, after making a fairly large investment in porting kotlintest over to kotest...

sksamuel commented 4 years ago

Which version of intellij @gchallen

gchallen commented 4 years ago

Latest CE: 2020.2.

gchallen commented 4 years ago

Any update on this issue? Again, this causes severe usability issues with kotest. I can't be the only person experiencing this.

sksamuel commented 4 years ago

I think this is good now. I have the plugin able to detect the gradle/intellij settings.

image

It would be very useful if you could test this. Attached is a build for 2020.2. You would need to uninstall the version you have, and add this manually via the install from disk option in plugin settings.

kotest-plugin-intellij-1.1.0-SNAPSHOT-IC-2020.2.zip

sksamuel commented 4 years ago

How are you getting on with the new build @gchallen ?

gchallen commented 4 years ago

Thanks! Haven't tested yet... Will soon.

gchallen commented 4 years ago

Looks great! Thanks for fixing this.

sksamuel commented 4 years ago

Cool

On Wed, 28 Oct 2020 at 14:24, Geoffrey Challen notifications@github.com wrote:

Looks great! Thanks for fixing this.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-intellij-plugin/issues/96#issuecomment-718156612, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGTH2EN22PC2PIVSS5LSNBVXJANCNFSM4RJRGDLQ .

mriehl commented 3 years ago

What's the status on this? I'm using the kotest intellij plugin 1.1.24-IC-2020.3 and I cannot get idea to run the tests with gradle. The "run tests using" option is set to gradle, and I've tried deleting the test configurations, but no luck so far.

Edit: so running the entire spec class seems to work and uses gradle. It's running one of the nested tests that doesn't use gradle as expected (I am using FreeSpec). Is this a known limitation of the current implementation - that running an entire spec with gradle is possible, but running one of the nested tests is not?