On Wednesday, May 6, 2015 at 11:00:38 AM UTC-7, Mirko Friedenhagen wrote: > Hello Leela, > > please just google for jacoco and powermock, both modify the loaded classes, > so depending on your scenario different approaches are valid. > > Regards > > Mirko > > -- > > Sent from my mobile > > On May 6, 2015 7:05 PM, "leela kumili" <[email protected]> wrote: > > Have a multi-module maven project. > > > Each module has couple of testng and powermock unit test cases. We are using > jacoco for code coverage report. But, jacoco is analyzing unit test coverage > based on testng unit test cases and ignoring powermock unit test case. So, > total code coverage is coming low. > > > Here is how I have configured the jacoco-maven-plugin and unit-test cases: > > > Jacoco-Maven-Plugin configuration: > > > > <plugin> > <groupId>org.jacoco</groupId> > <artifactId>jacoco-maven-plugin</artifactId> > > <version>${jacoco-maven-plugin.version}</version> > <configuration> > > <propertyName>coverageAgent</propertyName> > <append>true</append> > </configuration> > <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>${sonar.jacoco.reportPath}</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>${sonar.jacoco.reportPath}</dataFile> > <excludes> > > <exclude>com.walmart.services.*</exclude> > </excludes> > <!-- Sets the output > directory for the code coverage report. --> > > <outputDirectory>${jacoco.reports.unit.dir}</outputDirectory> > </configuration> > </execution> > > </executions> > </plugin> > > > > > Unit-test case profile: > > > > <!-- For mapping unit tests and covered code --> > <profile> > <id>jacoco-ut</id> > <build> > <plugins> > <plugin> > > <groupId>org.apache.maven.plugins</groupId> > > <artifactId>maven-surefire-plugin</artifactId> > <configuration > combine.self="override"> > > <testFailureIgnore>true</testFailureIgnore> > > <threadCount>25</threadCount> > > <argLine>${surefireArgLine}</argLine> > <suiteXmlFiles> > > <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> > </suiteXmlFiles> > </configuration> > </plugin> > <plugin> > > <artifactId>maven-failsafe-plugin</artifactId> > <version>2.12</version> > <dependencies> > <dependency> > > <groupId>org.apache.maven.surefire</groupId> > > <artifactId>surefire-junit47</artifactId> > > <version>2.10</version> > </dependency> > <dependency> > > <groupId>org.jacoco</groupId> > > <artifactId>org.jacoco.agent</artifactId> > > <version>${jacoco-maven-plugin.version}</version> > </dependency> > </dependencies> > </plugin> > </plugins> > </build> > </profile> > > > > > -- > > 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/ebeba784-9a19-4c8a-954f-791176f5cc0d%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout.
PowerMock and Jacoco has a work around for maven build projects where you preinstrument the classes but I have tried the same approach in ant build project but this does not seems to work for ant build projects. Evengy Gudkov has provided an example on maven based project to make jacoco and powermock work together in offline mode...It would be really great if you someone could post similar example for ant build projects -- 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/d18ec666-1462-41fc-8d39-ba210a42758a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
