No luck with code coverage
Folks,
I'm trying to take advantage of the code coverage feature in TeamCity 3 (I'm having lots of problems with IDEA 7 not displaying the results properly, so I thought I would try my luck in TeamCity), but I'm not having any luck. The first issue is that I can't seem to find any documentation beyond the scant few sentences on this page: http://www.jetbrains.net/confluence/display/TCD3/Code+Coverage Am I missing some other documentation that explains the setup and usage of this feature in greater detail?
My primary problem is that, when I enable code coverage, I get a NoClassDefFoundError. I have an ant runner configured for my TeamCity project, and the error seems to be happening as part of a call to javac. I have included emma.jar and emma_ant.jar in my ant/lib directory. Do I have to edit all of my ant files to include emma.jar in the classpath of any invocations of javac, junit, etc? I really don't understand how this works. If anyone can point me to some documentation that explains the requirements, I would really appreciate it. Here's my error in case anyone is interested:
: Compiling 1 source file to /opt/TeamCity/buildAgent/work/7573b74006230899/build/classes
: EMMA: Instrumenting classes (<1s)
: EMMA commandline:
: EMMA: processing instrumentation path ...
: EMMA: instrumentation path processed in 65 ms
: EMMA:
: EMMA: metadata merged into {in 6 ms}
: Adding emma system properties to Java task.
: java (<1s)
: JVM args ignored when same JVM is used.
: java.lang.NoClassDefFoundError: com/vladium/emma/rt/RT
: Unable to find /opt/TeamCity/buildAgent/work/7573b74006230899/coverage.ec, cannot create EMMA report
Please sign in to leave a comment.
Hello Paul,
It looks like your Ant build runs a java process using class files compiled in your build.
As long as classes are instrumented with EMMA, you need to add emma.jar to the class path
of the java task.
Corresponding jar file can be included from buildAgent/plugins/coveragePlugin/lib/emma.jar
In your case you can reference this jar as ../../plugins/coveragePlugin/lib/emma.jar
Hope this helps,
KIR
Kirill,
Thank you very much for the response. Is there any detailed documentation of the use of this feature anywhere?
I still don't understand what I need to do exactly. The error is happening when javac is called (or at least it appears to me that it is). Why would instrumentation be turned on for javac? Also, I don't want to have to update all of our ant files if I can avoid it. I tried putting emma.jar in the ant/lib directory, but that did not work. Do you know of any way to put the emma.jar in a shared location so that I do not have to make any changes to our ant files?
Regards,
Paul
Hello Paul,
According to your attached log, the problem is not with javac task (it works fine, because classes are instrumented successfully).
After the javac, your build script calls java task:
00:37:17: java JVM args ignored when same JVM is used.
00:37:17: java java.lang.NoClassDefFoundError: com/vladium/emma/rt/RT
You need to:
1. set attribute fork="true" for this java task
2. to the classpath of this task add emma.jar (or put this emma.jar to some shared location, used by this java task).
Kind regards,
KIR
Kirill,
This seems to have done the trick. Thank you very much. The build ran, and the emma coverage.ec and coverage.em files were generated and show up in the Artifacts tab. Unfortunately, I don't see the Code Coverage tab in the build results, so I need to do some digging through this forum to see if there are any answers as to why that might be.
Regards,
Paul
I have added emma.jar to the java task class path and still see the following error in the Teamcitybuild log
java.lang.NoClassDefFoundError: net/internalname/internalname/intername/internalname/ConfigurationException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
Is there a way I can check if it did include the emma.jar files
Thanks,
Lachi