Skip to content

Commit 9ce2cfd

Browse files
committed
reinstated allOf mismatch description.
To make sure there’s enough diagnostic information in the failure.
1 parent 34dc394 commit 9ce2cfd

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public AllOf(Iterable<Matcher<? super T>> matchers) {
2222
public boolean matches(Object o, Description mismatch) {
2323
for (Matcher<? super T> matcher : matchers) {
2424
if (!matcher.matches(o)) {
25+
mismatch.appendDescriptionOf(matcher).appendText(" ");
2526
matcher.describeMismatch(o, mismatch);
2627
return false;
2728
}

hamcrest-core/src/test/java/org/hamcrest/core/AllOfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ public final class AllOfTest {
6060

6161
@Test public void
6262
hasAMismatchDescriptionDescribingTheFirstFailingMatch() {
63-
assertMismatchDescription("was \"bad\"", allOf(equalTo("bad"), equalTo("good")), "bad");
63+
assertMismatchDescription("a string starting with \"good\" was \"bad\"", allOf(equalTo("bad"), startsWith("good")), "bad");
6464
}
6565
}

hamcrest-core/src/test/java/org/hamcrest/core/CombinableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class CombinableTest {
3737
@Test public void
3838
bothDescribesItself() {
3939
assertDescription("(not <3> and not <4>)", NOT_3_AND_NOT_4);
40-
assertMismatchDescription("was <3>", NOT_3_AND_NOT_4, 3);
40+
assertMismatchDescription("not <3> was <3>", NOT_3_AND_NOT_4, 3);
4141
}
4242

4343
@Test public void

hamcrest-core/src/test/java/org/hamcrest/core/IsCollectionContainingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public final class IsCollectionContainingTest {
8282
reportsMismatchWithAReadableDescriptionForMultipleItems() {
8383
final Matcher<Iterable<Integer>> matcher = hasItems(3, 4);
8484

85-
assertMismatchDescription("mismatches were: [was <1>, was <2>, was <3>]",
85+
assertMismatchDescription("a collection containing <4> mismatches were: [was <1>, was <2>, was <3>]",
8686
matcher, asList(1, 2, 3));
8787
}
8888

0 commit comments

Comments
 (0)