Is there a better way to test the following in kot...
# kotest
j
Is there a better way to test the following in kotest:
Copy code
collection.find { it is SomeType }.shouldNotBeNull()
I was looking for something in the line of:
Copy code
collection.shouldContainOneOf<SomeType>()
e
Copy code
collection.forOne { it is SomeType }
j
Ah, nice.
Still a neat idea to be able to reify the type, e.g.:
Copy code
collection.shouldContainOneOf<SomeType>() {
    it.shouldBeTypeOf<SomeType>()
}
I guess doing this is the best way:
Copy code
collection.forOne {
    it.shouldBeTypeOf<SomeType>()
    it.someFieldInSomeType shouldBe somethingElse
}
it
will be type casted.
s
list.filterIsInstance<Foo>().shouldNotBeNull()