Skip to content

Commit 0f061d6

Browse files
committed
Mismatch description for AllOf changes to be consistent with other matchers.
Example: is(2) against 3, would give a description of: was <3> allOf(is(greaterThan(2)), is(equalTo(4))) against 3, normally gives a mismatchDescription consisting of the description followed by the mismatched value, as in: (is a value greater than <2> and is <4>) was <3> It now only resturns the actual mismatch as for most other matchers: was <3>
1 parent 4c4c3fa commit 0f061d6

4 files changed

Lines changed: 4 additions & 5 deletions

File tree

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public AllOf(Iterable<Matcher<? super T>> matchers) {
2525
public boolean matches(Object o, Description mismatch) {
2626
for (Matcher<? super T> matcher : matchers) {
2727
if (!matcher.matches(o)) {
28-
mismatch.appendDescriptionOf(matcher).appendText(" ");
29-
matcher.describeMismatch(o, mismatch);
28+
matcher.describeMismatch(o, mismatch);
3029
return false;
3130
}
3231
}

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

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

6666
@Test public void
6767
hasAMismatchDescriptionDescribingTheFirstFailingMatch() {
68-
assertMismatchDescription("\"good\" was \"bad\"", allOf(equalTo("bad"), equalTo("good")), "bad");
68+
assertMismatchDescription("was \"bad\"", allOf(equalTo("bad"), equalTo("good")), "bad");
6969
}
7070
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public final class CombinableTest {
4242
@Test public void
4343
bothDescribesItself() {
4444
assertDescription("(not <3> and not <4>)", NOT_3_AND_NOT_4);
45-
assertMismatchDescription("not <3> was <3>", NOT_3_AND_NOT_4, 3);
45+
assertMismatchDescription("was <3>", NOT_3_AND_NOT_4, 3);
4646
}
4747

4848
@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
@@ -87,7 +87,7 @@ public final class IsCollectionContainingTest {
8787
reportsMismatchWithAReadableDescriptionForMultipleItems() {
8888
final Matcher<Iterable<Integer>> matcher = hasItems(3, 4);
8989

90-
assertMismatchDescription("a collection containing <4> mismatches were: [was <1>, was <2>, was <3>]",
90+
assertMismatchDescription("mismatches were: [was <1>, was <2>, was <3>]",
9191
matcher, asList(1, 2, 3));
9292
}
9393

0 commit comments

Comments
 (0)