org.hamcrest.junit
public class MatcherAssume extends java.lang.Object
// only provides information if database is reachable.
\@Test public void calculateTotalSalary() {
DBConnection dbc = Database.connect();
assumeNotNull(dbc);
// ...
}
These methods can be used directly: Assume.assumeTrue(...), however, they
read better if they are referenced through static import:
import static org.junit.Assume.*;
...
assumeTrue(...);
| Constructor and Description |
|---|
MatcherAssume() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
assumeThat(java.lang.String message,
T actual,
org.hamcrest.Matcher<? super T> matcher)
Call to assume that
actual satisfies the condition specified by matcher. |
static <T> void |
assumeThat(T actual,
org.hamcrest.Matcher<? super T> matcher)
Call to assume that
actual satisfies the condition specified by matcher. |
public static <T> void assumeThat(T actual,
org.hamcrest.Matcher<? super T> matcher)
actual satisfies the condition specified by matcher.
If not, the test halts and is ignored.
Example:
: assumeThat(1, equalTo(1)); // passes foo(); // will execute assumeThat(0, equalTo(1)); // assumption failure! test halts int x = 1 / 0; // will never execute
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as assumeThat(1, is("a"))}actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed valuesMatcher,
JUnitMatcherspublic static <T> void assumeThat(java.lang.String message,
T actual,
org.hamcrest.Matcher<? super T> matcher)
actual satisfies the condition specified by matcher.
If not, the test halts and is ignored.
Example:
: assumeThat(1, is(1)); // passes foo(); // will execute assumeThat(0, is(1)); // assumption failure! test halts int x = 1 / 0; // will never execute
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as assumeThat(1, is("a"))actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed valuesCoreMatchers,
JUnitMatchers