|
|
|
Artima SuiteRunner |
Why |
Getting Started |
Tutorial |
Get Help |
Discuss |
Print |
Email |
First Page |
Previous |
Next
|
Suite Execution by Overriding execute
|
Advertisement
|
Account
The Artima SuiteRunner distribution ZIP file includes several simple examples, most of which revolve
around a very simple Account API in package com.artima.examples.account.ex6.
The Account API includes two types, Account and InsufficientFundsException.
Starting with release 1.0beta6, the distribution ZIP
file also includes an example in package com.artima.examples.scriptdriven.ex1.
This package contains two classes:
ScriptDrivenAccountSuite -- a Suite subclass that tests the Account API's
Account class 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 Account.
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 Suite
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
write tests.
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.
The 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.
|
Sponsored Links
|