Menu

How do I get a 93.55% test coverage with 129 test cases

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

  • make the test wait (de.mgmechanics.myflipflops.swing.test.Rest)
  • get a reference on Swing objects in the running application including objects in dialog windows (de.mgmechanics.myflipflops.swing.test.ComponentFinder)
  • run the application in own thread so that the test does not stop if the application stops including a function which allows to handle dialog windows *) (de.mgmechanics.myflipflops.swing.test.Automat)

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.

Posted by Michael Groß 2013-01-08

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.