Code coverage report generation using Java, Ant , JUnit, Mockito , Powermockito & JACOCO framework

preview_player
Показать описание
Generate code coverage using JACOCO , JUnit, Mockito, Powermockito frameworks
Рекомендации по теме
Комментарии
Автор

thanks..it was very clear. it helped a lot

aaaaaaaaaa
Автор

Thanks for the video. If somebody has the problem with starting the project just change Build.xml to build.xml

romanmotovilov
Автор

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
Автор

Quite precise and quite you please share the link for the above project

MayankSingh-cfrk
Автор

hi can you share with maven example for offline

prasad
Автор

Please refer below git URL for this code

tech-yug
join shbcf.ru