Skip to content

chenliushan/JacocoExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An example of using Jacoco

This project is an example of generating detailed line coverage report with the JACOCO library.

The detailed line coverage report is the test execution coverage with detailed information about specific executed lines (lines hit information during test execution), which is a richer information than the general percentage coverage of classes/methods/lines.

The detailed report example

Requirements

  • Maven3.5
  • JDK 1.8

Install JDK1.8 and Maven on Ubuntu

Steps

There are three steps to generate the detailed coverage report:

  • Configure the project with maven (create/config the 'pom.xml' as this example)

  • Test the project with Jacoco agent (run the test with Java VM argument -javaagent:path/to/jacocoagent.jar)

    mvn -Dtest=lab.RectangleTest#rotate test
    
  • Generate the coverage report with Jacoco ant

    mvn antrun:run@generate-report -Dskip.int.tests.report=false
    

The generated report is under dirtarget/coverage-report/html/jacoco-multi


Note that, you can generate the detailed test execution coverage report for each test by running the test and generating report (step 2 and 3) repeatedly with following command.

mvn -Dtest=lab.RectangleTest#rotate test

PS: the source code under src and test is just a small demo for test execution

Acknowledgement and references

JACOCO https://github.com/pszeliga/jacoco-e2e-coverage/blob/master/pom.xml

About

An example of generating detailed line coverage report with the JACOCO.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors