【问题标题】:JUnit Plug-in Test Ignores Target Platform in Eclipse NeonJUnit 插件测试忽略 Eclipse Neon 中的目标平台
【发布时间】:2016-09-06 12:36:13
【问题描述】:

我在让 JUnit 插件测试使用 Eclipse Neon M7 工作时遇到了一些问题,我真的很想得到任何使用测试的人的意见(必须有某人,对吗?) .

每当我开始在 Eclipse Luna 中运行的测试(但 didn't in Mars,我认为这是一个错误)并继续使用 Tycho 运行时,我都会收到以下异常:

!SESSION 2016-05-11 10:25:41.456 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_73
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -version 3 -port 60297 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames org.acme.test.test.core.ActivatorTest -application org.eclipse.pde.junit.runtime.uitestapplication -testApplication org.eclipse.ui.ide.workbench -testpluginname test.core
Command-line arguments:  -os win32 -ws win32 -arch x86 -consoleLog -version 3 -port 60297 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames org.acme.test.test.core.ActivatorTest -application org.eclipse.pde.junit.runtime.uitestapplication -testApplication org.eclipse.ui.ide.workbench -data C:\workspaces\MyWorkspace/../junit-workspace -dev file:C:/workspaces/MyWorkspace/.metadata/.plugins/org.eclipse.pde.core/pde-junit/dev.properties -os win32 -ws win32 -arch x86 -consoleLog -testpluginname test.core

!ENTRY org.eclipse.pde.junit.runtime 4 0 2016-05-11 10:25:42.373
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.eclipse.pde.junit.runtime [81]
  Unresolved requirement: Require-Bundle: org.eclipse.core.runtime; bundle-version="[3.11.0,4.0.0)"

    at org.eclipse.osgi.container.Module.start(Module.java:434)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1561)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

!ENTRY org.eclipse.pde.junit.runtime 2 0 2016-05-11 10:25:42.719
!MESSAGE Could not resolve module: org.eclipse.pde.junit.runtime [81]
  Unresolved requirement: Require-Bundle: org.eclipse.core.runtime; bundle-version="[3.11.0,4.0.0)"


!ENTRY org.eclipse.osgi 4 0 2016-05-11 10:25:42.720
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: Application "org.eclipse.pde.junit.runtime.uitestapplication" could not be found in the registry. The applications available are: org.eclipse.ant.core.antRunner, org.eclipse.ui.ide.workbench, org.eclipse.help.base.infocenterApplication, org.eclipse.help.base.helpApplication, org.eclipse.help.base.indexTool, org.acme.test.rxp.rxpdemo, org.eclipse.equinox.app.error.
    at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:248)
    at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

显然,此时这不是 Eclipse 错误,但我做错了什么。没有迹象表明测试中启动了哪种插件,但从版本范围来看,我认为它又是错误的——运行的 Eclipse 实例的插件而不是工作区目标中定义的插件平台。

启动配置仍然声称使用了后来的目标平台。

如何配置插件单元测试以使其采用当前活动的目标平台?

【问题讨论】:

  • 您的目标平台是基于 Eclipse 3.7/8 的吗?当我的开发和目标平台版本不同时,我遇到了类似的问题,我将尝试挖掘我为解决它所做的工作。
  • @JonahGraham 是的,它是 Eclipse 3.7,因此明显比 Eclipse Neon 旧。请挖掘问题的解决方案:)
  • 我无法重现问题,因此无法重现解决方案。我提供了我的笔记作为答案,希望对您有所帮助。

标签: java eclipse junit eclipse-plugin


【解决方案1】:

这里的问题是 Eclipse 4.4 (Luna, 2014) 及更低版本的 org.eclipse.core.runtime 版本与宿主 Eclipse 版本的 org.eclipse 兼容.pde.junit.runtime。当依赖性增加时,这在 4.5 中发生了变化。

正如您正确地得出结论,配置指向错误的org.eclipse.pde.junit.runtime。这可能是由于未清除的配置状态。确保正在清除配置,这样您就不会使用过时的版本运行。即确保在启动配置的配置选项卡中选中启动前清除配置区域

您可以通过查看 ${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit/org.eclipse.equinox 准确了解 PDE 已将哪些内容解析为已配置的捆绑包。 simpleconfigurator/bundles.info(在启动配置的配置选项卡中指定的位置)

【讨论】:

  • “清除工作区数据”和“启动前清除配置区域”在默认情况下被选中以进行测试,所以我没有什么可以改变的。为什么他甚至使用除了工作区目标平台中的版本之外的任何其他版本?我们的默认目标平台中没有simpleconfigurator - 但如果这是问题,我会尝试添加它。
  • simpleconfigurator 帮助我发现我的目标平台缺少“org.eclipse.pde.junit.runtime”,因此 Eclipse 出于某种奇怪的原因在其插件文件夹中使用了该平台。
  • +1 用于指出 bundles.info 文件,您可以在该文件中查看 PDE 解决了哪些捆绑包 - 它帮助我解决了由我的 Eclipse 安装加载 org.eclipse.jdt.junit4.runtime 引起的类似问题目标平台的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-22
  • 1970-01-01
  • 1970-01-01
  • 2010-10-31
相关资源
最近更新 更多