codenoob
codenoob

Reputation: 79

How to get test coverage percentage for java maven based program?

I have a Java program based on maven and for that I need to know the test coverage percentage. For testing, I am using testng.

I can already run the tests using command mvn test. All the tests are passing and I can see the report in surefire-reports/index.html. But I could not get the test coverage percentage that I need to supply for reporting.

mvn test

Expected result is Test Coverage Percentage is x%

Upvotes: 2

Views: 13938

Answers (2)

Kiryamwibo Yenusu
Kiryamwibo Yenusu

Reputation: 176

For those Using Netbeans IDE, do the following

  1. Right Click on the Project
  2. Select Code Coverage
  3. then choose Show Report

As shown Below

enter image description here

Code coverage for every file will be displayed.

Upvotes: 1

Ludov Dmitrii
Ludov Dmitrii

Reputation: 592

You can use Intellij to get a coverage report. Right-click on a test folder: run all with coverage and here you go,

how to run all tests with coverage

maybe you will need to call report window explicitly, it's located View -> Tool Windows -> Coverage. The last question about default plugin. The only information I can tell you about it is located in settings-> plugins: coverage plugin location

Upvotes: 1

Related Questions