我的 PITEST 无法运行。覆盖生成minion异常退出。我需要帮助来正确配置我的 pom.xml

Øyv*_*oth 13 java mutation-testing maven-3 pitest junit-jupiter

运行时mvn org.pitest:pitest-maven:mutationCoverage出现如下错误( Environment: Windows 10, Maven 3.6.1, Java 11, junit-jupiter 5.4.1, pitest 1.4.7

[ERROR] Failed to execute goal org.pitest:pitest-maven:1.4.7:mutationCoverage (default-cli) on project hello-strange-world: Execution default-cli of goal org.pitest:pitest-maven:1.4.7:mutationCoverage failed: Coverage generation minion exited abnormally. Please check the classpath.
[ERROR]
[ERROR] Please copy and paste the information and the complete stacktrace below when reporting an issue
[ERROR] VM : Java HotSpot(TM) 64-Bit Server VM
[ERROR] Vendor : Oracle Corporation
[ERROR] Version : 11.0.2+9-LTS
[ERROR] Uptime : 4936
[ERROR] Input ->
[ERROR]  1 : -Dclassworlds.conf=C:\DEVRES\apache-maven-3.6.1\bin\..\bin\m2.conf
[ERROR]  2 : -Dmaven.home=C:\DEVRES\apache-maven-3.6.1\bin\..
[ERROR]  3 : -Dlibrary.jansi.path=C:\DEVRES\apache-maven-3.6.1\bin\..\lib\jansi-native
[ERROR]  4 : -Dmaven.multiModuleProjectDirectory=D:\DATA02\DEVELOPMENT\hellostrangeworld
[ERROR] BootClassPathSupported : false
[ERROR]
[ERROR]
[ERROR] Please copy and paste the information and the complete stacktrace below when reporting an issue
[ERROR] VM : Java HotSpot(TM) 64-Bit Server VM
[ERROR] Vendor : Oracle Corporation
[ERROR] Version : 11.0.2+9-LTS
[ERROR] Uptime : 4936
[ERROR] Input ->
[ERROR]  1 : -Dclassworlds.conf=C:\DEVRES\apache-maven-3.6.1\bin\..\bin\m2.conf
[ERROR]  2 : -Dmaven.home=C:\DEVRES\apache-maven-3.6.1\bin\..
[ERROR]  3 : -Dlibrary.jansi.path=C:\DEVRES\apache-maven-3.6.1\bin\..\lib\jansi-native
[ERROR]  4 : -Dmaven.multiModuleProjectDirectory=D:\DATA02\DEVELOPMENT\hellostrangeworld
[ERROR] BootClassPathSupported : false
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Run Code Online (Sandbox Code Playgroud)

参考:https://github.com/ooroor/hellostrangeworld/blob/make_pitest_work/pom.xml

met*_*ron 8

我按照 Mkyong 先生在Maven \xe2\x80\x93 PITest 突变测试示例中的示例修复了 JUnit 5 和“minion 异常退出”问题。

\n

向下滚动到 pom.xml 部分,在 pom 文件的构建部分中定义了一个偷偷摸摸的 Pitest-junit5-plugin 依赖项:

\n
<dependencies>\n    <dependency>\n        <groupId>org.pitest</groupId>\n        <artifactId>pitest-junit5-plugin</artifactId>\n        <version>0.8</version>\n    </dependency>\n</dependencies>\n
Run Code Online (Sandbox Code Playgroud)\n

这是我在 Maven 测试阶段用于 jacoco 代码覆盖率和坑突变的工作 pom.xml。如果您只对坑部分感兴趣,请随意从构建标签中删除整个 jacoco 插件部分。

\n
<?xml version="1.0" encoding="UTF-8"?>\n<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n         xmlns="http://maven.apache.org/POM/4.0.0"\n         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\n    <modelVersion>4.0.0</modelVersion>\n\n    <groupId>code</groupId>\n    <artifactId>scans</artifactId>\n    <version>0.0.1-SNAPSHOT</version>\n\n    <properties>\n        <maven.compiler.target>1.8</maven.compiler.target>\n        <maven.compiler.source>1.8</maven.compiler.source>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.junit.jupiter</groupId>\n            <artifactId>junit-jupiter-engine</artifactId>\n            <version>5.5.2</version>\n            <scope>test</scope>\n        </dependency>\n    </dependencies>\n\n    <build>\n        <plugins>\n\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-surefire-plugin</artifactId>\n                <version>3.0.0-M1</version>\n            </plugin>\n\n            <plugin>\n                <groupId>org.jacoco</groupId>\n                <artifactId>jacoco-maven-plugin</artifactId>\n                <version>0.8.4</version>\n                <executions>\n\n                    <execution>\n                        <goals>\n                            <goal>prepare-agent</goal>\n                        </goals>\n                    </execution>\n\n                    <!--attach execution to maven\'s test phase-->\n                    <execution>\n                        <id>report</id>\n                        <phase>test</phase>\n                        <goals>\n                            <goal>report</goal>\n                        </goals>\n                    </execution>\n\n                    <!-- fail build if line coverage is lover then defined threshold -->\n                    <execution>\n                        <id>jacoco-check</id>\n                        <goals>\n                            <goal>check</goal>\n                        </goals>\n                        <configuration>\n                            <rules>\n                                <rule>\n                                    <element>PACKAGE</element>\n                                    <limits>\n                                        <limit>\n                                            <counter>LINE</counter>\n                                            <value>COVEREDRATIO</value>\n                                            <minimum>0.9</minimum>\n                                        </limit>\n                                    </limits>\n                                </rule>\n                            </rules>\n                        </configuration>\n                    </execution>\n\n                </executions>\n            </plugin>\n\n\n            <plugin>\n                <groupId>org.pitest</groupId>\n                <artifactId>pitest-maven</artifactId>\n                <version>1.4.10</version>\n\n                <!--attach execution to maven\'s test phase-->\n                <executions>\n                    <execution>\n                        <id>pit-report</id>\n                        <phase>test</phase>\n                        <goals>\n                            <goal>mutationCoverage</goal>\n                        </goals>\n                    </execution>\n                </executions>\n\n                <!--allows to work with JUnit 5-->\n                <dependencies>\n                    <dependency>\n                        <groupId>org.pitest</groupId>\n                        <artifactId>pitest-junit5-plugin</artifactId>\n                        <version>0.9</version>\n                    </dependency>\n                </dependencies>\n\n                <!--optional-->\n                <configuration>\n                    <targetClasses>\n                        <param>code.scans*</param>\n                    </targetClasses>\n                    <targetTests>\n                        <param>code.scans*</param>\n                    </targetTests>\n                </configuration>\n\n            </plugin>\n\n        </plugins>\n    </build>\n\n</project>\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的环境详细信息:

\n
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T02:58:13-05:00)\nMaven home: C:\\DEV\\apache-maven-3.5.2\\bin\\..\nJava version: 1.8.0_221, vendor: Oracle Corporation\nJava home: C:\\Progra~1\\Java\\jdk1.8.0_221\\jre\nDefault locale: en_US, platform encoding: Cp1252\nOS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"\n
Run Code Online (Sandbox Code Playgroud)\n


Mar*_*lic 6

JUnit 似乎缺少依赖项,因此请尝试将以下内容添加到pom.xml

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)