Question

We have inherited a NetBeans Modules project (a.k.a. NetBeans Platform project) which builds using the NetBeans Ant tasks. We want to generate a code coverage report of the project to get an idea of what components are not being unit tested. Generating a report is not part of the build process, it is simply something we want to do to understand the existing unit test coverage in the project.

We've decided to use JaCoCo to try and generate this. However the native support in NetBeans is for maven based projects. Unfortunately the TikiOne JaCoCoverage plugin currently does not support NetBeans Modules projects.

We are happy to just drive this via CLI to get an initial report. Does anyone have a success means of doing so under the given constraints?

Was it helpful?

Solution 2

We have been successful in generating the report by doing the following:

  1. Edited the project.properties file to run the JaCoCo agent when unit tests run. This is done by adding the following:

    test.run.args=-javaagent:[yourpath/]jacocoagent.jar=destfile=[yourpath/]jacoco.exec
    
  2. Use Netbeans to run the test task. This produces the jacoco.exec file.

  3. Create a simple ant buildfile to generate reports from an .exec file (see this post)
  4. Run the ant buildfile to generate the report.

OTHER TIPS

Someone recently posted a related message to one of NetBeans mailing lists - https://netbeans.org/projects/platform/lists/dev/archive/2014-04/message/124

Short version: Cobertura plugin that does what you're looking for is not maintained now but you can build it and run it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top