Conclusions

We've completed development of our user interface. Not every aspect of a GUI can be unit-tested through the approach we've used, but we've identified a number of useful techniques:

  • Even GUI development can maintain the cycle-in-the-small of test-code design.

  • GUI tests can be robust against changes in how the widgets are arranged on-screen.

  • Fields and buttons can be simulated with getText(), setText(), doClick(), and so on.

  • Stub out the services provided by the model to get fine-grained control over what the GUI test shows.

  • We can test relative positioning using getLocationOnScreen().

Unit tests can be tedious to write, but they save you time in the future (by catching bugs after changes). Less obvious, but just as important, is that they ...

Get Extreme Programming Installed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.