Git Product home page Git Product logo

jaccoco-codebuild's Introduction

Java code coverage example

Jacoco, Spring Boot, Maven and Junit 5, JaCoCo Jenkins Plugin

This project runs JUnit tests under code coverage and creates a coverage report (target/site/jacoco/index.html).

run:

mvn clean verify

Also this project excludes MainApplication.class to show how excludes/includes works (https://www.jacoco.org/jacoco/trunk/doc/report-mojo.html#excludes).

If you want, comment or remove <configuration> <excludes> under <plugins>section in the pom.xml and you will still have 100% code coverage because contextLoads() @Test is implemented. But keep in mind that there are scenarios where you don't want this behavior. Instead, @Test void contextLoads(){...} can be part of integration Tests.

JaCoCo Jenkins Plugin

I am going to show you how to use the JaCoCo Jenkins Plugin to achieve the same goal of jacoco-maven-plugin and have overall code coverage statistics for all modules.

The first step is installing the JaCoCo Jenkins plugin

Go to Jenkins -> Manage Jenkins -> Manage Plugins -> Available(tab) and find JaCoCo plugin

  • notice that you need to have JaCoCo Maven plugin in your pom.xml, like this project.

Add Post-build Actions to the job responsible for packaging the application. -> Record JaCoCo coverage report.

Important

for simplicity you can use this project.

Install and configure Jenkins if you had not done so before.

For this example, I use a maven project. If you don't have Maven Project option. This link can help you: https://stackoverflow.com/questions/45205024/maven-project-option-is-not-showing-in-jenkins-under-new-item-section-latest

Also you need to configure Jenkins -> Global Tool Configuration: JDK, Maven (Add Maven)

The result, as shown in the image below, is something like this in Coverage Trend

image

jaccoco-codebuild's People

Contributors

dnilay avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.