On Monday, January 30, 2017 at 12:01:09 PM UTC-8, David Karr wrote:
>
> On Sunday, January 22, 2017 at 11:42:27 PM UTC-8, Evgeny Mandrikov wrote:
>>
>> As stated on page http://www.jacoco.org/jacoco/trunk/doc/offline.html : 
>> "Unlike with on-the-fly instrumentation offline instrumented classes get a 
>> direct dependency on the JaCoCo runtime."
>>
>> In our example at 
>> http://www.jacoco.org/jacoco/trunk/doc/examples/build/pom-offline.xml as 
>> well as in cited example at 
>> https://github.com/powermock/powermock-examples-maven/blob/master/jacoco-offline/pom.xml#L56-L61
>>  
>> there is such dependency, which you seem to be missed:
>>
>> <dependency>
>>   <groupId>org.jacoco</groupId>
>>   <artifactId>org.jacoco.agent</artifactId>
>>   <version>${jacoco.version}</version>
>>   <classifier>runtime</classifier>
>> </dependency>
>>
>
> I'm still having trouble with this, even though I've added this dependency.
>
> Here is an excerpt of my build output:
> [INFO] --- jacoco-maven-plugin:0.7.8:instrument (default-instrument) @ usl
> -creditcheck-impl ---
> [INFO] 
> [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources
> ) @ usl-creditcheck-impl ---
> [INFO] Using 'UTF-8' encoding to copy filtered resources.
> [INFO] Copying 32 resources
> [INFO] 
> [INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ 
> usl-creditcheck-impl ---
> [INFO] Changes detected - recompiling the module!
> [INFO] Compiling 31 source files to C:\users\dk068x\git\oce_usl\usl-parent
> \usl-creditcheck-impl\target\test-classes
> [INFO] 
> [INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ usl-
> creditcheck-impl ---
>
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running ...
> Results :
>
> Tests run: 70, Failures: 0, Errors: 0, Skipped: 0
>
> [INFO] 
> [INFO] --- jacoco-maven-plugin:0.7.8:restore-instrumented-classes (default
> -restore-instrumented-classes) @ usl-creditcheck-impl ---
> [INFO] 
> [INFO] --- jacoco-maven-plugin:0.7.8:report (default-report) @ usl-
> creditcheck-impl ---
> [INFO] Skipping JaCoCo execution due to missing execution data file.
>
>  Here is a segment of the effective pom:
>   <dependencies>
> ...
>     <dependency>
>       <groupId>org.jacoco</groupId>
>       <artifactId>org.jacoco.agent</artifactId>
>       <version>0.7.8</version>
>       <classifier>runtime</classifier>
>       <scope>test</scope>
>     </dependency>
>   </dependencies>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.jacoco</groupId>
>         <artifactId>jacoco-maven-plugin</artifactId>
>         <version>0.7.8</version>
>         <executions>
>           <execution>
>             <id>default-instrument</id>
>             <goals>
>               <goal>instrument</goal>
>             </goals>
>             <configuration>
>               <dataFile>...\target/coverage.exec</dataFile>
>             </configuration>
>           </execution>
>           <execution>
>             <id>default-restore-instrumented-classes</id>
>             <goals>
>               <goal>restore-instrumented-classes</goal>
>             </goals>
>           </execution>
>           <execution>
>             <id>default-report</id>
>             <phase>prepare-package</phase>
>             <goals>
>               <goal>report</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-surefire-plugin</artifactId>
>         <version>2.19.1</version>
>         <executions>
>           <execution>
>             <id>default-test</id>
>             <phase>test</phase>
>             <goals>
>               <goal>test</goal>
>             </goals>
>             <configuration>
>               <argLine>-Xmx1024m</argLine>
>               <includes>
>                 <include>**/*Test.java</include>
>               </includes>
>               <systemPropertyVariables>
>                 <jacoco-agent.destfile>...\target/coverage.exec
> </jacoco-agent.destfile>
>               </systemPropertyVariables>
>             </configuration>
>           </execution>
>         </executions>
>         <configuration>
>           <argLine>-Xmx1024m</argLine>
>           <includes>
>             <include>**/*Test.java</include>
>           </includes>
>           <systemPropertyVariables>
>             <jacoco-agent.destfile>...\target/coverage.exec
> </jacoco-agent.destfile>
>           </systemPropertyVariables>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
> </project>
>
> What am I missing?
>

It seems clear this has something to do with a disconnect on the name of 
the ".exec" file to use.  From my effective pom, I appear to be telling it 
to use "coverage.exec", but if I run with "-X" I see conflicting 
information that says it expects to find "jacoco.exec", like this:
[DEBUG] Configuring mojo 'org.jacoco:jacoco-maven-plugin:0.7.8:report' with 
basic configurator -->
[DEBUG]   (f) dataFile = ...\target\jacoco.exec
[DEBUG]   (f) outputDirectory = ...\target\site\jacoco
[DEBUG] -- end configuration --
[INFO] Skipping JaCoCo execution due to missing execution data file.

 

>
>
>> On Sunday, January 22, 2017 at 9:57:44 PM UTC+1, David Karr wrote:
>>>
>>> Using the information at 
>>> https://github.com/powermock/powermock/wiki/Code-coverage-with-JaCoCo 
>>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fpowermock%2Fpowermock%2Fwiki%2FCode-coverage-with-JaCoCo&sa=D&sntz=1&usg=AFQjCNHUjB20b60xH6KCVta-3FfzhVABZg>
>>>  
>>> and the offline example it links to, I set up jacoco in my largish maven 
>>> multiproject build.  The build has an overall parent pom that all the child 
>>> modules inherit from, and there is a separate aggregator pom.  I put the 
>>> settings for jacoco in the parent pom.
>>>
>>> The following is a paraphrased view of the parent pom, with some 
>>> elements removed that I believe are irrelevant:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
>>> http://www.w3.org/2001/XMLSchema-instance";
>>>     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
>>> http://maven.apache.org/xsd/maven-4.0.0.xsd";>
>>>     <modelVersion>4.0.0</modelVersion>
>>>     <properties>
>>>         <maven.compiler.target>1.8</maven.compiler.target>
>>>         <maven.compiler.source>1.8</maven.compiler.source>
>>>         <junit.version>4.11</junit.version>
>>>         <mockito.version>1.10.19</mockito.version>
>>>         <powermock.version>1.6.6</powermock.version>
>>>     </properties>
>>>     <dependencyManagement>
>>>         <dependencies>
>>>             <dependency>
>>>                 <groupId>junit</groupId>
>>>                 <artifactId>junit</artifactId>
>>>                 <version>${junit.version}</version>
>>>                 <scope>test</scope>
>>>             </dependency>
>>>             <dependency>
>>>                 <groupId>org.mockito</groupId>
>>>                 <artifactId>mockito-core</artifactId>
>>>                 <version>${mockito.version}</version>
>>>                 <scope>test</scope>
>>>             </dependency>
>>>             <dependency>
>>>                 <groupId>org.powermock</groupId>
>>>                 <artifactId>powermock-module-junit4</artifactId>
>>>                 <version>${powermock.version}</version>
>>>                 <scope>test</scope>
>>>             </dependency>
>>>             <dependency>
>>>                 <groupId>org.powermock</groupId>
>>>                 <artifactId>powermock-api-mockito</artifactId>
>>>                 <version>${powermock.version}</version>
>>>                 <scope>test</scope>
>>>             </dependency>
>>>         </dependencies>
>>>     </dependencyManagement>
>>>
>>>     <dependencies>
>>>         <dependency>
>>>             <groupId>junit</groupId>
>>>             <artifactId>junit</artifactId>
>>>             <scope>test</scope>
>>>         </dependency>
>>>         <dependency>
>>>             <groupId>org.mockito</groupId>
>>>             <artifactId>mockito-core</artifactId>
>>>             <scope>test</scope>
>>>         </dependency>
>>>         <dependency>
>>>             <groupId>org.powermock</groupId>
>>>             <artifactId>powermock-module-junit4</artifactId>
>>>             <scope>test</scope>
>>>         </dependency>
>>>         <dependency>
>>>             <groupId>org.powermock</groupId>
>>>             <artifactId>powermock-api-mockito</artifactId>
>>>             <scope>test</scope>
>>>         </dependency>
>>>         <dependency>
>>>             <groupId>org.apache.maven.surefire</groupId>
>>>             <artifactId>surefire-junit4</artifactId>
>>>             <version>2.19.1</version>
>>>             <scope>test</scope>
>>>         </dependency>
>>>     </dependencies>
>>>     <build>
>>>         <plugins>
>>>         </plugins>
>>>         <pluginManagement>
>>>             <plugins>
>>>             <plugin>
>>>                 <groupId>org.jacoco</groupId>
>>>                 <artifactId>jacoco-maven-plugin</artifactId>
>>>                 <version>0.7.8</version>
>>>                 <executions>
>>>                     <execution>
>>>                         <id>default-instrument</id>
>>>                         <goals>
>>>                             <goal>instrument</goal>
>>>                         </goals>
>>>                         <configuration>
>>>                           <dataFile>
>>> ${project.build.directory}/coverage.exec</dataFile>
>>>                         </configuration>
>>>                     </execution>
>>>                     <execution>
>>>                         <id>default-restore-instrumented-classes</id>
>>>                         <goals>
>>>                             <goal>restore-instrumented-classes</goal>
>>>                         </goals>
>>>                     </execution>
>>>                     <execution>
>>>                         <id>report</id>
>>>                         <phase>prepare-package</phase>
>>>                         <goals>
>>>                             <goal>report</goal>
>>>                         </goals>
>>>                     </execution>
>>>                 </executions>
>>>             </plugin>
>>>                 <plugin>
>>>                     <groupId>org.apache.maven.plugins</groupId>
>>>                     <artifactId>maven-surefire-plugin</artifactId>
>>>                     <version>2.19.1</version>
>>>                     <configuration>
>>>                         <forkCount>3</forkCount>
>>>                         <aggregate>true</aggregate>
>>>                         <reuseForks>true</reuseForks>
>>>                         <argLine>-Xmx1024m</argLine>
>>>                         <testSourceDirectory>
>>> ${project.build.testSourceDirectory}</testSourceDirectory>
>>>                         <includes>
>>>                             <include>**/*Test.java</include>
>>>                         </includes>
>>>                         <systemPropertyVariables>
>>>                           <jacoco-agent.destfile>
>>> ${project.build.directory}/coverage.exec</jacoco-agent.destfile>
>>>                         </systemPropertyVariables>
>>>                     </configuration>
>>>                 </plugin>
>>>             </plugins>
>>>         </pluginManagement>
>>>     </build>
>>> </project>
>>>
>>> When I run the build at the top-level, or in one of the child modules, I 
>>> see every test failing with the following:
>>> java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_e5875b2/
>>> Offline
>>>
>>> Any ideas what might be wrong here?
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/510e616f-fbae-4189-8ce7-9e6292eeabe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to