Boolean Assumptions

Learn how to use boolean assumptions in JUnit 5.

The assumeTrue() method

Assertions verify that expected conditions are met after some executions. In some cases, the assertions may not even be necessary to run. This means that assertions can have assumptions. JUnit 5 provides static methods in the org.junit.jupiter.api.Assumptions class to describe test assumptions. When the assumption is invalid, the org.opentest4j.TestAbortedEx is thrown and the test is aborted. There are three groups of static methods in assumptions, namely assumeTrue(), assumeFalse(), and assumingThat().

Get hands-on with 1200+ tech skills courses.