1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Testing in Java

Connected

Exercise

BeforeEach: Alerting

As the complexity of your project grows, tests may require longer and longer setup. Anticipating this, you revisit the DurationMonitorTest and use the new annotations to extract some of the test setup in a setup() method.

Use @BeforeEach to make the setup execute before each test.

Instructions

100 XP
  • Annotate the setup() method with the correct annotation.
  • Write down the necessary setup inside: AlertService is a mock, DurationMonitor takes in that mock.