selenium+JUint+Ant运行成功但没有测试结果
这个是我的代码<?xml version="1.0" encoding="UTF-8"?>
<project name = "Testcase" default = "init">
<!-- 指定JUnit类库的位置 -->
<property name = "junitJar" value = "lib/junit.jar"/>
<target name = "init">
<mkdir dir = "report"/>
<mkdir dir = "htmlreport"/>
</target>
<!-- //编译源文件 -->
<target name = "compile">
<javac destdir = "src" srcdir = "src" includeantruntime="on">
<classpath>
<pathelement location = "${junitJar}"/>
</classpath>
</javac>
</target>
<!-- //执行JUnit测试 -->
<target name = "run" depends = "compile">
<echo message = "start run Junit test"/>
<junit>
<classpath>
<pathelement location = "src"/>
<pathelement location = "${junitJar}"/>
</classpath>
<romatter type = "xml"/>
<batchtest haltonfailure = "no" todir = "report">
<fileset dir = "src">
<include name = "**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<!--//生成html报表 -->
<junitReport todir = "./htmlreport">
<fileset dir = "./report">
<include name = "TEST-*.xml"/>
</fileset>
<report format = "noframes" todir = "./htmlreport"/>
</junitReport>
<echo message = "end running junit test"/>
</target>
</project>
执行后,显示如下结果
Buildfile: C:\Documents and Settings\ccxopen\workspace\Anttest\build.xml
init:
BUILD SUCCESSFUL
Total time: 67 milliseconds
也就是只执行了init 这个target,complie和run都没有执行,为什么呢,谁能跟我说一下吗 <project name = "Testcase" default = "init">
把default设成你最后一个target 的name,然后各个target之间用depends = "" 连起来 回复 2# robin.von
不行啊。。编译可以通过,但没有run。。 http://blog.csdn.net/shendl/archive/2005/11/18/532587.aspx 本帖最后由 yangl326 于 2011-7-27 14:18 编辑
project name = "Testcase" default = "init"
只执行了init 标签 默认为执行inittarget
<!-- //编译源文件 -->
<target name = "compile">
<javac destdir = "src" srcdir = "src" includeantruntime="on">
<classpath>
<pathelement location = "${junitJar}"/>
</classpath>
</javac>
</target>
改成
<!-- //编译源文件 -->
<target name = "compile" depends=“init”>
<javac destdir = "src" srcdir = "src" includeantruntime="on">
<classpath>
<pathelement location = "${junitJar}"/>
</classpath>
</javac>
</target>
加上depends=“init”
project中 把default 执行的 init改成run
这样ant执行标签顺序是
默认执行run的时候
run依赖compile就先执行compile
compile依赖 init 就先执行init
即执行target顺序init->compile->run
楼主可以查询下ant中target标签的depends属性
页:
[1]