I execute the following command on my mac terminal, then I can get the file "jacoco.exec". I use Ant to extract report, but the coverages are always 0.
java -javaagent:/Users/sunweisong/Desktop/jacocoagent.jar=includes=net.mooctest.*,output=file,destfile=jacoco.exec
<structure.jpg>
--
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 jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/b102c9d5-4fa6-4bb9-8c51-b56fa783ef0a%40googlegroups.com.
<structure.jpg>
<?xml version="1.0" ?>
<project xmlns:jacoco="antlib:org.jacoco.ant" name="Ant Build with JaCoCo" default="jacoco">
<description>
Ant is employed to extract the report from jacoco running results.
</description>
<property name="src.dir" location="src/main/java"/>
<property name="result.dir" location="target"/>
<property name="result.classes.dir" location="${result.dir}/classes"/>
<property name="result.report.dir" location="${result.dir}/jacoco"/>
<property name="result.exec.file" location="jacoco.exec"/>
<property name="jacocoant.dir" location="/Users/sunweisong/Desktop/java resource/jacoco-0.8.4/lib/jacocoant.jar"/>
<!-- Step 1: Import JaCoCo Ant tasks -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacocoant.dir}" />
</taskdef>
<target name="jacoco">
<delete dir="${result.report.dir}" />
<mkdir dir="${result.report.dir}" />
<jacoco:report>
<!-- 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 Report">
<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>
</project>
<target name="test" depends="compile"><!-- Step 2: Wrap test execution with the JaCoCo coverage task --><jacoco:coverage destfile="${result.exec.file}"><java classname="org.jacoco.examples.parser.Main" fork="true"><classpath path="${result.classes.dir}"/><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></jacoco:coverage></target>Hi,obviously your command line does not execute anything. There is no main class to be executed.As a general rule we recommend to first make your test setup run, and then add code coverage to it. It it does not run without code coverage it will neither run with JaCoCo ;)Regards,-marc
On 4. Jul 2019, at 04:57, Weisong Sun <weison...@gmail.com> wrote:
I execute the following command on my mac terminal, then I can get the file "jacoco.exec". I use Ant to extract report, but the coverages are always 0.Thank you for your attenting my question.java -javaagent:/Users/sunweisong/Desktop/jacocoagent.jar=includes=net.mooctest.*,output=file,destfile=jacoco.exec<structure.jpg>
--
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 jac...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/3a93f881-70d8-4f5d-ad1f-abc50aeefcb3%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/3a93f881-70d8-4f5d-ad1f-abc50aeefcb3%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/3a93f881-70d8-4f5d-ad1f-abc50aeefcb3%40googlegroups.com.