kotest-assertions-core / io.kotest.matchers.nulls / kotlin.Any / shouldBeNull

shouldBeNull

fun Any?.shouldBeNull(): Unit

Verifies that this value is null

Matcher to verify that a specific value contains a reference to null. Opposite of shouldNotBeNull

Example:

    val nullable: String? = null
    val nonNull: String? = "NonNull"

    nullable.shouldBeNull()    // Passes
    nonNull.shouldBeNull()     // Fails