[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null: ExceptionInInitializerError: Unexpected ClassNotFoundException looking up class 'org.apache.maven.cli.MavenCli' -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project ASPEN: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:197) at org.apache.maven.surefire.util.ReflectionUtils.invokeGetter(ReflectionUtils.java:69) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.getSuites(ProviderFactory.java:148) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.getSuitesIterator(ForkStarter.java:317) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:149) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:118) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:199) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:176) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:135) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 20 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) ... 30 more Caused by: java.lang.ExceptionInInitializerError ... 2 more at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.junit.runner.Description.getTestClass(Description.java:207) at org.apache.maven.surefire.common.junit48.FilterFactory$GroupMatcherCategoryFilter.shouldRun(FilterFactory.java:207) at org.apache.maven.surefire.junitcore.JUnitCoreProvider.getSuitesAsList(JUnitCoreProvider.java:169) at org.apache.maven.surefire.junitcore.JUnitCoreProvider.getSuites(JUnitCoreProvider.java:102) ... 35 more Caused by: java.lang.RuntimeException: Unexpected ClassNotFoundException looking up class 'org.apache.maven.cli.MavenCli' ... 12 more (deleted lines here)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>sample</artifactId>
<groupId>sample</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>webapp</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
</plugins>
</reporting>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<configuration>
<groups>com.webapp.api.annotation.type.${group.include}</groups>
<excludedGroups>com.webapp.api.annotation.type.${group.exclude}</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</project>
有什么想法吗?
谢谢
为什么不把版本放入这个pom中,因为这个pom是由您控制的,任何使用您的项目的人都会惊讶于它不工作,因为他错过了在命令行上给出属性。顺便问一下:您是否通过mvn-x-dsurefire.version=2.12等检查了输出,我想您会得到相同的错误消息。
我已经重新检查了,如果你用这种方式定义版本,你的项目就不再正确了,如果有人错过了选项(-D...)在命令行中,您将得到如下内容:
INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.soebes.katas:code:1.0-SNAPSHOT (/home/katas/pom.xml) has 1 error
[ERROR] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin must be a valid version but is '${surefire.version}'. @ line 36, column 20
[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/ProjectBuildingException
换句话说,通过命令行上的选项来定义插件版本(或插件的依赖关系)是一个非常糟糕的主意。我只建议您在pom中定义所需的所有版本,并通过surefire和/或failsafe插件正确使用单元测试和集成测试。这会解决你的问题。
运行似乎surefire没有执行其测试目标(或者至少没有选择我在配置中包含的测试)。 这是一个多模块maven项目,目前全部在groovy中,其结构类似于以下内容: 我在pom中有以下surefire配置。xml: 但是,当我针对这个pom执行
我正在使用Maven构建我的项目。我目前将测试分为不同的层次结构: 单元测试- 这里是我的部分: <代码> 我尝试了,它运行所有的测试——单元测试、集成测试和外部测试。但是,对于默认测试套件,我只想运行单元测试。 我如何在Maven中实现这一点? 裁判:
在eclipse中运行的测试,mvn测试,命令行中也运行,但不在Jenkins中运行。控制台中的maven surefire插件说没有要运行的测试。我怀疑maven surefire插件不能选择测试。我的POM看起来像: http://maven.apache.org/xsd/maven-4.0.0.xsd“>4.0.0 groupid artifactiddemo 0.0.1-快照 null 我
现有结构:src/test/java-- 更新:我也尝试了构建助手插件 现在,如果我运行“测试”目标,我看到添加了C:\Developer\Code\myProj\rc\test\groovy。 但是我没有看到任何为groovy文件生成的类。 最后的答案,感谢@khmarbaise,我刚刚升级了版本,并删除了GMaven编译
我在使用maven成功编译测试时遇到问题。我正在使用EasyMock V4.0.2模拟服务。我应该提到的是,使用intellij IDE运行测试不会出现问题,下面是附带的代码。当我尝试将模拟注入模拟测试时,问题似乎就出现了。我已经看到了一些关于这个问题的帖子,但没有任何能解决我的问题。 我见过的最接近的一次是这次Spring启动未能执行目标组织。阿帕奇。专家插件:maven surefire插件:
是的,包含测试的Java类命名正确。(它们以测试结尾) 尝试在pom.xml中添加以下配置: 测试位于以下结构下: /src/test/packagename/JavaClassTest.java,其中Packagename与src/main/java路径下编写的单元测试下的包相同。 我正在使用jupiter JUnit 5和maven-surefire-plugin与2.22.2 我仍然在mvn