I am trying to unit test my OSGI R6 annotated classes. I found out that I have to specify some info in the maven-bundle-plugin: <a href="http://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-faq.html#use-scr-metadata-generated-by-bnd-in-unit-tests" rel="nofollow">http://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-faq.html#use-scr-metadata-generated-by-bnd-in-unit-tests</a> --> Use SCR metadata generated by BND in Unit Tests.
If I invalidate cache in Intellij and restart and try to execute my test again it fails. If I manually trigger the manifest goal of the maven-bundle-plugin and run the test it succeeds, can I automate the generation of the metadata?
Will this configuration still work for tests that are written for classes using the older felix src annotations?Answer1:
<exportScr>true</exportScr> in the maven config. Now I only have to run my test later in the lifecyle as explained here: <a href="https://github.com/Adobe-Marketing-Cloud/aem-project-archetype/blob/8aecf81ea5bb897a7d8dd5f241d5fcd561c36aa6/src/main/archetype/it.launcher/pom.xml" rel="nofollow">https://github.com/Adobe-Marketing-Cloud/aem-project-archetype/blob/8aecf81ea5bb897a7d8dd5f241d5fcd561c36aa6/src/main/archetype/it.launcher/pom.xml</a> and all will be good.