What is Latka

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 Apache Commons homepage is present and that all the Commons Components have online documenation.

Running Latka

A Latka test suite can be run:

  • From a command prompt

  • From the Latka web application

  • From a JUnit TestRunner

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

Running Latka from the command prompt

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://commons.apache.org/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

Running Latka from a web application (Under Construction)

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 eith er

  1. Run a latka

Running Latka as a JUnit Test Case

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 Test s 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 .

Anatomy of a test suite (Under Construction)

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

Latka Properties (Under Construction)

Definitive list of p roperties and their meanings...