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.
npx agentmods add rules/e-gov/cursor-prompts/spring-testinggit clone --depth 1 https://github.com/e-gov/cursor-promptsWhat 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 | $0.02802 | $0.02802 |
| Opus 5 | $0.01401 | $0.01401 |
| Sonnet 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 2d 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.
- 2d 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 4mo ago), licensed MIT. It adds 2,802 tokens to every session, about $0.0140 per session on Opus 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
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.