Sponsored Link •
SuiteExecution by Overriding
The Artima SuiteRunner distribution ZIP file includes several simple examples, most of which revolve
around a very simple Account API in package
The Account API includes two types,
Starting with release 1.0beta6, the distribution ZIP
file also includes an example in package
This package contains two classes:
Suitesubclass that tests the Account API's
Accountclass by interpreting test commands in a test script and executing the requested tests.
ScriptGenerator-- a Java application that generates a test script containing a command-line specified number of test commands for testing class
The purpose of the scripting language shown in this article's example is to demonstrate how to
customize test execution by overriding
execute in a
subclass. Although in real-world projects, it will rarely be useful to create a
scripting language devoted to testing a single class,
you may in some cases want to devise a more generic test scripting language for your system.
A custom scripting language may, for example, be useful if you
want non-Java programmers to write tests, or to provide a quicker way for Java programmers to
In addition, you may find it beneficial to automatically generate script- or data-based tests
to replace or supplement tests written by hand in Java.
You could, for example, create a
Suite subclass that reads in automatically
generated data in a table or XML format, and executes tests based on that data.
ScriptGenerator application included in this example generates
a test script for class
Account by making random deposits and withdrawals and
checking for the expected result.
By automating the generation of test data or script commands, you can broaden the coverage
of your tests compared to hand-written tests.