Skip to content

Commit 9f5dfd8

Browse files
committed
fix ResultMatchers#hasFailureContaining
It should not match when the given PrintableResult has no failures.
1 parent 9b1bc4a commit 9f5dfd8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: src/main/java/org/junit/experimental/results/ResultMatchers.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.hamcrest.TypeSafeMatcher;
77

88
import static org.hamcrest.Matchers.equalTo;
9+
import static org.hamcrest.Matchers.greaterThan;
910

1011
/**
1112
* Matchers on a PrintableResult, to enable JUnit self-tests.
@@ -77,7 +78,7 @@ public void describeTo(Description description) {
7778
public static Matcher<PrintableResult> hasFailureContaining(final String string) {
7879
return new BaseMatcher<PrintableResult>() {
7980
public boolean matches(Object item) {
80-
return item.toString().contains(string);
81+
return failureCount(greaterThan(0)).matches(item) && item.toString().contains(string);
8182
}
8283

8384
public void describeTo(Description description) {

0 commit comments

Comments
 (0)