[英]Jenkins not running TestNG tests via surefire
使用Maven和TestNG進行本地設置,可以很好地構建。 鑒於要運行測試,首先需要打包的JAR,因此構建有點奇怪。 因此實際上是本地設置運行
#!/bin/bash
mvn clean package -Dmaven.test.skip.exec=true
mvn test
在Jenkins上運行時,clean / package步驟與測試一樣成功,但實際上沒有運行測試:
[workspace] $ mvn -f some_sub_directory/pom.xml test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ...-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/jobs/...
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ project ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ project ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ project ---
[INFO] Tests are skipped.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.222s
[INFO] Finished at: Fri Nov 22 18:34:00 UTC 2013
[INFO] Final Memory: 11M/89M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS
好像surefire插件中的testCompile和test目標沒有找到任何測試類。
pom.xml中是否需要其他配置?
測試類的默認路徑和推薦路徑為{basedir} / src / test / java /。 但是您可以在pom.xml中精確定位路徑
<build>
<testSourceDirectory>{basedir}/path/to/test/classes</testSourceDirectory>
...
</build>
您需要指定需要運行的測試。 我相信,它會尋找以test *開頭的測試。 如果您使用的是testng xml,則需要進行設置。 查看此鏈接 ,獲取有關如何以不同方式指定測試的示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.