There are many books published which describe on how to write unit test eg: using JUnit for Java program. Those books are come from simple-complex scenario depending on the book target reader. However, there are only a few which specialized on User Interface testing. So if you ever wondered on how to test Java GUI, then Swing Extreme Testing by Tim Lavers and Lindsay Peters from Packt Publishing might interest you.
Because there is already review of this book by Alex Ruiz who focused on pro and cons, so in this review I will focus on the book’s content itself.
Swing Extreme Testing book is come with 311 pages. The chapters structure is nice and follow the logical step and easy to follow. This books use real life application as the example rather than using imaginative sample. The content is very interesting it start with the methodology (Extreme Testing) as the author called. What needs to be tested, who is to write the tests, when they are to be written, so on. Then go to management of test class and test data. And the testing of User Interface itself. This books also describe the technique to test JavaHelp, ResourceBundle Testing, Server and User Interface Testing, and Multiple JVM testings.
In this books, the author present Cyborg, a higher-level wrapper for java.awt.Robot class. This is the tool for user interface testing. The books also discuss some very important techniques for testing Swing applications. These techniques are: how to set up user interfaces in a thread-safe manner, how to find the objects representing particular components on the screen and how to interrogate a component for its state.
The book is closed with flaky test, tests that occasionally fail or do not terminate. As the authors says
“The problem with having flaky tests is that they remove the element of reproducibility from our testing process. If our tests pass, we don’t know whether all the bugs we’re testing against have actually been fixed, or whether they just happened not to manifest themselves in that testing run. If our tests fail, this could be due to either production errors or testing errors, or both. If we can’t be sure of our test results, we can’t be sure of our software.”
Finally, all the tests presented are automated test. This books also contains many tips and trick using real life application (what worked for them and what didn’t). Those tips and tricks itself worth the book.
Some note: I really surprised when book also describe the ResourceBundle and JavaHelp tests.