pitest-mutation
БесплатноБез исполняемых скриптовНе проверенUse for any question about mutation testing in Java or Kotlin, or when a JVM suite has high line coverage but may assert nothing: sets up PIT (PITest) with…
от testland★ 18 звёзд на GitHubОб этом скилле
pitest-mutation
Overview
Per pit-home:
"PIT is a mutation testing system for Java and JVM applications. It automatically introduces faults into code, then runs tests to see if they catch these modifications."
"Faults (or mutations) are automatically seeded into your code, then your tests are run. If your tests fail then the mutation is killed, if your tests pass then the mutation lived." (pit-home)
Per pit-home, PIT differentiates on speed: "analyzes in minutes rather than days" vs older mutation tools.
When to use
- A JVM project (Java, Kotlin via plugin) needs mutation-quality verification.
- A team wants to identify "partial testing that traditional metrics miss" (pit-home).
- Maven / Gradle integration is required (PIT is first-class for both).
How to use
- Add the
pitest-maven(orinfo.solidsoft.pitestGradle) plugin, includingpitest-junit5-pluginfor JUnit 5 suites. - Point
targetClassesat production packages andtargetTestsat the matching test packages - never mutate test code. - Set
mutationThresholdandcoverageThresholdto the current baseline and request HTML + XMLoutputFormats. - Run
mvn pitest:mutationCoverage(or./gradlew pitest) and opentarget/pit-reports/<timestamp>/index.html. - For each surviving mutant, add or strengthen a test until it is killed.
- Use
-DwithHistoryfor PR runs so only changed code is re-mutated. - In CI, run full weekly and incremental per-PR, uploading
target/pit-reports/as an artifact.
Step 1 - Install (Maven)
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.17.0</version>
<configuration>
<targetClasses>
<param>com.example.checkout.*</param>
</targetClasses>
<targetTests>
<param>com.example.checkout.*Test</param>
</targetTests>
<mutationThreshold>75</mutationThreshold>
<coverageThreshold>80</coverageThreshold>
<outputFormats>
<format>HTML</format>
<format>XML</format>
</outputFormats>
</configuration>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</plugin>
For JUnit 5, the pitest-junit5-plugin is required; for JUnit 4
the default plugin works.
Step 2 - Run
mvn pitest:mutationCoverage
Reports land at target/pit-reports/<timestamp>/. The
index.html shows per-class mutation coverage.
Step 3 - Configure (Gradle)
plugins {
id 'java'
id 'info.solidsoft.pitest' version '1.15.0'
}
pitest {
targetClasses = ['com.example.checkout.*']
targetTests = ['com.example.checkout.*Test']
mutationThreshold = 75
coverageThreshold = 80
outputFormats = ['HTML', 'XML']
junit5PluginVersion = '1.2.1'
}
// Run via:
// ./gradlew pitest
Step 4 - Mutators
PIT's default mutator set covers conditional, arithmetic, return
value, void method calls, and constructor calls. Activate
additional mutator sets via <mutators>:
<mutators>
<mutator>STRONGER</mutator> <!-- All default + extra -->
<mutator>DEFAULTS</mutator> <!-- Default set -->
<mutator>ALL</mutator> <!-- Everything -->
</mutators>
Per pit-home, reports "combine line coverage with mutation coverage data."
Step 5 - pitmp-maven-plugin for incremental runs
For PRs, only mutate changed code:
mvn pitest:mutationCoverage -DwithHistory
withHistory reads / writes a history file in target/; subsequent
runs only mutate code different from the cached history. For PR
runs, combine with git diff to scope further:
mvn pitest:mutationCoverage \
-Dfeatures='+gitci(level[1])' \
-Dpitmp.git.diff.target=origin/main
(The pitmp-maven-plugin extension adds git-diff-based scoping;
not in core PIT.)
Step 6 - CI integration
- uses: actions/setup-java@v4
with: { distribution: temurin, java-version: '21' }
- name: Mutation testing (full)
if: github.event_name == 'schedule' # weekly cron
run: mvn pitest:mutationCoverage
- name: Mutation testing (incremental, PR)
if: github.event_name == 'pull_request'
run: mvn pitest:mutationCoverage -DwithHistory
- uses: actions/upload-artifact@v4
if: always()
with:
name: pit-reports
path: target/pit-reports/
The XML output (mutations.xml) is machine-parseable for
dashboards.
Step 7 - Kotlin support
PIT works with Kotlin via standard Maven/Gradle Kotlin plugins; mutators apply to compiled bytecode. Per pit-home, "ArcMutate, from the same team, extends PIT with Kotlin support, Spring integration, and Git analysis" - for richer Kotlin / Spring support, evaluate ArcMutate (commercial).
Worked example
CheckoutService in com.example.checkout has a free-shipping rule and green JUnit 5 tests.
- Wire the plugin (
Установить pitest-mutation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл pitest-mutation?
Use for any question about mutation testing in Java or Kotlin, or when a JVM suite has high line coverage but may assert nothing: sets up PIT (PITest) with Maven or Gradle, target classes, mutators, mutation-score thresholds that fail the build, incremental runs, Kotlin support and the HTML and XML reports.
Как установить скилл pitest-mutation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pitest-mutation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic