Code Coverage for NetBeans modules

NetBeans 6.7 and Later

To run test coverage on modules from source tree, default JDK must be used (see Issue 145107 for details). Specify property


and perhaps


(when the build script complaints that it should be run with JDK 5) when running Ant target.

Unit tests

For module suites and standalone modules, just run ant coverage-report from command line, which runs the tests and generates HTML report in build/test/unit/cobertura-report folder. From NetBeans IDE, you can also invoke target display-coverage-report ("Run Target" on context menu of "Important Files/Build Script" node in project window), which directly opens generated report in your web browser.

Functional tests (6.8 and later)

To run code coverage for qa-functional tests, run ant coverage-report-qa-functional from command line. The HTML report is generated in build/test/qa-functional/cobertura-report.

Sometimes, the functional tests cover more modules than just the one they're in (example is spi.debugger.ui). In that case it is possible to define a set of modules which will be measured. This is done by setting a property in of the module the tests reside in.

Example:*/modules/org-netbeans-spi-debugger-ui.jar, java*/modules/org-netbeans-modules-debugger-jpda.jar, java*/modules/org-netbeans-modules-debugger-jpda-ui.jar

The modules need to be defined as a list of jars by the path from netbeans root directory, separated by ',' and all on a single line.

IMPORTANT NOTICE: During code coverage, the original jars are backed up, replaced by instrumented ones and finally restored. Do NOT interrupt the code coverage process or you will end up with a non-working build (cobertura library is not on netbeans classpath by default). If you do, you will have to rebuild the instrumented jars or restore them manually from build/test/qa-functional/modulesbackup.

NetBeans 6.1 and Earlier

Code coverage measures how many code was used by tests. NBM projects in NetBeans CVS contains coverage ant target in project builds script. It generates html report. For example it can be executed from command line.

cd nbcvs/your_module
ant coverage

For other types of NBM project can be used Experimetal Project Extension module from nbxdoclet project. Some details about this feature are described here.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo