PIT覆盖生成minion异常退出

问题描述 投票:0回答:4

在 build.gradle 中添加所有必需的配置后,在我的项目中运行 Pitest gradle 任务时,我看到以下堆栈跟踪。你能帮我解决这个问题吗?我使用的是 1.5.1 版本的插件。

已按照 https://github.com/szpak/gradle-pitest-plugin

中的说明在 build.gradle 中完成更改
7:00:32 PM PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue.
    7:00:33 PM PIT >> INFO : Sending 46 test classes to minion
    7:00:33 PM PIT >> INFO : Sent tests to minion
    7:00:33 PM PIT >> SEVERE : Error generating coverage. Please check that your classpath contains modern JUnit 4 or PIT test plugin for other test tool (JUnit 5, TestNG, ...) is enabled.
    Exception in thread "main" org.pitest.util.PitError: Coverage generation minion exited abnormally. Please check the classpath and/or enable test plugin for used test tool.

Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : OpenJDK 64-Bit Server VM
Vendor : Private Build
Version : 25.252-b09
Uptime : 1723
Input -> 
 1 : -Dfile.encoding=UTF-8
 2 : -Duser.country=US
 3 : -Duser.language=en
 4 : -Duser.variant
BootClassPathSupported : true


Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : OpenJDK 64-Bit Server VM
Vendor : Private Build
Version : 25.252-b09
Uptime : 1724
Input -> 
 1 : -Dfile.encoding=UTF-8
 2 : -Duser.country=US
 3 : -Duser.language=en
 4 : -Duser.variant
BootClassPathSupported : true

        at org.pitest.util.Unchecked.translateCheckedException(Unchecked.java:20)
        at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:105)
        at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:51)
        at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:115)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:121)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:51)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:87)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
Caused by: org.pitest.util.PitError: Coverage generation minion exited abnormally. Please check the classpath and/or enable test plugin for used test tool.

Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : OpenJDK 64-Bit Server VM
Vendor : Private Build
Version : 25.252-b09
Uptime : 1723
Input -> 
 1 : -Dfile.encoding=UTF-8
 2 : -Duser.country=US
 3 : -Duser.language=en
 4 : -Duser.variant
BootClassPathSupported : true

        at org.pitest.coverage.execute.DefaultCoverageGenerator.gatherCoverageData(DefaultCoverageGenerator.java:143)
        at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:89)
        ... 6 more

FAILURE: Build failed with an exception.
code-coverage mutation-testing pitest
4个回答
3
投票

根据错误消息,您没有启用 Pitest junit 5 插件。

如果你添加

junit5PluginVersion = '0.12'

对于配置,插件将被启用并且测试应该被选择。


0
投票

问题是最新版本的 PIT 使用的是 JUnit5,而我使用的是 JUnit4。所以,我通过迁移到 JUnit5 解决了这个问题

如果您使用的是 Maven,请将以下行添加到您的 pom 文件中:

  <properties>
    <junit.jupiter.version>5.8.1</junit.jupiter.version>
    <junit.platform.version>1.8.1</junit.platform.version>
  </properties>
  
  <dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-suite</artifactId>
        <version>${junit.platform.version}</version>
        <scope>test</scope>
    </dependency>

</dependencies>

0
投票

这是因为我们没有提供正确版本的 junit5PluginVersion 在KTS中我们需要给出这样的配置

    // Configure the PitestPluginExtension
configure<PitestPluginExtension> {
    // Set the JUnit 5 plugin version
    junit5PluginVersion.set("1.2.0")

    // Avoid calls to the specified classes
    avoidCallsTo.set(setOf("kotlin.jvm.internal"))

    // Set the mutators to be used
    mutators.set(setOf("STRONGER"))

    // Specify the target classes for mutation testing
    targetClasses.set(setOf("com.arcesium.treasury.margin.web.service.*"))

    // Specify the test classes for mutation testing
    targetTests.set(setOf("com.arcesium.treasury.margin.web.service.*"))

    // Set the number of threads for mutation testing
    threads.set(Runtime.getRuntime().availableProcessors())

    // Set the output formats for the mutation testing report
    outputFormats.set(setOf("XML", "HTML"))

    // Set the mutation threshold
    mutationThreshold.set(0)

    // Set the coverage threshold
    coverageThreshold.set(0)
}

// Make the 'check' task depend on the 'pitest' task
tasks.named("check") {
    dependsOn(":pitest")
}

0
投票

确保您没有任何 jqwik 依赖项。由于某种原因,这与最糟糕的配置混淆了。

© www.soinside.com 2019 - 2024. All rights reserved.