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

shouldNotBeInstanceOf

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

Verifies that this is NOT Instanceof T

Verifies that this value is not an instance of T.

Opposite of shouldBeInstanceOf

For an exact type, use shouldNotBeTypeOf

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

list.shouldNotBeInstanceOf<LinkedList<Int>>