我的 PITEST 不会 运行。覆盖生成minion异常退出。我需要帮助来正确配置我的 pom.xml
My PITEST won't run. Coverage generation minion exited abnormally. I need help to configure my pom.xml properly
当运行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
参考:https://github.com/ooroor/hellostrangeworld/blob/make_pitest_work/pom.xml
JUnit 似乎缺少依赖项,因此请尝试将以下内容添加到 pom.xml
:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
我通过关注先生修复了 JUnit 5 和 "minion exited abnormally" 问题。 Mkyong 示例 here.
向下滚动到 pom.xml 部分,在 pom 文件的构建部分中定义了一个偷偷摸摸的 pitest-junit5-plugin 依赖项:
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.8</version>
</dependency>
</dependencies>
这是我在 maven 测试阶段针对 jacoco 代码覆盖率和 pit-mutation 的工作pom.xml。如果您只对 pit 部分感兴趣,请随意从构建标签中删除整个 jacoco 插件部分。
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>code</groupId>
<artifactId>scans</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!--attach execution to maven's test phase-->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<!-- fail build if line coverage is lover then defined threshold -->
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.9</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.10</version>
<!--attach execution to maven's test phase-->
<executions>
<execution>
<id>pit-report</id>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
</executions>
<!--allows to work with JUnit 5-->
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.9</version>
</dependency>
</dependencies>
<!--optional-->
<configuration>
<targetClasses>
<param>code.scans*</param>
</targetClasses>
<targetTests>
<param>code.scans*</param>
</targetTests>
</configuration>
</plugin>
</plugins>
</build>
这是我的环境详细信息:
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T02:58:13-05:00)
Maven home: C:\DEV\apache-maven-3.5.2\bin\..
Java version: 1.8.0_221, vendor: Oracle Corporation
Java home: C:\Progra~1\Java\jdk1.8.0_221\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
在我的例子中,我得到了这个错误,因为 junit vintage 引擎包含在 pom 中,并且没有发现使用 Junit 4 的测试,所以我只是从 spring-boot 中排除了 junit-vintage。我还排除了 junit 和 mockito 核心,因为我手动设置那些具有固定版本的依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
我的设置是这样的:
<profile>
<id>pitest</id>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<configuration>
<targetClasses>
<param>pl.marcinchwedczuk.rfid*</param>
</targetClasses>
<targetTests>
<param>pl.marcinchwedczuk.rfid*Test</param>
</targetTests>
<avoidCallsTo>
<avoidCallsTo>org.slf4j</avoidCallsTo>
</avoidCallsTo>
</configuration>
<executions>
<execution>
<id>run-pitest</id>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>${maven-pitest-junit.plugin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
为了在这里补充我的两分钱,我使用了 JUnit 5 和记录的插件。但是,我对 junit-jupiter-api
有 JUnit 依赖,我应该一直使用 junit-jupiter-engine
.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
当运行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
参考:https://github.com/ooroor/hellostrangeworld/blob/make_pitest_work/pom.xml
JUnit 似乎缺少依赖项,因此请尝试将以下内容添加到 pom.xml
:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
我通过关注先生修复了 JUnit 5 和 "minion exited abnormally" 问题。 Mkyong 示例 here.
向下滚动到 pom.xml 部分,在 pom 文件的构建部分中定义了一个偷偷摸摸的 pitest-junit5-plugin 依赖项:
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.8</version>
</dependency>
</dependencies>
这是我在 maven 测试阶段针对 jacoco 代码覆盖率和 pit-mutation 的工作pom.xml。如果您只对 pit 部分感兴趣,请随意从构建标签中删除整个 jacoco 插件部分。
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupId>code</groupId>
<artifactId>scans</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!--attach execution to maven's test phase-->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<!-- fail build if line coverage is lover then defined threshold -->
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.9</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.10</version>
<!--attach execution to maven's test phase-->
<executions>
<execution>
<id>pit-report</id>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
</executions>
<!--allows to work with JUnit 5-->
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.9</version>
</dependency>
</dependencies>
<!--optional-->
<configuration>
<targetClasses>
<param>code.scans*</param>
</targetClasses>
<targetTests>
<param>code.scans*</param>
</targetTests>
</configuration>
</plugin>
</plugins>
</build>
这是我的环境详细信息:
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T02:58:13-05:00)
Maven home: C:\DEV\apache-maven-3.5.2\bin\..
Java version: 1.8.0_221, vendor: Oracle Corporation
Java home: C:\Progra~1\Java\jdk1.8.0_221\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
在我的例子中,我得到了这个错误,因为 junit vintage 引擎包含在 pom 中,并且没有发现使用 Junit 4 的测试,所以我只是从 spring-boot 中排除了 junit-vintage。我还排除了 junit 和 mockito 核心,因为我手动设置那些具有固定版本的依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
我的设置是这样的:
<profile>
<id>pitest</id>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<configuration>
<targetClasses>
<param>pl.marcinchwedczuk.rfid*</param>
</targetClasses>
<targetTests>
<param>pl.marcinchwedczuk.rfid*Test</param>
</targetTests>
<avoidCallsTo>
<avoidCallsTo>org.slf4j</avoidCallsTo>
</avoidCallsTo>
</configuration>
<executions>
<execution>
<id>run-pitest</id>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>${maven-pitest-junit.plugin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
为了在这里补充我的两分钱,我使用了 JUnit 5 和记录的插件。但是,我对 junit-jupiter-api
有 JUnit 依赖,我应该一直使用 junit-jupiter-engine
.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>