Eclipse 功能集成测试的最佳实践
我正在开发一个由多个 Eclipse 插件组成的 Eclipse 功能,使用 Equinox Declarative Services (DS) 在运行时将插件连接在一起。 我想添加集成测试来验证春分配置。
特别是,我想验证
- 服务组件是否按预期绑定在一起,
- 捆绑包已激活
插件按预期共享信息(请参阅编辑2)
此外,我想让此集成测试使用 Eclipse PDE 无头构建来测试我的持续集成过程的一部分(如所述 这里和这里)。
我的问题是: 您能否推荐任何能够在我确定的限制范围内促进此类集成测试的框架、工具或实践?
到目前为止,我发现了两个线索:
- Spring Dynamic Modules 包含一个用于 OSGi 集成测试的框架。 但是,我无法在 Eclipse 中运行简单的 Spring DM 测试。 它抱怨说“该平台已经在运行”。
- Pax Exam(以前称为 Pax Drone)是另一个 OSGi 集成测试框架。
编辑:澄清一下,每个插件都有一个使用组件定义 xml 文件配置的 OSGi 服务组件。 这些配置文件之一中的错误不会破坏任何插件依赖项,并且很容易在运行时之前被忽视。 集成测试对于检测此类故障是必要的。
编辑 2:到目前为止,我所看到的一切似乎都证实了 Uri 的断言(见下文),即多插件 Eclipse 功能并未在功能/产品级别进行集成测试。 如果我至少可以自动验证服务组件是否正确绑定在一起,我愿意不进行全面的集成测试。
我的方法(尚未工作):
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()
我使用 Eclipse 插件测试启动配置运行我的代码,将我的 Eclipse 产品作为“要运行的程序”启动。 测试运行时,我可以验证捆绑包是否处于活动状态,但服务组件未激活,并且 getServicesInUse 和 getRegisteredServices 方法返回 null。 我从每个包中加载了一个类,以防出现延迟激活问题,但这没有帮助。 我还验证了所有服务组件都是“直接”组件,因此它们应该在其捆绑包被激活后立即被激活。 为什么 Equinox DS 没有发挥其魔力?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们基于以下方法的组合编写了自己的小测试执行框架:
a) rcp bundletestcollector (http: //rcpquickstart.com/2008/06/12/running-unit-tests-for-rcp-and-osgi-applications/)
这是由 RCP 主要成员之一 Pascal Rapidcault 撰写的。 它从运行的 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/< /a>)。
We wrote our own little test execution framework based on a combination of to approaches:
a) rcp bundletestcollector (http://rcpquickstart.com/2008/06/12/running-unit-tests-for-rcp-and-osgi-applications/)
This is written by Pascal Rapidcault who is one of the main RCP guys. It collects test classes from bundles in a running OSGi environment.
b) the knopflerfish testing framework (http://knopflerfish.org/releases/2.1.1/knopflerfish_osgi_tests_2.1.1.zip)
Registers test cases as services that can be executed by a test runner. There is also an XML output, which unfortunately differs a bit from the ant junit XML format.
This way we can execute integration tests living in separate test bundles as well as tests that are closer to classical unit tests and live in fragments to their bundles under test (see http://rcpquickstart.com/2007/06/20/unit-testing-plug-ins-with-fragments/).