Skip to content

Commit 84dcb64

Browse files
committed
Add reference to ExpectedException. Fixes #806.
The ExpectedException can be used for better exception testing. The reference should guide the reader to its documentation.
1 parent e792dc4 commit 84dcb64

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/junit/Test.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
* &#064;Test(<b>expected=IndexOutOfBoundsException.class</b>) public void outOfBounds() {
3232
* new ArrayList&lt;Object&gt;().get(1);
3333
* }
34-
* </pre></p>
34+
* </pre>
35+
* If the exception's message or one of its properties should be verified, the
36+
* {@link org.junit.rules.ExpectedException ExpectedException} rule can be used. Further
37+
* information about exception testing can be found at the
38+
* <a href="https://github.com/junit-team/junit/wiki/Exception-testing">JUnit Wiki</a>.
3539
* <p>
3640
* The second optional parameter, <code>timeout</code>, causes a test to fail if it takes
3741
* longer than a specified amount of clock time (measured in milliseconds). The following test fails:
@@ -73,7 +77,9 @@ private None() {
7377

7478
/**
7579
* Optionally specify <code>expected</code>, a Throwable, to cause a test method to succeed if
76-
* and only if an exception of the specified class is thrown by the method.
80+
* and only if an exception of the specified class is thrown by the method. If the Throwable's
81+
* message or one of its properties should be verified, the
82+
* {@link org.junit.rules.ExpectedException ExpectedException} rule can be used instead.
7783
*/
7884
Class<? extends Throwable> expected() default None.class;
7985

0 commit comments

Comments
 (0)