Restricting coverage collection to source directories rather then class packages

On a related note, I would like to exclude my test-only code from the coverage analysis.  My test code is in the same package as my prod code, (but in a different source tree,) so filtering by package at the report generation stage won't work.  Filtering by class name is very unwieldy, as we have a huge amount of test setup code and we couldn't effectively maintain the list of ignored classes.  Additionally, we commonly generate stub classes from WSDL to test web services, however we only use a fraction of the code in the stub - meaning that the unused code falsely drives down our coverage score.

Ideally, what I would like to do is to specify, for a given invocation of javac, whether the classes should be instrumented or not - perhaps by setting an ant property.  However, according to the TeamCity 5 docs, ALL invocations of javac are intercepted for instrumentation purposes.

Note: we use ant for scripting our builds and the TeamCity/Emma coverage analysis feature.

Any ideas?

Message was edited by: Yegor Yarko Branched from

1 comment
Comment actions Permalink


TeamCity does not allow to influence per-javac invocation options.

If you know a way of achieving your goal with EMMA parameters (assuming all the javac tasks get the same options), you might tweak the EMMA settings in UI. Othervise you can probably turn off TeamCity coverage integration and implement coverage inside your build script manually, then publish the report into TeamCity as artifact.

A side note: As TeamCity now integrates with InteeliJ IDEA code coverage engine it's unlikely that we will add new features into EMMA-related coverage (because EMMA is not actively developed). IDEA coverage does not support your case either, but you can file an issue on that into IDEA tracker.


Please sign in to leave a comment.