Git Product home page Git Product logo

jacoco-gerrit-maven-plugin's Introduction

JaCoCo to Gerrit Maven plugin

JaCoCo to Gerrit Maven plugin enables your Gerrit with test code coverage visible as an editor's gutter.
Gerrit Test Code Coverage Gutter Example

What it does

This maven plugin collects test line coverage for files changed in a particular Gerrit changset and uploads the results to Gerrit. However, following tweaks need to be in place

Usage

In Gerrit, the user (denoted by gerrit.user bellow) needs to have enabled HTTP access: Settings -> HTTP Password -> Generate HTTP password.

To run this maven plugin

  1. at first, execute mvn test (or mvn verify) with enabled JaCoCo probes (see next chapter to get hints how to do that), which creates jacoco.exec file with coverage data. This data file is read by this plugin and the collected information is uploaded to Gerrit.

  2. to run this plugin:

    • if executed as a Jenkins/Hudson job with enabled Gerrit Trigger (if the build is triggered by an Gerrit Event, several system environment variables (prefixed with GERRIT_*) are set and used by this plugin)

        $ net.uvavru.maven.plugin:jacoco-gerrit-maven-plugin:jacoco-to-gerrit -Djacoco.execFile=target/jacoco.exec -Dgerrit.password=***** -Dgerrit.port=8080 -Dgerrit.username=robot -Dgerrit.host=gerrit.someorg.com
      
    • otherwise additional parameters must be set explicitly:

        $ ... -Dgerrit.projectName=gerrit-project-name -Dgerrit.branchName=master -Dgerrit.changeId=I156abb8bf7d9bbb151ebfe130bb4568320c3252b -Dgerrit.revisionId=d80c5bffddcebc7d88baf57ad4cc3da42a9692e3
      

      these parameters are configurable by system environment variables as well: GERRIT_PROJECT, GERRIT_BRANCH, GERRIT_CHANGE_ID, GERRIT_PATCHSET_REVISION (which are automatically set by Jenkins/Hudson if Gerrit Trigger is used).

Running tests with JaCoCo probes

To run maven tests with JaCoCo probes, jacoco agent has to be enabled in the JVM running the tests. For further information, refer to Jacoco plugin site.

  1. Configure org.jacoco:jacoco-maven-plugin to generate JVM agent property or to set surefire or failsafe argLine directly

  2. Configure the location where to write Jacoco probes - the jacoco.exec file

  3. Configure maven-surefire-plugin (or maven-failsafe-plugin) to use the enhanced JVM parameters

  4. Execute test (or verify) maven phase

    $ mvn clean test
    

    or

    $ mvn clean verify
    
  5. Now, when the jacoco.exec file is generated, this plugin can be run in order to collect relevant information and upload it to Gerrit.

As a concrete example of a configuration of Jacoco and test execution in Maven, one can consider looking at Jersey sources.

Notes

This maven plugin is a substitution for https://github.com/muryoh/sonar-gerrit-plugin which is capable of the same functionality (i.e., to upload test code coverage to Gerrit). However, in that case, Sonarqube is required and the Sonar analysis has to be executed.

jacoco-gerrit-maven-plugin's People

Contributors

stepanv 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.