Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Issue regarding Junit testing of Sightly components

Avatar

Former Community Member

Hello,

We are trying to Unit test Controllers of our Sightly components. 

We are using PowerMock, Mokito and Junit.

Our Controller class extends WCMuse class as our component is in sightly. We tried to do Mock the WCMuse by @Mock annotation. 

But the issue is we get NullPointerException when we try to "getProperties()". This getProperties() is a method in WCMuse class and internally uses the javax.script.Bindings class to fetch the properties.Bindings is private in the WCMuse class. 

As per the  errorstack, this Bindings object is null. So getproperties() is null.Hence the error. As Bindings is private so we are not able to mock it.

Let me know if there is any other way to do it ?Can WCMuse class be mocked?

Please let me know if someone has any successful implementation of JUnit testing of WCMuse.class.

Let me know if you need any other details.

Thanks in advance.

 

Suneel.

1 Accepted Solution

Avatar

Correct answer by
Employee

You need to use something like JMockito here.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

You need to use something like JMockito here.