The maven project support in netbeans is fantastic, and much better then the competition. However, this benefit is
severely diminished because code coverage data can't be displayed inline in the editor for maven projects.
Please extend the maven code project support to work with the code coverage plugin.
this is something to be filed against the code coverage plugin. I'm not aware of any API that maven support could
implement to get code coverage.
what coverage plugin are we talking about?
Sorry for not replying sooner.
In my case, the maven projects uses cobertura. I can use this data by running the cobertura:cobertura goal, then opening
the generated html files to see which classes need their coverage improved. My colleagues who use another IDE have
coverage data presented in the IDE directly in the java view.
There are plugins available for netbeans projects which provide this functionality (http://codecoverage.netbeans.org/)
however this doesnt appear to work in maven projects
Ideally i would like maven projects to be compatible with all plugins that work with standard projects, but code
coverage is of particular concern given the industry drive to high levels of code coverage.
There is a tutorial how to hack coverage plugin to work with Maven projects. http://sharebear.co.uk/blog/2009/01/21/code-coverage-maven-projects-netbeans/
http://wiki.netbeans.org/RubyCodeCoverage discusses comparable support for Ruby projects, using the gsf.codecoverage API. Probably this could be implemented for Java source files in Maven projects. Not sure what exactly is needed, since I cannot yet get it to work reliably in Ruby projects.
I'm experimenting with a Maven provider based on the Cobertura plugin. Past feature freeze for 7.0 so it can't go into the standard distribution, but could be put on Beta AU perhaps.
Great news! Let me know if you want a beta tester
you might be interested in jacoco - http://www.eclemma.org/jacoco/trunk/
haven't used it, just haveve seen it demoed at Eclipsecon in March. The great advantage of jacoco compared to other tools is that it doesn't require additional compilation cycle. it's just a java agent that gets set for the executed tests..
Integrated into 'main-golden', will be available in build *201011140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jesse Glick <firstname.lastname@example.org>
Log: Starting work on #157946: Maven code coverage.
This is great news! Note that code coverage is also implemented for PHP, see http://blogs.sun.com/netbeansphp/entry/code_coverage_for_php_why
Cobertura support should be on dev AU when core-main #e14bbcdb5ce3 propagates.
The "Test" button does not work - limitation of API - but "All Tests" does. So for now you cannot refresh coverage on a single class, only the whole module.
For now you have to add the Cobertura plugin to your project manually (the module will not set it up for you); suffices to be declared in plugin section, or added as a 2.x-style or 3.x-style reporting plugin. The generic UI has a checkbox to disable coverage but this does nothing for now.
There are probably some other rough spots, but this may be enough to get started with.
JaCoCo sounds interesting. Not sure if it is easy for a Maven plugin to tell Surefire to use an extra agent param, though.
It is on the dev update center for anyone who wants to test it. Will only work in 7.0 dev builds (after the Beta).
Can more explicit instructions for how to use this be provided? I couldn't figure out how to get it to work.
(In reply to comment #13)
> I couldn't figure out how to get it to work.
Did you install the plugin from dev AU? Do you have the Cobertura plugin configured on your project? Is there a Code Coverage menu item on your project's context menu? Did you open the report, Run All Tests, and did results appear? Does target/site/cobertura/coverage.xml exist with plausible contents?
Environment: NetBeans Dev 201011210001 - Mac OS X 10.6.5 - Java 1.6.0_22
Did you install the plugin from dev AU?
Yes (Maven Test Coverage - also restarted NetBeans after installing the plug-in)
Do you have the Cobertura plugin configured on your project?
Yes (maven-cobertura-plugin [1.4] added to Test Dependencies - Also re-started NetBeans after configuring this)
Is there a Code Coverage menu item on your project's context menu?
Did you open the report, Run All Tests, and did results appear?
Does target/site/cobertura/coverage.xml exist with plausible contents?
(In reply to comment #15)
> Yes (maven-cobertura-plugin [1.4] added to Test Dependencies
Ah. This doesn't make any sense; you are not compiling your tests against a Maven plugin! So don't add it to the dependencies section. The IDE will look in the build plugins section (although this plugin defines no default executions, so defining it here is probably uncommon), or in the reporting plugins section (using either Maven 2.x or 3.x syntax). If it can't find the plugin mentioned in any of these places, the submenu will be suppressed.
OK. I edited the POM to include cobertura and the cobertura-maven-plugin and I'm not able to see the context menu, select the Show Reports... and use the Run All Tests to generate test coverage. I'm often encountering Null Pointer Exception, Array Out of Index and some other errors when using it. Not sure if that's related to not having all of the required plug-ins included or there are still some bugs to be worked out. I'm submitting reports as they occur.
(In reply to comment #17)
> I'm often encountering Null Pointer
> Exception, Array Out of Index and some other errors when using it. Not sure if
> that's related
Might be completely unrelated to coverage support, hard to say. Just use the exception reporter every time and they will get dealt with.
Petr helpfully wrote up a little tutorial!