[go: nahoru, domu]

Skip to content

Commit

Permalink
Add reference to ExpectedException. Fixes #806.
Browse files Browse the repository at this point in the history
The ExpectedException can be used for better exception testing. The
reference should guide the reader to its documentation.
  • Loading branch information
stefanbirkner committed Jan 30, 2014
1 parent e792dc4 commit 84dcb64
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/junit/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
* &#064;Test(<b>expected=IndexOutOfBoundsException.class</b>) public void outOfBounds() {
* new ArrayList&lt;Object&gt;().get(1);
* }
* </pre></p>
* </pre>
* 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
* information about exception testing can be found at the
* <a href="https://github.com/junit-team/junit/wiki/Exception-testing">JUnit Wiki</a>.
* <p>
* The second optional parameter, <code>timeout</code>, causes a test to fail if it takes
* longer than a specified amount of clock time (measured in milliseconds). The following test fails:
Expand Down Expand Up @@ -73,7 +77,9 @@ private None() {

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

Expand Down

0 comments on commit 84dcb64

Please sign in to comment.