There's the traditional, brute force way - write a JUnit test case that opens a HttpURLConnection to your servlet, reads the content, and does various String.indexOf() and String.subString() operations until you're satisfied that all is well (or you're tired of … https://www.tutorialspoint.com/junit Here is very simple example: Case 2: Writing test cases for AEM Helper class Learn more about unit testing here Why you need JUnit testing. Writing test cases for AEM servlets This is very similar to how you would do test cases for Service. Writing unit tests for @SlingServletResourceType is very simple. In my previous blog post, I talked about how you can switch from WCMUsePojo API to Sling Models for Adobe Experience Manager (AEM) component. @org.junit.Test annotation: The Test annotation tells JUnit that the public void method to which it is attached can be run as a test case. 1 @Test. How to run JUnit test cases from the command line, How do servlets work? See copyright notice in CopyRight.txt. JUnitCore class is used to execute these tests. There's the traditional, brute force way - write a JUnit test case that opens a HttpURLConnection to your servlet, reads the content, and does various String.indexOf() and String.subString() operations until you're satisfied that all is well (or you're tired of hacking together String operations). To run the method, JUnit first constructs a fresh instance of the class then invokes the annotated method. Current version is junit 4. Click here to learn to sugar coat registered AEM servlet scripts and paths endpoint. in a previous post.. For this test we add a few dependencies to the pom.xml org.springframework spring-test 3.2.3.RELEASE