Recipe 22Drive a Swing Interface with FEST

Problem

You want to test a Java program with a user interface implemented in Swing.

Ingredients

  • JRuby,[135] a pure-Java implementation of Ruby

  • FEST,[136] a Java library for driving Swing GUIs

  • PresentationClock,[137] the example Java app we’ll be testing

Solution

The Java testing community has created an amazing number of GUI automation libraries. They vary based on the type of user interfaces they can automate—Swing, SWT, JavaFX, and so on.

For this recipe, you’ll be testing PresentationClock, a simple Swing app. The FEST automation library is a good fit for driving this program: it’s actively maintained, well-documented,[138] and relatively easy to use.

You can operate FEST from Java using Cucumber-JVM ...

Get Cucumber Recipes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.