一键导入
add-test
// Creates tests for an existing feature following OpenAEV patterns: fixture class, composer, integration test with @Nested groups, and optionally unit tests. Use when asked to add tests or improve test coverage.
// Creates tests for an existing feature following OpenAEV patterns: fixture class, composer, integration test with @Nested groups, and optionally unit tests. Use when asked to add tests or improve test coverage.
Scaffolds a complete feature end-to-end: JPA entity, repository, service, DTOs, mapper, controller, migration, tests (fixture + composer + integration test), and frontend actions/page. Use when asked to create a new feature or module.
Step-by-step general code review procedure for OpenAEV pull requests. Covers architecture, conventions, code quality, and delegation to specialized agents.
Frontend review checklist for OpenAEV React/TypeScript code: component patterns, forms, MUI usage, permissions, i18n, state management, dead code. Use when reviewing PRs or auditing frontend features.
Step-by-step tenant isolation audit for OpenAEV pull requests. Use when reviewing PRs that touch entities, repositories, native queries, or migrations.
Creates a Flyway Java-based migration for schema changes. Handles table creation, column additions, tenant isolation, and ES reindex. Use when asked to modify the database schema.
Performance review checklist for OpenAEV code: N+1 queries, fetch strategy, pagination, indexing, memory usage. Use when reviewing PRs or auditing performance of a feature.
| name | add-test |
| description | Creates tests for an existing feature following OpenAEV patterns: fixture class, composer, integration test with @Nested groups, and optionally unit tests. Use when asked to add tests or improve test coverage. |
Location: openaev-api/src/test/java/io/openaev/utils/fixtures/files/
public class {Entity}Fixture {
public static {Entity} createDefault{Entity}() {
{Entity} entity = new {Entity}();
entity.setName("{Entity}-" + RandomStringUtils.random(25, true, true));
// set required fields
return entity;
}
}
Location: openaev-api/src/test/java/io/openaev/utils/fixtures/composers/
ComposerBase<{Entity}>Composer with persist(), delete(), get(), withId()Location: openaev-api/src/test/java/io/openaev/rest/ or api/
Structure:
@TestInstance(PER_CLASS)
@Transactional
@DisplayName("{Feature} API tests")
public class {Feature}ApiTest extends IntegrationTest {
public static final String URI = "/api/{features}";
@Autowired private MockMvc mvc;
@Autowired private {Feature}Composer composer;
@BeforeEach void setup() { composer.reset(); }
@Nested @WithMockUser(isAdmin = true) @DisplayName("CRUD operations")
class CrudOperations {
@Test @DisplayName("Can create") void given_validInput_should_createEntity() { /* Arrange / Act / Assert */ }
@Test @DisplayName("Can read") void given_existingId_should_returnEntity() { ... }
@Test @DisplayName("Can update") void given_existingEntity_should_updateSuccessfully() { ... }
@Test @DisplayName("Can delete") void given_existingEntity_should_deleteSuccessfully() { ... }
@Test @DisplayName("Can search") void given_searchInput_should_returnPage() { ... }
}
@Nested @WithMockUser(withCapabilities = {...}) @DisplayName("Permission checks")
class PermissionChecks { ... }
}
For controllers that don't manage entities (e.g. static endpoints, utility APIs, configuration endpoints):
@WithMockUser when @RBAC(skipRBAC = true) is present@TestInstance(PER_CLASS)
@DisplayName("{Feature} API tests")
class {Feature}ApiTest extends IntegrationTest {
@Autowired private MockMvc mvc;
@Nested @DisplayName("GET /endpoint")
class EndpointGroup {
@Test @DisplayName("Should respond without authentication")
void given_unauthenticatedRequest_should_respondSuccessfully() throws Exception {
// Arrange & Act
var result = mvc.perform(get("/endpoint"));
// Assert
result
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_PLAIN))
.andExpect(content().string(EXPECTED_BODY)) // static import from controller
.andExpect(header().string("Custom-Header", EXPECTED_VALUE));
}
}
}
Key rules for lightweight tests:
static final (package-private) in the controller, imported via static import in the test@Nested + @DisplayName@RBAC(skipRBAC = true)For complex service logic:
@ExtendWith(MockitoExtension.class)
class {Feature}ServiceUnitTest {
@Mock private {Entity}Repository repository;
@InjectMocks private {Feature}Service service;
// given_X_should_Y naming + AAA (Arrange/Act/Assert) pattern
}
mvn test -pl openaev-api -Dtest="{Feature}ApiTest"
mvn jacoco:check
| Sub-Skill | Use when... |
|---|---|
| TENANT_ISOLATION.md | Adding tenant isolation tests (@Nested TenantIsolation) to verify cross-tenant data doesn't leak |