我跑硒单元测试TestNG中与蚂蚁Java的任务,像这样:Ant中的<pathelement>属性'路径'和'位置'有什么区别?
<java classpathref="runtime.classpath"
classname="org.testng.TestNG"
failonerror="false">
<arg value="-d" />
<arg value="${grid.location}/target/reports" />
<arg value="${lib.location}/testng.xml"/>
</java>
runtime.classpath
是pathlike结构,包括<pathelement path="${basedir}/target/classes/" />
,我认为需要让TestNG的知道跑哪班。
<path id="runtime.classpath">
...
<!-- Target classes -->
<pathelement path="${basedir}/target/classes/" />
</path>
但是,我一直在日志中看到TestNG发现了0个适用的类。
我终于从同事一些帮助,看来这是关键的变化:
<path id="runtime.classpath">
...
<!-- path attribute changed to location -->
<pathelement location="${basedir}/target/classes/" />
</path>
这也拉动了测试类正确:
<java classpathref="runtime.classpath"
classname="org.testng.TestNG"
failonerror="false">
<arg value="-d" />
<arg value="${grid.location}/target/reports" />
<arg value="${lib.location}/testng.xml"/>
<classpath>
<pathelement location="${basedir}/target/classes/" />
</classpath>
</java>
有什么之间的区别path
和location
属性?我看过Writing a Simple Buildfile(特别是类似路径的结构部分),但在该手册中,它看起来像location
比path
更具体。这在经验上似乎并非如此,但我无法弄清楚为什么。
这是如何区分'pathelement'的'path'和'location'属性的?您的意思是,将路径结构添加为Java任务的类路径引用会有所不同,具体取决于Ant JVM还是分叉的JVM正在运行? – Feanor
好问题。在上面添加了一些,你可能想尝试在详细模式下使用调试(-v -d)运行它们,并查看这两个文件的不同之处。 –