使用Surefire的Maven拒绝运行单一测试方法? [英] Maven with Surefire refuses to run single test method?

查看:148
本文介绍了使用Surefire的Maven拒绝运行单一测试方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用Maven和Surefire插件来运行一些JUnit单元测试。

I've been trying to use Maven with the Surefire plugin to run some JUnit unit tests.

按照Maven和Surefire人员提供的说明进行操作: http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

Following the instructions provided by Maven and the Surefire folks here: http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

我对maven的命令如下:

My command for maven is as follows:

mvn clean -Dtest-group=regression -Dtest=TestClass#testMethod test

TestGroup从@IfProfileValue语句中提取并始终有效:

TestGroup is pulled from an @IfProfileValue statement and has always worked:

@IfProfileValue(name = "test-group", values = {"regression"})

然而,在我运行命令之后,尽管确定testClass有一个名为testMethod的方法(如果我没有将#testMethod添加到命令)我的输出如下:

However after I run the command, despite being sure that testClass has a method named testMethod(which would run if I didn't add the #testMethod to the command) my output is as follows:

~/REPOS/app: mvn clean -Dtest-group=regression -Dtest=TestClass#testmethod test

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.app:GuiAuto:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.twitter4j:twitter4j-core:jar -> version 2.2.4 vs [3.0,) @ line 127, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 147, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GuiAuto 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ GuiAuto ---
[INFO] Deleting /Users/llaskin/REPOS/app/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ GuiAuto ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 92 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ GuiAuto ---
[INFO] Compiling 762 source files to /Users/llaskin/REPOS/app/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ GuiAuto ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ GuiAuto ---
[INFO] Compiling 762 source files to /Users/llaskin/REPOS/app/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ GuiAuto ---
[INFO] Surefire report directory: /Users/llaskin/REPOS/app/target/surefire-reports
[INFO] parallel='classes', perCoreThreadCount=false, threadCount=5, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0, parallelOptimized=true

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.379s
[INFO] Finished at: Mon Nov 17 12:27:59 CST 2014
[INFO] Final Memory: 27M/571M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project GuiAuto: No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


推荐答案

也许这是因为Surefire 2.16和2.17中的 SUREFIRE-1028 中的错误。这个错误在Surefire 2.18中得到修复。

Maybe this is because of the bug SUREFIRE-1028 in Surefire 2.16 and 2.17. This bug is fixed in Surefire 2.18.

请您升级并告诉我们您的问题是否已通过Surefire 2.18修复。

Can you please upgrade and tell us whether your problem is fixed with Surefire 2.18 or not.

这篇关于使用Surefire的Maven拒绝运行单一测试方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