Thank you for the explanation. I have understood it and addressed it. 在 2019年7月4日星期四 UTC+8下午11:53:13,Marc R. Hoffmann写道: > > I can only reiterate my advice to proceed as follows: > > 1) Make your test setup run without code coverage > 2) Add JaCoCo to it > > In exact this sequence. Not the other way round. > > > On 4. Jul 2019, at 07:19, Weisong Sun <[email protected] <javascript:>> > wrote: > > <?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> > > The above is my "build.xml" file, whether I need to add the configuration > as like the following? > <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> > > > > 在 2019年7月4日星期四 UTC+8上午11:58:31,Marc R. Hoffmann写道: >> >> 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 <[email protected]> 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. >> >> java -javaagent:/Users/sunweisong/Desktop/jacocoagent.jar=includes=net. >> mooctest.*,output=file,destfile=jacoco.exec >> Thank you for your attenting my question. >> >> <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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jacoco/b102c9d5-4fa6-4bb9-8c51-b56fa783ef0a%40googlegroups.com >> >> <https://groups.google.com/d/msgid/jacoco/b102c9d5-4fa6-4bb9-8c51-b56fa783ef0a%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> <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 [email protected] <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jacoco/3a93f881-70d8-4f5d-ad1f-abc50aeefcb3%40googlegroups.com > > <https://groups.google.com/d/msgid/jacoco/3a93f881-70d8-4f5d-ad1f-abc50aeefcb3%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/24cf2084-0541-457a-9dd5-3a4eeda5b536%40googlegroups.com.
