org.junit.experimental.results.ResultMatchers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reactor-junit4 Show documentation
Show all versions of reactor-junit4 Show documentation
JUnit is a unit testing framework for Java, created by Erich Gamma and Kent Beck.
The newest version!
package org.junit.experimental.results;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
/**
* Matchers on a PrintableResult, to enable JUnit self-tests.
* For example:
*
*
* assertThat(testResult(HasExpectedException.class), isSuccessful());
*
*/
public class ResultMatchers {
/**
* Matches if the tests are all successful
*/
public static Matcher isSuccessful() {
return failureCountIs(0);
}
/**
* Matches if there are {@code count} failures
*/
public static Matcher failureCountIs(final int count) {
return new TypeSafeMatcher() {
public void describeTo(Description description) {
description.appendText("has " + count + " failures");
}
@Override
public boolean matchesSafely(PrintableResult item) {
return item.failureCount() == count;
}
};
}
/**
* Matches if the result has exactly one failure, and it contains {@code string}
*/
public static Matcher