簡體   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