|
2 | 2 | */ |
3 | 3 | package org.hamcrest.core; |
4 | 4 |
|
5 | | -import static org.hamcrest.MatcherAssert.assertThat; |
| 5 | +import static org.hamcrest.AbstractMatcherTest.assertDescription; |
| 6 | +import static org.hamcrest.AbstractMatcherTest.assertMatches; |
6 | 7 | import static org.hamcrest.core.IsAnything.anything; |
7 | 8 |
|
8 | | -import org.hamcrest.AbstractMatcherTest; |
9 | 9 | import org.hamcrest.Matcher; |
| 10 | +import org.junit.Test; |
10 | 11 |
|
11 | | -public class IsAnythingTest extends AbstractMatcherTest { |
| 12 | +public final class IsAnythingTest { |
12 | 13 |
|
13 | | - @Override |
14 | | - protected Matcher<?> createMatcher() { |
15 | | - return anything(); |
16 | | - } |
| 14 | + private final Matcher<Object> matcher = anything(); |
17 | 15 |
|
18 | | - public void testAlwaysEvaluatesToTrue() { |
19 | | - assertThat(null, anything()); |
20 | | - assertThat(new Object(), anything()); |
21 | | - assertThat("hi", anything()); |
| 16 | + private static class CustomThing { } |
| 17 | + |
| 18 | + @Test public void |
| 19 | + alwaysEvaluatesToTrue() { |
| 20 | + assertMatches("didn't match null", matcher, null); |
| 21 | + assertMatches("didn't match Object", matcher, new Object()); |
| 22 | + assertMatches("didn't match custom object", matcher, new CustomThing()); |
| 23 | + assertMatches("didn't match String", matcher, "hi"); |
22 | 24 | } |
23 | 25 |
|
24 | | - public void testHasUsefulDefaultDescription() { |
25 | | - assertDescription("ANYTHING", anything()); |
| 26 | + @Test public void |
| 27 | + hasUsefulDefaultDescription() { |
| 28 | + assertDescription("ANYTHING", matcher); |
26 | 29 | } |
27 | 30 |
|
28 | | - public void testCanOverrideDescription() { |
| 31 | + @Test public void |
| 32 | + canOverrideDescription() { |
29 | 33 | String description = "description"; |
30 | 34 | assertDescription(description, anything(description)); |
31 | 35 | } |
|
0 commit comments