What are Assumptions in JUnit 5 ?

This lesson describes Assumptions in JUnit 5 and its usage.

We'll cover the following

Assumptions in JUnit 5

Assumptions in JUnit 5 is a collection of utility methods that support conditional test execution based on assumptions. In comparison 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.

If the assumptions are not satisfied then, TestAbortedException is thrown.

There are 3 types of Assumptions in Junit 5:

  • assumeTrue
  • assumeFalse
  • assumingThat

In the upcoming lesson, let’s look into each Assumptions in detail.

Get hands-on with 1400+ tech skills courses.