簡體   English   中英

在Eclipse Indigo中運行JUnit插件測試的正確目標平台?

[英]Right target platform for running JUnit plugin tests in Eclipse Indigo?

對於我的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平台並返回我的第一次運行測試后,有時我不會看到此錯誤。 奇。

我不喜歡在這里吹響自己的號角,但我現在能夠想出的唯一解決辦法(經過幾個小時的實驗)將launch-config設置為"all workspace and enabled target plugins"而不是使用功能或基於插件的啟動。 我認為這表明在插件解析過程中有一些可疑的東西,默認情況下Eclipse是正確的,但是當你開始限制可用的功能/插件時卻沒有。

通過這種改變,似乎可以在Eclipse和Buckminster中可靠地工作(使目標平台保持不變(!)不受原始問題中有問題的設置的影響)。 所以我得出結論,目標平台原則上是正確的,它一定是關於發布的東西。

謝謝大家(@ andrew-eisenberg,至少@PaulWebster)的輸入!

如果JUnit不是目標平台的一部分,您如何編譯和啟動JUnit測試? 您需要做的第一件事是將org.junit和org.junit4包添加到目標平台。 由於您看起來正在使用基於功能的目標平台,因此您可能需要為這些捆綁包創建自定義功能。

其次,由於您不太可能希望使用插件發布測試,因此您可能希望遵循將測試分離為* .. tests插件的標准Eclipse實踐。

通常,您只是不在最終的RCP應用程序或更新站點中包含測試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM