【问题标题】:Ant TestNG build works in Eclipse but not from terminalAnt TestNG 构建在 Eclipse 中工作,但不能从终端
【发布时间】:2011-10-06 06:56:39
【问题描述】:

我可以通过右键单击并选择 Ant Build 从 Eclipse 运行 Ant 构建。

当我尝试通过从 cmd 运行 Ant 来执行相同的构建时,我得到“构建成功”的结果,但没有构建任何内容。

Build.xml 文件

<property name ="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="name" value="value"/>

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

<target name="loadTestNG" depends="setClassPath">
    <taskdef resource="testngtasks" classpath="${test.classpath}"/>
</target>

<target name="init">
    <mkdir dir="${build.dir}"/>
</target>

<target name="clean">
    <echo message="deleting existing build directory"/>
    <delete dir="${build.dir}"/>
</target>

<target name="compile" depends="clean, init, setClassPath, loadTestNG">
    <echo message="classpath: ${test.classpath}"/>
    <echo message="compiling..."/>
    <javac destdir="${build.dir}" srcdir="${src.dir}" classpath="${test.classpath}"           encoding="cp1252"/>
</target>

<target name="run" depends="compile">
    <testng classpath ="${test.classpath}:${build.dir}">
    <xmlfileset dir="${basedir}" includes="testng.xml"/>
    </testng>

</target>

</project>

还有Testng.xml

<suite name="Regression Test Suite">

  <test name="My Test">

  <classes>

    <class name="com.RegressionTest.Sometest"/>

  </classes>

  </test>

</suite>

【问题讨论】:

    标签: eclipse ant selenium testng


    【解决方案1】:

    我确定了这个问题。我没有在我的项目设置中指明默认目标。 Eclipse IDE 能够编译,但在终端中我只使用 ANT 并没有指示要构建哪个目标。所以它成功地“构建”了,因为我没有告诉它要构建什么。

    【讨论】:

    • 嗨,Armando,我知道这是不久前的事了,但您还记得您在哪里指出的吗?
    猜你喜欢
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 2018-03-11
    • 2015-09-29
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    相关资源
    最近更新 更多