Review and improve Java unit tests using modern JUnit 5, AssertJ, and Mockito best practices.
Prerequisites: Run ./mvnw compile or mvn compile before applying any change. If compilation fails, stop immediately and do not proceed — compilation failure is a blocking condition.
Core areas: JUnit 5 annotations (@Test, @BeforeEach, @AfterEach, @DisplayName, @Nested, @ParameterizedTest), AssertJ fluent assertions (assertThat, assertThatThrownBy), Given-When-Then test structure, descriptive test naming, single-responsibility tests, test independence and isolated state, parameterized tests with @ValueSource/@CsvSource/@MethodSource, Mockito dependency mocking (@Mock, @InjectMocks, MockitoExte...
當您需要審查、改進或編寫 Java 單元測試時使用 - 包括從 JUnit 4 遷移到 JUnit 5、採用 AssertJ 進行流暢斷言、使用 Give-When-Then 構建測試、確保測試獨立性、應用參數化測試、使用 Mockito 模擬依賴關係、驗證邊界條件(RIGHT-BICEP、CORRECT、A-TRIP.空安全註解或消除測試反模式(例如基於反射)測試或共享可變狀態。 java 技能專案的一部分 來源:jabrena/cursor-rules-java。