liveBook · Manning

Java Swing

As explained in Test Driven: Practical TDD and Acceptance TDD for Java Developers

The Swing API is the set of Java programming interfaces provided by the Swing GUI toolkit.

Java Swing is a Java GUI toolkit for building user interfaces. Testing Swing means considering not only widget behavior, but also how people use and perceive the interface. section 8.0

Swing UI testing can consider three aspects:

Swing is influenced by Model-View-Controller (MVC), but combines view and controller in one component. To test their logic, instantiate widgets in a simple window and operate them programmatically; this can make tests slower or harder to run on headless build servers. section 8.2

Figure 8.1. The MVC triad and its relationships. The controller acts on the model based on input from the view, the model worries about domain logic unaware of any details of the view or the controller, and the view registers with the model for change notifications and renders the data it obtains from the model.

The diagram shows how MVC divides input handling, domain logic, and presentation. section 8.2

How Test Driven: Practical TDD and Acceptance TDD for Java Developers covers it

How deep it goes
Explains GUI testing categories and Swing’s MVC influence, including view-controller coupling and its testing drawbacks.
Examples
Considers plumbing, rendering, layout, and interaction, including programmatically operating widgets in a simple window.
What you can do after
Apply it via plain JUnit and Abbot to test-drive Swing code.
How it connects
Connects Swing UI design to Model-View-Controller and the Observer pattern.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Test Driven: Practical TDD and Acceptance TDD for Java Developers. The section links point to the parts of the book it draws on.