The JetBrains Guide is shutting down on March 30, 2026. more...

JUnit 5 Lifecycle

Introduction and annotations.

Introduction

  • How JUnit's lifecycle works.
  • @BeforeEach / @AfterEach: Running something before/after every test method.
  • @BeforeAll / @AfterAll: Running something once before/after a test class.