Hi, kotest newbie here. Is there a matcher to asse...
# kotest
j
Hi, kotest newbie here. Is there a matcher to assert if all elements in a collection equals to certain value?
I’m in general new to testing, and currently the setting for testing is using junit5 as test runner and using the assertions from kotest.
Copy code
// part of build.gradle.kts
testImplementation(kotlin("test-junit5"))
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")

// kotest    testImplementation("io.kotest:kotest-assertions-core-jvm:4.1.0.291-SNAPSHOT")
For my use case, I have a function which would return the same value, say
0
for some invalid input, and when I test invalid inputs, I didn’t want to write multiple duplicate lines of
… shouldBe 0
. So I started to wonder if there is a better way.
m
Hi, there are matchers for collections, they’re called “Inspectors”: https://github.com/kotest/kotest/wiki/Reference-Doc#inspectors
👍🏻 1
j
Thanks a lot, I had overlooked about this.
m
you’re welcome