Discussion:
[java code coverage] Jacoco code coverage is affected by AspectJ
zhz shi
2015-08-14 05:16:28 UTC
Permalink
Hi,

We're using AspectJ in our project and also Jacoco for test coverage
report, currently we're facing an issue that due to AspectJ changed the
byte code during compiling phase, which makes the code coverage report not
correct. One example is due to AspectJ adds extra if-else statement, then
the branch coverage shows something like 1/4 but actually there's no
condition branch in the source code. Is there some good way to tell Jacoco
to ignore all code generated by AspectJ?


I also created an issues 335 <https://github.com/jacoco/jacoco/issues/335> on
Github and posted an question on SO
<http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj>
.


Thanks a lot.
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marc Hoffmann
2015-08-14 08:04:53 UTC
Permalink
Hi,

JaCoCo works on class files only. It reports whatever it sees in the
class files which get instrumented and analyzed. Future versions might
come with the option to filter certain constructs, but for AspectJ this
will probably not work as you can inject any code.

To solve this you have to make sure that the class files get instrumeted
by JaCoCo *before* AspectJ kicks in. If you use the AspectJ agent it has
to be configured after the JaCoCo agent. If you want to pre-compile your
classes you can use JaCoCo offline instrumentation first:
http://www.eclemma.org/jacoco/trunk/doc/offline.html

Regards,
-marc
Post by zhz shi
Hi,
We're using AspectJ in our project and also Jacoco for test coverage
report, currently we're facing an issue that due to AspectJ changed
the byte code during compiling phase, which makes the code coverage
report not correct. One example is due to AspectJ adds extra if-else
statement, then the branch coverage shows something like 1/4 but
actually there's no condition branch in the source code. Is there some
good way to tell Jacoco to ignore all code generated by AspectJ?
I also created an issues 335 [1] on Github and posted an question on
SO [2].
Thanks a lot.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
[3].
For more options, visit https://groups.google.com/d/optout [4].
------
[1] https://github.com/jacoco/jacoco/issues/335
[2]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&utm_source=footer
[4] https://groups.google.com/d/optout
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/5d10b47fe28d7712d83c101540dd3689%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.
zhz shi
2015-08-14 16:17:56 UTC
Permalink
Thanks @marc for your information. I'm trying to use the jacoco
offline instrumentation with the following configuration:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>


and also with dependency:


<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<version>0.7.5.201505241946</version>
</dependency>


but all tests failed due to org/jacoco/agent/rt/internal_b0d6a23/Offline
can not be found. Is there anything wrong with my configration?
Post by Marc Hoffmann
Hi,
JaCoCo works on class files only. It reports whatever it sees in the
class files which get instrumented and analyzed. Future versions might
come with the option to filter certain constructs, but for AspectJ this
will probably not work as you can inject any code.
To solve this you have to make sure that the class files get instrumeted
by JaCoCo *before* AspectJ kicks in. If you use the AspectJ agent it has
to be configured after the JaCoCo agent. If you want to pre-compile your
http://www.eclemma.org/jacoco/trunk/doc/offline.html
Regards,
-marc
Post by zhz shi
Hi,
We're using AspectJ in our project and also Jacoco for test coverage
report, currently we're facing an issue that due to AspectJ changed
the byte code during compiling phase, which makes the code coverage
report not correct. One example is due to AspectJ adds extra if-else
statement, then the branch coverage shows something like 1/4 but
actually there's no condition branch in the source code. Is there some
good way to tell Jacoco to ignore all code generated by AspectJ?
I also created an issues 335 [1] on Github and posted an question on
SO [2].
Thanks a lot.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
Post by zhz shi
[3].
For more options, visit https://groups.google.com/d/optout [4].
------
[1] https://github.com/jacoco/jacoco/issues/335
[2]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
Post by zhz shi
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&utm_source=footer
Post by zhz shi
[4] https://groups.google.com/d/optout
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marc R. Hoffmann
2015-08-14 16:38:22 UTC
Permalink
Looks like for whatever reason the JaCoCo runtime is not on the
classpath or cannot be loaded in your testsetup.

You might check with the -X Maven option how the command line for your
test runtime looks like.

Also here you can find a working example:
http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom-offline.xml

