Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/e-gov/cursor-promptsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/e-gov/cursor-prompts/spring-testing)<a href="https://agentmods.dev/rules/e-gov/cursor-prompts/spring-testing"><img src="https://agentmods.dev/badge/rules/e-gov/cursor-prompts/spring-testing/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/e-gov/cursor-prompts/spring-testing"><img src="https://agentmods.dev/badge/rules/e-gov/cursor-prompts/spring-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.02802 | $0.02802 |
| Opus 5.5 | $0.01121 | $0.01121 |
| Sonnet 5.5 | $0.00560 | $0.00560 |
| Haiku 4.5 | $0.00280 | $0.00280 |
Grade A, and why
spring-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 329 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Spring Boot Testing Standards
Context
- Apply when creating or modifying Spring Boot test classes
- For testing controllers, services, repositories, and integration scenarios
- When using Spring Boot Test framework with JUnit 5
- For both unit tests and integration tests with TestContainers
- When using jOOQ for database access and complex mocking scenarios
- Follow integration-first testing approach: comprehensive API tests, then focused unit tests
- Note: Some examples show Spring Boot 4-specific patterns (marked with "Spring Boot 4+"). For Spring Boot 3.5, use
PostgreSQLContainer<?>(with generic) andTestRestTemplatefromorg.springframework.boot.test.web.client.TestRestTemplatewithout@AutoConfigureTestRestTemplate
Requirements
- Test Strategy: Prefer integration tests against the API first, then unit tests with mocks for specific logic testing
- Test Structure: Use appropriate Spring Boot test slices (
@WebMvcTest,@DataJpaTest,@JsonTest, etc.) - Integration Tests: Use
@SpringBootTestwith TestContainers for full integration testing - Mocking: Use
@Mock+@InjectMocksfor unit tests. Use@MockitoBeanin Spring test slices when bean replacement is necessary - Test Profiles: Use
@ActiveProfiles("test")for test-specific configuration - Database Testing: Use TestContainers with PostgreSQL for realistic database testing
- Web Layer Testing: Use MockMvc for controller testing with proper content type assertions
- Base Test Classes: Use inheritance for shared test infrastructure and common setup
- TestContainers Configuration: Use singleton pattern with
@ServiceConnectionfor container reuse - External HTTP APIs: Use WireMock for mocking external HTTP dependencies in tests
Examples
private static final Logger log = LoggerFactory.getLogger(TestcontainersConfiguration.class);
private static final DockerImageName POSTGRES_IMAGE = DockerImageName.parse("postgres:15")
.asCompatibleSubstituteFor("postgres");
// Spring Boot 4+ / Testcontainers 2.x: No generic type parameter
// Spring Boot 3.5: Use PostgreSQLContainer<?>
private static final PostgreSQLContainer POSTGRES_CONTAINER;
static {
log.info("Initializing PostgreSQL Testcontainer with reuse enabled...");
POSTGRES_CONTAINER = new PostgreSQLContainer(POSTGRES_IMAGE)
.withDatabaseName("bookstore_test")
.withUsername("test")
.withPassword("test")
.withReuse(true)
.withStartupTimeout(Duration.ofSeconds(60))
.withConnectTimeoutSeconds(60);
POSTGRES_CONTAINER.start();
// Add shutdown hook for robustness
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (POSTGRES_CONTAINER != null && POSTGRES_CONTAINER.isRunning()) {
POSTGRES_CONTAINER.close();
}
}));
}
@Bean
@ServiceConnection
// Spring Boot 4+ / Testcontainers 2.x: No generic type parameter
// Spring Boot 3.5: Use PostgreSQLContainer<?>
public PostgreSQLContainer postgresContainer() {
return POSTGRES_CONTAINER;
}
@DynamicPropertySource
public static void registerDynamicProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", POSTGRES_CONTAINER::getJdbcUrl);
registry.add("spring.datasource.username", POSTGRES_CONTAINER::getUsername);
registry.add("spring.datasource.password", POSTGRES_CONTAINER::getPassword);
registry.add("spring.datasource.driver-class-name", POSTGRES_CONTAINER::getDriverClassName);
}
// Spring Boot 4+ / Testcontainers 2.x: No generic type parameter
// Spring Boot 3.5: Use PostgreSQLContainer<?>
public static PostgreSQLContainer getPostgresContainer() {
return POSTGRES_CONTAINER;
}
}
</example>
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 329 lines · 2,802 tokens per session scan A 54c3485eca41
spring-testing is a cursor rule published in the GitHub repository e-gov/cursor-prompts (34 stars, last pushed 6mo ago), licensed MIT. It adds 2,802 tokens to every session, about $0.0112 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
junit
This guide provides definitive, opinionated best practices for writing high-quality, maintainable, and effective unit tests using JUnit 5 (Jupiter) in Java projects.
mockito
This guide provides definitive best practices for writing robust, maintainable, and readable unit tests using Mockito with JUnit 5, focusing on modern patterns and common pitfalls.
121-java-unit-testing
Java Unit testing guidelines.
java-testing
A specification for generating unit tests for the Repository layer of Spring Boot applications. A repository is the code that reads and writes application data, and Spring Boot is a Java framework for building such applications.
python-general-coding-standards
A set of general standards for Python projects, including type hints, input checking, code style, security, web requests, background work, and tests. It also covers FastAPI-specific tasks such as CORS and authentication.
mocking-dependencies-in-tests
Cursor rule "mocking-dependencies-in-tests" from PaulJPhilp/EffectPatterns, covering mocking dependencies in tests and example.