Gradle - 运行 仅对子项目进行 pitest

Gradle - Run pitest only on subprojects

我正在尝试让 Jenkins 运行 pitest 参与我的项目。 父项目 build.gradle 与子项目的事实似乎是一个问题。

当运行宁gradle pitest我得到:

12:14:17 PIT >> INFO : Sending 0 test classes to minion

12:14:17 PIT >> INFO : Sent tests to minion

12:14:17 PIT >> SEVERE : Error generating coverage. Please check that your classpath contains JUnit 4.6 or above.

Exception in thread "main" org.pitest.util.PitError: Coverage generation minion exited abnormally. Please check the classpath.

我尝试只为子项目配置 pitest,正如某些帖子中所建议的那样,但没有任何区别

subprojects { subproject ->
  pitest {
  verbose = true
  targetClasses = ['com.xyz.*']
  threads = 16
  enableDefaultIncrementalAnalysis = true
  historyInputLocation = ['build/reports/pitest/fastermutationtesting']
  historyOutputLocation = ['build/reports/pitest/fastermutationtestingoutput']
  outputFormats = ['XML', 'HTML']
  timestampedReports = true
  mutationThreshold = 80
}

如果我尝试 运行 对子项目进行 pitest,例如gradle subOne:pitest gradle 表示不存在这样的任务。

有什么建议吗?

试试 gradle :subOne:pitest.

您可以在主项目中包含pitest,而无需为子项目重复

问题实际上是插件的应用方式。

设置后

id 'info.solidsoft.pitest' version '1.3.0' apply false

plugins中然后添加

apply plugin: 'info.solidsoft.pitest'

subprojects 中一切正常。