I use Kotest with FreeSpec. I really like it, but ...
# kotest
h
I use Kotest with FreeSpec. I really like it, but wverytime a test fails it is marked as 2 failures. What can I do to prevent this? I have a class:
Copy code
import io.kotest.core.spec.IsolationMode
import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.shouldBe

internal class Test : FreeSpec() {

  override fun isolationMode(): IsolationMode = IsolationMode.InstancePerTest

  init {
    beforeTest {
      print("beforeTest")
    }

    "fails" - {
      true shouldBe false
    }

    "passes" - {
      true shouldBe true
    }
  }
}
the result looks in intellij like screenshot 1 and in gradle I get the error “2 failed” with the tests visible in screenshot 2. How can I get rid of the
init
in intellij and the
Test.executionError
in gradle? Is it the Spec I am using or something wrong with kotest? I am using kotlin 1.3.72 and kotest 4.1.3
☑️ 1
p
I'm also seeing this execution error, would be interested if anyone knows how to fix this.
h
@phil-t good to hear I am not alone 🙂 Do you also use FreeSpec or a different Spec?
p
I'm using StringSpec but haven't tried any others.
h
ok, just wanted to clarify that it is not the specs fault 🙂
s
Don't use the minus symbol on the leaf tests
Only use the minus symbol for parent tests
It's due to a long standing bug in gradle
3 years and counting
h
@sam thanks, that was the problem 🙂
p
Did you find a way to stop this error from happening, or just not using gradle?
s
What's your stack trace phil
h
@sam just saw that not all the problems are fixed. the bug in intellij is gone, BUT the problem with gradle is still there, it seems to add another test, as I have 1 more test called
executionError
Do you know how to get ridof that?
p
Here's part of the stack trace from an Allure report. The stack trace is identical on the test which failed.
s
That just looks like a test failure?
h
Yes exactly, I have the same thing. BUT I would expect the test to fail once not twice: In screenshot one there is the ‘test’
executionError
In screenshot 2 there is the ‘test’
fails
. If you look closely you can see that it fails at exxactly the same point. All in all I would expect just the test
fails
to be there, not in addition the
executionError
🤔
s
The executionError is a weird gradle thing that we're trying to get rid of. It shouldn't happen if you're using the plugin only.
h
which plugin?
p
Yeah I think this is the gradle bug, I see exactly the same thing as you Ruth when gradle is used to run the tests, but not when using the kotest plugin.
h
I see you meant the intellij plugin. Yes then the error is not there also the init error is gone. So what can we do to prevent this additional ‘failed test’ to appear?