بنقرة واحدة
test
Write or fix tests for a class or feature; run suite; enforce coverage gate. Triggers on /test.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Write or fix tests for a class or feature; run suite; enforce coverage gate. Triggers on /test.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation. Project-canonical fork — in this repo use this, not superpowers:brainstorming.
Verify build is green, stage explicit paths, commit with Conventional Commits, open PR draft. Triggers on /commit.
Plan, write, and validate a Flyway database migration. Triggers on /migrate.
Review staged/recent changes against project conventions, or audit and score existing code against best practices, design principles, and patterns. Triggers on /review.
Implement a feature end-to-end following project conventions. Triggers on /write.
| name | test |
| description | Write or fix tests for a class or feature; run suite; enforce coverage gate. Triggers on /test. |
| allowed-tools | Read, Write, Edit, Bash, Grep, Glob |
@RegisterExtension
static WireMockExtension wm = WireMockExtension.newInstance()
.options(wireMockConfig().dynamicPort()).build();
@DynamicPropertySource
static void props(DynamicPropertyRegistry r) {
r.add("inventory.base-url", wm::baseUrl);
}
@Test
void should_returnProduct_when_inventoryResponds() {
wm.stubFor(get("/inventory/123").willReturn(okJson("""{"stock":5}""")));
// call service and assert
}
should_<expectedBehavior>_when_<condition>AbstractIntegrationTest from common-test module@Sql("/db/seed-<entity>.sql") for test data setup, not Java builders in @BeforeEach@Transactional on test method; use @DirtiesContext only as last resortawait().atMost(10, SECONDS)
.pollInterval(200, MILLISECONDS)
.until(() -> repo.findByCorrelationId(id).isPresent());
./mvnw test./mvnw verify — gate is 80% line, 100% domain model.Kafka integration tests must assert Avro deserialization correctness:
@Test
void should_deserializePaymentCompletedEvent_when_messageConsumed() {
PaymentCompletedEvent event = PaymentCompletedEvent.newBuilder()
.setOrderId(UUID.randomUUID().toString())
.setTraceId("trace-123")
.setCorrelationId(UUID.randomUUID().toString())
.setAmount(99.99)
.build();
kafkaTemplate.send("order.payment.completed", event);
await().atMost(10, SECONDS).untilAsserted(() -> {
var saved = orderRepo.findByCorrelationId(event.getCorrelationId().toString());
assertThat(saved).isPresent();
assertThat(saved.get().getAmount()).isEqualByComparingTo("99.99");
});
}
MockSchemaRegistryClient or Schema Registry Testcontainer wired via @DynamicPropertySourceRun on the producing service before publishing stubs:
# 1. Generate and run contract tests on producer
./mvnw spring-cloud-contract:generateTests verify -pl <producer-module>
# 2. Install stubs to Maven local (consumed by downstream services in CI)
./mvnw install -pl <producer-module> -DskipTests
Add to producer pom.xml:
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<testFramework>JUNIT5</testFramework>
<baseClassForTests>com.example.BaseContractTest</baseClassForTests>
</configuration>
</plugin>
BaseContractTest must set up a MockMvc or real @SpringBootTest context with stubs for dependencies.
Consumer tests use @AutoConfigureStubRunner pointing to installed stubs.
Use @ParameterizedTest + @MethodSource for boundary values and multiple inputs sharing identical logic:
@ParameterizedTest
@MethodSource("invalidOrderSizes")
void should_throwValidationException_when_orderSizeInvalid(int size) {
assertThatThrownBy(() -> new CreateOrderCommand(UUID.randomUUID(), items(size)))
.isInstanceOf(ValidationException.class);
}
static Stream<Integer> invalidOrderSizes() { return Stream.of(0, -1, 51, 100); }
Do NOT use @ParameterizedTest when:
@Test methods for those.Postgres, MongoDB, Redis, Kafka are all started once per suite via @Container static fields. The MongoDB container is present for all services — do not remove it even if the service doesn't use Mongo. @DynamicPropertySource wires all four into the Spring context automatically.