JU

JUnit 5

Used in 194 java projects (avg ★285)

Java
Testing
Default
Used by 194 projects

Details

Language / Topic
javaJava
Category
Testing

Rules

balanced
- In Java: Use `@Test` for test methods with descriptive, backtick-quoted names like `should handle null input`.
- Mock all dependencies to isolate the unit under test and avoid testing multiple classes.
- Prefer inline initialization of test data over `@BeforeEach`.
- Define constants like test addresses in a private companion object.
- In Java: Limit `@BeforeEach` to shared setup such as test dispatchers or resettable state to reduce test interdependence.
- Use data class `.copy()` to efficiently create variations of test objects without recreation.
- Ensure tests cover failure states with descriptive error expectations.
- Structure tests to mimic real usage while maintaining strict isolation.