java 如何解决maven中“无法执行目标”maven-surefire-plugin:2.19.1”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40229895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 05:01:00  来源:igfitidea点击:

How to solve "failed to execute goal "maven-surefire-plugin:2.19.1" in maven

javamavenjenkins

提问by Luna Paglarelli

Im tryig to get a simple valid login test build in maven to later run in a jenkins server.

我尝试在 maven 中构建一个简单的有效登录测试,以便稍后在 jenkins 服务器中运行。

The thing is: everytime I build (clean install) i get the following error:

问题是:每次构建(全新安装)时,都会出现以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project validLogin: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Users\Me\workspace\validLogin\target\surefire-reports for the individual test results.
[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

I litteraly losing my hair here, how to fix this? (the error not the hair)

我在这里经常掉头发,怎么解决?(错误不是头发)

回答by Ashutosh Jindal

There are failing tests for your build which need to be fixed. To see whichtests are failing, In the surefire plugin configuration section of your pom.xml, check that the printSummary option is set to true.

您的构建存在需要修复的失败测试。要查看哪些测试失败,在 pom.xml 的 surefire 插件配置部分,检查 printSummary 选项是否设置为true

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19</version>
            <configuration>
                <printSummary>true</printSummary>
            </configuration>
        </plugin>

Once this option is set, you should see the full list of test results (including failures) in your command-line output.

设置此选项后,您应该会在命令行输出中看到测试结果(包括失败)的完整列表。

The test failures are also listed inside C:\Users\Me\workspace\validLogin\target\surefire-reports

测试失败也列在C:\Users\Me\workspace\validLogin\target\surefire-reports

回答by T.Tony

You can use

您可以使用

mvn clean install -DskipTests

Instead to skip tests if you don't want them to be executed.

如果您不希望它们被执行,而是跳过测试。