Exceptions, timeouts and assumptions

What a test says about a failure: assertThrows takes the exception type and hands the test the exception itself, so the message and the cause can be checked too, and assertDoesNotThrow states the other side. A time limit comes in two forms: assertTimeout runs the code on the test thread and reports the time it took, while assertTimeoutPreemptively interrupts it, and the report says which one was used. Assumptions follow: an assumeTrue that does not hold aborts the test, which the report counts apart from a failure. The part ends with the exception that never comes, the most common red test of them all, and the report line that names it.

021 assertThrows the exception type, the message, the cause Open 022 No exception and a time limit assertDoesNotThrow, assertTimeout Open 023 A test that is interrupted assertTimeoutPreemptively, the difference in the report Open 024 Assumptions assumeTrue aborts a test, the aborted count Open 025 The exception that never comes assertThrows fails, the report, the fix Open

Lessons