java-coverage
Strategies and patterns to boost test coverage to 80%+ line or 60%+ branch coverage.
Skill by hellyguo
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hellyguo-java-coverage
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/java-coverage
What's inside
- Skill name
java-coverage- Description
- Strategies and patterns to boost test coverage to 80%+ line or 60%+ branch coverage. Includes integration testing, MockMvc, and coverage optimization techniques.
- License
- Apache-2.0
- Instructions
- 191 lines in SKILL.md · view on GitHub
Files (14)
- SKILL.md
- MEMORY.md · assets/
- html-report-template.md · assets/
- pom-test-xml-template.md · assets/
- test-code-templates.md · assets/
- test-framework-cache.md · assets/
- error-guide.md · references/
- build-optimization.md · templates/
- coverage-checklist-table.md · templates/
- coverage-checklist.md · templates/
- error-knowledge-record.md · templates/
- init-flow.md · templates/
- method-classification-matrix.md · templates/
- run-tests-script.md · templates/
SKILL.md (first lines)
# Java 测试覆盖率提升 **目标**: 将测试覆盖率提升至行覆盖率>80%或分支覆盖率>60%;增量测试只需将测试内容覆盖率提升至目标值。 ## 适用范围 本技能面向采用固化文件工作流的项目:以 `MEMORY.md` 记录测试框架与模块信息,以 `docs/test-*.md` 保存模板与缓存。目标项目没有这些文件时,先按 `templates/init-flow.md` 初始化;仅在临时排查时可跳过固化文件,按通用流程执行并在报告中注明。 ## When to Use This Skill Use this skill when the user: - 对当前增量代码进行单元测试 - 对当前项目代码进行单元测试 - 生成增量/全量单元测试报告、增量/全量覆盖率报告 ## 强制要求 1. **不允许修改源项目的文件** 2. **增量源文件 100% 覆盖**(见 [templates/coverage-checklist-table.md](templates/coverage-checklist-table.md)) 3. **生成可重复执行的脚本文件**(见 [templates/run-tests-script.md](templates/run-tests-script.md)) ## 约束条件 在应用任何单元测试更改之前,确保项目能够编译。如果编译失败,请立即停止——在问题解决之前不要继续。应用改进后,运行完整验证。 ## 测试编写要点 本技能不依赖外部测试技能,以下要点直接内联执行。 ### 单元测试 - 使用 JUnit 5 注解(`@Test`、`@BeforeEach`、`@ParameterizedTest`)、AssertJ 断言,按 Given-When-Then 组织用例 - 参数化测试使用 `@ValueSource`、`@CsvSource`、`@MethodSource` - Mockito 使用 `@Mock`、`@InjectMocks`、`when`、`verify`,只 mock 外部依赖,不 mock 被测类内部实现 - 边界条件参考 RIGHT-BICEP 与 CORRECT,覆盖空值、非法输入、循环边界与异常路径 ### Spring Boot 集成测试 - Controller:`@WebMvcTest` + MockMvc,覆盖认证与权限分支 - Service:`@SpringBootTest` + `@MockBean` + 事务回滚 - Repository:`@DataJpaTest` + `TestEntityManager` ## 固化数据优先读取 **执行任何步骤前,先读取以下固化文件(存在则读,缺失按「适用范围」的初始化规则处理),避免重复探索:** | 文件 | 用途 | | ------ | ------ | | `MEMORY.md` | 项目基本信息、测试框架版本、模块结构、用户偏好 | | `docs/test-framework-cache.md` | 测试依赖版本、模块路径、pom-test.xml差异化字段 | | `docs/test-code-templates.md` | 各层测试代码模板(枚举/Domain/Service/工具类) | | `docs/pom-test-xml-template.md` | pom-test.xml 生成模板 | | `docs/html-report-template.md` | HTML 报告样式和组件清单 | | `references/error-guide.md` | 已知错误知识库(编译/运行时问题及修复方案) | **初始化规则**:如果 `MEMORY.md` 已存在且包含测试框架信息 → **跳过初始化**,直接读取全部固化文件后进入增量分析。如果不存在 → 执行初始化流程(见 [templates/init-flow.md](templates/init-flow.md))。 ## 执行流程 ### 步骤一:确认分析类型 当用户提出问题时,需要明确: 1. 该项目是 Java/C/Python 语言(已固化到 MEMORY.md,优先读取) 2. 是增量分析还是全量分析 3. 如果是增量分析,获取差异数据 #### 差异数据获取 | 检测项 | 方法 | 命令 | | -------- | ------ | ------ | | SVN | 项目根目录下存在 `.svn/` 目录 | `svn diff` 或 `svn diff -r 版本1:版本2` | | Git | 项目根目录下存在 `.git/` 目录 | `git diff` 或 `git diff 基线分支...HEAD` | **停止条件**:当无法获取差异数据时,提示用户提供 diff 数据文件路径、版本范围或基线分支名。 ### 步骤二:挑选测试框架 (已固化,优先从 MEMORY.md 读取) - C 项目:Unity (嵌入式) / Check (通用) - Java 项目:JUnit5 + Mockito + AssertJ - Python 项目:pytest **注意**:如果固化文件中已有测试框架信息,直接使用,不重新分析 pom.xml。 ### 步骤三:增量执行流程 **禁止进入 brainstorming 流程**。用户提出增量测试需求时,直接按以下标准流程执行。 #### 3.1 diff 分析与源文件读取(并行化) - Step A [并行]: Agent A 解析 diff 输出变更清单;Agent B 检查各模块是否已有 pom-test.xml - Step B [并行]: 每个 Agent 读取一个模块的变更源文件,不超过5个并行 **Agent 输出约束**:每个源文件只返回类签名、依赖注入列表、新增/变更方法的签名和核心逻辑(10~30行)。单个 Agent 返回总量控制在 200 行以内。 #### 3.2 知识库预防性学习(测试编写前,强制) **在编写任何测试文件之前,必须先读取以下两个文件**: - `MEMORY.md`:重点关注"踩坑速查索引"和"关键类包路径" - `references/error-guide.md`:扫描所有问题标题,提取与当前测试类型相关的预防规则 **输出格式**:读完后输出简表,表明已掌握的规则。 #### 3.3 测试文件编写(同步统计) 编写测试文件时,**同步维护统计数据**,避免最后再扫描一遍。创建每个测试文件时,立即记录:file、module、testCount、paramTestCount、nestedCount、coversSource、coversMethods。 #### 3.4 pom-test.xml 创建(模板化) 检查目标模块是否已有 pom-test.xml: - **已有** → 跳过,直接使用 - **未有** → 从 `docs/pom-test-xml-template.md` 读取模板,填入差异化字段 #### 3.5 编译执行与错误知识沉淀
From hellyguo/self-ai-spec, Apache-2.0.
More from hellyguo/self-ai-spec
- 0.618score
code-review
hellyguo
代码审查框架:通用审查流程 + 语言特定规则引用,支持多语言代码审查
SkillAFreshness: A★ 8Claude Code +9 - 0.614score
code-deconstruct
hellyguo
读取所有源代码,解构为设计图、设计文档、数据库设计; 没有执行文件,请按流程执行
SkillAFreshness: A★ 8Claude Code +9 - 0.592score
gdb-heap-analysis
hellyguo
GDB heap/arena memory analysis for core dump debugging.
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
java-check-spotbugs
hellyguo
SpotBugs静态分析技能:使用SpotBugs、Find Security Bugs、fb-contrib进行Java代码缺陷和安全分析
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
cpp-tscancode
hellyguo
TscanCode静态分析技能:使用TscanCode(腾讯开源)进行C/C++代码质量分析,检测缺陷、安全漏洞和代码风格问题
SkillBFreshness: B★ 8Claude Code +9 - 0.580score
ast-grep-block
hellyguo
基于 ast-grep 的代码审查门禁:使用 code-checklist 规则集对 Java/C++/ANSI C 项目分级扫描(high/medium/low),输出命中清单与 CI 退出码。仅使用 CLI 模式(run.sh),适用于交互式审查、CI 质量门禁、批量检测
SkillBFreshness: B★ 8Claude Code +9 - 0.578score
java-check-pmd
hellyguo
PMD静态分析技能:使用PMD进行Java代码质量分析,检测代码坏味道、编码规范和安全问题
SkillBFreshness: B★ 8Claude Code +9 - 0.578score
java-env
hellyguo
该skill没有执行文件,为信息输入:Java开发需要的环境信息
SkillBFreshness: B★ 8Claude Code +9 - 0.575score
code-refactor
hellyguo
该skill没有执行文件,为操作指引:如何重构
SkillBFreshness: B★ 8Claude Code +9 - 0.575score
java-asprof
hellyguo
该skill没有执行文件,为操作指引:采集Java执行情况
SkillBFreshness: B★ 8Claude Code +9 - 0.574score
code-part-modification
hellyguo
局部代码修改技能:最小化修改完成功能,确保无蝴蝶效应,支持独立测试验证和全量关联检查
SkillBFreshness: B★ 8Claude Code +9 - 0.530score
cpp-clang-tidy
hellyguo
Clang-Tidy 静态分析技能:使用 clang-tidy 进行 C/C++ 代码质量检测,支持自定义检查规则和自动修复
SkillCFreshness: C★ 8Claude Code +9
Signals
- Stars
- 8
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jul 27, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/hellyguo/self-ai-spec
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from hellyguo
- 0.618score
code-review
hellyguo
代码审查框架:通用审查流程 + 语言特定规则引用,支持多语言代码审查
SkillAFreshness: A★ 8Claude Code +9 - 0.614score
code-deconstruct
hellyguo
读取所有源代码,解构为设计图、设计文档、数据库设计; 没有执行文件,请按流程执行
SkillAFreshness: A★ 8Claude Code +9 - 0.592score
gdb-heap-analysis
hellyguo
GDB heap/arena memory analysis for core dump debugging.
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
cpp-tscancode
hellyguo
TscanCode静态分析技能:使用TscanCode(腾讯开源)进行C/C++代码质量分析,检测缺陷、安全漏洞和代码风格问题
SkillBFreshness: B★ 8Claude Code +9 - 0.581score
java-check-spotbugs
hellyguo
SpotBugs静态分析技能:使用SpotBugs、Find Security Bugs、fb-contrib进行Java代码缺陷和安全分析
SkillBFreshness: B★ 8Claude Code +9 - 0.580score
ast-grep-block
hellyguo
基于 ast-grep 的代码审查门禁:使用 code-checklist 规则集对 Java/C++/ANSI C 项目分级扫描(high/medium/low),输出命中清单与 CI 退出码。仅使用 CLI 模式(run.sh),适用于交互式审查、CI 质量门禁、批量检测
SkillBFreshness: B★ 8Claude Code +9
Cite this page
java-coverage skill. Agent Mart. https://agentmart.dev/skills/hellyguo-java-coverage (last updated 2026-10-24)