Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

When you execut your Unit Tests using AEM Mocks, Sling Mocks or OSGi Mocks you may encounter a stack trace like this:

...

To run the unit tests in the mocked OSGi environment the OSGi metadata files located in the bundle JAR file at /OSGI-INF need to be present in the folder target/classes during unit test execution. If this stack trace occurs they are not present, and thus the mocked OSGi dos not run.

Solution

Maven Bundle Plugin configuration

First, you have to make sure you have properly set up the maven-bundle-plugin to make sure there is an additional execution of the "manifest" goal, and the configuration parameter "exportScr" is set to true.

...

If you have used the Adobe AEM Project Archetype or the wcm.io Maven Archetype for AEM this is already correctly configured.

Unit tests fail only in Eclipse

If the Unit Tests fail only in Eclipse, execute a "Project → Clean" command to start a fresh rebuild of the project in Eclipse which should generate the required metadata. It should be done automatically by Eclipse, but sometimes this fails.

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@4e99be7
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ( "mocks" , "aem" ) and type = "page" and space = "WCMIO"
labelsaem mocks

...

Page Properties
hiddentrue


Related issues