November 2024
Intermediate to advanced
300 pages
7h 12m
English
You learned about @BeforeEach in your first JUnit example (see Chapter 1, Building Your First JUnit Test). Let’s take a closer look at this initialization hook, as well as some other useful hooks that JUnit provides.
In Abstraction: Eliminating Boring Details, you learned to use @BeforeEach to put common initialization in one place. Methods annotated with @BeforeEach are executed before each test in scope.
JUnit also provides another initialization hook known as @BeforeAll, which you must declare as a static method. Each method annotated with @BeforeAll gets executed once per test class and prior to the execution of anything else within that ...
Read now
Unlock full access