При запуске 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

8
Øyvind Roth 15 Апр 2019 в 00:05

2 ответа

Лучший ответ

JUnit, похоже, отсутствует в зависимостях, поэтому попробуйте добавить следующее в pom.xml:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>
2
Mario Galic 14 Апр 2019 в 21:33

Я исправил JUnit 5 и проблема "миньон вышел ненормально", выполнив команду mr. Пример Mkyong здесь.

Прокрутите вниз до раздела pom.xml, в разделе сборки файла pom определена скрытая зависимость pitest-junit5-plugin:

<dependencies>
    <dependency>
        <groupId>org.pitest</groupId>
        <artifactId>pitest-junit5-plugin</artifactId>
        <version>0.8</version>
    </dependency>
</dependencies>

Это мой рабочий файл pom.xml для покрытия кода jacoco и пит-мутации в фазе тестирования maven. Если вас интересует только часть пита, не стесняйтесь удалять весь плагин 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"
0
metatron 4 Окт 2019 в 00:59