Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Jacoco Introduction and how to use it for our java application, Slides of Java Programming

Introduction about the tool and the way to proceed with the tool and the syntax about that are given

Typology: Slides

2018/2019

Uploaded on 10/14/2019

AADARSH0509
AADARSH0509 🇮🇳

1 document

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JaCoCo Introduction
JaCoCo Coverage tool has been developed and used with Sun JDK (and later
Oracle JDK) from the very beginning of Java. It is an open source toolkit for
measuring code coverage and reporting java code coverage and reporting it
through visual reports.
It measures block, line and branch coverage based on the code covered by
running unit test cases and provides a visual report, including highlighted
lines of code and the total percentage of code executed in each method.
From this developer can easily assess the code that has not been adequately
tested. It’s is the best practice to focus on the areas where the coverage is
particularly low and try to analyse why this code hasn’t been tested fully.
pf3
pf4
pf5

Partial preview of the text

Download Jacoco Introduction and how to use it for our java application and more Slides Java Programming in PDF only on Docsity!

JaCoCo Introduction

 (^) JaCoCo Coverage tool has been developed and used with Sun JDK (and later Oracle JDK) from the very beginning of Java. It is an open source toolkit for measuring code coverage and reporting java code coverage and reporting it through visual reports.  (^) It measures block, line and branch coverage based on the code covered by running unit test cases and provides a visual report, including highlighted lines of code and the total percentage of code executed in each method.  (^) From this developer can easily assess the code that has not been adequately tested. It’s is the best practice to focus on the areas where the coverage is particularly low and try to analyse why this code hasn’t been tested fully.

Code Coverage

 (^) Code coverage is measured by determining the number of lines that are run through unit tests. This is called line coverage, which is the measurement most tools focus on. Line coverage simply reports the percentage of lines of code executed by taking the number of executed lines over the total number of lines of code.  (^) Branch coverage is another type of measurement that coverage tools report. This measures the coverage of decision points and conditional logic, such as blocks containing logical ANDs or ORs. It measures which decision outcomes have been tested. Branch coverage is important because it ensures that no branches lead to any other fault or abnormality of the program’s functionality and it validates that all branches in the code are reached. Branch coverage is calculated by taking the number of decision outcomes executed over the total number of decision outcomes.

 (^) The report obtained highlights the lines of instructions that have not been called and having low code coverage. This is illustrated by the various colours below.  (^) The general colour coding scheme that JaCoCo follows following are: Green – fully covered lines. Yellow – party covered lines. Red – lines that have not been executed at all.

Getting Coverage Report

 (^) For Standalone Application:  (^) Initially we have to add the JaCoCo plugin in pom.xml.  (^) When we successfully build the project for a standalone application using the command “mvn clean install”, directly against the "pom.xml" using the stand-alone Maven, Upon a successful Maven build, the code coverage report jacoco.exec is created in the "target
site\jacoco" folder in the Maven project.  (^) To check the coverage report in the browser, we have to provide the command “mvn test” which will provide the coverage report in html format.