Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sigpwned/jacoco-badge-maven-plugin

A simple maven plugin to generate JaCoCo build badges
https://github.com/sigpwned/jacoco-badge-maven-plugin

build-tool jacoco java maven maven-plugin testing

Last synced: 24 days ago
JSON representation

A simple maven plugin to generate JaCoCo build badges

Awesome Lists containing this project

README

        

# jacoco-badge-maven-plugin ![Build Status](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiYW50WHpPZStGUnVwT0VIWUpkUkhQZGVNWllGdWZuT3cvb3lVRk1ic0p6d0ZUdCt6ZWlyaDRub1E0b2lNNXlUdEQ2YlpBNEhXNTRsaDRBU3p2VnFXTENBPSIsIml2UGFyYW1ldGVyU3BlYyI6IkdjS0JTcFErUURac3VTbisiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master) ![Test Coverage](target/jacoco.svg)

A simple maven plugin to generate JaCoCo build badges

## Configuration

Before we can generate a JaCoCo test coverage badge, we need to run
JaCoCo test coverage!

JaCoCo measures test coverage of surefire unit tests and failsafe
integration tests. Both cases require that JaCoCo be configured to
integrate directly with the plugin in question.

### Configuring JaCoCo for Unit Tests

Here is a simple setup for surefire and JaCoCo that generates a
formatted HTML JaCoCo test coverage report.


**/IT*.java



org.jacoco
jacoco-maven-plugin
0.8.0








prepare-code-coverage

prepare-agent


surefireArgLine







report-code-coverage

report





verify-test-coverage

check




BUNDLE

*Mojo



INSTRUCTION
COVEREDRATIO
70%




${project.reporting.outputDirectory}/jacoco-aggregate



With this configuration, running `mvn test` should generate a friendly
HTML report of test coverage at `target/site/jacoco-aggregate/index.html`.

### Configuring Badge Generation

Once JaCoCo has been configured to generate a formatted report, it's
time to generate a badge from that report. Here is an example
configuration of this plugin to generate a badge based on unit tests:


com.sigpwned
jacoco-badge-maven-plugin
0.1.3


generate-jacoco-badge
verify

badge



70


instruction



## Including the Badge in your README

There are a couple of good ways to include the badge file into your
README:

* GitHub Only -- Generate the badge file into a resource directory,
and then embed a reference to the badge into your README. This has
the benefit of being very simple, but won't allow for the testing of
pull requests, etc. For an example, look at this README.

* CodeBuild -- Save the generated badge file as an artifact; configure
S3 to send an event every time a badge is uploaded; use a lambda
function to copy the latest badge to a known, fixed location; embed
a link to that fixed location.