Kotest Pitest拡張
Pitest拡張について紹介する。
ミューテーションテストツールPitestは、拡張モジュールを通じてKotestと統合される。
Gradle configuration
Pitestを構成した後、依存関係にもio.kotest.extensions:kotest-extensions-pitestモジュールを追加する。
testImplementation("io.kotest.extensions:kotest-extensions-pitest:<version>")
NOTE: Pitestは拡張機能であるため、コアモジュールとは異なるMavenグループ名(
io.kotest.extensions)を使用する。
その後、Kotestをテストプラグイン(testPlugin)として使用することをPitestに知らせる必要がある。
// Assuming that you have already configured the Gradle/Maven extension
configure<PitestPluginExtension> {
// testPlugin.set("Kotest") // needed only with old PIT <1.6.7, otherwise having kotest-extensions-pitest on classpath is enough
targetClasses.set(listOf("my.company.package.*"))
}
Maven configuration
まずMaven Pitestプラグインを構成する必要がある。
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>${pitest-maven.version}</version>
<configuration>
<targetClasses>...</targetClasses>
<coverageThreshold>...</coverageThreshold>
... other configurations as needed
</configuration>
</plugin>
その後、Pitest Kotest拡張に依存関係を追加する。
<dependencies>
... the other Kotest dependencies like kotest-runner-junit5-jvm
<dependency>
<groupId>io.kotest.extensions</groupId>
<artifactId>kotest-extensions-pitest</artifactId>
<version>${kotest-extensions-pitest.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
これでPitestを実行し、Maven Pitestプラグインで説明されているようにレポートを取得できる。