Skip to content

Commit d5f2a7f

Browse files
author
smgfreeman
committed
improved mismatch message for IsInstanceOf
1 parent 3288ef3 commit d5f2a7f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

hamcrest-core/src/main/java/org/hamcrest/core/IsInstanceOf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected boolean matches(Object item, Description mismatchDescription) {
3232
}
3333

3434
if (!theClass.isInstance(item)) {
35-
mismatchDescription.appendText("[" + item.getClass().getSimpleName() + "] ").appendValue(item);
35+
mismatchDescription.appendValue(item).appendText(" is a " + item.getClass().getName());
3636
return false;
3737
}
3838

hamcrest-unit-test/src/main/java/org/hamcrest/core/IsInstanceOfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void testHasAReadableDescription() {
2727
}
2828

2929
public void testDecribesActualClassInMismatchMessage() {
30-
assertMismatchDescription("[String] \"some text\"", instanceOf(Number.class), "some text");
30+
assertMismatchDescription("\"some text\" is a java.lang.String", instanceOf(Number.class), "some text");
3131
}
3232

3333
public void testInstanceOfRequiresACastToReturnTheCorrectTypeForUseInJMock() {

0 commit comments

Comments
 (0)