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
Q&A
Please use this thread to ask the related questions.
Kautuk Sahni