https://kotlinlang.org logo
Title
c

christophsturm

10/14/2020, 2:27 PM
does kotest support mapping like strikt?
val subject = Pantheon.NORSE
expectThat(subject)
  .get(Pantheon::ruler) // reference to a property
  .get { toString() }   // return type of a method call
  .isEqualTo("Odin")
s

sam

10/14/2020, 2:32 PM
subject.ruler shouldBe "Odin"
That would be the equivalent for testing a single property
m

MiSikora

10/14/2020, 2:52 PM
Will it convert
ruler
to a String or is
toString()
missing? Seems kind of spooky if it converts
s

sam

10/14/2020, 3:19 PM
I assumed panthon.ruler was a string, so if it's not, then
subject.ruler.toString() shouldBe "Odin"
👍 1
c

christophsturm

10/14/2020, 7:48 PM
The difference is in the failure message.
With the strikt syntax you get something like expected pantheon.Norse to have ruler Odin.
I Guess I can just use strikt with kotest
s

sam

10/14/2020, 8:11 PM
Yeah I see what you mean. The word "ruler" won't be present in the kotest error.
I think the closest right now would be
withClue("greek ruler") {
   Pantheon.Greek.ruler() shouldBe "Zeus"
}
Then your error would be something like
greek ruler
Expected :"Odin"
Actual   :"Zeus"
Or as you say, you don't have to use kotest assertions (or you can use them and strickt)
c

christophsturm

10/15/2020, 9:58 AM
I’m right now using strikt and minutest, but I’m looking at kotest for the multiplatform support, and because its not junit dependent
s

sam

10/15/2020, 10:35 AM
Right. The JVM support is currently on top of JUnit5, unless you use the experimental gradle plugin, then you can ditch junit completely. The kotest intellij plugin is junit free. Hopefully in 4.4 / 4.5 we can make the JUnit support 2nd class in favour of our native gradle support (the output is much better). The JS support uses the mocha/karma runners (whichever one the JS plugin pulls down now).