2016-03-29 5 views
2

Die jacoco-ut.exec Datei wird im Ziel/erstellt coverage-report/jacoco-ut.exec aber es gibt keinen Ort/Verzeichnis zu sehen.Mein Jacoco Bericht Ziel ist nicht bindend an die Testphase

Hier ist die Jacoco Konfiguration:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.19.1</version> 
    <configuration> 
     <skipTests>false</skipTests> 
     <argLine>${surefireArgLine}</argLine> 
     <excludes> 
     <exclude>**/integration/*.java</exclude> 
     </excludes> 
    </configuration> 
    </plugin> 
    <plugin> 
    <groupId>org.jacoco</groupId> 
    <artifactId>jacoco-maven-plugin</artifactId> 
    <version>0.7.6.201602180812</version> 
    <configuration> 
     <skip>false</skip> 
     <output>file</output> 
     <append>true</append> 
    </configuration> 
    <executions> 
     <execution> 
     <id>pre-unit-test</id> 
     <goals> 
      <goal>prepare-agent</goal> 
     </goals> 
     <configuration> 
      <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile> 
      <propertyName>surefireArgLine</propertyName> 
     </configuration> 
     </execution> 
     <execution> 
     <id>post-unit-test</id> 
     <phase>test</phase> 
     <goals> 
      <goal>report</goal> 
     </goals> 
     <configuration> 
      <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> 
      <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

Hier ist die Ausgabe der Konsole:

[DEBUG] ----------------------------------------------------------------------- 
[DEBUG] Goal:   org.jacoco:jacoco-maven-plugin:0.7.6.201602180812:prepare-agent (pre-unit-test) 
[DEBUG] Style:   Regular 
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <address>${jacoco.address}</address> 
    <append>true</append> 
    <classDumpDir>${jacoco.classDumpDir}</classDumpDir> 
    <destFile default-value="${project.build.directory}/jacoco.exec">/home/stephane/dev/java/projects/x/x/x/target/coverage-reports/jacoco-ut.exec</destFile> 
    <dumpOnExit>${jacoco.dumpOnExit}</dumpOnExit> 
    <exclClassLoaders>${jacoco.exclClassLoaders}</exclClassLoaders> 
    <inclBootstrapClasses>${jacoco.inclBootstrapClasses}</inclBootstrapClasses> 
    <inclNoLocationClasses>${jacoco.inclNoLocationClasses}</inclNoLocationClasses> 
    <jmx>${jacoco.jmx}</jmx> 
    <output>file</output> 
    <pluginArtifactMap>${plugin.artifactMap}</pluginArtifactMap> 
    <port>${jacoco.port}</port> 
    <project>${project}</project> 
    <propertyName>surefireArgLine</propertyName> 
    <sessionId>${jacoco.sessionId}</sessionId> 
    <skip default-value="false">false</skip> 
</configuration> 
[DEBUG] ----------------------------------------------------------------------- 

[DEBUG] ----------------------------------------------------------------------- 
[DEBUG] Goal:   org.jacoco:jacoco-maven-plugin:0.7.6.201602180812:report (post-unit-test) 
[DEBUG] Style:   Regular 
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <dataFile default-value="${project.build.directory}/jacoco.exec">/home/stephane/dev/java/projects/x/x/x/target/coverage-reports/jacoco-ut.exec</dataFile> 
    <outputDirectory default-value="${project.reporting.outputDirectory}/jacoco">/home/stephane/dev/java/projects/x/x/x/target/site/jacoco-ut</outputDirectory> 
    <outputEncoding default-value="UTF-8">${project.reporting.outputEncoding}</outputEncoding> 
    <project>${project}</project> 
    <skip default-value="false">false</skip> 
    <sourceEncoding default-value="UTF-8">${project.build.sourceEncoding}</sourceEncoding> 
</configuration> 
[DEBUG] ======================================================================= 

[INFO] --- jacoco-maven-plugin:0.7.6.201602180812:prepare-agent (pre-unit-test) @ x --- 
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=1, ConflictMarker.nodeCount=158, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=47, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=4, ConflictResolver.conflictItemCount=108, DefaultDependencyCollector.collectTime=191, DefaultDependencyCollector.transformTime=5} 
[DEBUG] org.jacoco:jacoco-maven-plugin:jar:0.7.6.201602180812: 

[DEBUG] Excluded: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1 
[DEBUG] Excluded: classworlds:classworlds:jar:1.1-alpha-2 
[DEBUG] Excluded: org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-6 
[DEBUG] Configuring mojo org.jacoco:jacoco-maven-plugin:0.7.6.201602180812:prepare-agent from plugin realm ClassRealm[plugin>org.jacoco:jacoco-maven-plugin:0.7.6.201602180812, parent: [email protected]] 
[DEBUG] Configuring mojo 'org.jacoco:jacoco-maven-plugin:0.7.6.201602180812:prepare-agent' with basic configurator --> 
[DEBUG] (f) append = true 
[DEBUG] (f) destFile = /home/stephane/dev/java/projects/x/x/x/target/coverage-reports/jacoco-ut.exec 
[DEBUG] (f) output = file 
[DEBUG] (f) pluginArtifactMap = {org.jacoco:jacoco-maven-plugin=org.jacoco:jacoco-maven-plugin:maven-plugin:0.7.6.201602180812:, backport-util-concurrent:backport-util-concurrent=backport-util-concurrent:backport-util-concurrent:jar:3.1:compile, org.codehaus.plexus:plexus-interpolation=org.codehaus.plexus:plexus-interpolation:jar:1.11:compile, junit:junit=junit:junit:jar:4.8.2:compile, org.codehaus.plexus:plexus-utils=org.codehaus.plexus:plexus-utils:jar:1.5.6:compile, org.apache.maven.shared:file-management=org.apache.maven.shared:file-management:jar:1.2.1:compile, org.apache.maven.shared:maven-shared-io=org.apache.maven.shared:maven-shared-io:jar:1.1:compile, org.apache.maven.reporting:maven-reporting-api=org.apache.maven.reporting:maven-reporting-api:jar:2.2.1:compile, org.apache.maven.doxia:doxia-sink-api=org.apache.maven.doxia:doxia-sink-api:jar:1.1:compile, org.apache.maven.doxia:doxia-logging-api=org.apache.maven.doxia:doxia-logging-api:jar:1.1:compile, org.apache.maven.reporting:maven-reporting-impl=org.apache.maven.reporting:maven-reporting-impl:jar:2.1:compile, org.apache.maven.doxia:doxia-core=org.apache.maven.doxia:doxia-core:jar:1.1.2:compile, xerces:xercesImpl=xerces:xercesImpl:jar:2.8.1:compile, commons-lang:commons-lang=commons-lang:commons-lang:jar:2.4:compile, commons-httpclient:commons-httpclient=commons-httpclient:commons-httpclient:jar:3.1:compile, commons-codec:commons-codec=commons-codec:commons-codec:jar:1.2:compile, org.apache.maven.doxia:doxia-site-renderer=org.apache.maven.doxia:doxia-site-renderer:jar:1.1.2:compile, org.apache.maven.doxia:doxia-decoration-model=org.apache.maven.doxia:doxia-decoration-model:jar:1.1.2:compile, org.apache.maven.doxia:doxia-module-xhtml=org.apache.maven.doxia:doxia-module-xhtml:jar:1.1.2:compile, org.apache.maven.doxia:doxia-module-fml=org.apache.maven.doxia:doxia-module-fml:jar:1.1.2:compile, org.codehaus.plexus:plexus-i18n=org.codehaus.plexus:plexus-i18n:jar:1.0-beta-7:compile, org.codehaus.plexus:plexus-velocity=org.codehaus.plexus:plexus-velocity:jar:1.1.7:compile, org.apache.velocity:velocity=org.apache.velocity:velocity:jar:1.5:compile, commons-collections:commons-collections=commons-collections:commons-collections:jar:3.2:compile, commons-validator:commons-validator=commons-validator:commons-validator:jar:1.2.0:compile, commons-beanutils:commons-beanutils=commons-beanutils:commons-beanutils:jar:1.7.0:compile, commons-digester:commons-digester=commons-digester:commons-digester:jar:1.6:compile, commons-logging:commons-logging=commons-logging:commons-logging:jar:1.0.4:compile, oro:oro=oro:oro:jar:2.0.8:compile, xml-apis:xml-apis=xml-apis:xml-apis:jar:1.0.b2:compile, org.jacoco:org.jacoco.agent=org.jacoco:org.jacoco.agent:jar:runtime:0.7.6.201602180812:compile, org.jacoco:org.jacoco.core=org.jacoco:org.jacoco.core:jar:0.7.6.201602180812:compile, org.ow2.asm:asm-debug-all=org.ow2.asm:asm-debug-all:jar:5.0.4:compile, org.jacoco:org.jacoco.report=org.jacoco:org.jacoco.report:jar:0.7.6.201602180812:compile} 
[DEBUG] (f) project = MavenProject: com.x:3.2.1 @ /home/stephane/dev/java/projects/x/x/x/pom.xml 
[DEBUG] (f) propertyName = surefireArgLine 
[DEBUG] (f) skip = false 
[DEBUG] -- end configuration -- 
[INFO] surefireArgLine set to -javaagent:/home/stephane/.m2/repository/org/jacoco/org.jacoco.agent/0.7.6.201602180812/org.jacoco.agent-0.7.6.201602180812-runtime.jar=destfile=/home/stephane/dev/java/projects/x/x/x/target/coverage-reports/jacoco-ut.exec,append=true,output=file 

Und das ist alles.

UPDATE: Ich lief den folgenden Befehl ein: mvn jacoco: Bericht -X und sagte, es etwas Interessantes:

[DEBUG] (f) dataFile = /home/stephane/dev/java/projects/x/x/x/target/jacoco.exec 
[DEBUG] (f) outputDirectory = /home/stephane/dev/java/projects/x/x/x/target/site/jacoco 
[DEBUG] (f) outputEncoding = UTF-8 
[DEBUG] (f) project = MavenProject: com.x:3.2.1 @ /home/stephane/dev/java/projects/x/x/x/pom.xml 
[DEBUG] (f) skip = false 
[DEBUG] (f) sourceEncoding = UTF-8 
[DEBUG] -- end configuration -- 
[INFO] Skipping JaCoCo execution due to missing execution data file:/home/stephane/dev/java/projects/x/x/x/target/jacoco.exec 

Es ist für eine jacoco.exec Datei suchen, wenn ich es eine jacoco- schaffen hatte ut.exec Datei.

Dies ist ein wenig überraschend, da die Datei erstellt wurde:

$ ll target/coverage-reports/jacoco-ut.exec 
-rw-rw-r-- 1 stephane 2.9M Mar 29 09:47 target/coverage-reports/jacoco-ut.exec 

Ich glaube, ich muss irgendwo, dass die Dateinamen in der Berichtskonfiguration angeben.

UPDATE: Nach dem Bewegen des destfile und datafile Konfiguration oben in der Jacoco Konfiguration wurde das Problem behoben und der Bericht in der Site/Verzeichnis erzeugt.

Die vollständige Plugin sieht nun wie:

<plugin> 
    <groupId>org.jacoco</groupId> 
    <artifactId>jacoco-maven-plugin</artifactId> 
    <version>0.7.6.201602180812</version> 
    <configuration> 
     <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile> 
     <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> 
     <skip>${skipTests}</skip> 
     <output>file</output> 
     <append>true</append> 
    </configuration> 
    <executions> 
     <execution> 
     <id>pre-unit-test</id> 
     <goals> 
      <goal>prepare-agent</goal> 
     </goals> 
     <configuration> 
      <propertyName>surefireArgLine</propertyName> 
     </configuration> 
     </execution> 
     <execution> 
     <id>post-unit-test</id> 
     <phase>test</phase> 
     <goals> 
      <goal>report</goal> 
     </goals> 
     <configuration> 
      <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

Obwohl das Plugin in dem Plugin-Elemente definiert ist, und nicht in dem pluginManagement Elemente, um den Bericht zu bekommen brauche ich noch den Befehl auszuführen:

mvn jacoco:report 

ich den Bericht möchte erzeugt werden, wenn der Befehl ausgeführt wird:

mvn clean install 

Antwort

0

Verwenden Sie diese Konfiguration, und Sie sollten keine Probleme beim Generieren der Site mit mvn clean install haben.

Innerhalb der Site-Ordner wird es zwei verschiedene Ordner sein: jacoco den Bericht Ihrer Unit-Tests enthalten und jacoco-it den Bericht Ihrer Integrationstests enthält.

JaCoco Konfiguration

konfiguriert Jacoco Konfigurationsvariablen zu belichten Unit-Tests (jacoco.argLine) und Integrationstests (jacoco.it.argLine) zu integrieren und einen Ordner mit den Berichten von Integrationen Tests (jacoco-it) zu erzeugen:

 <plugin> 
      <groupId>org.jacoco</groupId> 
      <artifactId>jacoco-maven-plugin</artifactId> 
      <version>0.7.4.201502262128</version> 
      <executions> 
       <execution> 
        <id>prepare-agent</id> 
        <goals> 
         <goal>prepare-agent</goal> 
        </goals> 
        <configuration> 
         <excludes> 
          <exclude>**/*Test</exclude> 
         </excludes> 
         <includes> 
          <include>com.vectorsf.*</include> 
         </includes> 
         <propertyName>jacoco.argLine</propertyName> 
        </configuration> 
       </execution> 

       <execution> 
        <id>report</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>report</goal> 
        </goals> 
       </execution> 

       <execution> 
        <id>prepare-agent-it</id> 
        <phase>pre-integration-test</phase> 
        <goals> 
         <goal>prepare-agent</goal> 
        </goals> 
        <configuration> 
         <destFile>${project.build.directory}/jacoco-integration.exec</destFile> 
         <excludes> 
          <exclude>**/*IT</exclude> 
         </excludes> 
         <includes> 
          <include>com.vectorsf.*</include> 
         </includes> 
         <propertyName>jacoco.it.argLine</propertyName> 
        </configuration> 
       </execution> 

       <execution> 
        <id>report-it</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>report</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> 
         <dataFile>${project.build.directory}/jacoco-integration.exec</dataFile> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

Failsafe Konfiguration

 <plugin> 
      <artifactId>maven-failsafe-plugin</artifactId> 
      <executions> 
       <execution> 
        <goals> 
         <goal>integration-test</goal> 
         <goal>verify</goal> 
        </goals> 
        <configuration> 
         <redirectTestOutputToFile>true</redirectTestOutputToFile> 
         <includes> 
          <include>**/*IT.java</include> 
         </includes> 
         <excludes> 
          <exclude>**/Application.java</exclude> 
         </excludes> 
         <argLine>${jacoco.it.argLine}</argLine> 
         <encoding>UTF-8</encoding> 
         <runOrder>alphabetical</runOrder> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

