ANT BUILD ERROR:无法创建任务或输入testng

时间:2015-09-17 07:49:24

标签: ant selenium-webdriver build.xml

  

您好,问题是,我无法触发ANT运行命令   项目,它给了我错误。当我触发ANT clean和ANT编译时   ,建立成功。

BUILD.XML代码错误行 在线获取错误:2

str_pad($n, 3, '0', STR_PAD_LEFT)

错误日志: 问题:无法创建任务或输入testng 原因:名称未定义。 行动:检查拼写。 操作:检查是否已声明任何自定义任务/类型。 操作:检查是否已发生任何/声明。

FULL BUILD.xml代码

<!-- run -->
<target name="run" depends="compile">
<testng classpath="${test.classpath}:${test.dest}" suitename="suite1" outputDir="test-output" >  
<xmlfileset dir="${ws.home}" includes="TestNG.xml" />
</testng>
<!--suite 1 begin -->
<property name="suite.web.CopyRegressionCustomer" value="CopyRegressionCustomer" />
<testng classpath="${test.classpath}:${test.dest}" suitename="CopyRegressionCustomer" outputDir="test-output" >
<xmlfileset dir="${ws.home}" includes="TestNG.xml" />
</testng>
<antcall target="testngReportCopy">
<param name="testngDir" value="${testng.report.dir}${suite.web.CopyRegressionCustomer}"/>
 </antcall> 

1 个答案:

答案 0 :(得分:0)

仔细查看您的ant脚本,它用于将TestNG ant任务定义为:

<taskdef resource="testngtasks" classpath="testng.jar"/>

但在你的情况下,你有这个定义评论:

<!--
<taskdef name="testng" classpath="/Users/mac/Downloads/selenium-2.47.1" classname="org.testng.TestNGAntTask" /> 
<!- use direct path for classpath if you don't prefer to use 'lib' directory: classpath="/Users/yash/Documents/Jar Files/testng-6.8.jar" ->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="./lib/testng.jar"/>
</classpath>
</taskdef>
-->

您需要取消注释或为脚本添加新的防御。