public class Assert
extends java.lang.Object
Entry point for all the functionality in the "Assertion framework". Not instantiable. Provides bunch of static methods for easy access.
"assertThat" methods are clones of "checkThat" methods from the AssertBuilder,
and are similar by functionality, but with assertion itself performed immediately.
Method fail(String, Object...) allows you to create an assertion result
consisting only from a single message, and then instantly throw an assertion error with this result.
Easiest way to momentarily indicate functional fail.
Method builder() provides the most obvious and easy way to create instance of the AssertBuilder.
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
assertThat(T item,
org.hamcrest.Matcher<T> matcher)
Performs assertion check of the specified item using hamcrest
Matcher object. |
static <T> void |
assertThat(T item,
org.hamcrest.Matcher<T> matcher,
java.lang.String message)
Performs assertion check of the specified item using hamcrest
Matcher object. |
static <T> void |
assertThat(T item,
org.hamcrest.Matcher<T> matcher,
java.lang.String message,
java.lang.Throwable cause)
Performs assertion check of the specified item using hamcrest
Matcher object. |
static AssertBuilder |
builder()
Create instance of the
AssertBuilder. |
static void |
fail(java.lang.String message,
java.lang.Object... args)
Create message with arguments and throw
AssertError immediately. |
public static AssertBuilder builder()
AssertBuilder.
Just a substitute for a constructor, with no additional functionality.public static void fail(java.lang.String message,
java.lang.Object... args)
Create message with arguments and throw AssertError immediately.
Equivalent to AssertBuilder.addMessage(String, Object...)
public static <T> void assertThat(T item,
org.hamcrest.Matcher<T> matcher)
Performs assertion check of the specified item using hamcrest Matcher object.
If item doesn't match expectations - AssertError is created, and AssertError is thrown instantly.
public static <T> void assertThat(T item,
org.hamcrest.Matcher<T> matcher,
java.lang.String message)
Performs assertion check of the specified item using hamcrest Matcher object.
If item doesn't match expectations - AssertError is created with the specified message,
and AssertError is thrown instantly.
public static <T> void assertThat(T item,
org.hamcrest.Matcher<T> matcher,
java.lang.String message,
java.lang.Throwable cause)
Performs assertion check of the specified item using hamcrest Matcher object.
If item doesn't match expectations - AssertError is created with the specified message
and the specified cause, and AssertError is thrown instantly.