Skip to content

Commit 4d66107

Browse files
committed
convert test to JUnit4
1 parent cce6e4b commit 4d66107

1 file changed

Lines changed: 38 additions & 24 deletions

File tree

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

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,47 @@
22
*/
33
package org.hamcrest.core;
44

5+
import static org.hamcrest.AbstractMatcherTest.assertDescription;
6+
import static org.hamcrest.AbstractMatcherTest.assertDoesNotMatch;
7+
import static org.hamcrest.AbstractMatcherTest.assertMatches;
8+
import static org.hamcrest.AbstractMatcherTest.assertNullSafe;
9+
import static org.hamcrest.AbstractMatcherTest.assertUnknownTypeSafe;
510
import static org.hamcrest.core.IsEqual.equalTo;
611
import static org.hamcrest.core.IsInstanceOf.instanceOf;
712
import static org.hamcrest.core.IsNot.not;
813

9-
import org.hamcrest.AbstractMatcherTest;
1014
import org.hamcrest.Matcher;
15+
import org.junit.Test;
1116

12-
public class IsNotTest extends AbstractMatcherTest {
13-
@Override
14-
protected Matcher<?> createMatcher() {
15-
return not("something");
16-
}
17-
18-
public void testEvaluatesToTheTheLogicalNegationOfAnotherMatcher() {
19-
assertMatches("should match", not(equalTo("A")), "B");
20-
assertDoesNotMatch("should not match", not(equalTo("B")), "B");
21-
}
22-
23-
public void testProvidesConvenientShortcutForNotEqualTo() {
24-
assertMatches("should match", not("A"), "B");
25-
assertMatches("should match", not("B"), "A");
26-
assertDoesNotMatch("should not match", not("A"), "A");
27-
assertDoesNotMatch("should not match", not("B"), "B");
28-
}
29-
30-
public void testUsesDescriptionOfNegatedMatcherWithPrefix() {
31-
assertDescription("not an instance of java.lang.String", not(instanceOf(String.class)));
32-
assertDescription("not \"A\"", not("A"));
33-
}
34-
}
17+
public final class IsNotTest {
18+
19+
@Test public void
20+
copesWithNullsAndUnknownTypes() {
21+
Matcher<String> matcher = not("something");
22+
23+
assertNullSafe(matcher);
24+
assertUnknownTypeSafe(matcher);
25+
}
26+
27+
@Test public void
28+
evaluatesToTheTheLogicalNegationOfAnotherMatcher() {
29+
final Matcher<String> matcher = not(equalTo("A"));
30+
31+
assertMatches("didn't match", matcher, "B");
32+
assertDoesNotMatch("matched unexpectedly", matcher, "A");
33+
}
34+
35+
@Test public void
36+
providesConvenientShortcutForNotEqualTo() {
37+
final Matcher<String> matcher = not("A");
38+
39+
assertMatches("didn't match", matcher, "B");
40+
assertDoesNotMatch("matched unexpectedly", matcher, "A");
41+
}
42+
43+
@Test public void
44+
usesDescriptionOfNegatedMatcherWithPrefix() {
45+
assertDescription("not an instance of java.lang.String", not(instanceOf(String.class)));
46+
assertDescription("not \"A\"", not("A"));
47+
}
48+
}

0 commit comments

Comments
 (0)