doc / ch.tutteli.atrium.api.infix.en_GB / message

message

val <T : Throwable> Expect<T>.message: Expect<String> (source)

Expects that the property Throwable.message of the subject of this expectation is not null, creates an Expect for it and returns it.

expect(RuntimeException("abc")).message toContain "a"
//                                 | subject is now of type String

fails {
    expect(RuntimeException("abc")).message toContain "d"
    //                                 | subject is now of type String
}

Return
The newly created Expect for the property Throwable.message of the subject of this expectation.

infix fun <T : Throwable> Expect<T>.message(assertionCreator: Expect<String>.() -> Unit): Expect<T> (source)

Expects that the property Throwable.message of the subject of this expectation is not null and holds all assertions the given assertionCreator creates for it and returns an Expect for the current subject of this expectation.

expect(RuntimeException("abc")) message { // subject inside this block is of type String (actually "abc")
    toContain("a")
}

fails {
    expect(RuntimeException("abc")) message { // subject inside this block is of type String (actually "abc")
        toContain("d")
    }
}

Return
an Expect for the subject of this expectation.