Junit Coverage for Core Teaser Component | Community
Skip to main content
New Participant
March 3, 2023
Solved

Junit Coverage for Core Teaser Component

  • March 3, 2023
  • 1 reply
  • 1509 views

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.
Best answer by krishna_sai

@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

1 reply

krishna_sai
krishna_saiAccepted solution
New Participant
March 3, 2023

@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

gskittuAuthor
New Participant
March 3, 2023

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

krishna_sai
New Participant
March 3, 2023

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