Pitest 不是 运行 Kotlintest 测试

Pitest not running with Kotlintest tests

我在我的项目中使用 kotlintest,我想 运行 使用 pitest 进行突变测试。

已经尝试单独使用 pitest 和 junit5 插件,但结果总是:

Found  0 tests


================================================================================
- Statistics
================================================================================
>> Generated 610 mutations Killed 0 (0%)
>> Ran 0 tests (0 tests per mutation)

我正在使用:

我知道 kotlintest 从 v3.3.0 开始支持 pitest(根据 here),但我不知道如何让它工作。

有什么想法可以正确地 运行 吗?

谢谢!

我破解了

有关参考,请参阅 gradle pitest plugin documentation

中的 "PIT test-plugins support" 部分

首先,您需要像这样设置 buildscript

buildscript {
   repositories {
       mavenCentral()
   }
   configurations.maybeCreate('pitest')
   dependencies {
       classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.4.5'
       pitest "io.kotlintest:kotlintest-plugins-pitest:3.4.2"
   }
}

然后你应该在 pitest

中设置 PIT 插件名称
pitest {
    testPlugin = 'KotlinTest'
    // rest of your pitest configuration
}

之后它应该可以工作了。希望这对您有所帮助!