Issue :
We tried creating the jUnit using jupiter API for one of our nested multifield model, but currently it is not able to fetch the multifield and nested multifield values hence we are getting a NPE.
Surprisingly, it works when we remove the tag <packaging>bundle<packaging> from the core pom file.
Analysis :
When we remove <packaging>bundle<packaging>, the default value of <packaging> tag which is 'jar' will be considered and hence our testcases are running smoothly. but we cannot remove <packaging>bundle<packaging> this from the core pom.
Any thoughts / inputs would definitely help us.
Info:
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi,
The archetype by default includes the junit-jupiter dependencies (https://github.com/adobe/aem-project-archetype/blob/758aa13f33d4dabf5d01d0605491b2b6ae728553/src/mai...), so you should be able to use it without any problems. Ideally, if you are testing multifield or nested multifield values, you should mock those values. If the framework is unable to fetch them, there may be an issue with how you are initializing or loading the resources for the test. Could you please post the error you are encountering? Additionally, you can check here for information on how to test a multifield: https://medium.com/@veena.vikraman19/aem-junit-for-simple-aem-component-with-multifield-2326f61c8982
Hope this helps.
Views
Replies
Total Likes
@EstebanBustamante Thanks for the response. As I mentioned in my original post, the project is not created using the archetype, it is created using the lazybone template https://github.com/Adobe-Consulting-Services/lazybones-aem-templates/tree/master/templates/aem-multi... which doesn't have any jUnit related configurations by default.
Let me know if you have any thoughts.
Views
Replies
Total Likes
Sorry about that, I didn't read it carefully.
Which version of the junit-jupiter dependency are you using? My thought is that the version of Junit you are trying to run does not function properly due to a missing phase in the bundle packaging type. Are you using the Maven Bundle Plugin? can you try running an older version of Junit?
Views
Replies
Total Likes
Below are the junit related dependencies which I'm using.
<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
<version>1.3.6</version>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.testing.aem-mock-plugin</artifactId>
<version>${core.wcm.components.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
Also, Yes I'm using Maven Bundle Plugin too.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
</plugin>
and in my core pom, I have included it in the below manner under <build>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>com.xyz.xyz-project</Bundle-SymbolicName>
<Sling-Model-Packages>com.xyz.core.models, com.xyz.core.v3.models</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies