Skip to content
/ jacoco Public

A sample project to demonstrate the usage of JaCaCo for Integration Tests

Notifications You must be signed in to change notification settings

3r1co/jacoco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Coverage with TomEE, JaCoCo and SonarQube

In this little example I present you how to easily run code coverage analysis for integration tests.

How To Run

  1. Compile the project with Maven first, as the class files need to be available for the Code Coverage Analysis:

    mvn clean package
    
  2. Download the Jacoco Agent from here.

  3. Place it in the root of the repository (as it is linked in the docker-compose.yml)

  4. Start the docker-compose stack.

    docker-compose up -d
    
  5. Connect to the maven container and change to /app:

    docker exec -it jacoco_maven_1 bash
    bash-4.3# cd /app
    
  6. Fetch the JaCoCo Dump:

    mvn jacoco:dump -Djacoco.address=app
    
  7. Run the SonarQube Analysis:

    mvn sonar:sonar -Dsonar.host.url=http://sonar:9000
    
  8. Access the SonarQube Analysis under http://localhost:9000 and see the coverage report. It should say 0% of your code is covered.

  9. Access the sample application under http://localhost:8888/jacoco-example. Do some math calculations to see the analysis work.

  10. Fetch the JaCoCo Dump again:

    mvn jacoco:dump -Djacoco.address=app
    
  11. Run the SonarQube Analysis again:

    mvn sonar:sonar -Dsonar.host.url=http://sonar:9000
    
  12. Access the SonarQube Analysis under http://localhost:9000 and see the coverage report. You should see 85.7% of Code Coverage.

About

A sample project to demonstrate the usage of JaCaCo for Integration Tests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published