MCP HubMCP Hub
返回技能列表

mutation-testing

proffesor-for-testing
更新于 Today
149 次查看
99
21
99
在 GitHub 上查看
其他mutationstrykertest-qualitykill-rateassertionseffectiveness

关于

The mutation-testing skill evaluates test suite effectiveness by automatically introducing code mutations and measuring the kill rate. It helps developers identify weak tests and improve test quality by revealing which bugs tests actually catch. This specialized-testing skill uses multiple agents to mutate code, run tests against mutants, and highlight areas needing stronger assertions.

快速安装

Claude Code

推荐
插件命令推荐
/plugin add https://github.com/proffesor-for-testing/agentic-qe
Git 克隆备选方式
git clone https://github.com/proffesor-for-testing/agentic-qe.git ~/.claude/skills/mutation-testing

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Mutation Testing

<default_to_action> When validating test quality or improving test effectiveness:

  1. MUTATE code (change + to -, >= to >, remove statements)
  2. RUN tests against each mutant
  3. VERIFY tests catch mutations (kill mutants)
  4. IDENTIFY surviving mutants (tests need improvement)
  5. STRENGTHEN tests to kill surviving mutants

Quick Mutation Metrics:

  • Mutation Score = Killed / (Killed + Survived)
  • Target: > 80% mutation score
  • Surviving mutants = weak tests

Critical Success Factors:

  • High coverage ≠ good tests (100% coverage, 0% assertions)
  • Mutation testing proves tests actually catch bugs
  • Focus on critical code paths first </default_to_action>

Quick Reference Card

When to Use

  • Evaluating test suite quality
  • Finding gaps in test assertions
  • Proving tests catch bugs
  • Before critical releases

Mutation Score Interpretation

ScoreInterpretation
90%+Excellent test quality
80-90%Good, minor improvements
60-80%Needs attention
< 60%Significant gaps

Common Mutation Operators

CategoryOriginalMutant
Arithmetica + ba - b
Relationalx >= 18x > 18
Logicala && ba || b
Conditionalif (x)if (true)
Statementreturn x(removed)

How Mutation Testing Works

// Original code
function isAdult(age) {
  return age >= 18; // ← Mutant: change >= to >
}

// Strong test (catches mutation)
test('18 is adult', () => {
  expect(isAdult(18)).toBe(true); // Kills mutant!
});

// Weak test (mutation survives)
test('19 is adult', () => {
  expect(isAdult(19)).toBe(true); // Doesn't catch >= vs >
});
// Surviving mutant → Test needs boundary value

Using Stryker

# Install
npm install --save-dev @stryker-mutator/core @stryker-mutator/jest-runner

# Initialize
npx stryker init

Configuration:

{
  "packageManager": "npm",
  "reporters": ["html", "clear-text", "progress"],
  "testRunner": "jest",
  "coverageAnalysis": "perTest",
  "mutate": [
    "src/**/*.ts",
    "!src/**/*.spec.ts"
  ],
  "thresholds": {
    "high": 90,
    "low": 70,
    "break": 60
  }
}

Run:

npx stryker run

Output:

Mutation Score: 87.3%
Killed: 124
Survived: 18
No Coverage: 3
Timeout: 1

Fixing Surviving Mutants

// Surviving mutant: >= changed to >
function calculateDiscount(quantity) {
  if (quantity >= 10) { // Mutant survives!
    return 0.1;
  }
  return 0;
}

// Original weak test
test('large order gets discount', () => {
  expect(calculateDiscount(15)).toBe(0.1); // Doesn't test boundary
});

// Fixed: Add boundary test
test('exactly 10 gets discount', () => {
  expect(calculateDiscount(10)).toBe(0.1); // Kills mutant!
});

test('9 does not get discount', () => {
  expect(calculateDiscount(9)).toBe(0); // Tests below boundary
});

Agent-Driven Mutation Testing

// Analyze mutation score and generate fixes
await Task("Mutation Analysis", {
  targetFile: 'src/payment.ts',
  generateMissingTests: true,
  minScore: 80
}, "qe-test-generator");

// Returns:
// {
//   mutationScore: 0.65,
//   survivedMutations: [
//     { line: 45, operator: '>=', mutant: '>', killedBy: null }
//   ],
//   generatedTests: [
//     'test for boundary at line 45'
//   ]
// }

// Coverage + mutation correlation
await Task("Coverage Quality Analysis", {
  coverageData: coverageReport,
  mutationData: mutationReport,
  identifyWeakCoverage: true
}, "qe-coverage-analyzer");

Agent Coordination Hints

Memory Namespace

aqe/mutation-testing/
├── mutation-results/*   - Stryker reports
├── surviving/*          - Surviving mutants
├── generated-tests/*    - Tests to kill mutants
└── trends/*             - Mutation score over time

Fleet Coordination

const mutationFleet = await FleetManager.coordinate({
  strategy: 'mutation-testing',
  agents: [
    'qe-test-generator',     // Generate tests for survivors
    'qe-coverage-analyzer',  // Coverage correlation
    'qe-quality-analyzer'    // Quality assessment
  ],
  topology: 'sequential'
});

Related Skills


Remember

High code coverage ≠ good tests. 100% coverage but weak assertions = useless. Mutation testing proves tests actually catch bugs.

Focus on critical paths first. Don't mutation test everything - prioritize payment, authentication, data integrity code.

With Agents: Agents run mutation analysis, identify surviving mutants, and generate missing test cases to kill them. Automated improvement of test quality.

GitHub 仓库

proffesor-for-testing/agentic-qe
路径: .claude/skills/mutation-testing
agenticqeagenticsfoundationagentsquality-engineering

相关推荐技能

regression-testing

其他

该Skill提供智能化的回归测试策略,帮助开发者在验证代码修复时确保现有功能不被破坏。它通过变更影响分析和风险评估,智能选择测试用例并优化执行顺序,避免全量测试的时间消耗。适用于CI/CD流程中的测试套件规划、变更验证和快速反馈场景,能显著提升回归测试效率。

查看技能

test-environment-management

其他

该Skill专注于测试环境管理,提供基于基础设施即代码的自动化配置,支持使用Docker/Kubernetes确保环境一致性。它适用于创建与生产环境保持高度一致的测试环境,并通过服务虚拟化和成本优化策略来提升测试效率。开发者可用它来管理测试基础设施生命周期,优化资源使用成本。

查看技能

localization-testing

其他

该Skill为全球化产品提供国际化和本地化测试,特别适用于发布新市场或构建多语言产品。它能验证翻译覆盖、测试本地格式(日期/货币)、检查RTL布局和字符编码,并评估文化适应性。开发者可通过它系统检测本地化问题,确保产品符合不同区域的要求。

查看技能

mobile-testing

其他

该Skill为移动应用提供全面的测试支持,涵盖iOS和Android平台。它专门处理移动端特有场景,如手势操作、传感器、权限及设备碎片化测试,适用于原生应用、混合应用和移动网页。通过定义设备覆盖矩阵和使用真机测试,帮助开发者在1000+设备变体上保障应用质量。

查看技能