Thanks for details.
I have gone through these documents but i didn't find any unit test files
are ran using junit in the ant offline instrumentation example.
Also when i ran the below mentioned build.xml (which is from offline
instrumentation) it's not working and i am getting the error message as
compile:
[mkdir] Created dir:
/Users/gvijayakuma2/code/src/vsphere/com.csc.agility.adapters.cloud.vsphere/target/classes
[javac] Compiling 31 source files to
/Users/gvijayakuma2/code/src/vsphere/com.csc.agility.adapters.cloud.vsphere/target/classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
instrument:
[jacoco:instrument] Instrumented 72 classes to
/Users/gvijayakuma2/code/src/vsphere/com.csc.agility.adapters.cloud.vsphere/target/classes-instr
test:
[java] Error: Could not find or load main class
org.jacoco.examples.parser.Main
[java] Java Result: 1
report:
[jacoco:report] Loading execution data file
/Users/gvijayakuma2/code/src/vsphere/com.csc.agility.adapters.cloud.vsphere/target/jacoco.exec
Request you to share me the example for instrumentation of classes, unit
test using junit for ant build.xml which uses powerMock
<project name="com.csc.agility.adapters.cloud.vsphere" basedir="." default=
"help" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- =====================================================================
Definitions
================================================================= -->
<!-- version properties -->
<property name="version.major" value="2" />
<property name="version.minor" value="0" />
<property name="version.build" value="0" />
<property name="bundle.version" value=
"${version.major}.${version.minor}.${version.build}" />
<property name="rpm.version" value=
"${version.major}.${version.minor}-${version.build}"/>
<property name="src.dir" location="./src"/>
<property name="result.dir" location="./target"/>
<property name="result.classes.dir" location="${result.dir}/classes"/>
<property name="result.classes.instr.dir" location=
"${result.dir}/classes-instr"/>
<property name="result.report.dir" location="${result.dir}/site/jacoco"/>
<property name="result.exec.file" location="${result.dir}/jacoco.exec"/>
<path id="compile.classpath">
<fileset dir="./lib" includes="**/*.jar"/>
<fileset dir="./ivy-lib">
<include name="com.servicemesh.agility.api-*.jar" />
<include name="com.servicemesh.agility.api.script-*.jar" />
<include name="com.servicemesh.agility.sdk.cloud-*.jar" />
<include name="com.servicemesh.core-*.jar" />
<include name="com.servicemesh.io-*.jar" />
<include name="log4j-*.jar" />
<include name="osgi-*.jar" />
<include name="/jacoco-0.7.6/**.*.jar" />
</fileset>
</path>
<!-- Step 1: Import JaCoCo Ant tasks -->
<taskdef uri="org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="../../../lib/jacocoant.jar"/>
<classpath path="../../../lib/jacocoagent.jar"/>
</taskdef>
<target name="clean">
<delete dir="${result.dir}"/>
</target>
<target name="compile">
<mkdir dir="${result.classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${result.classes.dir}" debug="true"
includeantruntime="false">
<classpath>
<path refid="compile.classpath"/>
</classpath>
</javac>
</target>
<target name="instrument" depends="compile">
<!-- Step 2: Instrument class files -->
<jacoco:instrument destdir="${result.classes.instr.dir}" xmlns:jacoco=
"org.jacoco.ant">
<fileset dir="${result.classes.dir}"/>
</jacoco:instrument>
</target>
<target name="test" depends="instrument">
<!-- Step 3: Run tests with instrumented classes -->
<java classname="org.jacoco.examples.parser.Main" fork="true">
<!-- jacocoagent.jar must be on the classpath -->
<classpath>
<pathelement path="./ivy-lib/jacoco-0.7.6/lib/jacocoagent.jar"/>
<pathelement path=
"./ivy-lib/jacoco-0.7.6/lib/org.jacoco.ant-0.7.6.201602180812.jar"/>
<pathelement path="./ivy-lib/jacoco-0.7.6/lib/**.*jar"/>
<pathelement path="${result.classes.instr.dir}"/>
</classpath>
<!-- Agent is configured with system properties -->
<sysproperty key="jacoco-agent.destfile" file="${result.exec.file}"/>
<arg value="2 * 3 + 4"/>
<arg value="2 + 3 * 4"/>
<arg value="(2 + 3) * 4"/>
<arg value="2 * 2 * 2 * 2"/>
<arg value="1 + 2 + 3 + 4"/>
<arg value="2 * 3 + 2 * 5"/>
</java>
</target>
<target name="report" depends="test">
<!-- Step 4: Create coverage report -->
<jacoco:report xmlns:jacoco="org.jacoco.ant">
<!--
This task needs the collected execution data and ...
-->
<executiondata>
<file file="${result.exec.file}"/>
</executiondata>
<!-- the class files and optional source files ... -->
<structure name="JaCoCo Ant Example">
<classfiles>
<fileset dir="${result.classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}"/>
</sourcefiles>
</structure>
<!-- to produce reports in different formats. -->
<html destdir="${result.report.dir}"/>
<csv destfile="${result.report.dir}/report.csv"/>
<xml destfile="${result.report.dir}/report.xml"/>
</jacoco:report>
</target>
<target name="rebuild" depends="clean,compile,instrument,test,report"/>
</project>
On Sunday, September 25, 2016 at 1:30:25 AM UTC+5:30, Evgeny Mandrikov
wrote:
>
> Excuse me, but is it that hard to find and read documentation and apply
> learned material for your needs?
>
> http://www.eclemma.org/jacoco/trunk/doc/offline.html
>
>
> <https://lh3.googleusercontent.com/-7SjFXOpGE5c/V-baIIEYPzI/AAAAAAAABx0/fnM4Hr04mMg37SOtRF4ZfZeKgRBbkeNDwCLcB/s1600/Selection_001.png>
>
>
> And BTW there is already an example
>
>
> http://www.eclemma.org/jacoco/trunk/doc/
>
>
>
> <https://lh3.googleusercontent.com/-oe4FFRvU_4I/V-bakjQcr9I/AAAAAAAABx4/FIqG2W3efzEoEy9yXzBKxwCfyrpKM_ttQCLcB/s1600/Selection_002.png>
>
>
> If something will still be unclear, the please post more specific question.
>
>
> Thank you for your understanding.
>
>
>
>
> On Thursday, September 22, 2016 at 7:50:13 PM UTC+2, vijay kumar wrote:
>>
>> Hi Marc, In another post i can see jacoco supports with powerMock.
>>
>> https://groups.google.com/forum/#!msg/jacoco/t9WwY9_ODnA/VfoWrdPVMMIJ
>>
>> Request you to share me working example which we have with ant.
>>
>> On Thursday, September 22, 2016 at 3:42:49 PM UTC+5:30, vijay kumar wrote:
>>>
>>> Hi,
>>>
>>>
>>>
>>> Workaround i can see is
>>>
>>> - Use offline instrumentation
>>> <http://www.eclemma.org/jacoco/trunk/doc/offline.html> before you
>>> run your tests. This way classes get instrumented by JaCoCo before any
>>> runtime modification can take place. Note that in this case the report
>>> has
>>> to be generated with the *original* classes, not with instrumented
>>> ones.
>>>
>>> Please share us the example in which offline instrumentation is
>>> implemented with Ant with reference to my implementation which i shared.
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, September 21, 2016 at 7:36:54 PM UTC+5:30, Marc R.
>>> Hoffmann wrote:
>>>>
>>>> Hi,
>>>>
>>>> the JaCoCo agent does not work with frameworks like Powermock which
>>>> modify the classes under test. Please find a detailed discussion and
>>>> possible workarounds here:
>>>>
>>>> http://www.eclemma.org/jacoco/trunk/doc/classids.html
>>>>
>>>> Regards,
>>>> -marc
>>>>
>>>> On 2016-09-21 15:13, vijay kumar wrote:
>>>> > Hi, We have integrated jacoco with our ant project and code coverage
>>>> > report is not generated for the classes in which we have used
>>>> > @RunWith(PowerMockRunner.class) (Powermock-mockito-1.5-full.jar)
>>>> >
>>>> > Request you to refer the below mentioned build.xml configuration
>>>> > details :
>>>> >
>>>> > Please inform is there any changes which we need to do in build.xml
>>>> > file or need to do changes in our junit test files.
>>>> >
>>>> > <!-- jacoco -->
>>>> >
>>>> > <taskdef uri="org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
>>>> >
>>>> > <classpath
>>>> > path="${basedir}/${ivy.lib}/jacoco-0.7.6/lib/jacocoant.jar"/>
>>>> >
>>>> > </taskdef>
>>>> >
>>>> > <target name="unit_test" depends="unit_test_compile"
>>>> >
>>>> > description="Run junit tests">
>>>> >
>>>> > <jacoco:coverage destfile="${coverage.dir}/jacoco.exec"
>>>> > xmlns:jacoco="org.jacoco.ant">
>>>> >
>>>> > <junit fork="yes" forkmode="perBatch" haltonfailure="yes"
>>>> > printsummary="true">
>>>> >
>>>> > <classpath refid="unit.test.classpath" /> <!-- classpath contains
>>>> > nessary jar files for junit and powermockito -->
>>>> >
>>>> > <formatter type="xml"/>
>>>> >
>>>> > <batchtest fork="yes" todir="${unit.test.reports}">
>>>> >
>>>> > <fileset dir="${unit.test.src}">
>>>> >
>>>> > <include name="**/*Test*.java"/>
>>>> >
>>>> > <exclude name="**/AllTests.java"/>
>>>> >
>>>> > <exclude name="**/TestHelpers.java"/>
>>>> >
>>>> > </fileset>
>>>> >
>>>> > </batchtest>
>>>> >
>>>> > </junit>
>>>> >
>>>> > </jacoco:coverage>
>>>> >
>>>> > </target>
>>>> >
>>>> > <target name="coverage-report" depends="unit_test">
>>>> >
>>>> > <jacoco:report xmlns:jacoco="org.jacoco.ant">
>>>> >
>>>> > <executiondata>
>>>> >
>>>> > <file file="${coverage.dir}/jacoco.exec" />
>>>> >
>>>> > </executiondata>
>>>> >
>>>> > <structure name="Jacoco">
>>>> >
>>>> > <classfiles>
>>>> >
>>>> > <fileset dir="${bin}" />
>>>> >
>>>> > </classfiles>
>>>> >
>>>> > <sourcefiles encoding="UTF-8">
>>>> >
>>>> > <fileset dir="${src}" />
>>>> >
>>>> > </sourcefiles>
>>>> >
>>>> > </structure>
>>>> >
>>>> > <html destdir="${coverage.report.dir}" />
>>>> >
>>>> > </jacoco:report>
>>>> >
>>>> > </target>
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> > Groups "JaCoCo and EclEmma Users" group.
>>>> > To unsubscribe from this group and stop receiving emails from it,
>>>> send
>>>> > an email to [email protected].
>>>> > To view this discussion on the web visit
>>>> >
>>>> https://groups.google.com/d/msgid/jacoco/7d2e0d22-6be6-43d4-afe5-e8115d0ecc81%40googlegroups.com
>>>>
>>>> > [1].
>>>> > For more options, visit https://groups.google.com/d/optout.
>>>> >
>>>> >
>>>> > Links:
>>>> > ------
>>>> > [1]
>>>> >
>>>> https://groups.google.com/d/msgid/jacoco/7d2e0d22-6be6-43d4-afe5-e8115d0ecc81%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>
>>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/3987b3dc-cf09-4e53-b2d1-910d6f66604f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.