Precondition:
- I can not afford a capture-replay-tool like HP QuickTest(R) Professional(R).
- Even if I could - Open Source should never depend on Closed Source software.
- Trying two Open Source Frameworks (UISpec4J and FEST) end up in frustation: I couldn't get even the beginners examples running spending over an hour each.
Solution:
Inspired by an article in the MSDN Magazine (see also Wikipedia Lightweight software test automation I wrote my own solution. It works more like one of the well-known capture-and-replay-tool often used in big software projects but without "capture" function. Here it is done with three tiny classes which
While java.awt.robot is used for pressing the "intractable" buttons on File Dialog windows (i.e. "Save") and to emulate user key types only.
The price for testing everything with three tiny classes is that you need to start the application under test by creating an object from the main class. You can not use the main method. I solved this by cleaning up the main method and copying the few remaining lines of code into a test class (de.mgmechanics.jdecisiontable.App among the test files).
*) A dialog window "holds on" the application. This is intended. But if you run the doClick method of a menu item which runs a test which raises dialog you should observe that the doClick method does not end until the dialog window is closed. Automat has a function to run doClick() in the thread of the application under test so that your test case continues while the dialog is shown.