Junit Coverage for Core Teaser Component | Community
Skip to main content
Level 2
Mar 3, 2023 12:06 PM UTC
Solved

Junit Coverage for Core Teaser Component

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?

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
krishna_sai
krishna_saiAccepted solution
New Participant
Mar 3, 2023 12:16 PM UTC

@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

ExampleTest.java

 



Hope this helps,
Krishna

4 replies

krishna_sai
krishna_saiAccepted solution
New Participant
Mar 3, 2023 12:16 PM UTC

@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

ExampleTest.java

 



Hope this helps,
Krishna

Translate
gskittuAuthor
Level 2
Mar 3, 2023 1:44 PM UTC

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

Translate
krishna_sai
New Participant
Mar 3, 2023 1:58 PM UTC

@gskittu you can do check for asserNull for methods which you are not using

Translate