Skip to content

Commit c5050d1

Browse files
committed
convert to JUnit4 test
1 parent edbb2d1 commit c5050d1

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

‎hamcrest-core/src/test/java/org/hamcrest/core/IsAnythingTest.java‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,34 @@
22
*/
33
package org.hamcrest.core;
44

5-
import static org.hamcrest.MatcherAssert.assertThat;
5+
import static org.hamcrest.AbstractMatcherTest.assertDescription;
6+
import static org.hamcrest.AbstractMatcherTest.assertMatches;
67
import static org.hamcrest.core.IsAnything.anything;
78

8-
import org.hamcrest.AbstractMatcherTest;
99
import org.hamcrest.Matcher;
10+
import org.junit.Test;
1011

11-
public class IsAnythingTest extends AbstractMatcherTest {
12+
public final class IsAnythingTest {
1213

13-
@Override
14-
protected Matcher<?> createMatcher() {
15-
return anything();
16-
}
14+
private final Matcher<Object> matcher = anything();
1715

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");
2224
}
2325

24-
public void testHasUsefulDefaultDescription() {
25-
assertDescription("ANYTHING", anything());
26+
@Test public void
27+
hasUsefulDefaultDescription() {
28+
assertDescription("ANYTHING", matcher);
2629
}
2730

28-
public void testCanOverrideDescription() {
31+
@Test public void
32+
canOverrideDescription() {
2933
String description = "description";
3034
assertDescription(description, anything(description));
3135
}

0 commit comments

Comments
 (0)