O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Jupiter assertions

Let's move on to the JUnit 5 programming model. Jupiter comes with many of the assertion methods such as the ones in JUnit 4, and also adds several that can be used with Java 8 lambdas. All JUnit Jupiter assertions are static methods in the Assertions class located in org.junit.jupiter package.

The following picture shows the complete list of these methods:

Complete list of Jupiter assertions (class org.junit.jupiter.Assertions)

The following table reviews the different types of basic assertions in Jupiter:

Assertion

Description

fail

Fails a test with a given message and/or exception

assertTrue

Asserts ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required