Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test coverage missing in Netbeans 8.1?

I downloaded recently Netbeans 8.1 here

I chose second option: "Java EE".

But I can't find how to run test coverage for my unit tests. I have this menu:

enter image description here

It's a Maven Web Application.

When I go to Tools -> Plugins and search for "coverage", I have this:

enter image description here

I installed it and restarted the IDE, I saw it was installing the plugin but there's no change in my menu. If I search "coverage" in the Installed plugins, nothing shows up else than the one I just installed... I thought Netbeans had it implemented? I also thought Netbeans has the Maven test coverage as well...

I read that the plugin I installed (TikiOne JaCoCoverage) is just an extension of the already existing Netbeans Test Coverage.. so that would explain why I can't see it.

How can I enable test coverage?

Thanks.

like image 894
anthomaxcool Avatar asked Aug 02 '16 13:08

anthomaxcool


People also ask

How do I get code coverage in NetBeans?

Code Coverage on the NetBeans Platform In the IDE, go to Tools | Plugins and install "Cobertura Module Test Coverage".

How do I run test cases in NetBeans?

The easiest way to run all the unit tests for the project is to choose Run > Test <PROJECT_NAME> from the main menu. If you choose this method, the IDE runs all the test classes in the Test Packages. To run an individual test class, right-click the test class under the Test Packages node and choose Run File.

How do I check STS coverage?

Right-click on project > Properties > Coverage to enable code coverage. Then, right-click on project > Run Code Coverage.


1 Answers

you should add the JaCoCo plugin into <plugins> section of your pom.xml file.

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.7.201606060606</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

After you build the project, the menu item for Code Coverage menu item appears when you right-click the project.

Netbeans Code Coverage Menu

Finally, you can select Show Report from the menu. Everything is described here.

like image 116
javaeeeee Avatar answered Sep 30 '22 21:09

javaeeeee