2013-11-22 75 views
0

使用Maven和TestNG進行了本地設置,它的構建很好。構建有點奇怪,因爲爲了運行測試,首先需要打包的JAR。因此,在影響地方安裝運行詹金斯沒有通過surefire運行TestNG測試

#!/bin/bash 

mvn clean package -Dmaven.test.skip.exec=true 
mvn test 

當詹金斯運行,清潔/包裝步驟成功一樣測試,除了沒有測試實際運行:

[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 

好像在testCompile和測試surefire插件中的目標沒有找到任何測試類。

在pom.xml中是否需要額外的配置?

回答

0

測試類的默認路徑和推薦路徑爲{basedir}/src/test/java /。 但你可以精確的在你的pom.xml

<build> 
    <testSourceDirectory>{basedir}/path/to/test/classes</testSourceDirectory> 
    ... 
</build> 
+0

我們修改了源文件和測試文件的路徑,但是這些文件在pom.xml中指定,就像我提到的那樣,在本地工作正常。 –

0

您需要指定您的測試,需要運行的路徑。我相信,它會從測試*開始尋找測試。如果您使用的是testng xml,那麼您需要設置它。有關如何以不同方式指定測試的示例,請查詢this link