Code coverage is a number of metrics that measure how your code is covered by unit tests. Code coverage information displays for those build configurations, where this metric is configured in the Code Coverage section of a build runner (Build Configuration Home Page > Edit Build Configuration Settings > 3.Runners). In TeamCity the code coverage is available for Ant and Ipr build runners. The engine is based on the EMMA open-source toolkit. View the code coverage summary in the Overview tab of the Build Results page; detailed report displays in the Code Coverage tab. Chart for code coverage is also available in the Statistics tab of the build configuration. EMMA Integration NotesThere are several steps when collecting coverage with EMMA:
Code Coverage TroubleshootingNo coverage, there is a message: EMMA: no output created: metadata is emptyPlease make sure that all your classes (whose coverage is to be evaluated) are recompiled during the build. Usually, this requires adding a kind of "clean" task at the beginning of the build. java.lang.NoClassDefFoundError: com/vladium/emma/rt/RTThis message appears when your build loads EMMA-instrumented class files in runtime, and it cannot find emma.jar file in classpath. For test tasks, like junit or testng, TeamCity adds emma.jar to classpath automatically. But for other tasks, this is not the case and you might need to modify your build script or to exclude some classes from instrumentation. If your build runs a java task, which uses your own compiled classes, you'll have to either add emma.jar to classpath of the java task, Corresponding emma.jar file can be taken from buildAgent/plugins/coveragePlugin/lib/emma.jar. To exclude classes from compilation, use settings for EMMA instrumentation task. TeamCity UI has a field to pass these parameters to EMMA, labeled "Coverage instrumentation parameters". To exclude some package from instrumenting, use syntax like: -ix -com.foo.task.*,+com.foo.*,-*Test*, where package com.foo.task.* contains files for your custom task. EMMA coverage results are unstablePlease make sure that your junit task has attribute fork=true. The recommended combination of attributes is "fork=true forkmode=once". See Also:
|