Expand my Community achievements bar.

SOLVED

Test classes for AEM 6

Avatar

Level 2

Hi

 

How do i mock the getCuurentPage.. like methods. I am using Junit4Mockery.

 

Thanks

Abhinav

1 Accepted Solution

Avatar

Correct answer by
Level 6

Same way as you Mock any any interface. But, beware, you eventually will end up mocking the whole AEM (or it will feel like it).

In many cases, the Sling Test framework provides a better solution. Take a look at http://sling.apache.org/documentation/tutorials-how-tos/testing-sling-based-applications.html

"it felt safer to test it in a realistic situation rather than mock everything." - Could not agree more.

/Ove

View solution in original post

1 Reply

Avatar

Correct answer by
Level 6

Same way as you Mock any any interface. But, beware, you eventually will end up mocking the whole AEM (or it will feel like it).

In many cases, the Sling Test framework provides a better solution. Take a look at http://sling.apache.org/documentation/tutorials-how-tos/testing-sling-based-applications.html

"it felt safer to test it in a realistic situation rather than mock everything." - Could not agree more.

/Ove