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

Test lifecycle

As we saw in Chapter 1Retrospective on software quality and Java testing, a unit test case is composed of four stages:

  1. Setup (optional): First, the test initializes the test fixture (before the picture of the SUT).
  2. Exercise: Second, the test interacts with the SUT, getting some outcome from it as a result.
  3. Verify: Third, the outcome from the system under test is compared to the expected value using one or several assertions (also known as predicates). As a result, a test verdict is created.
  4. Teardown (optional): Finally, the test releases the test fixture to put the SUT back into the initial state.

In JUnit 4, there were different annotations to control these test phases. JUnit 5 follows the same approach, that is, Java ...

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