After implementing compile time weaving by following my previous blog
http://weavingwithaspectj.blogspot.in/
I found a problem that suddenly my code coverage goes down and suddenly JACOCO stop showing coverage as the classes were changed after apsects are weaved.The test cases are running fine but the coverage get hampered.
I google around the problem , didn't find any direct solution to it.
https://groups.google.com/forum/#!topic/jacoco/QyYAFu5n8iY
The problem is that jacoco plugin pick the jacoco.exec file and execution data is still collected for the modified classes. Report is not working as class versions at runtime and at report generation have to match.
So finally go with a solution to
I copied the class files some other folder using maven-ant-run plugin here for eg : classesForSonar
<!-- pluging to run ant task for copy class files before aspects weaved -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<copy todir="${project.build.directory}/classesForSonar">
<fileset dir="${project.build.directory}/classes"
includes="**/*" />
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
and yes this done the magic I get my code coverage back.please feel free to share your experience and post comment in case you face any issue in implementing it
http://weavingwithaspectj.blogspot.in/
I found a problem that suddenly my code coverage goes down and suddenly JACOCO stop showing coverage as the classes were changed after apsects are weaved.The test cases are running fine but the coverage get hampered.
I google around the problem , didn't find any direct solution to it.
https://groups.google.com/forum/#!topic/jacoco/QyYAFu5n8iY
The problem is that jacoco plugin pick the jacoco.exec file and execution data is still collected for the modified classes. Report is not working as class versions at runtime and at report generation have to match.
So finally go with a solution to
I copied the class files some other folder using maven-ant-run plugin here for eg : classesForSonar
- For this add maven-antrun-plugin to your pom.xml
<!-- pluging to run ant task for copy class files before aspects weaved -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<copy todir="${project.build.directory}/classesForSonar">
<fileset dir="${project.build.directory}/classes"
includes="**/*" />
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
- Add the binary code in sonar propertied to tell sonar to pick class file form that customized folder instead of target one.Add this to your pom.xml.
<!-- sonar property to give the class file path for code coverage with compile time weaving -->
<properties>
<sonar.binaries>${project.build.directory}/classesForSonar</sonar.binaries>
</properties>
Nice, you covered the pain of using compile time weaving and JACACO..
ReplyDelete