assumingThat() method

This lesson demonstrates how to use the assumingThat method in JUnit 5 to make conditional assumptions.

We'll cover the following

assumingThat()

Assumptions API in JUnit 5 has a static utility method called, assumingThat(). This method takes a boolean assumption and an Executable. It validates the given assumption and based on its outcome it decides whether to execute an Executable or not.

  • If the assumption is invalid, this method does nothing.
  • If the supplied assumption is valid, it executes the supplied Executable.

There are basically two useful overloaded methods for assumingThat.

Get hands-on with 1400+ tech skills courses.