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

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K
kautuk_sahni
Community Manager

13-07-2020

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.

AEM AEMEBlogSeeding Experience Manager