[英]Running JUnit tests on eclipse-test-plugins from maven
我有一個Maven3多模塊RCP Eclipse項目。 我想從Maven運行JUnit測試。 具有JUnit測試的模塊是eclipse插件。 我試圖通過在pom文件中添加以下代碼來使用Tycho Surefire Plugin
運行它們:
<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。
[錯誤]無法在項目xxxx.contact上執行目標org.eclipse.tycho:tycho-surefire-plugin:0.24.0:test(默認測試)。contact:啟動測試運行時發生意外錯誤(返回碼13)。 有關詳細信息,請參見日志。 -> [幫助1]
日志包含:
!SESSION 2019-03-05 11:31:23.457 -------------------------------------- --------- eclipse.buildId =未知的java.version = 1.8.0_191 java.vendor = Oracle Corporation BootLoader常數:OS = win32,ARCH = x86_64,WS = win32,NL = zh_CN框架參數:-application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties xxxx \\ target \\ surefire.properties命令行參數:-data xxxx \\ target \\ work \\ data -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties xxxx \\目標\\ surefire.properties
!ENTRY org.eclipse.tycho.surefire.junit4 2 0 2019-03-05 11:31:24.892!MESSAGE無法解析模塊:org.eclipse.tycho.surefire.junit4 [134]未解決的要求:進口包裝:junit .framework; version =“ 3.0.0”未解決的要求:導入包:junit.framework; 版本= “3.0.0”
!ENTRY org.eclipse.osgi 4 0 2019-03-05 11:31:24.893!消息應用程序錯誤!堆棧1 org.apache.maven.surefire.util.SurefireReflectionException:java.lang.ClassNotFoundException:org.apache.maven。位於org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:128)的org.apache.maven.surefire.util.ReflectionUtils.loadClass(ReflectionUtils.java:251)的surefire.junit4.JUnit4Provider org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:113)上的apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.java:235)在org.apache.maven.surefire.booter上。 org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.run(HeadlessTestApplication.java:上的ProviderFactory.invokeProvider(ProviderFactory.java:78)在org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:91) 21)at sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62),位於org.eclipse.equinox.internal.app的java.lang.reflect.Method.invoke(Method.java:498),位於sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)。 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.org)上的org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)上的EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587) java:134)位於org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)位於org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) .eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)位於sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)位於sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在java.lang.reflect.Method.in 在org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:656)在org.eclipse.equinox.launcher.Main.basicRun(Main.java:592)在org.eclipse。 org.eclipse.equinox.launcher.Main.main(Main.java:1471)處的.equinox.launcher.Main.run(Main.java:1498)原因:java.lang.ClassNotFoundException:org.apache.maven.surefire org.eclipse.tycho.surefire.osgibooter.CombinedClassLoader.findClass(CombinedClassLoader.java:37)上的.junit4.JUnit4Provider位於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個
我究竟做錯了什么? 先感謝您!
我已經找出了問題所在。 我不得不在MANIFEST.MF
以及org.junit
添加依賴項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.