一键导入
qa-junit5-writer
Generate JUnit 5 unit and integration tests for Java with parameterized tests, nested classes, extensions, Mockito mocking, and AssertJ assertions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate JUnit 5 unit and integration tests for Java with parameterized tests, nested classes, extensions, Mockito mocking, and AssertJ assertions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | qa-junit5-writer |
| description | Generate JUnit 5 unit and integration tests for Java with parameterized tests, nested classes, extensions, Mockito mocking, and AssertJ assertions. |
| output_dir | tests/unit |
Write JUnit 5 unit and integration tests from test case specifications. Transform structured test cases into executable JUnit 5 test classes with parameterized tests, nested classes for organization, extensions, Mockito mocking, and AssertJ assertions.
| Feature | Description |
|---|---|
| @Test | Standard test methods |
| @ParameterizedTest | Data-driven tests with @CsvSource, @MethodSource, @EnumSource |
| @Nested | Logical grouping; inner classes with @BeforeEach per level |
| @ExtendWith | Extensions (MockitoExtension, custom) |
| Mockito | @Mock, @InjectMocks, when().thenReturn(), verify() |
| AssertJ | Fluent assertions: assertThat().isEqualTo(), containsExactly() |
| @TestInstance | PER_CLASS for shared setup; PER_METHOD default |
| @Tag | Categorization for selective execution |
| @DisplayName | Human-readable test names |
{Class}Test.java with appropriate structuremvn test or ./gradlew test| Pattern | Usage |
|---|---|
@Test | JUnit 5 test method |
@ParameterizedTest | Data-driven test |
@CsvSource({"a,1", "b,2"}) | Inline CSV data |
@MethodSource("provideData") | Method-provided data |
@Nested | Group related tests |
@ExtendWith(MockitoExtension.class) | Enable Mockito |
@Mock | Mock dependency |
@InjectMocks | Inject mocks into SUT |
when(mock.method()).thenReturn(value) | Stub mock |
verify(mock, times(1)).method() | Verify interaction |
assertThat(actual).isEqualTo(expected) | AssertJ assertion |
@ParameterizedTest
@CsvSource({"admin, true", "user, false"})
void shouldCheckAccess(String role, boolean expected) {
assertThat(service.hasAccess(role)).isEqualTo(expected);
}
@ParameterizedTest
@MethodSource("provideInvalidInputs")
void shouldRejectInvalidInput(String input) {
assertThatThrownBy(() -> validator.validate(input))
.isInstanceOf(ValidationException.class);
}
Use @Nested for logical grouping; each nested class gets its own @BeforeEach:
@DisplayName("UserService")
class UserServiceTest {
@Nested
@DisplayName("when user exists")
class WhenUserExists {
@Test
void shouldReturnUser() { ... }
}
@Nested
@DisplayName("when user not found")
class WhenUserNotFound {
@Test
void shouldThrowException() { ... }
}
}
{Class}Test.java — Test classes (e.g., UserServiceTest.java, OrderValidatorTest.java)src/test/java mirroring production package structureCan do (autonomous):
Cannot do (requires confirmation):
Will not do (out of scope):
mvn test)references/patterns.md — Parameterized, nested, extensions, lifecyclereferences/assertions.md — AssertJ assertion referencereferences/config.md — Maven/Gradle JUnit 5 config, Surefire plugin{Class}Test.java convention| Symptom | Likely Cause | Fix |
|---|---|---|
| Mock not injected | Wrong extension or order | Use @ExtendWith(MockitoExtension.class); @InjectMocks before @Mock |
| ParameterizedTest fails | Invalid CSV/method source | Check @CsvSource format; ensure @MethodSource returns Stream |
| Nested @BeforeEach runs twice | Misunderstanding lifecycle | Each @Nested level has own lifecycle; @BeforeEach runs per test in that level |
| AssertJ import error | Wrong static import | Use import static org.assertj.core.api.Assertions.assertThat |
| Test order dependent | Shared state | Ensure test isolation; use @TestInstance(PER_METHOD) or fresh fixtures |
| Surefire skips tests | JUnit 4 engine conflict | Exclude junit-vintage; use junit-platform-surefire-provider |
Master skill coordinating all QA skills through pipeline modes (full-cycle, docs-only, testcases-only, write-tests, report), formalized handoff chains, scheduler rules, and framework/language selection based on project context.
QA project memory with auto-update. Structured log of bugs, decisions, tests, regressions, environments. Automatically updated after every QA task. Archive system with searchable index for large projects. Trigger phrases (EN): "initialize memory", "init qa memory", "find known bug", "search memory", "show what was done", "check regressions", "memory status", "archive memory", "log a bug", "add decision", "memory summary", "what bugs do we know", "update memory", "show test log". Trigger phrases (UA): "ініціалізувати пам'ять", "знайти відомий баг", "пошук у пам'яті", "показати що було зроблено", "перевірити регресії", "статус пам'яті", "архівувати пам'ять", "залогувати баг", "додати рішення", "зведення пам'яті", "які баги відомі", "оновити пам'ять", "показати лог тестів", "що ми вирішили про", "які тестові середовища є".
Analyze OpenAPI/Swagger spec (JSON or YAML) against existing test files and generate an HTML coverage report with QA automation tasks. Use when user provides an OpenAPI spec file and wants to know test coverage status.
Generate accessibility tests for WCAG 2.2 compliance using axe-core, Pa11y, and Lighthouse with automated checks for ARIA patterns, keyboard navigation, color contrast, and screen reader support.
Manage and formalize API contracts from existing endpoints, swagger/JSON, network traffic, or developer interviews into OpenAPI specifications.
Autonomously explore live web applications using Playwright MCP to collect page structure, form fields, validation rules, API endpoints, and user flows for test case generation.