I have an implementation bundle and fragment bundle dependent on it (Fragment-Host in MANIFEST). Moreover, there is a bundle with some tests.
Now I want to test my implementation and use the tycho-surefire-plugin. The bundle with tests refers to the implementation bundle by means of Require-Bundle in MANIFEST. So far so good. The question is how do I get the fragment bundle into the test runtime? I have tried the dependency in the configuration of the tycho-surefire-plugin in my eclipse-test-plugin. But it does not work. What is the right way?
EDIT: pom.xml of my test plugin
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<testSuite>com.example.impl.tests</testSuite>
<testClass>com.example.impl.tests.MyTest</testClass>
<dependencies>
<dependency>
<type>eclipse-plugin</type>
<artifactId>com.example.impl.config</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
MANIFEST of the fragment bundle:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.example.config
Bundle-SymbolicName: com.example.config
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: example
Fragment-Host: com.example.impl;bundle-version="1.0.0.qualifier"
Bundle-ClassPath: resources/
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
extract from reactor pom.xml:
<modules>
<module>../com.example.impl</module>
<module>../com.example.impl.config</module>
<module>../com.example.impl.tests</module>
</module>
Thank you!
Using a fragment for unit testing is also a valid approach. Compared with the typical Java approach to have the test code located in the same project in a separate source folder, using a fragment is similar and gives the same opportunities.
assertEquals ("nospmiS", inverter.invert ("Simpson")); The test can be executed via right click -> Run As -> JUnit Test Integration tests or black-box-tests are used to test if our bundle and the provided services behave correctly in an OSGi environment.
The first approach for testing components is to write unit tests. In a plain Java project such tests are added in an additional source folder (typically named test ). They can then be executed from the IDE and at build time, but left out in the resulting JAR. With Bndtools the same approach is used for unit or white-box-testing.
It seams I have found an answer myself. In case anyone has the same problem: .qualifier version in Fragment-Host bundle-version is not automatically expanded by Tycho.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With