https://kotlinlang.org logo
#kotest
Title
# kotest
i

Ioannis Mavroukakis

11/03/2023, 1:10 PM
Folks I have an IDE related question - is it possible to use Kotest and get all the IDE prompts (like run gutter markers etc) without using the plugin?
If that is not the case, what is the state of play with non IntelliJ IDEs?
l

LeoColman

11/03/2023, 1:11 PM
I don't think so. Gradle is only able to see the top level/class and execute it
You can run without the plugin, but not with all features
Testing-wise it will work exactly the same, as for example when running
./gradlew test
you'll run through gradle anyway
The only gutter icon you'll see without the plugin is "Run Test Class using Gradle"
i

Ioannis Mavroukakis

11/03/2023, 1:12 PM
but I won't be able to let's say, run an individual test method without it, correct?
i.e. IJ does not understand that this is a test class if the plugin is not included
which means that for people using VSCode or Eclipse this is a non-starter
l

LeoColman

11/03/2023, 1:15 PM
Correct. People using Eclipse will only be able to run the whole class inside the IDE
w

wasyl

11/03/2023, 1:16 PM
Perhaps you can try some tricks like adding
@Test
annotation on the test class and somehow making sure it's not picked up by regular JUnit runner
but I won't be able to let's say, run an individual test method without it, correct?
I find Kotest IJ plugin to be really wonky when running individual tests anyway, I pretty much never do that anymore, I just run whole classes instead
i

Ioannis Mavroukakis

11/03/2023, 1:22 PM
@LeoColman your suggestion about "Run Test Class using Gradle" does not seem to work when the plugin is not installed, am I missing something?
l

LeoColman

11/03/2023, 1:23 PM
Maybe. Which IDE are you using?
i

Ioannis Mavroukakis

11/03/2023, 1:23 PM
IJ
l

LeoColman

11/03/2023, 1:23 PM
In IntelliJ I know for sure the gutter icon appears
Let me check on mine
i

Ioannis Mavroukakis

11/03/2023, 1:24 PM
Nope, just checked on a project I had, unloaded the plugin and there is no gutter icon
I also have a colleague that hasn't installed the plugin and he cannot see any gutter icons at all
it's as if the class is not recognised as a test class from IJ
l

LeoColman

11/03/2023, 1:25 PM
Which version of IJ are you using?
i

Ioannis Mavroukakis

11/03/2023, 1:26 PM
2023.1 and 2023.2.4
l

LeoColman

11/03/2023, 1:27 PM
I'm failing to get the gutter icon as well
I expected it to be at line 28, near the number
i

Ioannis Mavroukakis

11/03/2023, 1:27 PM
sounds like a bug?
l

LeoColman

11/03/2023, 1:28 PM
Sounds to me, yes. But in IntelliJ, I think
@sam
"Old UI" also doesn't show the icon
image.png
i

Ioannis Mavroukakis

11/03/2023, 1:29 PM
yup I'm on the new UI, friend is on the old UI
l

LeoColman

11/03/2023, 1:32 PM
• Tests still run with
./gradlew test
• The correct test is still ran with
./gradlew :test --tests "<http://br.com|br.com>.colman.simplecpfvalidator.CpfValidatorTest"
Funnily, if you do this you can get the gutter icon:
image.png
The class won't compile, but IntelliJ will be able to generate the runnable
i

Ioannis Mavroukakis

11/03/2023, 1:33 PM
yes, we discovered that also
l

LeoColman

11/03/2023, 1:33 PM
image.png
i

Ioannis Mavroukakis

11/03/2023, 1:34 PM
(the annotation thing)
in fact, if you trick intellij with the annotation, the gutter icons stay for each method even if it is
@Test
from the kotest package
it's weird
l

LeoColman

11/03/2023, 1:36 PM
Dum-dum IntelliJ, mixing all the options. It indeed looks like a bug/regression to me. @sam is the plugin expert, he might know what's going on
i

Ioannis Mavroukakis

11/03/2023, 1:39 PM
No worries!if I may, got a totally naive question. AFAIK ,
Spock
works out of the box in IJ (meaning the chevrons)? I really like Kotest but am just a bit sceptical about having to buy into a plugin to get the features I normally have
l

LeoColman

11/03/2023, 1:47 PM
I understand. I usually don't run with the plugin, so this caught me offguard as well 😄
👍 1
e

Edoardo Luppi

11/03/2023, 2:10 PM
You need the plugin for test functions to be recognized as runnable and thus having the gutter runners.
i

Ioannis Mavroukakis

11/03/2023, 2:27 PM
yeah I can maybe live without that - but it seems there's an IJ bug where it won't even recognise a test class at all
e

Edoardo Luppi

11/03/2023, 2:28 PM
I mean why would it recognize a Kotest test class? That's a third party framework that doesn't work with kotlin.test annotations
i

Ioannis Mavroukakis

11/03/2023, 2:30 PM
why does it recognise a Spock one as a test without an additional plugin 🤷
e

Edoardo Luppi

11/03/2023, 2:37 PM
As far as I can see Spock is actually supported by Gradle internals.
i

Ioannis Mavroukakis

11/03/2023, 2:39 PM
interesting! where is that?
e

Edoardo Luppi

11/03/2023, 2:41 PM
I can see hardcoded testing frameworks in the Gradle sources. But it might simply be that IntelliJ is smart enough to infer them as Spock tests, unlike Kotest, which I don't think has a userbase comparable to the Spock one.
i

Ioannis Mavroukakis

11/03/2023, 2:44 PM
yup fair point - although it's able to run them as tests using junit jupiter so there's probably nothing much we can do on the IDE front?
l

LeoColman

11/03/2023, 2:51 PM
The classes had a JUnit annotation to trick IJ into seeing them. I'm not sure what changed since I last checked this
i

Ioannis Mavroukakis

11/03/2023, 2:56 PM
ooh ok!
A colleague is saying that this behaviour works in
4.6.3
s

sam

11/03/2023, 6:47 PM
Intellij has built in support for things like junit which is why you don't need the plugin. The kotest plugin just does what intellij itself does for junit etc. Intellij has a bunch of extension points that we plug into.
If the plug isn't working for you, then it might be because you upgrraded intellij, and sometimes the plugin doesn't get updated along with it - I would try removing the plugin, restarting IJ and reinstalling it.
l

LeoColman

11/03/2023, 6:48 PM
They don't want to use the plugin, the plug that is gone is the one to execute with gradle
i

Ioannis Mavroukakis

11/03/2023, 6:53 PM
^^^this 🙂
s

sam

11/03/2023, 6:54 PM
Without the kotest plugin, you won't get gutter icons for either the class or the tests.
You can run gradle check|test from the gradle window
But that will be across the suite
l

LeoColman

11/03/2023, 6:55 PM
When did the gutter icon for the class stop working?
s

sam

11/03/2023, 8:30 PM
Back in 4.x, we used a junit hack. I can't remember exactly what it was, but it was before the plugin existed.
@LeoColman not sure why it's not working for the class. It's working for me on the latest plugin and intellij 2023.2
i

Ioannis Mavroukakis

11/04/2023, 8:00 AM
@sam any chance this can be brought back into play? I imagine with that hack, VSCode, Eclipse AND IJ would work without the plugin
s

sam

11/04/2023, 5:17 PM
With the hack we can't have per test functionality, so it's the lesser of two evils.
i

Ioannis Mavroukakis

11/06/2023, 12:05 PM
cool, unfortunately that makes it a non starter for our use! Thanks for looking into it
s

sam

11/06/2023, 3:33 PM
no prob
3 Views