diff --git a/src/main/java/org/junit/Test.java b/src/main/java/org/junit/Test.java index 0a9b7aa3e299..1db6fc7ab073 100644 --- a/src/main/java/org/junit/Test.java +++ b/src/main/java/org/junit/Test.java @@ -1,5 +1,7 @@ package org.junit; +import org.junit.function.ThrowingRunnable; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -37,8 +39,16 @@ * new ArrayList<Object>().get(1); * } * - * If the exception's message or one of its properties should be verified, the - * {@link org.junit.rules.ExpectedException ExpectedException} rule can be used. Further + * + * Using the parameter expected for exception testing comes with + * some limitations: only the exception's type can be checked and it is not + * possible to precisely specify the code that throws the exception. Therefore + * JUnit 4 has improved its support for exception testing with + * {@link Assert#assertThrows(Class, ThrowingRunnable)} and the + * {@link org.junit.rules.ExpectedException ExpectedException} rule. + * With assertThrows the code that throws the exception can be + * precisely specified. If the exception's message or one of its properties + * should be verified, the ExpectedException rule can be used. Further * information about exception testing can be found at the * JUnit Wiki. *