Swing Extreme Testing

Swing Extreme Testing
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 35%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Learn Swing user interface testing strategy
  • Automate testing of components usually thought too hard to test automatically
  • Practical guide with ready-to-use examples and source code
  • Based on the authors’ experience developing and testing commercial software

Book Details

Language : English
Paperback : 328 pages [ 235mm x 191mm ]
Release Date : June 2008
ISBN : 1847194826
ISBN 13 : 9781847194824
Author(s) : Lindsay Peters, Tim Lavers
Topics and Technologies : All Books, App Testing, Application Development, Java

Table of Contents

Chapter 1: What Needs Testing?
Chapter 2: Basics of Unit Testing
Chapter 3: Infrastructure for Testing
Chapter 4: Cyborg—a Better Robot
Chapter 5: Managing and Testing User Messages
Chapter 6: Making Classes Testable with Interfaces
Chapter 7: Exercising UI Components in Tests
Chapter 8: Showing, Finding, and Reading Swing Components
Chapter 9: Case Study: Testing a 'Save as' Dialog
Chapter 10: More Techniques for Testing Swing Components
Chapter 11: Help!
Chapter 12: Threads
Chapter 13: Logging
Chapter 14: Communication with External Systems
Chapter 15: Embedding User Interface Components in Server-side Classes
Chapter 16: Tests Involving Databases
Chapter 17: Function Tests
Chapter 18: Load Testing
Chapter 19: GrandTestAuto
Chapter 20: Flaky Tests
  • Chapter 1: What Needs Testing?
    • An Example
    • What Classes Do We Test?
    • Test First—Always!
    • What Classes Don't We Test?
    • What Methods Need Testing?
    • What Methods Don't We Test?
    • Invoking Hidden Methods and Constructors
    • Unit Test Coverage
    • Who Should Implement the Unit Tests?
    • What About Legacy Code?
    • Where Does Integration Testing Fit In?
    • Documentation of Unit Tests
    • Testing at the Application Level
    • Who Should Implement the Function Tests?
    • Automated Test Execution
    • A Hierarchy of Tests
    • What Language Should Our Tests Be In?
    • Is it Really Possible?
    • Summary
  • Chapter 2: Basics of Unit Testing
    • A Simple Example
    • The Default Implementation
    • Test Cases
    • Design by Contract and Non-Defensive Programming
    • Test Code Example
    • Bootstrapping Our Implementation
    • Load Testing
    • Summary
  • Chapter 3: Infrastructure for Testing
    • Where Should the Unit Tests Go?
    • Where Should the Function and Load Tests Go?
    • Management of Test Data
      • What Do We Require of a Test Data Management System?
    • Temporary Files
    • Summary
  • Chapter 7: Exercising UI Components in Tests
    • The LabWizard Login Screen
    • The Design of LoginScreen
    • UI Wrappers
      • The Correct Implementation of UILoginScreen
    • A Handler Implementation for Unit Testing
    • Setting Up our Tests
    • Our First Test
    • Further Tests
    • Some Implicit Tests
    • Other User Interfaces
    • Summary
  • Chapter 8: Showing, Finding, and Reading Swing Components
    • Setting Up User Interface Components in a Thread-Safe Manner
    • Finding a Component
    • Testing Whether a Message is Showing
    • Searching for Components by Name
    • Reading the State of a Component
    • Case Study: Testing Whether an Action Can Be Cancelled
    • The Official Word on Swing Threading
    • Summary
  • Chapter 9: Case Study: Testing a 'Save as' Dialog
    • The Ikon Do It 'Save as' Dialog
    • Outline of the Unit Test
    • UI Helper Methods
      • Dialogs
      • Getting the Text of a Text Field
      • Frame Disposal
    • Unit Test Infrastructure
      • The UISaveAsDialog Class
      • The ShowerThread Class
      • The init() Method
      • The cleanup() Method
    • The Unit Tests
      • The Constructor Test
      • The wasCancelled() Test
      • The name() Test
      • The show() Test
      • The Data Validation Test
      • The Usability Test
      • Summary
  • Chapter 10: More Techniques for Testing Swing Components
    • Testing with JColorChooser
    • Using JFileChooser
    • Checking that a JFileChooser has been Set Up Correctly
    • Testing the Appearance of a JComponent
    • Testing with Frames
      • Frame Location
      • Frame Size
    • Testing with Lists
      • List Selection Methods
      • List Rendering
      • List Properties
    • Testing a JTable
    • Testing with JMenus
      • Checking the Items
      • Using Menus with Cyborg
    • Testing JPopupMenus
    • Combo Boxes
    • Progress Bars
    • JSlider and JSpinner
    • JTree
    • Summary
  • Chapter 11: Help!
    • Overview
    • What Tests Do We Need?
      • An HTML File That is Not Indexed
      • An index item for which there is no HTML file
      • Broken links
      • Incorrectly titled help pages
    • Creating and Testing Context-Sensitive Help
    • Executing HelpGenerator
    • Summary
  • Chapter 12: Threads
    • The Waiting Class
    • Concurrent Modifiers
    • Concurrent Readers and Writers
    • Proof of Thread Completion
    • The Unit Test for waitForNamedThreadToFinish()
    • Counting Threads
    • Summary
    • Further Reading
  • Chapter 13: Logging
    • Logging to a File
    • Remember to Roll!
    • Testing What is Printed to the Console
      • Switching Streams
      • Reading the Output From a Second JVM
    • Summary
  • Chapter 17: Function Tests
    • Specification of the Tests
    • Implementation of the 'DeleteCase' Test
    • Tests Involving Multiple JVMs
    • Multiple JVMs with GUI Components
    • Use of a Function Test as a Tutorial
    • Testing a Web Service
    • Summary
  • Chapter 18: Load Testing
    • What to Test
      • Overnight 'Housekeeping' Takes Too Long
      • Deleting Cases Takes Too Long
      • The BMD Server is Too Slow to Start
    • Measuring Time
    • Measuring RAM Usage
    • The Load Tests for LabWizard
    • Profilers and Other Tools
    • Summary
  • Chapter 19: GrandTestAuto
    • What is GrandTestAuto?
    • Unit Test Coverage
    • Advantages of Using GTA
    • Getting Started
    • Testing Overloaded Methods
    • Testing Protected Methods
    • Extra Tests
    • Classes That Do Not Need Tests
    • Day-To-Day Use of GrandTestAuto
      • Running Just One Level of Test
      • Running the Unit Tests for a Single Package
      • Running the Unit Tests for a Single Class
      • Running the Tests for a Selection of Packages
      • Package Name Abbreviation
      • Running Tests for a Selection of Classes Within a Single Package
      • Running Individual Test Methods
      • Running GTA From Ant or CruiseControl
      • GTA Parameters
    • Distributed Testing Using GTA
      • How it Works—In Brief
      • A Distributed Testing Example
    • Summary
  • Chapter 20: Flaky Tests
    • A Flaky 'Ikon Do It' Unit Test
    • Writing Reliable Tests
    • Dealing with Flaky Tests
    • Diagnostic Tools
    • Tests That Do Not Terminate
      • Non-Daemon Threads
      • Remote Objects
      • Server Socket Still Waiting
      • Frame Not Properly Disposed
    • Summary

