Now I have got a requirement to do a code coverage and the firs thing came to my mind was JaCoCo.
But when I checked the test framework I found these issues
1. Test cases are compiled with ant build and created a bundle which will be installed on the remote device via telnet.
so the test cases are ran when telnet starts the bundle instead of regular java -jar xxx.jar format
so I'm unable to add javvagent during this part.
2. The alternative way I found was to run javaagent at device bootup while device calls built-in API's for initialization.
but now the boot directory is flagged as read-only and and I'm unable to add javaagent in boot file.
is there any other way to add javaagents? can I call jacoco programmatically to get coverage results?
--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/2GDpJXWsTQQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e9117db5-2dff-4693-9cf0-a619a1562bbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<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="../../../lib/jacocoagent.jar"/>
<pathelement path="${result.classes.instr.dir}"/></classpath>
.
.
.
the problem is, my ant build does not execute the test cases, it just compiles the class and create a jar file
this jar file is installed to device with our test framework and run from there.
is there any other workaround to run this?
<target name="TestSuite.Build">
<property name="src.testsuite" value="com/xxxxxxx/xxx/test/testcase/template/TestSuite.*" />
<property name="path.mf.testsuite" value="com/xxxxxxx/xxx/test/testcase/template/MANIFEST.MF" />
<property name="bundlename.testsuite" value="${ant.project.name}" />
<echo>Compiling TestSuite.Build</echo>
<javac destdir="${jacoco.dir}" source="1.5" target="1.5" debug="on">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
<include name="${src.testsuite}" />
</javac>
<copy file="${src.dir}/${path.mf.testsuite}" tofile="${build.dir}/${path.mf.testsuite}" />
</target>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="../bin/jacoco/jacocoant.jar" />
</taskdef>
<target name="instrumentation">
<jacoco:instrument destdir="${build.dir}" xmlns:jacoco="antlib:org.jacoco.ant">
<fileset dir="${jacoco.dir}" includes="**/*.class" />
</jacoco:instrument>
</target>
<!-- TestSuite.Bundle -->
<target name="TestSuite.Bundle" depends="TestSuite.Build, tbc.Bundle, instrumentation">
<echo> *********************************</echo>
<echo> TestSuite Compiling _ Making Bundle </echo>
<echo> *********************************</echo>
<echo>TestSuite.Bundle</echo>
<antcall target="tbc.Build" />
<mkdir dir="${jars.dir}" />
<jar destfile="${jars.dir}/${bundlename.testsuite}.jar" manifest="${build.dir}/${path.mf.testsuite}">
<fileset dir="${build.dir}">
<include name="${src.testsuite}" />
</fileset>
<fileset dir="${jars.dir}">
<include name="${bundlename.tbc}.jar" />
</fileset>
</jar>
</target>
<!-- tbc.Build-->
<target name="tbc.Build">
<property name="src.tbc" value="com/xxxxxxx/xxx/test/testcase/template/tbc/*.*" />
<property name="path.mf.tbc" value="com/xxxxxxx/xxx/test/testcase/template/tbc/MANIFEST.MF" />
<property name="bundlename.tbc" value="tbc" />
<echo> Compiling tbc</echo>
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="on">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
<include name="${src.tbc}" />
</javac>
<copy file="META-INF/MANIFEST.MF" tofile="${build.dir}/${path.mf.tbc}" />
</target>
<!-- tbc.Bundle-->
<target name="tbc.Bundle" depends="tbc.Build">
<echo> *********************************</echo>
<echo> tbc Compiling _ Making Bundle </echo>
<echo> *********************************</echo>
<echo>tbc.Bundle</echo>
<mkdir dir="${jars.dir}" />
<jar destfile="${jars.dir}/${bundlename.tbc}.jar" manifest="${build.dir}/${path.mf.tbc}">
<fileset dir="${build.dir}">
<include name="${src.tbc}" />
</fileset>
<fileset dir="." includes="testFiles/**" />
</jar>
</target>
jacoco-agent.properties(added in class path )-> jacoco-agent.destfile:\home\test\tmp\jacoco.exec
but no reports are generated