WindowTester Pro SWT records and playback UI tests for SWT applications. The following describes how to generate and play back a UI test for SWT applications.
Prerequisite: This tutorial requires either RCP Developer v2.7.0 and above or WindowTester Pro 2.2.0 and above.
- Create the Sample SWT project in your workspace.
- Setup a recording configuration and record user interactions.
- Stop recording and save recorded test.
- Playback the recorded test.
- Slower playback (optional).
- Select File > Import from the main menu.
- From the list of wizards, select WindowTester Pro > AddressBookSWT Example Project. Please note, this wizard is only available in WindowTester Pro v2.2.0 and above.
- Click Next.
- Click Finish. The AddressBookSWT example project is now created in your workspace.
Look for a tool item ( ) that looks like the run arrow with a little console under it (should be next to external tools).
- From its pull-down menu select "Record Configurations...".
- Select SWT Application on the left navigation.
- Click the New () icon.
- Name: Enter AddressBookUI
- Project: Click Browse... and select the AddressBookSWT project
- Main class: Click Browse and select com.demo.AddressBookUI
- Click the Record button. This will run the AddressBook SWT application in recording mode and opens the recording control shown below.
- To start recording, click on the record button (red ball) in the recorder. Perform user interactions by entering some text in the text fields.
To stop the recording, just close your application. A New UI Test dialog will open.
Fill in the following:
- Source folder: This is the source folder of your test plug-in project. We recommend that tests be placed into a project separate from the code under test.
- Create folder automatically if they do not exist - If the Source folder does not exist and this option is checked, it will automatically create the test project with the src and bin folders. If your project structure does not have a separate src and bin folders, uncheck this option and make sure your test project exists.
- Package: The package in your test project where you want to save the tests.
- Name: A name to call your test class.
- Click Finish to save your test.
SWT UI tests must be run as JUnit Tests.
- Right click on the newly recorded test class.
- Select "Run As > JUnit Test"
- The recorded test is played back. You should now see the AddressBookSWT application with the user interactions that you recorded.
You can slow down the playback by enabling the playback delay preference .Note: If you receive something like the following errors when you playback your test, then see the corresponding FAQ entries for possible solutions:
org.eclipse.swt.SWTException: Device is disposed
Adding Assertions (Optional)
Assertions can be generated at recording time using the assertion inspector tool. The assertion inspector is activated by clicking the inspector tool item on the recording controller. See the Assertion Inspector documentation.