kotest-assertions-core / io.kotest.matchers.types / kotlin.Any / shouldNotBeTypeOf

shouldNotBeTypeOf

fun <reified T : Any> Any?.shouldNotBeTypeOf(): Unit

Verifies that this is NOT exactly of type T

Verifies that this value is not of type T.

Opposite of shouldBeTypeOf

If you want to consider inheritance, use shouldNotBeInstanceOf

val list: List<Int> = arrayListOf(1, 2, 3)

list.shouldNotBeTypeOf<LinkedList<Int>>