Adding test-only dependencies for non-OSGi JUnit test in a Tycho project

霸气de小男生 提交于 2019-12-04 14:03:41

If you can run your test with a class path that you completely only compose of Maven dependencies (e.g. to Mockito), you could also create a module with jar packaging for these tests. From that module, you'd also add a dependency to the bundle, which would then be used as plain JAR.

What you'd loose in this case is the resolution of transitive dependencies. The jar project would then be resolved by Maven, and Maven doesn't know about the Manifest dependencies of the OSGi bundle. But depending on the exact nature of what you want to test, this may still work.

Typically you'll see tests in a separate bundle, with it's own manifest and dependencies. This is not the standard Maven structure, but it fits better with how OSGi bundles want to be structured.

For example, look at the JDT-core git repository, you'll see separate test bundles. Note that test bundles have a special packaging-type of eclipse-test-plugin.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!