Skip to content

Commit

Permalink
Deprecate Assert#assertThat
Browse files Browse the repository at this point in the history
The method "assertThat" is used for writing assertions with Hamcrest.
Hamcrest is an independent assertion library and contains an own
"assertThat" method in the class "org.hamcrest.MatcherAssert". It is
available both in the old Hamcrest 1.3 release and in the current
Hamcrest 2.1. Therefore the JUnit team recommends to use Hamcrest's own
"assertThat" directly.
  • Loading branch information
stefanbirkner committed Oct 13, 2019
1 parent 1ba4b2b commit 467c3f8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/junit/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,9 @@ public static void assertEquals(Object[] expecteds, Object[] actuals) {
* @param matcher an expression, built of {@link Matcher}s, specifying allowed
* values
* @see org.hamcrest.CoreMatchers
* @see org.hamcrest.MatcherAssert
* @deprecated use {@code org.hamcrest.MatcherAssert.assertThat()}
*/
@Deprecated
public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
assertThat("", actual, matcher);
}
Expand Down Expand Up @@ -955,8 +956,9 @@ public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
* @param matcher an expression, built of {@link Matcher}s, specifying allowed
* values
* @see org.hamcrest.CoreMatchers
* @see org.hamcrest.MatcherAssert
* @deprecated use {@code org.hamcrest.MatcherAssert.assertThat()}
*/
@Deprecated
public static <T> void assertThat(String reason, T actual,
Matcher<? super T> matcher) {
MatcherAssert.assertThat(reason, actual, matcher);
Expand Down

0 comments on commit 467c3f8

Please sign in to comment.