When testing Eclipse RCP plugins, it is good practice to have all test classes and resources live in a dedicated (test) fragment. This way all classes in the host plugin can be accessed, no matter if those packages are actually exported or not.
But what if I have a common test infrastructure, that is used by many plugins?
I cannot put this into a fragment, since I cannot reuse classes inside a fragment somewhere else.
A fragment does not exist at runtime. It is merged with its
Fragment-Host
.You either need to place the code in a regular bundle/plug-in, or use a poxy bundle that exposes the classes of the fragment to be accessible from other fragments or bundles. For example:
Host
Fragment
However, the latter approach uses the Eclipse-specific
Extensible-API
header that is only understood by the Equinox OSGi implementation.Therefore, my recommendation would be to leave the actual test classes in a fragment that corresponds to the bundle-under-test and put the reusable test helpers in a dedicated bundle.