kotest-assertions-core / io.kotest.matchers.nulls / beNull

beNull

fun beNull(): Matcher<Any?>

Matcher that verifies if a reference is null

Verifies that a given value contains a reference to null or not.

Example:

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

    nullable should beNull() // Passes
    nonNull should beNull()  // Fails

    nullable shouldNot beNull() // Fails
    nonNull shouldNot beNull()  // Passes

See Also

shouldBeNull

shouldNotBeNull