Regards,
-marc
Post by zhz shi
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<version>0.7.5.201505241946</version>
</dependency>
but all tests failed due
to org/jacoco/agent/rt/internal_b0d6a23/Offline can not be found. Is
there anything wrong with my configration?
Hi,
JaCoCo works on class files only. It reports whatever it sees in the
class files which get instrumented and analyzed. Future versions might
come with the option to filter certain constructs, but for AspectJ this
will probably not work as you can inject any code.
To solve this you have to make sure that the class files get instrumeted
by JaCoCo *before* AspectJ kicks in. If you use the AspectJ agent it has
to be configured after the JaCoCo agent. If you want to
pre-compile your
http://www.eclemma.org/jacoco/trunk/doc/offline.html
<http://www.eclemma.org/jacoco/trunk/doc/offline.html>
Regards,
-marc
Post by zhz shi
Hi,
We're using AspectJ in our project and also Jacoco for test
coverage
Post by zhz shi
report, currently we're facing an issue that due to AspectJ changed
the byte code during compiling phase, which makes the code coverage
report not correct. One example is due to AspectJ adds extra
if-else
Post by zhz shi
statement, then the branch coverage shows something like 1/4 but
actually there's no condition branch in the source code. Is
there some
Post by zhz shi
good way to tell Jacoco to ignore all code generated by AspectJ?
I also created an issues 335 [1] on Github and posted an
question on
Post by zhz shi
SO [2].
Thanks a lot.
--
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
Post by zhz shi
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
<https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com>
Post by zhz shi
[3].
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout> [4].
Post by zhz shi
------
[1] https://github.com/jacoco/jacoco/issues/335
<https://github.com/jacoco/jacoco/issues/335>
Post by zhz shi
[2]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
<http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj>
Post by zhz shi
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&utm_source=footer
<https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&utm_source=footer>
Post by zhz shi
[4] https://groups.google.com/d/optout
<https://groups.google.com/d/optout>
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com
<https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/55CE197E.8040906%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.
zhz shi
2015-08-17 03:44:07 UTC
Permalink
Thanks Marc.

For '*To solve this you have to make sure that the class files get
instrumeted by JaCoCo *before* AspectJ kicks in. *', is it possible to
make this happen if we're using AspectJ Compile Time Weaving, because I see
ajc directly compile java source file to class files.
Looks like for whatever reason the JaCoCo runtime is not on the classpath
or cannot be loaded in your testsetup.
You might check with the -X Maven option how the command line for your
test runtime looks like.
http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom-offline.xml
Regards,
-marc
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.5.201505241946</version> <executions> <execution> <id>default-instrument</id> <goals> <goal>instrument</goal> </goals> </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> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12.2</version> <configuration> <systemPropertyVariables> <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile> </systemPropertyVariables> </configuration></plugin>
<dependency> <groupId>org.jacoco</groupId> <artifactId>org.jacoco.agent</artifactId> <classifier>runtime</classifier> <version>0.7.5.201505241946</version></dependency>
but all tests failed due to org/jacoco/agent/rt/internal_b0d6a23/Offline
can not be found. Is there anything wrong with my configration?
Post by Marc Hoffmann
Hi,
JaCoCo works on class files only. It reports whatever it sees in the
class files which get instrumented and analyzed. Future versions might
come with the option to filter certain constructs, but for AspectJ this
will probably not work as you can inject any code.
To solve this you have to make sure that the class files get instrumeted
by JaCoCo *before* AspectJ kicks in. If you use the AspectJ agent it has
to be configured after the JaCoCo agent. If you want to pre-compile your
http://www.eclemma.org/jacoco/trunk/doc/offline.html
Regards,
-marc
Post by zhz shi
Hi,
We're using AspectJ in our project and also Jacoco for test coverage
report, currently we're facing an issue that due to AspectJ changed
the byte code during compiling phase, which makes the code coverage
report not correct. One example is due to AspectJ adds extra if-else
statement, then the branch coverage shows something like 1/4 but
actually there's no condition branch in the source code. Is there some
good way to tell Jacoco to ignore all code generated by AspectJ?
I also created an issues 335 [1] on Github and posted an question on
SO [2].
Thanks a lot.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
Post by zhz shi
[3].
For more options, visit https://groups.google.com/d/optout [4].
------
[1] https://github.com/jacoco/jacoco/issues/335
[2]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
Post by zhz shi
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&utm_source=footer
Post by zhz shi
[4] https://groups.google.com/d/optout
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com
<https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/0c4de744-f40b-4d9b-b6f9-ec7362d6ce68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marc Hoffmann
2015-08-17 09:07:06 UTC
Permalink
Hi,

