在蚂蚁TestNG中的taskdef定义使用Maven的依赖 [英] testNG taskdef definition in Ant using Maven dependencies

查看:275
本文介绍了在蚂蚁TestNG中的taskdef定义使用Maven的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Ant和Maven构建一个项目。我使用TestNG测试单位。这里说( http://testng.org/doc/ant.html )我已经定义在的taskdef如下:

I am trying to use Ant and Maven to build a project. I am using testNG for test units. As stated here ( http://testng.org/doc/ant.html ) I have defined the taskdef as follow:

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

在蚂蚁。

在Maven的我已经加入以下内容(如下所述: http://testng.org/doc/ maven.html

In Maven I have added the following (as stated here: http://testng.org/doc/maven.html)

<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.2</version>
</dependency>

的Maven正从Maven仓库中的文件和我检查下/.m2的位置。现在,我从行家获得TestNG的,我应该改变的taskdef在蚂蚁使用Maven仓库这一新的。我不知道该怎么做。我曾尝试以下内容:

Maven is getting the files from maven repository and I have checked the location under /.m2. Now that I am getting the testNG from maven, I should change the taskdef in ant to use this new one in Maven repository. I am not sure how to do that. I have tried the following:

<taskdef resource ="testngtasks" classname="org.testng" /> 

<taskdef resource ="testngtasks" classname="org.testng" classpathref="maven.compile.classpath"/>

<taskdef resource ="testngtasks" />

但没有成功,第二个抱怨说我不应该使用classpathref和第一个说我应该指定类。三是工作种,但不是全部。它thorugh去,我想它传递的taskdef一步,但它不执行测试。蚂蚁的一部分(第三个):

but no success, the second one complains that I shouldn't use classpathref and the first one says that I should specify class. The third one is working kind of, but not completely. It is going thorugh and I guess it passes the taskdef step but it is not executing the tests. Part of the Ant (for third one):

<taskdef  resource="testngtasks"  />

<target name="test" depends="compile">
<echo message="running tests" />

蚂蚁输出的部分:(请注意,回声执行时,它以某种方式通过的taskdef工序)

Part of the Ant output: (note that the echo executed, it is somehow passed the taskdef step)

compile:
    [javac] /home/shahin/Files/Development/Ant/ServiceEJBSample3/build-testNG.xml:31: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

test:
     [echo] running tests

BUILD FAILED
/home/shahin/Files/Development/Ant/ServiceEJBSample3/build-testNG.xml:84: Problem: failed to create task or type testng
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

我不知道如何使用TestNG的库Maven仓库中的蚂蚁来定义(的taskdef)的testngtasks。任何见解将是非常美联社preciated

I am not sure how to use testNG library in Maven repository to define ( taskdef ) the testngtasks in Ant. Any insights would be highly appreciated

推荐答案

试着将一个pathelement属性为您喜欢的taskdef的类路径:

try placing a pathelement property in for the classpath of your taskdef like:

<taskdef resource="testngtasks">
     <classpath>
          <pathelement path="[path to]/testng.jar"/>
     </classpath>
</taskdef>

第一个硬盘code为pathelement的路径,以确保它的工作适合你。

first hardcode the path for pathelement to make sure it's working for you.

这篇关于在蚂蚁TestNG中的taskdef定义使用Maven的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