Jacoco Tutorial: Introduction to Jacoco

preview_player
Показать описание
Jacoco: Jacoco is a free code coverage library for Java. In this you'll following:
- What is Jacoco
- How Jacoco gives code coverage
- How to integrate Jacoco with Java Tests
- How to generate report thorough Jacoco

CHECK OUT CODING SIMPLIFIED

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 500+ videos. My account is Partner Verified and I get my earnings direct deposited into my account every month.

★☆★ VIEW THE BLOG POST: ★☆★

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★


★☆★ SEND EMAIL At: ★☆★
Рекомендации по теме
Комментарии
Автор

Jacoco can be use in android automotive emulators for coverage report generation?

hemrajdangi
Автор

Hi,
I am trying to implement the Jacoco with Ant in my project. I am facing the below issue while executing the Junit tests. Please let me know if you could help me to implement it.

[jacoco:coverage] Enhancing junit with coverage
[junit] Running src/test/UnitTeststest.test1
[junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
[junit] TEST src/test/UnitTeststest.test1 FAILED
[junit] Running src/test/UnitTeststest.test2
[junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
[junit] TEST src/test/UnitTeststest.test2 FAILED
[junit] Tests FAILED

It is failing while executing unit tests, and I am not getting what is the issue. Below is my build.xml


<project name="JacocoExampleProject" basedir="." default="reportgen">

<property name="src.dir" value="src" />
<property name="test.dir" value="src/test" />
<property name="build.dir" value="build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="jar.dir" value="${build.dir}/jar" />

<property name="main-class" value="Arthematics" />
<property name="reports.dir" value="reports" />
<property name="lib.dir" value="lib" />

<path id="classpath">
<fileset dir="./lib">
<include name="**/*.jar" />
</fileset>
</path>

<taskdef uri="antlib:org.jacoco.ant"
<classpath path="./lib/jacocoant.jar" />
</taskdef>

<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${reports.dir}" />
<delete dir="${classes.dir}" />
</target>

<target name="compile" depends="clean">
<mkdir dir="${classes.dir}" />
<mkdir dir="${reports.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" />
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" />
</copy>
</target>

<target name="jar" depends="compile">
<mkdir dir="${jar.dir}" />
<jar basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
</jar>
</target>

<target name="main" depends="test.instrument">

</target>

<target name="clean-build" depends="clean, jar" />


<path id="application" />

<target name="instrument" depends="compile"
<!-- Step 2: Instrument class files -->
<jacoco:instrument
<fileset dir="${classes.dir}" />
</jacoco:instrument>
</target>


<target name="test.instrument" depends="instrument">
<echo>Tests are in: ${test.dir}</echo>
<echo>classes are in: ${classes.dir}</echo>
<jacoco:coverage
<junit fork="true" forkmode="once" printsummary="on">
<test />
<test />
<classpath>
location="./bin" />
</classpath>
</junit>

</jacoco:coverage>
</target>
<target name="reportgen" depends="test.instrument">
<jacoco:report
<executiondata>
<file />
</executiondata>
<structure name="JacocoExampleProject">
<classfiles>
dir="${build.dir}/classes" />
</classfiles>
</structure>
<html destdir="reports" />
</jacoco:report>
</target>
</project>

ravitejagutti