10

I am developing an Eclipse feature consisting of several Eclipse plugins, using Equinox Declarative Services (DS) to wire the plugins together at runtime. I would like to add integration tests to verify the equinox configuration.

In particular, I want to verify that

  • the service components bind together as expected
  • the bundles are activated
  • the plugins share information as expected (see Edit 2)

Furthermore, I want to make this integration testing a part of my continuous integration process using an Eclipse PDE headless build (as described here and here).

My question is: Can you recommend any frameworks, tools, or practices that will facilitate this type of integration testing within the constraints I've identified?

I've found two leads so far:

  • Spring Dynamic Modules includes a framework for OSGi integration testing. However, I haven't been able to get a simple Spring DM test to run within Eclipse. It complains that "the platform is already running".
  • Pax Exam (formerly Pax Drone) is another OSGi integration testing framework.

Edit: To clarify, each plugin has an OSGi service component configured with a component definition xml file. A mistake in one of these configuration files will not break any plugin dependencies and could easily go unnoticed until runtime. Integration testing is necessary to detect such failure.

Edit 2: So far every thing I've seen seems to confirm Uri's assertion (see below) that multi-plugin Eclipse features aren't integration-tested at the feature/product level. I'm willing to go without comprehensive integration tests if I can at least automatically verify that the service components bind together correctly.

My approach (not working yet):


In a JUnit test do
   For each bundle/plugin of interest
      Get the osgi Bundle object with org.eclipse.core.runtime.Platform.getBundle()
      Verify that the Bundle is active with Bundle.getState()
      Verify that the Bundle is using the expected services with Bundle.getServicesInUse()
      Verify that the Bundle has registered the expected services with Bundle.getRegisteredServices()

I'm running my code with an Eclipse Plug-in Test launch configuration, launching my Eclipse product as the "Program to Run". When the tests run, I can verify that the bundles are active but the service components do not get activated and the getServicesInUse and getRegisteredServices methods return null. I loaded a class from each bundle in case it was a lazy-activation issue, but that didn't help. I also verified that all the service components are "immediate" components, so they should be activated as soon as their bundle's are activated. Why isn't Equinox DS doing its magic?

4

1 回答 1

2

我们基于以下几种方法编写了自己的小测试执行框架:a)rcp bundletestcollector(http://rcpquickstart.com/2008/06/12/running-unit-tests-for-rcp-and-osgi-applications / ) 这是由 Pascal Rapidcault 编写的,他是 RCP 的主要成员之一。它从正在运行的 OSGi 环境中的包中收集测试类。

b) knopflerfish 测试框架 ( http://knopflerfish.org/releases/2.1.1/knopflerfish_osgi_tests_2.1.1.zip ) 将测试用例注册为可由测试运行器执行的服务。还有一个 XML 输出,遗憾的是它与 ant junit XML 格式有点不同。

通过这种方式,我们可以在单独的测试包中执行集成测试,也可以执行更接近经典单元测试并以片段形式存在于被测包中的测试(参见http://rcpquickstart.com/2007/06/20/unit- testing-plug-ins-with-fragments/)。

于 2009-05-18T05:27:17.377 回答