Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.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报告未显示使用Categories和ANT时测试的所有类_Java_Ant_Junit - Fatal编程技术网

Java JUnit报告未显示使用Categories和ANT时测试的所有类

Java JUnit报告未显示使用Categories和ANT时测试的所有类,java,ant,junit,Java,Ant,Junit,使用ANT脚本运行JUnit测试,一组测试(TestSCF)是所有测试的子集。这些测试将作为夜间构建的一部分运行,并生成报告。使用@IncludeCategory定义需要运行的测试,使用ClasspathSuite定位项目中的所有测试 示例测试类声明,定义为作为TestSCF子集运行。TestSCF是一个空接口 @Category(TestSCF.class) public class ErrorDialogTest extends TestCase { .... } 主测试套件 @R

使用ANT脚本运行JUnit测试,一组测试(TestSCF)是所有测试的子集。这些测试将作为夜间构建的一部分运行,并生成报告。使用@IncludeCategory定义需要运行的测试,使用ClasspathSuite定位项目中的所有测试

示例测试类声明,定义为作为TestSCF子集运行。TestSCF是一个空接口

@Category(TestSCF.class)
public class ErrorDialogTest extends TestCase
{
    ....
}
主测试套件

@RunWith(Categories.class)
@IncludeCategory(TestSCF.class)
@SuiteClasses({AllTests.class})
public class SCFTests
{
}
AllTests声明

@RunWith(ClasspathSuite.class)
public class AllTests
{
}
ANT脚本的相关部分

<!-- Run the unit tests -->
<junit showoutput   ="true"
       printsummary = "yes"
       fork         = "yes"
       timeout      = "60000" >
  <formatter type="xml"/>
  <classpath refid="cpath"/>

  <batchtest fork  = "yes"
             todir = "${test.report.dir}">
    <fileset dir="${src.dir}">
      <include name="**/SCFTests.java"/>
    </fileset>
  </batchtest>
</junit>

<!-- Copy the XML files that get deleted by junitreport -->
<mkdir dir="${junit.html.dir}/xml_files"/>
<copy todir="${junit.html.dir}/xml_files" preservelastmodified="true">
  <fileset dir="${test.report.dir}">
      <include name="*.xml"/>
  </fileset>
</copy>

<!-- Format the test results into browsable HTML -->
<junitreport todir="${junit.html.dir}">
  <fileset dir="${test.report.dir}">
    <include name="TEST-*.xml"/>
  </fileset>
  <report format="frames" todir="${junit.html.dir}"/>
</junitreport>
相对于

SCFTests 45 Passed, 3 Failures, 0 Errors

为了便于将来参考,我可以通过修改junit-frames.xsl文件将类路径打印在报告的“Name”列中,如下所示

<td>
  <a name="{@name}"/>
  <xsl:choose>
    <xsl:when test="boolean($show.class)">
      <a href="{concat($class.href, '#', @name)}"><xsl:value-of select="@name"/></a>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="@name"/>
    </xsl:otherwise>
  </xsl:choose>
</td>

junit-frames.xsl文件在哪里?在哪里进行更改以使用修改后的框架xsl?
<td>
  <a name="{@name}"/>
  <xsl:choose>
    <xsl:when test="boolean($show.class)">
      <a href="{concat($class.href, '#', @name)}"><xsl:value-of select="@name"/></a>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="@name"/>
    </xsl:otherwise>
  </xsl:choose>
</td>
<td>
  <a name="{@name}"/>
  <xsl:choose>
    <xsl:when test="boolean($show.class)">
      <a href="{concat($class.href, '#', @classname)}"><xsl:value-of select="@classname"/></a>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="@classname"/>
    </xsl:otherwise>
  </xsl:choose>
</td>
Name                         Status Type    Time(s)
dev.sca.test.ErrorDialogTest Success        1.45
dev.sca.test.SomeOtherTest   Success        2.03