Harness Test Automation

What is Harness Test Automation?

The harness is a server-side testing framework. It is being used for testing the server-side functionalities. Cactus (Jakarta product for java server-side testing) is a simple open-source test framework used for unit testing server-side java code (Servlets, EJBs, Tag Libs, Filters,…), and harness is built over it.

JUnit V/s Harness

JUnit tests run in the same JVM as the test subject whereas Harness tests start in one JVM and are sent to the app server’s JVM to be run. The package is sent via HTTP to the redirector. The redirector then unpacks the information, finds the test class and method, and performs the test.

HarnessAutomationStructure

How do the Cactus work?
Cactus has a class called ServletTestCase and it has 3 functionalities.
1) beginXXXX(WebRequestwebRequest){ }
2) testXXXXX(){ }
3) endXXXXX(WebResponsewebResponse ){ }

Begin() – Here parameters are added to a request. It is executed on the client side. eg): In login, we can add a username and password to webRequest.

Test() – Here we call the respective actions to be tested. In this, we get the implicit objects like request, response, and session as well as the parameters that we pass via Testcases.xml which are added inbeginXXXX(). Here we call the respective actions to be tested, which return pass or fail based on assertions. It is executed on the server-side.

End() – The values in the response from the action can be tested here. It is executed on the client side.

We have extended ServletTestCase to our harness framework with a class called FrameworkServletTestCase. FrameworkServletTestCase has the functionalities to getconfiguration files, testcases etc. The FrameworkServletTestCase is further extended to another class called QAToolTestCase. QAToolTestCase has postAssertions() and preAssertions()functionalities, which form the basis of whether a test case passes or fails.

Cactus is configured in its property file called cactus.properties.
Parameters configured are –
cactus.contextURL = http://localhost:8080/CServer
cactus.servletRedirectorName = ServletRedirector
cactus.enableLogging=true

We need to add the servlet class and servlet-mapping in web.xml for ServletRedirecton
<!– Cactus Servlet Redirector configuration –>
<servlet>
<servlet-name>ServletRedirector</servlet-name>
<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
</servlet>

<!– Cactus Servlet Redirector URL mapping –>
<servlet-mapping>
<servlet-name>ServletRedirector</servlet-name>
<url-pattern>/ServletRedirector</url-pattern>
</servlet-mapping>

Test cases are configured in the testcasexmls, where the parameters to be passed are defined. Test cases can be broken into smaller units called Snippets. These snippets are called fromTestCases.xml.

Have questions? Contact the software testing experts at InApp to learn more.

Ready to Build
Something
Extraordinary?

Join 300+ companies who trust us to turn their biggest ideas into market-leading solutions.

Our Global Team
500+ Engineers Worldwide
SOC 2 Certified

Get in Touch with Us

Our Global Team
500+ Engineers Worldwide
SOC 2 Certified

InApp India Office

121 Nila, Technopark Campus
Trivandrum, Kerala 695581
+91 (471) 277 -1800
mktg@inapp.com

InApp USA Office

999 Commercial St. Ste 210 Palo Alto, CA 94303
+1 (650) 283-7833
mktg@inapp.com

InApp Japan Office

6-12 Misuzugaoka, Aoba-ku
Yokohama,225-0016
+81-45-978-0788
mktg@inapp.com
Terms Of Use
© 2000-2026 InApp, All Rights Reserved