Code Coverage

I'm running TeamCity 3.1.1
I have a simple build running an ant script ( ANT 1.7.0) with a Junit task.
It doesn't compile the project, instead it is triggered by another TeamCity build that does.
I've checked "Enable code coverage" option for the Junit build, but it seams to have no effect.
At the end of the build log I see:

\[Publishing artifacts] Artifacts path coverage.txt not found
\[Publishing artifacts] Artifacts path coverage not found
\[Publishing artifacts] Artifacts path coverage.ec not found
\[Publishing artifacts] Artifacts path coverage.em not found

I can see that EMMA jars and system properties are added to the JVM running the unit tests, but that's the only thing related to EMMA in the log.

I could find virtually no documentation on how this code coverage feature is supposed to work.

In the GUI there is only the one check box "Enable code coverage" with a cryptic message under it:
"Add 'clean' target in your Ant build for this option to work".

What am I missing?

Thanks,
Dmitry

5 comments

Take a look at your build log, are there any messages about code instrumentation from EMMA? When your build starts TeamCity watches for compilation tasks and adds EMMA to instrument your compiled code. Then when Junit task started EMMA is added to the classpath of the Junit task, and if instrumentation performed correctly EMMA produces coverage report (coverage.txt and coverage.zip files). If all is correct then you should see additional tab on the build results page called "Code coverage", also there should be bar indicators on the build results page with coverage statistics.

If I understand your right your build with enabled coverage does not perform compilation of the project, in this case instrumentation was not performed and coverage will not be available. For this feature to work you need to compile sources and run tests in the same build.

--
Pavel Sher

0

Would it work if I'm using wlcompile task (from BEA Weblogic) instead of javac to compile my classes?
If not, maybe I can add a post processing step to perform after wlcompile and before junit.

0

Hello Dmitry,

wlcompile task from WebLogic is not supported.
Please vote for http://jetbrains.net/tracker/issue/TW-2292

Kind regards,
KIR

0

What about running instrumentation on my classes explicitly before junit?
Would it work?
I could call the emma/instr ant task...
Any special options I should use?

0

Yes, this should work, simply because this is what our emma-post processing does. We use -cp classpath and -m overwrite options.
But this way you'll miss per-file HTML report in the results, because report generation code won't know about paths to your source files.

Regards,
KIR

0

Please sign in to leave a comment.