public class Assert
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
protected |
Assert() |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertThat(boolean actual) |
static void |
assertThat(java.lang.String reason,
boolean actual) |
static <T> void |
assertThat(java.lang.String reason,
T actual,
org.hamcrest.Matcher<T> matcher)
Asserts that
actual satisfies the condition specified by
matcher. |
static <T> void |
assertThat(T actual,
org.hamcrest.Matcher<T> matcher)
Asserts that
actual satisfies the condition specified by
matcher. |
static void |
fail() |
static void |
fail(java.lang.String message) |
protected static java.lang.StackTraceElement[] |
getCleanStackTrace() |
public static void assertThat(boolean actual)
public static void assertThat(@Nullable
java.lang.String reason,
boolean actual)
public static <T> void assertThat(@Nullable
T actual,
@Nonnull
org.hamcrest.Matcher<T> matcher)
actual satisfies the condition specified by
matcher. If not, an AssertionError is thrown with
information about the matcher and failing value. Example:
assertThat(0, is(1)); // fails:
// failure message:
// expected: is <1>
// got value: <0>
assertThat(0, is(not(1))) // passes
T - the static type accepted by the matcher (this can flag obvious
compile-time problems such as assertThat(1, is("a"))actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed
valuesCoreMatchers,
JUnitMatcherspublic static <T> void assertThat(@Nullable
java.lang.String reason,
@Nullable
T actual,
@Nonnull
org.hamcrest.Matcher<T> matcher)
actual satisfies the condition specified by
matcher. If not, an AssertionError is thrown with
the reason and information about the matcher and failing value. Example:
:
assertThat("Help! Integers don't work", 0, is(1)); // fails:
// failure message:
// Help! Integers don't work
// expected: is <1>
// got value: <0>
assertThat("Zero is one", 0, is(not(1))) // passes
T - the static type accepted by the matcher (this can flag obvious
compile-time problems such as assertThat(1, is("a"))reason - additional information about the erroractual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed
valuesCoreMatchers,
JUnitMatcherspublic static void fail()
public static void fail(@Nullable
java.lang.String message)
@Nonnull protected static java.lang.StackTraceElement[] getCleanStackTrace()
Copyright © 2013 echocat. All Rights Reserved.