通过ANT生成的空白JUnit报告

时间:2014-05-23 12:35:44

标签: ant junit

      

  <property name="wspace.home" value="${basedir}"/>
  <property name="wspace.jars" value="D:\\softwares\\jars"/>
  <property name="test.dest" value="${wspace.home}/build"/>
  <property name="test.src" value="${wspace.home}/src"/>
  <property name="test.reportsDir" value="D:\reports"/>


  <path id="testcase.path">


    <pathelement location="${test.dest}"/>

    <fileset dir="${wspace.jars}">
        <include name="*.jar"/>
    </fileset>

  </path>


   <target name="setClassPath" unless="test.classpath">
        <path id="classpath_jars">
            <fileset dir="${wspace.jars}" includes="*.jar"/>
        </path>
        <pathconvert pathsep="."
            property="test.classpath"
            refid="classpath_jars"/>
    </target>

    <target name="init" depends="setClassPath">
        <tstamp>
            <format property="start.time" pattern="MM/dd/yyyy hh:mm aa" />
        </tstamp>
        <condition property="ANT"
            value="${env.ANT_HOME}/bin/ant.bat"
            else="${env.ANT_HOME}/bin/ant">
            <os family="windows" />
        </condition>

    </target>

    <!--  all -->
    <target name="all">
    </target>

    <!--  clean -->

    <target name="clean">
        <delete dir="${test.dest}"/>
    </target>

    <!--  compile -->
    <target name="compile" depends="init, clean">
        <delete includeemptydirs="true" quiet="true">
            <fileset dir="${test.dest}" includes="**/*"/>
        </delete>

        <echo message="making directory..."/>
        <mkdir dir="${test.dest}"/>
        <echo message="classpath-----: ${test.classpath}"/>
        <echo message="compiling..."/>
        <javac
            debug="true"
            destdir="${test.dest}"
            srcdir="${test.src}"
            target="1.5"
            classpath="${test.classpath}"
        >
        </javac>
    </target>


    <!--  build -->
    <target name="build" depends="init">
    </target>


    <target name="usage">
        <echo>
            ant run will execute the test
        </echo>
    </target>


    <path id="test.c">
            <fileset dir="${wspace.jars}" includes="*.jars"/>
    </path>




    <!--  run -->
    <target name="run">
        <delete includeemptydirs="true" quiet="true">
                <fileset dir="${test.reportsDir}" includes="**/*"/>
        </delete>
        <java jar="${wspace.jars}" fork="true" spawn="true"/>
        <junit fork="yes" haltonfailure="no" printsummary="yes">
            <classpath refid="testcase.path"/>

        <!-- <classpath ="&{test.classpath}"/> -->
        <batchtest todir="${test.reportsDir}" fork="true">
        <fileset dir="${test.dest}">


            <include name="TestSuite.class"/>


        </fileset>
        </batchtest>

        <formatter type="xml"/>
        <classpath refid="testcase.path"/>
    </junit>
        <junitreport todir="${test.reportsDir}">
            <fileset dir="${test.reportsDir}">
            <include name="TEST-.xml" />
            </fileset>
            <report todir="${test.reportsDir}"/>
        </junitreport>
        </target>

    </project>      

............................................... ...........................................

生成了Reoprts,但它们是空白的,尝试过提到的不同解决方案,但是仍然无法获得。

1 个答案:

答案 0 :(得分:0)

我认为testcase没有被执行,我在build.xml

中遇到了什么问题

检查以下命令提示符日志

C:\ Users \ Vaibhav \ Eclipse_Workspace \ WebDriverTests&gt; ant run

Buildfile:C:\ Users \ Vaibhav \ Eclipse_Workspace \ WebDriverTests \ build.xml

运行:

[junitreport]处理D:\ reports \ TESTS-TestSuites.xml到C:\ Users \ Vaibhav \ AppData \ Local \ Temp \ null526641997

[junitreport]加载样式表jar:file:/ C:/apache-ant-1.9.4/lib/ant-junit.jar

!/组织/阿帕奇/工具/蚂蚁/任务定义/可选/ JUnit的/ XSL / JUnit的-frames.xsl

[junitreport]转换时间:524毫秒

[junitreport]正在删除:C:\ Users \ Vaibhav \ AppData \ Local \ Temp \ null526641997

建立成功的作用 总时间:1秒