ker*_*000 5 tdd junit eclipse-rcp
We have a rather larger Eclipse RCP application and are not sure how to properly test it's plugins.
Problem: Running JUnit Plugin Tests takes a lot of time (seconds instead of millicseconds for simple JUnit Test) and resources, since the RCP Platform and all plugins need to start up.
Question: How can I efficiently minimize the plugins that are run for the test? What options do I have to minimize my dependencies to the RCP Platform (such as Preferences Service and Extension Points)? Are there maybe some Mocking libraries or at least some best practices for mocking RCP Platform services?
Right now I cannot imagine to do some decent TDD with the JUnit plugin test runner, it just takes too long to execute these tests.
Any advice and experience on that topic very welcome!
我能感觉到你的痛苦:插件测试很糟糕!而且我也没有找到一个完全令人满意的解决方案。
虽然您可能会获得一些(毫秒?)秒,因为您将所需的插件减少到绝对最小值,但我发现这是不切实际的,因为您的依赖关系图中的更改通常也需要调整启动配置。如果您的(共享)启动配置中有依赖于平台的片段(即 SWT),情况会变得更糟。我通常会回退到所有工作区并启用目标插件选项,并且没有看到启动速度的显着差异。
我不知道 RCP 平台的模拟库。
除了非常简单的情况外,我不会嘲笑平台的某些部分,因为您很容易将行为弄错。另见这篇文章:https : //stackoverflow.com/a/31938571/2986905
我的做法是尽可能将平台依赖性排除在我的应用程序代码之外,以便我可以编写简单的 JUnit 测试。平台 API 上的自定义抽象在这里可以帮助重复使用案例。
此外,可以在没有运行工作台的情况下使用数量惊人的平台 API,当然,例如所有 SWT 和 JFace API、首选项……因此,编写具有最小依赖性的小型简单类再次有助于远离插件- 在测试中。例如,将视图的内容与 IViewPart(或其 e4 等效项)分开允许编写测试而无需视图,进而运行工作台实例(如果我说的很明显,请原谅)。
| 归档时间: |
|
| 查看次数: |
521 次 |
| 最近记录: |