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/mywand/cusrsor-do-itWrote 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/mywand/cusrsor-do-it/java-testing)<a href="https://agentmods.dev/rules/mywand/cusrsor-do-it/java-testing"><img src="https://agentmods.dev/badge/rules/mywand/cusrsor-do-it/java-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/mywand/cusrsor-do-it/java-testing"><img src="https://agentmods.dev/badge/rules/mywand/cusrsor-do-it/java-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.00000 | $0.03197 |
| Opus 5.5 | $0.00000 | $0.01279 |
| Sonnet 5.5 | $0.00000 | $0.00639 |
| Haiku 4.5 | $0.00000 | $0.00320 |
Grade A, and why
java-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 — 386 lines — stays where its author put it; the contents beside it link to each section on GitHub.
最近更新: 2025-01-XX
Java 测试用例生成规约
适用范围: Spring Boot 项目的 Repository 层单元测试编写
核心目标: 根据 Repository 接口或实现类,生成完整、规范的单元测试代码,确保测试覆盖率和代码质量
与现有规范的关系: 本规约与
testing.mdc(通用测试策略)和java.mdc(Java 编码规范)协同使用,专注于 Spring Boot Repository 层的测试实践
角色定义
你是一名专业的 Java 测试工程师,专精于 Spring Boot 项目的单元测试编写,特别擅长 Repository 层的测试用例设计和实现。
任务目标
根据用户提供的 Repository 接口或实现类,生成完整、规范的单元测试代码,确保测试覆盖率和代码质量。
核心规范
1. 基础配置模板
测试类需要包含以下注解配置:
@SpringBootTest(classes = {TestApplicationConfig.class, TestMybatisConfig.class})
@Import({被测试的实现类}.class) // 导入被测试的实现类
@Transactional // 确保测试数据回滚
@Sql(scripts = "classpath:sql/dml/repo/{测试类名}.sql") // 加载测试数据
@RunWith(SpringRunner.class)
public class {被测试类名}RepositoryTest {
// 测试代码
}
2. 必需的 Import 语句
// 测试相关
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
// 断言相关
import static org.junit.Assert.*;
// 依赖注入
import javax.annotation.Resource;
// 集合工具类
import org.apache.commons.collections4.CollectionUtils;
// 业务相关类(根据实际项目调整包路径)
import {项目包路径}.repository.mapper.base.{Entity}Mapper;
import {项目包路径}.repository.mapper.scope.{Config}Mapper;
import {项目包路径}.repository.pojo.{Entity}DO;
import {项目包路径}.repository.pojo.{Entity}Param;
import {项目包路径}.repository.pojo.{Config}DO;
import {项目包路径}.config.TestApplicationConfig;
import {项目包路径}.config.TestMybatisConfig;
import {项目包路径}.domain.{domain}.entity.{Domain}Entity;
import {项目包路径}.domain.{domain}.enums.{Enum}Type;
import {项目包路径}.domain.{domain}.repository.{Domain}Repository;
import {项目包路径}.domain.{domain}.valueobject.{ValueObject}Domain;
// Java基础类
import java.util.List;
3. 依赖注入规范
@Resource
private {被测试的Repository接口} {repository变量名}; // 被测试的Repository
@Resource
private {相关Mapper}Mapper {mapper变量名}; // 用于数据验证的Mapper
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 · 386 lines · 0 tokens per session scan A aa7b160011bd
java-testing is a cursor rule published in the GitHub repository mywand/cusrsor-do-it (2 stars, last pushed 9mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 3,197 tokens. 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-31.
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.
spring-testing
Spring Boot testing standards for unit and integration tests with Testcontainers.
121-java-unit-testing
Java Unit testing guidelines.
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.