Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

writing-springboot-tests

БесплатноБез исполняемых скриптовНе проверен

Use when writing or adding tests or integration tests for Spring Boot code at a service's edges: HTTP clients that call other services (WireMock: 4xx and 5xx…

a-pavithraaот a-pavithraa★ 82 звезды на GitHub

Об этом скилле

Writing Spring Boot Tests

Use this for tests where the framework, not the logic, decides whether the test proves anything: calls and messages between services, retries, timeouts, transactions, and Boot 4 test wiring. For domain logic, see "Domain rules as properties". For other plain unit tests you need nothing here beyond the rules.

Rules

  1. Cases come from the contract, clause by clause. Every sentence of the Javadoc, the provider's API documentation, or an agreed message format is a case: units and formats (cents or decimals, field names), status codes with a special meaning (a 409 that means "already done"), headers, time limits, delivery promises (once only, after commit, poison messages dead-lettered). Call the code the way its callers do, with their values, so conversions run.
  2. Run the real thing at the edge. Real HTTP (WireMock), the real broker and database (Testcontainers), real transactions. A mocked client, template, or transaction manager can't show timeouts, retries, redelivery, or publish-after-commit. Timeout tests use the production timeout value. Build the client the way production does (its bean, or its builder settings) and point it at the stub. If the client can't be pointed elsewhere, make its base URL or endpoint configurable: that improves the design. If it has no timeout at all, report that as a finding instead of skipping the test. AWS SDK clients count: see traps.md.
  3. Show each test failing once, and treat a failing test as a finding. Break the guarded line and watch the test go red (PIT for classes with logic). If a test fails on the current code, report it with the contract clause; never weaken the assertion.
  4. Test through what the code does, not its internals. Assert on results, stored rows, sent messages, and calls to other services. Don't widen a method's visibility, or add a getter, counter or flag that only a test uses: UnusedCodeTests fails on a method only tests call. Changing the code for a test is right when it also improves the design, such as taking a Clock or a client through the constructor instead of creating it.

Before writing

Read ../code-reviewer/references/testing/traps.md: the Boot 4.1 / Framework 7 / Spring Kafka 4 traps found by running these templates (@Retryable behind an interface proxy, @RestClientTest ignoring timeouts, Apache HttpClient retrying 503, blocked partitions, corrupted dead letters, single-batch topic reads), and the Testcontainers and test-data traps.

Imports, starters and PIT: ../code-reviewer/references/testing/boot4-test-toolkit.md.

Templates

Take the mechanics (annotations, wiring, stubbing, polling) from them; take the cases from rule 1, not from the template.

Edge Template
Outbound HTTP client: request, 4xx, 5xx, retries, timeout, unusable answers assets/http-client-wiremock-test.java
Message listener: state change, redelivery, poison and non-JSON messages assets/message-listener-test.java
Event other services consume: after commit, never on rollback assets/event-publication-test.java
The whole service over HTTP, other services stubbed assets/api-integration-test.java
Secured routes: signing in as a named user through the app's own role mapping (session OIDC login, JWT bearer, or database users); who may call each route assets/personas-oidc.java, assets/personas-jwt.java or assets/personas-db.java; assets/route-access-test.java
Web slice, persistence slice, service unit test assets/webmvc-slice-test.java, assets/repository-slice-test.java, assets/service-unit-test.java
Where the transaction starts and ends around a remote call: the read before it, the write and audit row inside it, one commit assets/transaction-boundary-test.java
A rule that must hold across every replica (a cap, a rate limit, a claim, a once-only job, a cache invalidated on save): two instances built by hand over one Postgres, sharing one clock, with the race forced on a row lock assets/two-instances-test.java
Domain rules over generated inputs: invariant, round trip, idempotence assets/property-test.java
Shared containers; PIT assets/testcontainers-configuration.java, assets/pitest-plugin.xml

Rules that hold across replicas

A single-instance test can't show that a counter, a cache, an in-memory limiter or an unlocked @Scheduled job breaks on the second replica, and in a real codebase these were the fixes that reached production. When a change touches state the whole service shares (a cap, a limit, a claim, a once-only job, a setting read from a cache), write the test from two-instances-test.java: two object graphs over one database, one clock, both acting at once. Assert the rule on the database, not on either instance. Force the interleaving rather than hoping two futures overlap: the template's first instance holds the row lock, starts the second instance's call and waits (`pg_sta

Полный SKILL.md на GitHub

Установить writing-springboot-tests в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

assets/api-integration-test.javaassets/event-publication-test.javaassets/http-client-wiremock-test.javaassets/message-listener-test.javaassets/personas-db.javaassets/personas-jwt.javaassets/personas-oidc.javaassets/pitest-plugin.xmlassets/property-test.javaassets/repository-slice-test.javaassets/route-access-test.javaassets/service-unit-test.javaassets/testcontainers-configuration.javaassets/transaction-boundary-test.javaassets/two-instances-test.javaassets/webmvc-slice-test.java

FAQ

Что делает скилл writing-springboot-tests?

Use when writing or adding tests or integration tests for Spring Boot code at a service's edges: HTTP clients that call other services (WireMock: 4xx and 5xx responses, timeouts, retries), Kafka or RabbitMQ listeners (redelivery, poison messages, dead-letter topics), events published to other services, or full-API tests against real databases with Testcontainers; domain logic whose rules must hold for every input (calculations, value objects, state transitions, parsing and formatting), tested as properties over generated inputs; also when a Boot 4 test needs the right imports, slices or container wiring. Supplies verified Boot 4.1 templates and the framework traps that make such tests pass without proving anything. Not for reviewing existing tests (see code-reviewer) or Boot 3 to 4 test migration (see springboot-migration).

Как установить скилл writing-springboot-tests?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл writing-springboot-tests запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить writing-springboot-tests с