Eclipse 插件的二进制输出和测试
我正在开发一个 Eclipse 插件,并使用 Maven 来协调我的源结构。为了编译插件,我使用 maven 的 tycho 扩展。但是,我想知道如何执行unitests。
我想使用 Surefire 插件进行测试,因为我还使用声纳服务器进行源代码质量管理。如果我使用 eclipse-test-plugin 作为包目标,则应用 Unitests。但是,我想使用默认的 Surefire 插件来应用单元测试。
现在我发现包含我的单元测试包的 src/test/java 已正确读取和编译,但写入了错误的输出文件夹。我需要在目标/测试类中进行测试。然而它们被编译为目标/类。
由于我是 Eclipse 插件开发和 Maven 的新手,我不知道如何将测试写入正确的输出文件夹。我已经尝试添加和更改 eclipse-plugin 项目的 build.properties 。它也适用于其他非插件项目且不使用第谷的项目。
任何帮助表示赞赏。
问候, 弗洛里安
I am developing an Eclipse plugin and I use maven to coordinate my source structure. In order to compile the plugin I use the tycho extension for maven. However, I was wondering how to execute unitests.
I want to use the surefire plugin for testing as I additionally use a sonar server for source code quality management. Unitests are applyed if I use eclipse-test-plugin as package target. However, I want to make use of the default surefire plugin for applying unitests.
Now I figured out that the src/test/java that contains my unittest packages is read and compiled correctly but written into the wrong output folder. I need to have the tests in target/test-classes. However they are compiled to target/classes.
As I am new to Eclipse plugin development and maven I could not find out how to write the tests to the correct output folder. I've already tried adding and and changing the build.properties of the eclipse-plugin project. It works also fine for other projects that aren't plugin projects and do not make use of tycho.
Any help appreciated.
Regards,
Florian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与标准 Maven 项目不同,Eclipse 插件/OSGi 捆绑包的约定是将测试驻留在单独的项目中。这是因为 OSGi 中不存在 Maven 依赖范围“测试”之类的东西。
因此,将测试与被测代码放在同一个项目中将迫使您将测试代码/依赖项与高效代码/依赖项混合在一起。
正如您所提到的,Tycho 提供了一个单独的 Maven 打包类型“eclipse-test-plugin”,您应该将其用于专用测试插件/片段。请参阅https://docs.sonatype.org/display/TYCHO/PackagingTypes
没有第谷支持驻留在同一项目中的简单单元测试。
Unlike standard maven projects, the convention for eclipse plugins/OSGi bundles is to have tests reside in separate projects. This is because there is no such thing as a maven dependency scope "test" in OSGi.
Thus keeping your tests inside the same project as your code under test would force you to mix up test code/dependencies an productive code/dependencies.
As you mentioned, Tycho provides a separate maven packaging type "eclipse-test-plugin" which you should use for dedicated test plugins/fragments. See https://docs.sonatype.org/display/TYCHO/PackagingTypes
There is no support in Tycho for plain unit tests residing in the same project.