Lindsay Peters

Lindsay Peters is the Chief Technical Officer for Pacific Knowledge Systems. He an experience of 25 years in software management, formal analysis, algorithm development, software design, and implementation for large commercial and defense systems. Ten years ago, Lindsay and his team were the early adopters of Java, coupled with more rigorous design processes such as Design by Contract. He then helped transition the development team to the Extreme Programming model. Out of this exciting and successful experience grew the "Extreme Testing" approach. In the early 80's, Lindsay managed a software team that was one of the first to incorporate the newly discovered simulated annealing algorithm into a commercial application. This team solved a previously intractable real-world problem, which was the optimum assignment of radio frequencies to collocated mobile radios. Apart from software development and artificial intelligence systems, Lindsay has an interest in mathematical convexity, and has helped to progress the "Happy Ending" problem. He is also involved in politics, and in the last Australian Federal election he stood as the Greens candidate for the seat of Bennelong.

Contact Lindsay Peters

Tim Lavers

Tim Lavers is a Senior Software Engineer at Pacific Knowledge Systems, which produces LabWizard—the gold standard for rules-based knowledge acquisition software. In developing and maintaining LabWizard for almost 10 years, Tim has worked with many Java technologies, including network programming, Swing, reflection, logging, JavaHelp, web services, RMI, WebStart, preferences, internationalization, concurrent programming, XML, and databases. He has worked with tools as well, such as Ant and CruiseControl. His job also includes a healthy mix of user training, technical support, and support to marketing. In his previous job, he wrote servlets and built an image processing library. Along with his professional programming, he writes and maintains the distributed testing tool, GrandTestAuto. He has published a JavaWorld article on RMI as well as a number of mathematical papers. Tim's hobbies include running and playing the piano.

Contact Tim Lavers

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Swing Extreme Testing +    Microsoft Windows Azure Development Cookbook =
50% Off
the second eBook
Price for both: $37.50

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • What needs testing in a Java software project—the extreme testing approach
  • Managing test classes and test data
  • Useful tools for robotically testing Java applications
  • Managing and testing user interface components, and using UI wrappers in function testing
  • Setting up Swing GUI components in a thread-safe manner
  • Creating and testing a JavaHelp system for an application
  • Testing highly multi-threaded system and communication with external systems
  • Testing the logs produced by a software application
  • Embedding GUI components in server-side classes
  • Managing databases in a way that facilitates testing
  • Specifying and writing tests at the system level, tests using multiple JVMs
  • Basics of load testing
  • Exploring GrandTestAuto, a tool for test automation, coverage checking, and distributed testing
  • Dealing with intermittent test failures

In Detail

Thorough testing is the basis of good software. Whether we use an agile development methodology such as Extreme Programming, or a more traditional approach, we must test our software at the unit level and application level. The tests must run automatically and cover all aspects of the software.
In this book, the authors draw on more than 20 years of experience to show how automated testing can be applied to a real commercial product.

This book will teach you how to automatically test user interfaces (Swing GUIs), the help system, internationalization, log files, spreadsheets, email, and web services, how to perform tests involving multiple JVMs, and a host of other things. These tests are applied at the module level (unit tests) and at the application level (function tests).

The authors have developed the test processes in the broader context of an Extreme Programming (XP) methodology. However, the testing techniques are certainly not specific to XP, and may be applied within any given development methodology.

This book is a practical guide to automated software testing for extreme Java programming using Swing GUIs, with lots of ready-to-use real-life examples and source code for automated testing of the software components usually regarded as too hard to test automatically.


This book is a practical guide based on the authors’ daily experience developing and maintaining a cutting-edge Artificial Intelligence system. Every chapter comes up with real-life examples and the source code that comes with the book is full of useful (and well-tested) tools. The practical examples make this book suitable learning material for Swing developers.

Who this book is for

This book is for Swing developers who design and develop complex software for user interfaces that requires extensive testing. If you want to learn to test your Swing GUI components, this book is for you.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software