Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带有JUnit的Ant提供多个测试报告_Java_Ant_Junit - Fatal编程技术网

Java 带有JUnit的Ant提供多个测试报告

Java 带有JUnit的Ant提供多个测试报告,java,ant,junit,Java,Ant,Junit,我在Ant脚本中设置了以下目标以生成测试报告。它的工作做得很好,但我观察到,如果我编写了两个测试,我会得到单独的XML文件输出,还有一个聚合的XML文件,其中包含嵌套在标记中的相同信息 谁能告诉我如何避免生成此文件 下面给出了我的相关ANT目标和测试 <target name="test" depends="init,compile"> <junit printsummary="yes" haltonfailure="no" showoutput

我在Ant脚本中设置了以下目标以生成测试报告。它的工作做得很好,但我观察到,如果我编写了两个测试,我会得到单独的XML文件输出,还有一个聚合的XML文件,其中包含嵌套在标记中的相同信息

谁能告诉我如何避免生成此文件

下面给出了我的相关ANT目标和测试

<target name="test" depends="init,compile">
                <junit printsummary="yes" haltonfailure="no" showoutput="yes" >
                        <!--
                                Note the classpath order: instrumented classes are before the
                                original (uninstrumented) classes.  This is important.
                        -->
                        <classpath location="${instrumented.dir}" />
                        <classpath location="${classes.dir}" />

                        <!--
                                The instrumented classes reference classes used by the
                                Cobertura runtime, so Cobertura and its dependencies
                                must be on your classpath.
                        -->
                        <classpath refid="cobertura.classpath" />


                        <batchtest fork="yes" todir="${reports.xml.dir}">
                                <formatter type="xml" />
                                <fileset dir="${src.dir}">
                                        <include name="**/*Test*.java" />
                                </fileset>
                        </batchtest>
                </junit>

                <junitreport todir="${reports.xml.dir}">
                        <fileset dir="${reports.xml.dir}">
                                <include name="TEST-*.xml" />
                        </fileset>
                </junitreport>
        </target>
//TestMath.java

import junit.framework.*;

public class TestMath extends TestCase { 

  protected void setUp() { 

          // put common setup code in here
   }

  protected void tearDown() {

          // put common cleanup code in here
  }

  public void testAdd() {
          int num1 = 3;
          int num2 = 2;
          int total = 5;
          int sum = 0;
          sum = Math.add(num1, num2);
          assertEquals(sum, total);
  }
  public void testsubtract() {
                  int num1 = 5;
                  int num2 = 2;
                  int total = 3;
                  int sum = 0;
                  sum = Math.subtract(num1, num2);
                  assertEquals(sum, total);
          }


  public void testMulitply() {

          int num1 = 3; 
          int num2 = 7; 
          int total = 20;
          int sum = 0;
          sum = Math.multiply(num1, num2);
          assertEquals("Problem with multiply", sum, total);

   }

}

以下内容正在生成合并报告:

            <junitreport todir="${reports.xml.dir}">
                    <fileset dir="${reports.xml.dir}">
                            <include name="TEST-*.xml" />
                    </fileset>
            </junitreport>

发件人:

合并JUnit任务生成的各个XML文件,并 最终将结果合并文档上的样式表应用于 提供测试用例结果的可浏览报告


所以问题是如何避免聚合报告?是的,但保留其他输出@Sharath您不想删除聚合报告。是的。。但我还是得到了汇总报告。。即使在我删除了printsummary。。我希望有2个xml文件,每个编写的测试用例1个。但是第三个聚合报告仍然存在。@Sharath啊!那是因为
。请参见上面的编辑。
            <junitreport todir="${reports.xml.dir}">
                    <fileset dir="${reports.xml.dir}">
                            <include name="TEST-*.xml" />
                    </fileset>
            </junitreport>