This plugin runs Latka web testing scripts.
To use the plugin, you simply need to create some Latka test
scripts and place them in the src/test/latka
directory.
To execute the scripts, simply run
maven latka
By default this will simply print the results of running your Latka test suite to the console, and if the suite(s) failed, the build is stopped with an appropriate exception
Latka can be customised in many ways when running within the plugin. The Latka docs should be read thoroughly first as they should contain far more detail on the ways Latka can be tweaked.
Latka has the concept of listeners, classes whose job it is to listen for, and report on the progress of a Latka suite.
Latka looks for a listener at the start of the suite tag as
a Jelly
variable named latkaEventListener
. If one is not found,
Latka notes this internally and creates an XMLReporter
as the default listener.
You can provide your own listener to Latka simply by using jelly's
new
tag before the suite tag, e.g.
<j:new var="latkaEventListener" className="org.apache.commons.latka.XMLReporter" />
Once the suite is complete, you can then access the XML report using all the usual jelly xml tags. For example, to simply print out the resulting report in XML format use the following:
${latkaEventListener.documentAsString}
Once you have the report, you can then do anything else you may like such as
j:file
The plugin has a goal (latka:jmeter-convert) that takes a set of requests as recorded by JMeter's Http Proxy and converts them into a Latka suite.
This has only been tested with JMeter 1.8.x
You can easily set up a browser with the correct proxy settings, and simply by using your web application, you can create tests that this plugin can later replay.
The JMeter documentation contains a section on setting up the HTTP Proxy feature. This allows you to set 'listen' to requests being sent to the application and save the request details in XML format. JMeter can be set up to filter out requests by specifying a regular expression to match the incoming requests. This lets you only record relevant requests for your tests, e.g. HTML or JSP files, Struts actions with a .do extension etc.
The jmeter-convert
goal looks for a property passed to
Maven, jmeterFile
. If this file exists, the plugin
blindly assumes it's a JMeter file and generates a corresponding
Latka suite, containing all the requests in the JMeter file with
the appropriate web server, port, request path and parameters.
The file that is generated,
${maven.build.dir}/latka/jmeter-suite.latka
, can then
be editied and placed in the Latka source directory.
To convert a file, say C:\JMeter\test.jmx
, into a Latka
suite, invoke Maven like this:
maven -DjmeterFile=C:\JMeter\test.jmx latka:jmeter-convert
This will produce a file, target\latka\jmeter-suite.latka
ready for editing or execution.