Latka User's Guide Commons Documentation Team

Latka is a functional (end-to-end) testing tool. It is implemented in Java, and uses an XML syntax to define a series of HTTP (or HTTPS) requests and a set of validations used to verify that the request was processed correctly.

Note: Although Latka currently supports only HTTP and HTTPS request/response validations, it may be expanded to perform other sorts of functional testing as warranted.

A simple example of a Latka XML test suite is shown in our sample Latka test suite. When processed, this example would verify that the Jakarta Commons homepage is present and that all the Commons Components have online documenation.

A Latka test suite can be run:

Note:To run Latka as an ant task, we suggest you use the JUnit support of ant and write a small test case to invoke Latka, as discussed later

There are two scripts (or batch files) shipped with latka:

  1. latka.bat - for Windows machines

  2. latka.sh - for Unix machines

Both of the scripts take the following parameters:

  1. a test suite URL, e.g. file:./TestCommonsWebsite.xml or http://jakarta.apache.org/commons/latka/TestCommonsWebsite.xml

  2. Optionally properties files of Latka options can be specified using the propfile parameter: propfile:<file name>

  3. Optionally individual Latka options may be specified using the prop parameter: prop:<prop name>=<prop value>

For more information about what properties you can pass to Latka, please see the Latka Properties definition

The Latka release distribution comes with a web application (latka-webapp.war) ready to deploy on a conforming Servlet 2.2/ JSP 1.1 container.

For example, to install the Latka web application into a Tomcat 4 server, simply copy the .war file to Tomcat's webapp directory, e.g.

[Win32] copy latka-webapp.war c:\tomcat4\webapps

or

[Unix] cp latka-webapp.war /usr/java/jtomcat4/webapps

and restart Tomcat

Using the Latka Web App

Once you've gotten the Latka web app running, it's straightforward to use. You can either

  1. Run a latka

Here's hoping you're familiar with JUnit

Latka ships with a class JUnitTestAdapter that bridges Latka and JUnit. You can use this class to create JUnit Tests from Latka's XML documents. For example, calling JUnitTestAdapter.createTestFromFile(fileName) with a valid Latka XML document's file name will return you back a JUnit Test, ready to be added to a TestCase.

So, essentially you code a JUnit TestCase, and in the suite method, you add the Tests created by JUnitTestAdapter to the JUnit TestSuite. public static Test suite() { TestSuite suite = new TestSuite(); String fileName = "tests/samples/TestCommonsWebsite.xml"; suite.addTest(JUnitTestAdapter.createTestFromFile(fileName)); return suite; }

Once you have Latka's suite as a JUnit TestSuite, you can run it using any JUnit TestRunner to execute the suite, including those shipped with ant.

For a reference of the XML tags that can possibly be used in developing latka test suites, see The XML Reference

A Latka test suite is an XML document with a top level element of suite

Definitive list of properties and their meanings...