4.2.3. Design for testability in Swing

4.2.3.1. 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.

4.2.3.2. 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:

    http://git.eclipse.org/c/jubula/org.eclipse.jubula.core.git/
    tree/org.eclipse.jubula.examples.extension.swing.rc.renderer

  • 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.