Organizing Tests with @DisplayName and Nesting
Make your JUnit 5 test suites readable and well-structured using descriptive display names and nested test classes that group related scenarios.
Tests Are Documentation
A test suite is more than a safety net — it documents how your code should behave. JUnit 5’s @DisplayName and @Nested make that documentation shine.
The Problem with Method Names
A name like testAdd2 says almost nothing, and method names can’t hold spaces or punctuation — so they can only be so expressive.
@Test
void testAdd2() { /* ... */ }All lessons in this course
- Introduction to Unit Testing
- Basic JUnit 5 Annotations
- JUnit Assertions & Execution
- Organizing Tests with @DisplayName and Nesting