Assumptions

In this part of this section is about the so-called assumptions. Assumptions allow us to only run tests if certain conditions are as expected. All JUnit Jupiter assumptions are static methods in the class Assumptions, located inside the org.junit.jupiter package. The following screenshot shows all the methods of this class:

Methods of the class org.junit.jupiter.Assumptions

On the one hand, the methods assumeTrue and assumeFalse can be used to skip tests whose preconditions are not met. On the other hand, the method assumingThat is used to condition the execution of a part in a test:

package io.github.bonigarcia;import static ...

Get Mastering Software Testing with JUnit 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.