The Parts of an Individual Test
A handful of chapters ago (see Scannability: Arrange—Act—Assert), you learned how AAA provides a great visual mnemonic to help readers quickly understand the core parts of a test.
Some developers refer to a “four-phase test,”[22] where each test can be broken into (wait for it) four parts or phases:
-
Set up state/data in what’s sometimes called a fixture. Think of a fixture as the context in which a test runs—its world, so to speak. The fixture is managed for you by JUnit; you’ll learn more about that in this chapter as part of the JUnit test execution lifecycle.
-
Interact with the system to execute what you want to verify.
-
Do the verification (assert).
-
Tear down the fixture—clean up any side effects, if necessary. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access