【发布时间】:2019-07-26 16:56:45
【问题描述】:
我有一个 maven3 多模块 RCP eclipse 项目。我想从 maven 运行 JUnit 测试。具有 JUnit 测试的模块是 eclipse-plugins。我尝试使用Tycho Surefire Plugin 在 pom 文件中添加它来运行它们:
<packaging>eclipse-test-plugin</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/test</sourceDirectory>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>0.24.0</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<useUIHarness>false</useUIHarness>
<providerHint>junit4</providerHint>
</configuration>
</plugin>
</plugins>
</build>
</project>
mvn test 不会触发测试。只有类被编译。
使用mvn verify 我收到以下错误:
----------------------------------- -------- 测试 -------------------------------------------------- - - - 发生了错误。看看日志文件 E:\Git\EF8_Toolcenter_repository_custom\de.audi.eftc.platform.contact\target\work\data.metadata.log。
[ERROR] 未能执行目标 org.eclipse.tycho:tycho-surefire-plugin:0.24.0:test (default-test) on 项目 xxxx.contact:启动时发生意外错误 测试运行时(返回码 13)。有关详细信息,请参阅日志。 -> [帮助 1]
日志包含:
!会话 2019-03-05 11:31:23.457 ----------------------------------------------------------- eclipse.buildId =未知 java.version=1.8.0_191 java.vendor=Oracle 公司 BootLoader 常量:OS=win32, ARCH=x86_64, WS=win32, NL=en_US 框架参数:-application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties xxxx\target\surefire.properties 命令行参数:-data xxxx\目标\工作\数据 -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties xxxx\target\surefire.properties
!ENTRY org.eclipse.tycho.surefire.junit4 2 0 2019-03-05 11:31:24.892 !MESSAGE 无法解析模块:org.eclipse.tycho.surefire.junit4 [134] 未解决的要求:Import-Package: junit.framework; version="3.0.0" 未解决的要求:导入包: junit.framework;版本="3.0.0"
!ENTRY org.eclipse.osgi 4 0 2019-03-05 11:31:24.893 !MESSAGE 应用程序错误!堆栈 1 org.apache.maven.surefire.util.SurefireReflectionException: java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider 在 org.apache.maven.surefire.util.ReflectionUtils.loadClass(ReflectionUtils.java:251) 在 org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:128) 在 org.apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.java:235) 在 org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:113) 在 org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:78) 在 org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:91) 在 org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.run(HeadlessTestApplication.java:21) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587) 在 org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198) 在 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) 在 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) 在 org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) 在 org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:656) 在 org.eclipse.equinox.launcher.Main.basicRun(Main.java:592) 在 org.eclipse.equinox.launcher.Main.run(Main.java:1498) 在 org.eclipse.equinox.launcher.Main.main(Main.java:1471) 原因: java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider 在 org.eclipse.tycho.surefire.osgibooter.CombinedClassLoader.findClass(CombinedClassLoader.java:37) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:424) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:357) 在 org.apache.maven.surefire.util.ReflectionUtils.loadClass(ReflectionUtils.java:243) ... 24 更多
我做错了什么? 提前谢谢!
【问题讨论】:
标签: java eclipse maven junit rcp