@API(value=Maintained) public final class Assumptions extends Object
Assumptions
is a collection of utility methods that support
conditional test execution based on assumptions.
In direct contrast to failed assertions, failed assumptions do not result in a test failure; rather, a failed assumption results in a test being aborted.
Assumptions are typically used whenever it does not make sense to continue execution of a given test method — for example, if the test depends on something that does not exist in the current runtime environment.
TestAbortedException
,
Assertions
Modifier and Type | Method and Description |
---|---|
static void |
assumeFalse(boolean assumption)
Validate the given assumption.
|
static void |
assumeFalse(boolean assumption,
String message)
Validate the given assumption.
|
static void |
assumeFalse(BooleanSupplier assumptionSupplier)
Validate the given assumption.
|
static void |
assumeFalse(boolean assumption,
Supplier<String> messageSupplier)
Validate the given assumption.
|
static void |
assumeFalse(BooleanSupplier assumptionSupplier,
String message)
Validate the given assumption.
|
static void |
assumeFalse(BooleanSupplier assumptionSupplier,
Supplier<String> messageSupplier)
Validate the given assumption.
|
static void |
assumeTrue(boolean assumption)
Validate the given assumption.
|
static void |
assumeTrue(boolean assumption,
String message)
Validate the given assumption.
|
static void |
assumeTrue(BooleanSupplier assumptionSupplier)
Validate the given assumption.
|
static void |
assumeTrue(boolean assumption,
Supplier<String> messageSupplier)
Validate the given assumption.
|
static void |
assumeTrue(BooleanSupplier assumptionSupplier,
String message)
Validate the given assumption.
|
static void |
assumeTrue(BooleanSupplier assumptionSupplier,
Supplier<String> messageSupplier)
Validate the given assumption.
|
static void |
assumingThat(boolean assumption,
Executable executable)
Execute the supplied
Executable , but only if the supplied
assumption is valid. |
static void |
assumingThat(BooleanSupplier assumptionSupplier,
Executable executable)
Execute the supplied
Executable , but only if the supplied
assumption is valid. |
public static void assumeTrue(boolean assumption) throws TestAbortedException
assumption
- the assumption to validateTestAbortedException
- if the assumption is not true
public static void assumeTrue(BooleanSupplier assumptionSupplier) throws TestAbortedException
assumptionSupplier
- the supplier of the assumption to validateTestAbortedException
- if the assumption is not true
public static void assumeTrue(BooleanSupplier assumptionSupplier, String message) throws TestAbortedException
assumptionSupplier
- the supplier of the assumption to validatemessage
- the message to be included in the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not true
public static void assumeTrue(boolean assumption, Supplier<String> messageSupplier) throws TestAbortedException
assumption
- the assumption to validatemessageSupplier
- the supplier of the message to be included in
the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not true
public static void assumeTrue(boolean assumption, String message) throws TestAbortedException
assumption
- the assumption to validatemessage
- the message to be included in the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not true
public static void assumeTrue(BooleanSupplier assumptionSupplier, Supplier<String> messageSupplier) throws TestAbortedException
assumptionSupplier
- the supplier of the assumption to validatemessageSupplier
- the supplier of the message to be included in
the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not true
public static void assumeFalse(boolean assumption) throws TestAbortedException
assumption
- the assumption to validateTestAbortedException
- if the assumption is not false
public static void assumeFalse(BooleanSupplier assumptionSupplier) throws TestAbortedException
assumptionSupplier
- the supplier of the assumption to validateTestAbortedException
- if the assumption is not false
public static void assumeFalse(BooleanSupplier assumptionSupplier, String message) throws TestAbortedException
assumptionSupplier
- the supplier of the assumption to validatemessage
- the message to be included in the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not false
public static void assumeFalse(boolean assumption, Supplier<String> messageSupplier) throws TestAbortedException
assumption
- the assumption to validatemessageSupplier
- the supplier of the message to be included in
the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not false
public static void assumeFalse(boolean assumption, String message) throws TestAbortedException
assumption
- the assumption to validatemessage
- the message to be included in the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not false
public static void assumeFalse(BooleanSupplier assumptionSupplier, Supplier<String> messageSupplier) throws TestAbortedException
assumptionSupplier
- the supplier of the assumption to validatemessageSupplier
- the supplier of the message to be included in
the TestAbortedException
if the assumption is invalidTestAbortedException
- if the assumption is not false
@API(value=Experimental) public static void assumingThat(BooleanSupplier assumptionSupplier, Executable executable)
Executable
, but only if the supplied
assumption is valid.
If the assumption is invalid, this method does nothing.
If the executable
throws an exception, it will be rethrown
as is but masked
as an unchecked exception.
assumptionSupplier
- the supplier of the assumption to validateexecutable
- the block of code to execute if the assumption is validassumingThat(boolean, Executable)
@API(value=Experimental) public static void assumingThat(boolean assumption, Executable executable)
Executable
, but only if the supplied
assumption is valid.
If the assumption is invalid, this method does nothing.
If the executable
throws an exception, it will be rethrown
as is but masked
as an unchecked exception.
assumption
- the assumption to validateexecutable
- the block of code to execute if the assumption is validassumingThat(BooleanSupplier, Executable)