基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ForceInjection/domain-driven-design-skills --skill test-dev命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Conduct deep academic research for philosophy, neuroscience, cognitive science, and theoretical computer science (computability, complexity, AI theory, logic). Use when user asks to: research academic topics, find scholarly papers, conduct literature reviews, analyze citations, synthesize research findings, explore philosophical arguments, investigate consciousness/cognition, study computability/decidability/Turing machines, or analyze academic debates. Triggers on: 'research papers', 'literature review', 'academic sources', 'scholarly articles', 'philosophy of mind', 'computability theory', 'neuroscience studies', 'find papers on', 'what does the research say'.
Create clear action plans with steps, success criteria, and risk awareness. Use before implementing features, making changes, starting projects, or anytime you need a roadmap to success. Triggers on "plan this", "how should we approach", "what's the strategy", "steps to complete", or when facing complex multi-step work.
Add keyboard navigation to a feature using CommandRegistryService. Use when implementing keyboard shortcuts, vim-style navigation, or hotkeys for a page or component.
| name | test-dev |
| description | 测试开发专家,基于JUnit 5 + AssertJ + Mockito + JaCoCo的标准化测试规范。 |
| version | v1.0 |
| tags | ["testing","junit5","assertj","mockito","jacoco","coverage"] |
| allowed-tools | Read, Write, Edit, Bash |
| requires-skills | [] |
单一职责: 标准化测试框架 - JUnit 5 + AssertJ + Mockito + JaCoCo
<junit.version>5.11.3</junit.version>
<assertj.version>3.27.0</assertj.version>
<mockito.version>5.8.0</mockito.version>
<jacoco.version>0.8.12</jacoco.version>
| 模块 | 行覆盖率 | 分支覆盖率 |
|---|---|---|
| 核心引擎 | ≥90% | ≥85% |
| 指令实现 | ≥95% | ≥90% |
| 总体 | ≥85% | ≥80% |
格式: test{场景}_{期望结果}_when{条件}
// ✅ 好示例
void testIAddReturnsSum_whenStackHasTwoIntegers() { }
void testTypeCheckerRejectsInvalidBinaryOp_whenOperandsIncompatible() { }
// ❌ 差示例
void test1() { }
void testMethod() { }
@Test
@DisplayName("应正确执行 IADD 指令")
void testIAddInstruction() {
// Given - 准备测试数据
OperandStack stack = new OperandStack(10);
stack.push(10);
stack.push(20);
// When - 执行被测操作
instruction.execute(context);
// Then - 验证结果
assertThat(stack.pop()).isEqualTo(30);
}
// ✅ 推荐: AssertJ流畅断言
assertThat(result)
.isNotNull()
.isEqualTo(expected);
assertThat(list)
.isNotEmpty()
.hasSize(3);
// ❌ 避免: JUnit旧式断言
assertEquals(expected, result); // 顺序易错
@Tag("unit")
class InstructionTest {
@Test
@DisplayName("加法指令应正确计算")
void testAdd() {
// Given
AddInstruction add = new AddInstruction();
// When
add.execute(context);
// Then
assertThat(result).isEqualTo(8);
}
}
@Tag("integration")
class CompilerPipelineTest {
@Test
@DisplayName("完整编译流程应处理循环")
void testFullCompilation() {
// Given
String source = loadTestProgram("fibonacci.cymbol");
// When
CompilationResult result = compiler.compile(source);
// Then
assertThat(result.isSuccess()).isTrue();
}
}
@ParameterizedTest
@ValueSource(ints = {0, 1, 10, 100})
@DisplayName("数据栈应处理各种值")
void testStackPushPop(int value) {
stack.push(value);
assertThat(stack.pop()).isEqualTo(value);
}
# 运行测试
mvn test # 全部测试
mvn test -pl ep21 # 特定模块
mvn test -Dtest="*Optimizer*" # 特定测试
# 覆盖率
mvn jacoco:report # 生成报告
open ep21/target/site/jacoco/index.html # 查看报告
mvn jacoco:check # 检查覆盖率
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 测试独立失败 | 共享静态状态 | 使用@BeforeEach初始化 |
| 测试有逻辑 | if/else分支 | 拆分成多个测试 |
| 覆盖率不足 | 缺少边界测试 | 添加边界条件测试 |
版本: v1.0 | 垂直职责: 测试开发 | 2025-12-23