Package org.junit.jupiter.api
Class Assumptions
- java.lang.Object
-
- org.junit.jupiter.api.Assumptions
-
@API(status=STABLE, since="5.0") public final class Assumptions extends java.lang.Object
Assumptionsis 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.
- Since:
- 5.0
- See Also:
TestAbortedException,Assertions
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassumeFalse(boolean assumption)Validate the given assumption.static voidassumeFalse(boolean assumption, java.lang.String message)Validate the given assumption.static voidassumeFalse(boolean assumption, java.util.function.Supplier<java.lang.String> messageSupplier)Validate the given assumption.static voidassumeFalse(java.util.function.BooleanSupplier assumptionSupplier)Validate the given assumption.static voidassumeFalse(java.util.function.BooleanSupplier assumptionSupplier, java.lang.String message)Validate the given assumption.static voidassumeFalse(java.util.function.BooleanSupplier assumptionSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)Validate the given assumption.static voidassumeTrue(boolean assumption)Validate the given assumption.static voidassumeTrue(boolean assumption, java.lang.String message)Validate the given assumption.static voidassumeTrue(boolean assumption, java.util.function.Supplier<java.lang.String> messageSupplier)Validate the given assumption.static voidassumeTrue(java.util.function.BooleanSupplier assumptionSupplier)Validate the given assumption.static voidassumeTrue(java.util.function.BooleanSupplier assumptionSupplier, java.lang.String message)Validate the given assumption.static voidassumeTrue(java.util.function.BooleanSupplier assumptionSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)Validate the given assumption.static voidassumingThat(boolean assumption, Executable executable)Execute the suppliedExecutable, but only if the supplied assumption is valid.static voidassumingThat(java.util.function.BooleanSupplier assumptionSupplier, Executable executable)Execute the suppliedExecutable, but only if the supplied assumption is valid.
-
-
-
Method Detail
-
assumeTrue
public static void assumeTrue(boolean assumption) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumption- the assumption to validate- Throws:
org.opentest4j.TestAbortedException- if the assumption is nottrue
-
assumeTrue
public static void assumeTrue(java.util.function.BooleanSupplier assumptionSupplier) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumptionSupplier- the supplier of the assumption to validate- Throws:
org.opentest4j.TestAbortedException- if the assumption is nottrue
-
assumeTrue
public static void assumeTrue(java.util.function.BooleanSupplier assumptionSupplier, java.lang.String message) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumptionSupplier- the supplier of the assumption to validatemessage- the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is nottrue
-
assumeTrue
public static void assumeTrue(boolean assumption, java.util.function.Supplier<java.lang.String> messageSupplier) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumption- the assumption to validatemessageSupplier- the supplier of the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is nottrue
-
assumeTrue
public static void assumeTrue(boolean assumption, java.lang.String message) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumption- the assumption to validatemessage- the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is nottrue
-
assumeTrue
public static void assumeTrue(java.util.function.BooleanSupplier assumptionSupplier, java.util.function.Supplier<java.lang.String> messageSupplier) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumptionSupplier- the supplier of the assumption to validatemessageSupplier- the supplier of the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is nottrue
-
assumeFalse
public static void assumeFalse(boolean assumption) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumption- the assumption to validate- Throws:
org.opentest4j.TestAbortedException- if the assumption is notfalse
-
assumeFalse
public static void assumeFalse(java.util.function.BooleanSupplier assumptionSupplier) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumptionSupplier- the supplier of the assumption to validate- Throws:
org.opentest4j.TestAbortedException- if the assumption is notfalse
-
assumeFalse
public static void assumeFalse(java.util.function.BooleanSupplier assumptionSupplier, java.lang.String message) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumptionSupplier- the supplier of the assumption to validatemessage- the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is notfalse
-
assumeFalse
public static void assumeFalse(boolean assumption, java.util.function.Supplier<java.lang.String> messageSupplier) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumption- the assumption to validatemessageSupplier- the supplier of the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is notfalse
-
assumeFalse
public static void assumeFalse(boolean assumption, java.lang.String message) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumption- the assumption to validatemessage- the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is notfalse
-
assumeFalse
public static void assumeFalse(java.util.function.BooleanSupplier assumptionSupplier, java.util.function.Supplier<java.lang.String> messageSupplier) throws org.opentest4j.TestAbortedExceptionValidate the given assumption.- Parameters:
assumptionSupplier- the supplier of the assumption to validatemessageSupplier- the supplier of the message to be included in theTestAbortedExceptionif the assumption is invalid- Throws:
org.opentest4j.TestAbortedException- if the assumption is notfalse
-
assumingThat
public static void assumingThat(java.util.function.BooleanSupplier assumptionSupplier, Executable executable)Execute the suppliedExecutable, but only if the supplied assumption is valid.If the assumption is invalid, this method does nothing.
If the
executablethrows an exception, it will be rethrown as is butmaskedas an unchecked exception.- Parameters:
assumptionSupplier- the supplier of the assumption to validateexecutable- the block of code to execute if the assumption is valid- See Also:
assumingThat(boolean, Executable)
-
assumingThat
public static void assumingThat(boolean assumption, Executable executable)Execute the suppliedExecutable, but only if the supplied assumption is valid.If the assumption is invalid, this method does nothing.
If the
executablethrows an exception, it will be rethrown as is butmaskedas an unchecked exception.- Parameters:
assumption- the assumption to validateexecutable- the block of code to execute if the assumption is valid- See Also:
assumingThat(BooleanSupplier, Executable)
-
-