简体   繁体   English

詹金斯没有通过surefire运行TestNG测试

[英]Jenkins not running TestNG tests via surefire

Have a local set up using Maven and TestNG which builds just fine. 使用Maven和TestNG进行本地设置,可以很好地构建。 The build is a little odd given that in order for the tests to run, a packaged JAR is needed first. 鉴于要运行测试,首先需要打包的JAR,因此构建有点奇怪。 So in effect the local setup runs 因此实际上是本地设置运行

#!/bin/bash

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

When run on Jenkins, the clean/package step succeeds as does test, except no tests are actually run: 在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

Seems as though the testCompile and test goals in the surefire plugin aren't finding any test classes. 好像surefire插件中的testCompile和test目标没有找到任何测试类。

Is there an additional config needed in pom.xml? pom.xml中是否需要其他配置?

The default and recommended path for test classes is {basedir}/src/test/java/. 测试类的默认路径和推荐路径为{basedir} / src / test / java /。 But you can precise the path in your pom.xml 但是您可以在pom.xml中精确定位路径

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

You need to specify your tests that need to be run. 您需要指定需要运行的测试。 I believe, it looks for tests starting with test*. 我相信,它会寻找以test *开头的测试。 If you are using a testng xml then you need to set that up. 如果您使用的是testng xml,则需要进行设置。 Check this link out for examples on how to specify tests in different ways. 查看此链接 ,获取有关如何以不同方式指定测试的示例。

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

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