Git Product home page Git Product logo

sonar-scoverage-plugin's Introduction

#Sonar Scoverage Plugin#

Build Status

Plugin for SonarQube that imports statement coverage generated by Scoverage for Scala projects.

Scoverage measures how many statements of a given Scala program have been covered by automated tests. This new metric is much better for Scala than traditional line coverage and branch coverage because typically:

  1. There are many statements on a single line
  2. if statements are used rarely

This plugin reads XML report generated by Scoverage and populates several metrics in Sonar:

  1. Total number of statements
  2. Number of statements covered by tests
  3. Statement coverage rate (%)

Projects with sub-projects are supported as well. Overall statement coverage is (sum of number of covered statements for all sub-projects) / (total number of statements for all sub-projects). In other words, it's more intelligent than just plain average of coverage rates for sub-projects.

Requirements

Support for older version of Sonar 3.5.1

If you have Sonar 3.5.1, take a look into the [dedicated branch] Plugin351 or directly [download binary JAR] Plugin351Jar.

Installation

Download and copy [sonar-scoverage-plugin-1.0.0.jar] PluginJar to the Sonar plugins directory (usually <SONAR_INSTALLATION_ROOT>/extensions/plugins). Restart Sonar.

Configure Sonar runner

Set location of the scoverage.xml file in the sonar-project.properties located in your project's root directory:

...
sonar.scoverage.reportPath=target/scala-2.10/scoverage-report/scoverage.xml
...

Run Scoverage and Sonar runner

If your project is based on SBT and you're using [Scoverage plugin for SBT] sbt-scoverage you can generate the Scoverage report by executing following from command line:

$ sbt clean scoverage:test

And then run Sonar runner to upload the report to the Sonar server:

$ sonar-runner

Add statement coverage columns

To see the actual statement coverage percentage you need to log in to Sonar as admin. Click Components section on the left side, then click Customize ON in the top-right corner and then add Statement coverage column.

Add widget

You can also add Statement coverage widget to your project's dashboard. Log in to Sonar as admin. Go to the project dashboard, click Configure widgets in the top-right corner, click Add widget button in the Custom Measures section. Click Edit in the newly added Custom Measures widget and choose Statement coverage for Metric 1. Click Save, Back to dashboard. Enjoy.

Sample project

Take a look at a sample SBT multi-module project located in this repository in the samples folder.

Screenshots

Project dashboard with Scoverage plugin: Project dashboard with Scoverage plugin

Multi-module project overview: Multi-module project overview

Columns with statement coverage, total number of statements and number of covered statements: Columns

Source code markup with covered and uncovered lines: Source code markup

sonar-scoverage-plugin's People

Contributors

radoburansky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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