Werfen Sie einen Blick auf <argLine>${jacoco.it.argLine}</argLine>. Dieser Platzhalter wird durch alle vom JaCoco-Plugin angegebenen Parameter ersetzt. Es enthält die Konfigurationsvariablen, die Sie für die Integration von JaCoco in Ihre Integrationstests benötigen.

todsichere Konfiguration

 <plugin> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <redirectTestOutputToFile>true</redirectTestOutputToFile> 
       <includes> 
        <include>**/*Test.java</include> 
       </includes> 
       <excludes> 
        <exclude>**/*IT.java</exclude> 
        <exclude>**/Application.java</exclude> 
       </excludes> 
       <argLine> 
        ${jacoco.argLine} 
       </argLine> 
       <!-- Force alphabetical order to have a reproducible build --> 
       <runOrder>alphabetical</runOrder> 
      </configuration> 
      <dependencies> 
       <dependency> 
        <groupId>org.apache.maven.surefire</groupId> 
        <artifactId>surefire-junit47</artifactId> 
        <version>2.15</version> 
       </dependency> 
      </dependencies> 
     </plugin> 

wieder einen Blick auf <argLine>${jacoco.argLine}</argLine>. Es enthält die Konfigurationsvariablen, die für die Integration von JaCoco in Ihre Komponententests benötigt werden.

+0

Vielen Dank für die Freigabe Ihrer Konfiguration. Aber mein Problem ist nicht, dass ich das Jacoco-Plugin nicht ausführen kann, sondern dass ich es nicht innerhalb der Installationsphase ausführen kann. Der einzige Unterschied zwischen unseren Konfigurationen besteht darin, dass Sie für das Berichtsziel eine Vorbereitungspaketphase verwenden. Also habe ich es ausprobiert und meine Testphase durch eine Prepared-Package-Phase ersetzt. Aber es hat nichts geändert und das Problem ist geblieben. – Stephane

+0

Versuchen Sie 'mvn verify' zu verwenden, um die Ausführung von jacoco auszulösen. – jfcorugedo

+0

Der Aufruf der Verify-Phase macht keinen Unterschied. Wie in der Frage gesagt, mache ich bereits einen Lauf der Installationsphase, die nach der Verifikationsphase kommt. Sehen Sie die Phasen bei https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html, wenn nötig. – Stephane

Verwandte Themen