From 9f5dfd8c1a9a006bc2e5d93a9bc770f2449e7afa Mon Sep 17 00:00:00 2001 From: Alberto Scotto Date: Fri, 13 May 2016 01:53:21 +0100 Subject: [PATCH] fix ResultMatchers#hasFailureContaining It should not match when the given PrintableResult has no failures. --- .../java/org/junit/experimental/results/ResultMatchers.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/junit/experimental/results/ResultMatchers.java b/src/main/java/org/junit/experimental/results/ResultMatchers.java index 6c1590dad4e2..0b941c2eb444 100644 --- a/src/main/java/org/junit/experimental/results/ResultMatchers.java +++ b/src/main/java/org/junit/experimental/results/ResultMatchers.java @@ -6,6 +6,7 @@ import org.hamcrest.TypeSafeMatcher; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; /** * Matchers on a PrintableResult, to enable JUnit self-tests. @@ -77,7 +78,7 @@ public void describeTo(Description description) { public static Matcher hasFailureContaining(final String string) { return new BaseMatcher() { public boolean matches(Object item) { - return item.toString().contains(string); + return failureCount(greaterThan(0)).matches(item) && item.toString().contains(string); } public void describeTo(Description description) {