Test Driving Swing Cheat Sheet

ADVERTISEMENT

Composed by Patrick Kua () for Javazone 2006
Cheat Sheet on Test Driving Swing
Basic Principles:
Acceptance Test Patterns
• Avoid the UI Layer where possible
• Fixtures
• Break down UI components into smallest units possible
o Describe each significant screen (LoginDialog) with
things you can do on each screen.
o Use terms that the business uses to describe the
Model View Presenter
things on the screen
o Implemented using libraries internally to find
Extremely thin layer
existing swing components
Each method should be one line of delegation
• Threading
Expose callbacks to register event listeners
Views
o Wrap SwingUtilities in an interface (EventQueue)
and another implementation can be used in unit
Maintain state about view
tests to provide consistently predictable results
Understand which views get updated
• Be Careful Of
Only interact with a view of an interface
o Swing having side effects – frames are not
Do most of the work
disposed until we stop the JVM – so state may be
Presenters
inconsistent until the application finishes
Is used to tie the View and Presenters together
Threading typically handled here
Test Driven Development
Glue
• Acceptance Tests (1) may spawn multiple unit integration tests
and will spawn multiple unit tests
Assemble views into the final layout.
• Use the Acceptance Test to drive out other tests
Externalised from each view
• Split types of tests physically as well as run them separately
Layout
(faster running ones first)
Managers
• Requires high discipline
• Driven by a User Story or a Use Case
Used by the presenters and might be injected into
• Refactor to make code
the presenter
Tips
more readable and draw
Core part of the domain
– Small views are better
Model
out other design patterns
– Name every important UI
Rich models for business logic
• Takes practice
component
– Need several types of groups of
tests (acceptance or end-to-end, unit
integration, and pure unit tests)
– Layout generally not worth
automated regression testing

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go