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

SOLVED

How to write the JUnit

Ronnie09
Level 4
Level 4

For the below code I am unable to write the JUnit for @Postconstruct init()

 

But for text JUNIT is working fine via JSON. Need help

@inject
private Page currentPage;

@ValueMapValue
Private String text;

private String pageTitle;
@PostConstruct
protected void init() {
    if(!(currentPage.getName().equalsIgnoreCase("Product") || currentPage.getTemplate.getPath.equals("/conf/we-retail/settings/wcm/templates/hero")))
   {
       text="";
    }
}

public void getText()
{ return text;}

 

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

you don't need to write the junit for initi method. Amke sure you create 2 json one with your template and another with different template to make code coverage 100%

example

https://github.com/arunpatidar02/com.aemlab.junitapp/blob/master/core/src/main/java/com/aemlab/junit...

https://github.com/arunpatidar02/com.aemlab.junitapp/blob/master/core/src/test/java/com/aemlab/junit...

View solution in original post

0 Replies
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

you don't need to write the junit for initi method. Amke sure you create 2 json one with your template and another with different template to make code coverage 100%

example

https://github.com/arunpatidar02/com.aemlab.junitapp/blob/master/core/src/main/java/com/aemlab/junit...

https://github.com/arunpatidar02/com.aemlab.junitapp/blob/master/core/src/test/java/com/aemlab/junit...