Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Unit Testing in AEM - Hands on | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

Unit Testing in AEM - Hands on by Myaemlearnings

Abstract

This post is about hands-on on Unit Testing Java class, part of an AEM application.
We will be using AEM Mocks from io.wcm.testing.mock.aem.junit5.* and Mockito framework - org.mockito.*

JUnit Version : JUnit 5
AEM Maven archetype : 22
IDE : Eclipse
Testing related maven dependency : (available by default in AEM Maven archetype)
JUnit5 (org.junit)
AEM mocks (io.wcm.testing.aem-mock.junit5)
Mockito framework (org.mockito)

We mostly follow "Implementation first development" approach - Desired functionality is first coded and then test case is written for the same.
For creating Test Java class,
Create Test Java Class
Create AemContext
Implement setUp method (creating test fixture, annotated with @BeforeEach)
Implement methods to be tested. (annotated with @Test)

Read Full Blog

Unit Testing in AEM - Hands on

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies