diff --git a/src/main/java/org/junit/Assert.java b/src/main/java/org/junit/Assert.java index a2ca44edbf1c..8d11ece9b11a 100755 --- a/src/main/java/org/junit/Assert.java +++ b/src/main/java/org/junit/Assert.java @@ -967,22 +967,7 @@ public static void assertThat(String reason, T actual, } /** - * Asserts that {@code runnable} throws an exception of type {@code expectedThrowable} when - * executed. If it does not throw an exception, an {@link AssertionError} is thrown. If it - * throws the wrong type of exception, an {@code AssertionError} is thrown describing the - * mismatch; the exception that was actually thrown can be obtained by calling {@link - * AssertionError#getCause}. - * - * @param expectedThrowable the expected type of the exception - * @param runnable a function that is expected to throw an exception when executed - * @since 4.13 - */ - public static void assertThrows(Class expectedThrowable, ThrowingRunnable runnable) { - expectThrows(expectedThrowable, runnable); - } - - /** - * Asserts that {@code runnable} throws an exception of type {@code expectedThrowable} when + * Checks that {@code runnable} throws an exception of type {@code expectedThrowable} when * executed. If it does, the exception object is returned. If it does not throw an exception, an * {@link AssertionError} is thrown. If it throws the wrong type of exception, an {@code * AssertionError} is thrown describing the mismatch; the exception that was actually thrown can diff --git a/src/main/java/org/junit/function/ThrowingRunnable.java b/src/main/java/org/junit/function/ThrowingRunnable.java index 6e05d85c6580..2a1625d89e88 100644 --- a/src/main/java/org/junit/function/ThrowingRunnable.java +++ b/src/main/java/org/junit/function/ThrowingRunnable.java @@ -1,8 +1,8 @@ package org.junit.function; /** - * This interface facilitates the use of expectThrows from Java 8. It allows method references - * to void methods (that declare checked exceptions) to be passed directly into expectThrows + * This interface facilitates the use of {@code expectThrows} from Java 8. It allows method references + * to void methods (that declare checked exceptions) to be passed directly into {@code expectThrows}. * without wrapping. It is not meant to be implemented directly. * * @since 4.13 diff --git a/src/main/java/org/junit/rules/ErrorCollector.java b/src/main/java/org/junit/rules/ErrorCollector.java index 80a7c12712ef..2228de081dde 100644 --- a/src/main/java/org/junit/rules/ErrorCollector.java +++ b/src/main/java/org/junit/rules/ErrorCollector.java @@ -1,7 +1,7 @@ package org.junit.rules; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertThrows; +import static org.junit.Assert.expectThrows; import java.util.ArrayList; import java.util.List; @@ -117,7 +117,7 @@ public T checkSucceeds(Callable callable) { */ public void checkThrows(Class expectedThrowable, ThrowingRunnable runnable) { try { - assertThrows(expectedThrowable, runnable); + expectThrows(expectedThrowable, runnable); } catch (AssertionError e) { addError(e); } diff --git a/src/main/java/org/junit/rules/ExpectedException.java b/src/main/java/org/junit/rules/ExpectedException.java index 0f1cb82bd309..b20cbe097435 100644 --- a/src/main/java/org/junit/rules/ExpectedException.java +++ b/src/main/java/org/junit/rules/ExpectedException.java @@ -15,13 +15,10 @@ /** * The {@code ExpectedException} rule allows you to verify that your code * throws a specific exception. Note that, starting with Java 8, - * {@link org.junit.Assert#assertThrows(java.lang.Class, org.junit.function.ThrowingRunnable) - * Assert.assertThrows} + * {@link org.junit.Assert#expectThrows(java.lang.Class, org.junit.function.ThrowingRunnable) + * Assert.expectThrows} * is often a better choice since it allows you to express exactly where you - * expect the exception to be thrown. Use - * {@link org.junit.Assert#expectThrows(java.lang.Class, - * org.junit.function.ThrowingRunnable) expectThrows} - * if you need to assert something about the thrown exception. + * expect the exception to be thrown. * *

Usage

*