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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Junit Coverage for Core Teaser Component

Avatar

Level 2

Hi Team,

 

 I have written jUnit test cases for custom teaser component which extends the core Teaser component using the Delegation Pattern for Sling Models using "@Self @Via(type=ResourceSuperType.class)  as specified here: https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models

 

Junit coverage is less on environment, in my local it is 100 % I have covered junits for custom methods which written custom teaser model, There are methods in parent class ( below in screenshot ) which does not cover in my custom test class, How to overcome this issue?

 

gskittu_0-1677844904812.png

1 Accepted Solution

Avatar

Correct answer by
Level 5

@gskittu Have a getter method which returns Teaser teaser which you have injected @Self and @Via
Just showing an example below you can follow the same pattern while dealing with any delegate slingmodels

Example.class

krishna_sai_0-1677846599780.png

ExampleTest.java

krishna_sai_1-1677846631886.png

 



Hope this helps,
Krishna

View solution in original post

3 Replies

Avatar

Correct answer by
Level 5

@gskittu Have a getter method which returns Teaser teaser which you have injected @Self and @Via
Just showing an example below you can follow the same pattern while dealing with any delegate slingmodels

Example.class

krishna_sai_0-1677846599780.png

ExampleTest.java

krishna_sai_1-1677846631886.png

 



Hope this helps,
Krishna

Avatar

Level 2

Thanks you Krishna, There are some more methods which we don't require, With those fields coverage is less, how can we fix this issue

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now