4.2.3. Design for testability in Swing Naming components

Although components in the AUT can be recognized even when they are not named by the developers, using the setName method for the current Swing component class certainly makes it easier to test AUTs. Even if a whole area of the AUT has changed, the component will still be found based on this unique name. Adding support for text retrieval

You can add support for renderers for Swing components without the getText() method in order to access text that is otherwise non-readable during test execution.

  • An example of the adapter mechanism can be found here:


  • This does not replace the support for custom Swing renderers that can be changed directly by your developers.

  • If you are able to change the renderers yourself, you can still implement one of the following in your renderer:

    public String getTestableText(); public String getText();

Copyright BREDEX GmbH 2015. Made available under the Eclipse Public License v1.0.