Wie man Maven, unit test code coverage Arbeit
In Eclipse, das ich verwendet habe, EcLEmma, siehe den unit test code coverage. Die feinen gearbeitet.
Deshalb habe ich versucht, den JaCoCo-plugin für Maven zu sehen, der gleiche Bericht mit Surefire aus dem Maven-build, oder noch besser, mit einem bestimmten Profil oder in der Website-Zyklus. Ohne Erfolg. Alle vorgeschlagenen Lösungen hier nicht für mich arbeiten.
Was ist der beste Weg, um einen unit test code coverage report (mit surefire)?
[Bearbeiten]
um genauer zu sein, warum jacoco nicht für mich.... da bekam ich immer die
Überspringen von JaCoCo Ausführung aufgrund fehlender Daten Ausführung
vom pom
in den Eigenschaften
<jacoco.it.execution.data.file>${project.build.directory}/coverage-reports/jacoco-it.exec</jacoco.it.execution.data.file>
<jacoco.ut.execution.data.file>${project.build.directory}/coverage-reports/jacoco-ut.exec</jacoco.ut.execution.data.file>
in der Build-Abschnitt
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>${jacoco.version}</versionRange>
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent
which is passed as VM argument when Maven the Surefire plugin is executed. -->
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution
data. -->
<destFile>${jacoco.ut.execution.data.file}</destFile>
<!-- Sets the name of the property containing the settings for
JaCoCo runtime agent. -->
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!-- Ensures that the code coverage report for unit tests is created
after unit tests have been run. -->
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution
data. -->
<dataFile>${jacoco.ut.execution.data.file}</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
<!-- Prepares the property pointing to the JaCoCo runtime agent
which is passed as VM argument when Maven the Failsafe plugin is executed. -->
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution
data. -->
<destFile>${jacoco.it.execution.data.file}</destFile>
<!-- Sets the name of the property containing the settings for
JaCoCo runtime agent. -->
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<!-- Ensures that the code coverage report for integration tests
after integration tests have been run. -->
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution
data. -->
<dataFile>${jacoco.it.execution.data.file}</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</pluginExecutionFilter>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
war mein letzter Versuch, aber der pom wird größer und größer ohne Ergebnis
aufgibt, die mit
konfigurieren des Berichts-plugin org.apache.maven.plugins:maven-jxr-plugin:2.3
konfigurieren des Berichts-plugin org.jacoco:jacoco-maven-plugin:0.7.5.201505241946
Überspringen JaCoCo Ausführung aufgrund fehlender Ausführung von Daten-Datei:......\target\jacoco.exec
Überspringen JaCoCo Ausführung aufgrund fehlender Ausführung von Daten-Datei:......\target\jacoco-it.exec
.... => lange Projekt-Pfad
jacoco-maven-plugin
? Erklären Sie, was Sie getan hat und versucht bitte, dann könnten wir ale zu helfen.Hinzugefügt wurde die pom-Fragmente für die jacoco auf die Frage
Fügen Sie die Fehlermeldung, die Sie bekommen, wenn Sie mit Ihrem zu bauen. Ich wild raten, was Sie gesagt haben, ist der Weg Ihrer Ausführung Daten-Datei. Andere als die, die wir können nicht helfen ohne die Fehlermeldung von deinem build.
sorry, auch Hinzugefügt, dass
Warum hast du dies in der eclipse-lifecycle-mapping-plugin? Sind Sie mit maven innerhalb von eclipse oder von der Befehlszeile aus?
InformationsquelleAutor user3732793 | 2016-03-24
Du musst angemeldet sein, um einen Kommentar abzugeben.
Dank user3732793
Personnaly, ich brauchte nur zu fügen Sie diese zu meiner
pom.xml
Dann habe ich
und ich bekomme die HTML-Bericht unter
./target/site/jacoco/*.html
InformationsquelleAutor Julien
wie immer die Lösung ist einfach, nach dem Lesen der Dokumentation, die enthält Beispiel-poms jacoco-Dokumentation
diesem Profil
diese in der build-Abschnitt
und diese dann im Abschnitt Berichterstellung
als dies wird alle
mvn clean install site -P test
Dank
InformationsquelleAutor user3732793