Note: Script compiles the project first and then triggers the selenium tests against the application from compiled code-base.
Please refer the below script and let us know, where and what are we doing the mistake.
-----------------------------Script Begins-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<project name="Ant file for TestNG" default="all" basedir="." xmlns:sonar="antlib:org.sonar.ant" xmlns:jacoco="antlib:org.jacoco.ant">
<taskdef resource="net/sf/ant4eclipse/antlib.xml" />
<path id="class.path">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${bin.dir}" />
</path>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${it.test.report.dir}" />
</target>
<target name="init">
<mkdir dir="${it.test.report.dir}" />
</target>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="X:/.../.../.../.../jacocoant.jar"/>
<classpath path="X:/.../.../.../.../jacocoagent.jar"/>
</taskdef>
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="class.path">
</taskdef>
<target name="report">
<jacoco:agent property="agentvmparam" destfile="X:/.../.../.../.../jacoco.exec" includes="**/*.class" output="file" dumponexit="true" classdumpdir="X:/.../.../.../.../jclasses"/>
<jacoco:coverage>
<testng haltonfailure="yes" classpathref="class.path">
<xmlfileset dir="." includes="Demotestng.xml" />
<classpath refid="class.path" />
<jvmarg value="-Xshareclasses:none"/>
<jvmarg value="${agentvmparam}"/>
</testng>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="X:/.../.../.../.../jacoco.exec"/>
</executiondata>
<structure name="Example Integration Test Project">
<classfiles>
<fileset dir="X:/.../.../.../.../servlets">
<include name="**/*.class" />
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="X:/.../.../src/.../.../servlets">
<include name="**/*.java" />
</fileset>
</sourcefiles>
</structure>
<html destdir="jreport" />
</jacoco:report>
</target>
<target name="all" depends="clean,compilepresentation,report" />
</project>
--------------- Script Ends---------------------------------------
Made all the required changes and continuously trying with potential changes. However, unable to meet the objective of getting the coverage report.
Report generated as "Missed Instructions: All(RED Horizontal pipe), Coverage:0%:: Missed branchess: All(RED Horizontal pipe), Coverage:0%"
Kindly help me on this, it's been a week, we're unable to reach the goal.
Thanks
On the other hand, made below changes and ran Jenkins job,
Case-1: Removed <jacoco:coverage> </jacoco:coverage> and ran the script
Case-2: Removed <jacoco:agent property="agentvmparam" destfile="X:/.../.../.../.../jacoco.exec" includes="my.company.*" output="file" dumponexit="true" classdumpdir="X:/.../.../.../.../jclasses"/> and ran the build
Both the above cases resulted in same old result. Am I missing anything here?
Request other group members who've succeeded in getting code coverage for selenium UI tests to provide insight into this issue.
Thanks
Also looked at Sessions, it lists the Sessions, Start Time and End Time and says No execution data available.
Thanks