繁体   English   中英

如何从命令提示符下运行Maven项目testng.xml

[英]how to run maven project testng.xml from the command prompt

我正在使用linux机械(ubuntu 14)。 我的项目是具有testng框架工作的Maven项目。 在这里,我试图从命令提示符下运行testng.xml,以便可以在jenkins中进行配置。

project location : /home/subhash/workspace/myproject
class path is  : /home/subhash/workspace/myproject/bin
testng jar locattion is: /home/subhash/.m2/repository/org/testng/testng/6.9.4/testng-6.9.4.jar"

suite location is : /home/subhash/workspace/suites/src/test/resources/testng.xml

hence i executed the following command from command prompt from the location.
/home/subhash/workspace/myproject/bin$ 

$ java -cp ".:../lib/*:/home/subhash/.m2/repository/org/testng/testng/6.9.4/testng-6.9.4.jar" org.testng.TestNG /home/subhash/workspace/suites/src/test/resources/testng.xml

我得到以下异常:

Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException

因此,我在pom.xml中添加了依赖项,如下所示。

<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>

建立它。 成功了。 再次,我已经运行上述命令来运行testng.xml,但仍然显示相同的异常。

请帮我解决这个问题。

提前致谢。 苏巴。

看一下这个问题: 突然无法从蚂蚁运行TestNG测试([testng]原因:java.lang.ClassNotFoundException:com.beust.jcommander.ParameterException)

好像是同样的问题

希望有帮助!

UPDATE

尝试将m2中的“ beust” jar路径添加到cp java参数。

使用mvn test代替testng jar运行测试会更容易。 在pom中设置mvn surefire插件,并使用mvn test -DsuiteXmlFile = src / test / resources / yourxml.xml运行

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM