Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on pr

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zbj18314469395/article/details/84285383

问题所在:配置的参数、路径与实际项目里面的code不一样导致启动maven失败;仔细检查一下远程仓库代码与配置中的名字。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project AutomationBasePDF: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was an error in the forked process
[ERROR] org.apache.maven.surefire.testset.TestSetFailedException: Suite file
D:\Jenkins\**\**\mokeTest.xml is not a valid file
[ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.locateTestSets(TestNGXmlTestSuite.java:116)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:84)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[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/PluginExecutionException

不知道小伙伴本有没有遇到过类似的错误。
经过这几天的调试Jenkins跑Maven工程,发现只要出现这类的错误基本上都是Jenkins上面配置时的参数、路径错误,导致了run Maven时启动失败。 

解决方法:

再详细查看的Jenkins各项配置参数,以及查看报错日志的指向的具体原因。

我遇到最多的是:
1、由于准备调用xml 的Suit名字与实际代码中的名字不一致;

2、配置时,命令行的参数错误,导致运行不了Maven;

3、文件路径有误;
总之就是配置的参数、路径与实际项目的code不一样导致启动maven失败。

最后:

来说下插件maven-surefire-plugin的作用你就明白了。

  • Maven通过Maven Surefire Plugin插件执行单元测试。(通过Maven Failsafe Plugin插件执行集成测试
  • 在pom.xml中配置JUnit,TestNG测试框架的依赖,即可自动识别和运行src/test目录下利用该框架编写的测试用例(配置时参数、路径错误那就之别不了咯,肯定报错)
  • surefire也能识别和执行符合一定命名约定的普通类中的测试方法(POJO测试)。
  • 生命周期中test阶段默认绑定的插件目标就是surefire中的test目标,无需额外配置,直接运行mvn test就可以。

猜你喜欢

转载自blog.csdn.net/zbj18314469395/article/details/84285383
今日推荐