Harness Test Automation

What is Harness Test Automation Tool ?

Harness is 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 build 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 the Cactus works ?
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 request. It is executed on the client side.eg): In login we can add 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,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 basedon 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 anotherclass 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.



Author: InApp
We are a custom software development company offering Testing Services, Application Development, Mobility Solutions & more. Customers: Startups - Fortune 500

1 Comment

Leave a Reply

10 + seven =