【问题标题】:testng task not running with anttestng 任务未与 ant 一起运行
【发布时间】:2013-05-22 11:26:46
【问题描述】:

使用 ant 运行 testng 测试,但它没有运行或显示任何错误。甚至消息(运行测试)也没有打印在控制台中。这是build.xml。构建成功并创建了一个 JAR。感谢您对此的任何帮助。

<?xml version="1.0" encoding="UTF-8"?>
<project name="BANC">

<property name="project.path" value="." />
<property name="src" value="${project.path}/src" />
<property name="bin" value="${project.path}/bin" />
<property name="testngxmldir" value="${project.path}/src/com/portico/regressionsuite" />
<property name="bancJarFile.path" value="./build/BANC.jar" />

<!-- Set class path libraries to be used for compilation -->
<path id="class.path">
<pathelement location="lib" path="lib/activation.jar"/>
<pathelement location="lib" path="lib/commons-lang-2.4.jar"/>
<pathelement location="lib" path="lib/jxl.jar"/>
<pathelement location="lib" path="lib/logging-selenium-1.2.jar"/>
<pathelement location="lib" path="lib/mail.jar"/>
<pathelement location="lib" path="lib/ojdbc14.jar"/>
<pathelement location="lib" path="lib/poi-3.0.2-FINAL.jar"/>
<pathelement location="lib" path="lib/reportng-1.1.1.jar"/>
<pathelement location="lib" path="lib/saxon-8.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-demo-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-demo-standalone-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-hub-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-hub-standalone-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-remote-control-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-remote-control-standalone-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-tools-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-grid-tools-standalone-1.0.7.jar"/>
<pathelement location="lib" path="lib/selenium-server-1.0.3-standalone.jar"/>
<pathelement location="lib" path="lib/velocity-1.7.jar"/>
<pathelement location="lib" path="lib/jna-3.4.0.jar"/>
<pathelement location="lib" path="lib/sikuli-script.jar"/>
<pathelement location="lib" path="lib/testng-6.8.jar"/>
<pathelement location="lib" path="${bin}"/>
</path>

<!-- Compile targets-->
<target name="banc">
    <echo message="Compiling BANC Source..." />
    <mkdir dir="${bin}" />
    <javac classpathref="class.path" destdir="${bin}" encoding="UTF-8" optimize="off" 
    debug="on" failonerror="true" srcdir="${src}" />
    <jar destfile="${bancJarFile.path}" basedir="${bin}" />
</target>

<taskdef name="testng" classname="org.testng.TestNGAntTask">
    <classpath>
        <pathelement location="lib/testng-6.8.jar"/>
    </classpath>
</taskdef>

<target name="runTest">
<echo message="Running Tests..." />
    <testng classpathref="class.path" outputDir="${project.path}/test-output" 
    sourcedir="${bin}" haltOnfailure="true">
        <xmlfileset dir="${testngxmldir}" includes="regressionsuite.xml"/>
    </testng>   
</target>

 </project>

【问题讨论】:

  • 你是如何运行ant的? ant 文件既没有默认任务的根元素,也没有任务之间的任何依赖关系。
  • 这只是一个错字(现已更正)。我正在做一个示例运行,这就是为什么没有包含任何依赖项。我曾尝试从 Eclipse 和命令行运行 ant,但结果相同。

标签: ant testng


【解决方案1】:

看起来你并没有告诉 ant 运行哪个目标——所以它只是选择了第一个。如果您使用ant banc runTest 运行它,它应该可以正常工作。

执行此操作的常用方法是定义一个空目标,该目标取决于所有所需目标 aud 设置为 &lt;project&gt; 标记中的默认值。此外,您的“runTest”目标应该依赖于“banc”,因为运行测试需要事先构建项目。在这种情况下,您也可以简单地执行ant runTest -- ant 会自动以正确的顺序运行所有相关任务。

【讨论】:

  • 谢谢。 “蚂蚁银行运行测试”有效。大多数在线文档并没有真正提到如果它们之间没有依赖关系,则需要指定任务。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-14
  • 2013-07-12
  • 2011-03-31
  • 2017-08-01
  • 1970-01-01
  • 2011-10-05
  • 1970-01-01
相关资源
最近更新 更多