you might diskuss this question with the ApectJ project, we can't
provide support here. I think they have load time weaving options.

Regards,
-marc
Post by zhz shi
Thanks Marc.
For '_TO SOLVE THIS YOU HAVE TO MAKE SURE THAT THE CLASS FILES GET
INSTRUMETED BY JACOCO *BEFORE* ASPECTJ KICKS IN. _', is it possible
to make this happen if we're using AspectJ Compile Time Weaving,
because I see ajc directly compile java source file to class files.
Post by Marc R. Hoffmann
Looks like for whatever reason the JaCoCo runtime is not on the
classpath or cannot be loaded in your testsetup.
You might check with the -X Maven option how the command line for
your test runtime looks like.
http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom-offline.xml
Post by Marc R. Hoffmann
[1]
Regards,
-marc
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<version>0.7.5.201505241946</version>
</dependency>
but all tests failed due to
org/jacoco/agent/rt/internal_b0d6a23/Offline can not be found. Is
there anything wrong with my configration?
On Friday, August 14, 2015 at 4:04:56 PM UTC+8, Marc R. Hoffmann
wrote: Hi,
JaCoCo works on class files only. It reports whatever it sees in the
class files which get instrumented and analyzed. Future versions might
come with the option to filter certain constructs, but for AspectJ this
will probably not work as you can inject any code.
To solve this you have to make sure that the class files get
instrumeted
by JaCoCo *before* AspectJ kicks in. If you use the AspectJ agent it has
to be configured after the JaCoCo agent. If you want to pre-compile your
http://www.eclemma.org/jacoco/trunk/doc/offline.html [2]
Regards,
-marc
Post by zhz shi
Hi,
We're using AspectJ in our project and also Jacoco for test
coverage
Post by zhz shi
report, currently we're facing an issue that due to AspectJ
changed
Post by zhz shi
the byte code during compiling phase, which makes the code
coverage
Post by zhz shi
report not correct. One example is due to AspectJ adds extra
if-else
Post by zhz shi
statement, then the branch coverage shows something like 1/4 but
actually there's no condition branch in the source code. Is there
some
Post by zhz shi
good way to tell Jacoco to ignore all code generated by AspectJ?
I also created an issues 335 [1] on Github and posted an question
on
Post by zhz shi
SO [2].
Thanks a lot.
--
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
Post by zhz shi
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
Post by Marc R. Hoffmann
[3]
Post by zhz shi
[3].
For more options, visit https://groups.google.com/d/optout [4]
[4].
Post by zhz shi
------
[1] https://github.com/jacoco/jacoco/issues/335 [5]
[2]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
Post by Marc R. Hoffmann
[6]
Post by zhz shi
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&utm_source=footer
Post by Marc R. Hoffmann
[7]
Post by zhz shi
[4] https://groups.google.com/d/optout [4]
--
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,
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com
Post by Marc R. Hoffmann
[8].
For more options, visit https://groups.google.com/d/optout [4].
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/0c4de744-f40b-4d9b-b6f9-ec7362d6ce68%40googlegroups.com
[9].
For more options, visit https://groups.google.com/d/optout [4].
------
[1]
http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom-offline.xml
[2] http://www.eclemma.org/jacoco/trunk/doc/offline.html
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
[4] https://groups.google.com/d/optout
[5] https://github.com/jacoco/jacoco/issues/335
[6]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
[7]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&amp;utm_source=footer
[8]
https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com?utm_medium=email&amp;utm_source=footer
[9]
https://groups.google.com/d/msgid/jacoco/0c4de744-f40b-4d9b-b6f9-ec7362d6ce68%40googlegroups.com?utm_medium=email&utm_source=footer
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/f31f9e10f843964b8d51c44fcb7ba928%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.
zhz shi
2015-08-18 02:51:12 UTC
Permalink
Thanks Marc again :-)
Post by Marc Hoffmann
Hi,
you might diskuss this question with the ApectJ project, we can't
provide support here. I think they have load time weaving options.
Regards,
-marc
Post by zhz shi
Thanks Marc.
For '_TO SOLVE THIS YOU HAVE TO MAKE SURE THAT THE CLASS FILES GET
INSTRUMETED BY JACOCO *BEFORE* ASPECTJ KICKS IN. _', is it possible
to make this happen if we're using AspectJ Compile Time Weaving,
because I see ajc directly compile java source file to class files.
Post by Marc R. Hoffmann
Looks like for whatever reason the JaCoCo runtime is not on the
classpath or cannot be loaded in your testsetup.
You might check with the -X Maven option how the command line for
your test runtime looks like.
http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom-offline.xml
Post by Marc R. Hoffmann
[1]
Regards,
-marc
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<version>0.7.5.201505241946</version>
</dependency>
but all tests failed due to
org/jacoco/agent/rt/internal_b0d6a23/Offline can not be found. Is
there anything wrong with my configration?
On Friday, August 14, 2015 at 4:04:56 PM UTC+8, Marc R. Hoffmann
wrote: Hi,
JaCoCo works on class files only. It reports whatever it sees in the
class files which get instrumented and analyzed. Future versions might
come with the option to filter certain constructs, but for AspectJ this
will probably not work as you can inject any code.
To solve this you have to make sure that the class files get instrumeted
by JaCoCo *before* AspectJ kicks in. If you use the AspectJ agent it has
to be configured after the JaCoCo agent. If you want to pre-compile your
http://www.eclemma.org/jacoco/trunk/doc/offline.html [2]
Regards,
-marc
Post by zhz shi
Hi,
We're using AspectJ in our project and also Jacoco for test
coverage
Post by zhz shi
report, currently we're facing an issue that due to AspectJ
changed
Post by zhz shi
the byte code during compiling phase, which makes the code
coverage
Post by zhz shi
report not correct. One example is due to AspectJ adds extra
if-else
Post by zhz shi
statement, then the branch coverage shows something like 1/4 but
actually there's no condition branch in the source code. Is there
some
Post by zhz shi
good way to tell Jacoco to ignore all code generated by AspectJ?
I also created an issues 335 [1] on Github and posted an question
on
Post by zhz shi
SO [2].
Thanks a lot.
--
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
Post by zhz shi
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
Post by zhz shi
Post by Marc R. Hoffmann
[3]
Post by zhz shi
[3].
For more options, visit https://groups.google.com/d/optout [4]
[4].
Post by zhz shi
------
[1] https://github.com/jacoco/jacoco/issues/335 [5]
[2]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
Post by zhz shi
Post by Marc R. Hoffmann
[6]
Post by zhz shi
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&utm_source=footer
Post by zhz shi
Post by Marc R. Hoffmann
[7]
Post by zhz shi
[4] https://groups.google.com/d/optout [4]
--
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,
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com
Post by zhz shi
Post by Marc R. Hoffmann
[8].
For more options, visit https://groups.google.com/d/optout [4].
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/0c4de744-f40b-4d9b-b6f9-ec7362d6ce68%40googlegroups.com
Post by zhz shi
[9].
For more options, visit https://groups.google.com/d/optout [4].
------
[1]
http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom-offline.xml
[2] http://www.eclemma.org/jacoco/trunk/doc/offline.html
[3]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com
Post by zhz shi
[4] https://groups.google.com/d/optout
[5] https://github.com/jacoco/jacoco/issues/335
[6]
http://stackoverflow.com/questions/32001843/jacoco-code-coverage-is-affected-by-aspectj
Post by zhz shi
[7]
https://groups.google.com/d/msgid/jacoco/e96a08b4-8c44-469a-b32b-52f013e57bbd%40googlegroups.com?utm_medium=email&amp;utm_source=footer
Post by zhz shi
[8]
https://groups.google.com/d/msgid/jacoco/088f94d1-850a-4c7b-a420-ef39147daf80%40googlegroups.com?utm_medium=email&amp;utm_source=footer
Post by zhz shi
[9]
https://groups.google.com/d/msgid/jacoco/0c4de744-f40b-4d9b-b6f9-ec7362d6ce68%40googlegroups.com?utm_medium=email&utm_source=footer
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/d341115a-0f91-4dc8-a943-d599f95ef900%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alexander Kriegisch
2015-09-06 09:39:06 UTC
Permalink
You have two options with AspectJ if you want to avoid it compiling from source:

1) Use LTW with the weaving agent.

2) Move your aspects into a separate Maven module. Compile your Java modules with the normal Maven Compiler Plugin and the aspect module with AspectJ Maven. Then create another module which just uses AspectJ Maven in order to do binary weaving on a Java module, using both previously created artifacts as dependencies. In this scenario you need to make sure that JaCoCo offline instrumentation is bound to a phase before binary weaving is done.

The easiest way out, though, would be to test your aspects in isolation and also the Java code without aspects and measure coverage there without any issues.
--
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 jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/d696cd6e-7118-4893-8698-39774996e51c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...