4
votes

Mon PITEST ne fonctionnera pas. Le serviteur de la génération de couverture s'est arrêté anormalement. J'ai besoin d'aide pour configurer correctement mon pom.xml

Lors de l'exécution de mvn org.pitest: pitest-maven: mutationCoverage , j'obtiens l'erreur comme suit ( Environnement: 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

Réf.: https://github.com/ooroor/hellostrangeworld/blob/make_pitest_work/pom.xml a >


0 commentaires

3 Réponses :


3
votes

JUnit semble manquer dans les dépendances, essayez donc d'ajouter ce qui suit à pom.xml:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>


2 commentaires

Mais l'un des objectifs est de passer de junit à jupiter (4 à 5).


Bref, je l'ai essayé, même si je ne comprenais pas très bien pourquoi. Eh bien, les erreurs ont disparu! Alors merci beaucoup! Mais: pouvez-vous m'expliquer un peu ici? Je pensais que soit j'utilise 4, soit (exclusivement) j'utilise 5. Pas les deux. Que se passe t-il ici?



1
votes

J'ai corrigé le problème de JUnit 5 et de "minion sorti anormalement" en suivant mr. Exemple de Mkyong ici .

Faites défiler jusqu'à pom .xml, il y a une dépendance sournoise pitest-junit5-plugin définie dans la section build du fichier pom:

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"

Ceci est mon pom.xml de travail pour la couverture du code jacoco et le pit -mutation en phase de test maven. Si vous n'êtes intéressé que par la partie pit, n'hésitez pas à supprimer toute la section du plugin jacoco des balises de construction.

<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>

http://maven.apache.org/xsd/maven-4.0. 0.xsd "> 4.0.0

<?xml version="1.0" encoding="UTF-8"?>

Voici les détails de mon environnement:

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


0 commentaires

0
votes

Dans mon cas, j'ai eu cette erreur parce que le moteur junit vintage était inclus dans le pom et qu'aucun test utilisant Junit 4 n'a été trouvé, j'ai donc simplement exclu junit-vintage de spring-boot. J'ai également exclu junit et mockito core car je définis manuellement ces dépendances avec une version fixe.

    <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>


0 commentaires