This version 0.9.0 (030527)
The framework may also be used to create a demo or tutorial for an application. It can play back a prerecorded sequence of events, with optional annotations.
If you haven't done so yet, download the abbot package [tgz] [zip] (which includes source). Simply unpack and refer to the Quick Start information below. The overview of the Abbot system will give you an idea of the different system components and how it is used. There is also some background concerning the issues involved with Java GUI testing. JUnit is used as the controlling harness for running tests and suites of tests, but scripts can easily be wrapped to run in other environments. To use Abbot directly in Java code (unit tests), see the tutorial links below, the framework tests in the test subdirectory, and the API documentation for the ComponentTester and Robot classes. For latest changes, see the release notes. Abbot is provided under this license.
Please direct all questions and help requests to the
help forum. |
|
There are two ways of using this framework. One is to write the tests directly in Java code (see Tutorial 1 or Tutorial 2 for an example). The other is to use a script to control the event playback and testing. A script editor is provided to facilitate this form of test.
java -jar lib/abbot.jar
NOTE: Under some 1.3 VMs using X11, the splash screen may
trigger a VM bug. If this is the case, invoke as "java -cp
lib/abbot.jar abbot.editor.ScriptEditor"
instead.
main(String[] args)
method in class example.MyCode
with no arguments, you would edit
the launch step to look like this:In the interest of keeping scripts self-contained, it is recommended that you specify the classpath in the script rather than depending on the VM classpath argument or the environment classpath. See the Launch step for usage details. Now you can use Test->Launch to display the GUI under test. The example code will display a frame with a variety of sample components.![]()
shift+F2
), and perform
some user actions in the GUI. If you haven't already launched the GUI, the
editor will launch it for you. The editor will detect as many high-level
semantic events as it can and insert raw mouse motion and button events for
what it doesn't recognize. When you get the GUI to a point that you want to
make some tests of its state, press shift+F2
or activate the
editor window to suspend recording. The recording so far will be inserted
into the script as a sequence of steps.
shift+F1
. That component will be selected in the
component browser tree in the bottom half of the script editor. The hierarchy
view presents the full hierarchy of components that have been created. Once
you've selected a component, its associated properties will appear in the pane
to the right. Select a property ("Text" on a JButton, for instance), then
click the Assert equals button to insert an assertion
into the test. Repeat as necessary for other components, or press
shift+F2
to continue recording actions.
java -cp lib/abbot.jar junit.extensions.abbot.ScriptFixture doc/editor-tutorial-1.xml
-Dabbot.robot.auto_delay=100
" to make it look like a real
person is running the tests:
java -cp lib/example.jar:lib/abbot.jar example.FontChooserTest
java -cp lib/example.jar:lib/abbot.jar example.MyCodeTest
java -cp lib/example.jar:lib/abbot.jar junit.extensions.abbot.ScriptFixture src/example/applet.xml
The second example is intended to report a failed assertion, so you can see what a failed test looks like.
Note that the last example passes an Abbot script as an argument to the ScriptFixture class to run the script as a JUnit test. For a more complete description of the framework, see the overview document.
The home page for Abbot code development may be found here. Developers are welcome; after you've submitted a few acceptable patches you may be added to the developer's group with privileges to make changes directly to the code base.
If you are looking for additional support for Abbot or test integration services, please send email and we'll point you in the right direction.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
View the full license.
![]() |
This project generously hosted by |
![]() Click to subscribe to java-gui-testing |