Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM Mock : Coverage issue


Level 2

The below is the class / System under Test :


Test Case:   It is throwing null pointer at line 71


Coverage Output



What changes need to be done in the test case to cover the try catch section of the code. Please Suggest.

2 Replies



I am not sure if I understand your question completely. So, I am going to assume to want to understand the reason for the NullPointerException. From looking at the code, it appears that the object "resolver" is null because it has not been initialized in the method setUp(). Maybe adding the line below in the method setUp() will help.

resolver = context.mock(ResourceResolver.class);


Level 2

Thank you for your response and is a value add.

Also, It looks like this will work for Mockito but for AEM Mock , its context object is not recognizing the mock class.