messageToContain

Expects that the property Throwable.message of the subject of this expectation is not null and contains expected's toString representation using a non-disjoint search.

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(RuntimeException("abc")) messageToContain "b"

fails {
    expect(RuntimeException("abc")) messageToContain "d"
}

infix fun <T : Throwable> Expect<T>.messageToContain(values: Values<Any>): Expect<T>(source)

Expects that the property Throwable.message of the subject of this expectation is not null and contains values's toString representation using a non-disjoint search.

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed (this function expects Any for your convenience, so that you can mix String and Int for instance).

Return

an Expect for the subject of this expectation.

Since

0.17.0

Parameters

values

The values which are expected to be contained within Throwable.message -- use the function values(t, ...) to create a Values.

Samples

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
}