在Eclipse Indigo中运行JUnit插件测试的正确目标平台?

时间:2011-12-16 12:24:21

标签: eclipse junit eclipse-plugin

对于我的Eclipse插件项目,我定义了以下目标平台:

<location includeAllPlatforms="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
  <unit id="org.eclipse.equinox.executable.feature.group" version="3.5.0.v20110530-7P7NFUFFLWUl76mart"/>
  <unit id="org.eclipse.rcp.sdk.id" version="3.7.1.M20110909-1335"/>
  <unit id="org.eclipse.jdt.feature.group" version="3.7.1.r371_v20110810-0800-7z8gFcoFMLfTabvKsR5Qm9rBGEBK"/>
  <unit id="epp.package.java" version="1.4.1.20110909-1818"/>
...

我的插件有JUnit插件测试(在同一个插件中)。如果我尝试使用JUnit启动配置(org.eclipse.platform.ide)运行它们,我会收到以下有关junit的控制台消息,以及异常:

!ENTRY org.eclipse.osgi 2 0 2011-12-16 13:00:35.206
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2011-12-16 13:00:35.206
!MESSAGE Bundle reference:file:/Users/stolz/ws-bucky/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.jdt.junit4.runtime_1.1.200.v20110505-0800.jar was not resolved.
!SUBENTRY 2 org.eclipse.jdt.junit4.runtime 2 0 2011-12-16 13:00:35.206
!MESSAGE Missing required bundle org.junit_4.7.0.
!SUBENTRY 1 org.eclipse.osgi 2 0 2011-12-16 13:00:35.207
!MESSAGE Bundle reference:file:/Users/stolz/ws-bucky/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.junit4_4.8.1.v20100525/ was not resolved.
!SUBENTRY 2 org.junit4 2 0 2011-12-16 13:00:35.207
!MESSAGE Missing required bundle org.junit_4.8.1.

!SUBENTRY 1 org.eclipse.osgi 2 0 2011-12-16 13:00:35.234
!MESSAGE Bundle org.junit4_4.8.1.v20100525 [219] was not resolved.
!SUBENTRY 2 org.junit4 2 0 2011-12-16 13:00:35.235
!MESSAGE Missing required bundle org.junit_4.8.1.

!ENTRY org.eclipse.core.net 1 0 2011-12-16 13:00:39.889
!MESSAGE System property http.nonProxyHosts has been set to local|*.local|169.254/16|*.169.254/16 by an external source. This value will be overwritten using the values from the preferences
Exception in thread "Plug-in Tests Runner" java.lang.IllegalArgumentException: Bundle "org.eclipse.jdt.junit4.runtime" not found. Possible causes include missing dependencies, too restrictive version ranges, or a non-matching required execution environment.
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.getClassLoader(RemotePluginTestRunner.java:77)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.readPluginArgs(RemotePluginTestRunner.java:93)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.init(RemotePluginTestRunner.java:83)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:61)
    at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness$1.run(PlatformUITestHarness.java:47)
    at java.lang.Thread.run(Thread.java:680)

使用默认的JDT安装,单元测试运行正常,只是我想为Hudson-build定义一个合适的目标平台。毋庸置疑,我尝试在各个地方的两个违规平台上添加依赖项,但无济于事。

更新: 哎呀,我把它与另一组测试混淆了;这些不是无头的,而是工作台测试。

另一个奇怪的是,在切换到默认Eclipse平台并返回我的第一次运行测试后,有时我不会看到此错误。奇

2 个答案:

答案 0 :(得分:1)

我不喜欢在这里吹响自己的号角,但我现在能够想出的唯一解决办法(经过几个小时的实验)将launch-config设置为"all workspace and enabled target plugins"而不是使用功能或基于插件的启动。我认为这表明插件解析过程中有一些可疑的东西,默认情况下Eclipse是正确的,但是当你开始限制可用的功能/插件时却没有。

通过这种改变,似乎可以在Eclipse和Buckminster中可靠地工作(使目标平台保持不变(!)不受原始问题中有问题的设置的影响)。所以我得出的结论是,目标平台原则上是正确的,它一定是关于发布的。

感谢所有人(@ andrew-eisenberg,至少@PaulWebster)的投入!

答案 1 :(得分:0)

如果JUnit不是目标平台的一部分,您如何编译和启动JUnit测试?您需要做的第一件事是将org.junit和org.junit4包添加到目标平台。由于看起来您正在使用基于功能的目标平台,因此您可能需要为这些捆绑包创建自定义功能。

其次,由于您不太可能希望使用插件发布测试,因此您可能希望遵循将测试分成* .. tests插件的标准Eclipse实践。

通常,您只是不在最终的RCP应用程序或更新站点中包含测试。

相关问题