Package org.fest.swing.fixture

The power and flexibility of FEST-Swing come from the fixtures in this package.

See:
          Description

Interface Summary
ClientPropertyStorageFixture Understands retrieval of client properties from GUI components.
CommonComponentFixture Understands simulation of keyboard focus simulation of keyboard input simulation of mouse input state verification of a GUI component.
ComponentContainerFixture Understands lookup of Components contained in a Container.
EditableComponentFixture Understands state verification of an editable GUI component.
FocusableComponentFixture Understands simulation of input focus on a GUI component.
FrameLikeFixture Understands functional testing of frame-like components (not necessarily subclasses of Frame): user input simulation state verification property value query
ItemFixture Understands functional testing of GUI component items (e.g. a cell in a JTable or a row in a JList): user input simulation property value query Understands simulation of user events on an item belonging to a fixture's Component.
ItemGroupFixture Understands functional testing of GUI components that contains or display a group of items: user input simulation state verification property value query Understands simulation of user events on a Component that contains or displays a group of items, and verification of the state of such Component.
JComponentFixture Understands functional testing of JComponents: user input simulation state verification property value query
JPopupMenuInvokerFixture Understands input simulation on Components capable of invoking JPopupMenus.
JTreeNodeFixture Understands functional testing of single nodes in JTrees: user input simulation state verification property value query
KeyboardInputSimulationFixture Understands simulation of keyboard input on a GUI component.
MouseInputSimulationFixture Understands simulation of mouse input on a GUI component.
StateVerificationFixture Understands state verification of a GUI component.
TextDisplayFixture Understands state verification and property value queries of GUI components that display text.
TextInputFixture Understands simulation of user events on GUI components that accept text input from the user.
ToolTipDisplayFixture Understands state verification of GUI components that display a tool-tip.
TwoStateButtonFixture Understands state verification of "two-state" buttons.
WindowLikeContainerFixture Understands functional testing of window-like containers (not necessarily subclasses of Window): user input simulation state verification property value query
 

Class Summary
ColorFixture Understands state verification of Colors.
ComponentFixture<T extends Component> Understands functional testing of Components: user input simulation state verification property value query
ComponentFixtureExtension<C extends Component,F extends ComponentFixture<C>> Understands an "extension method" for implementations of ContainerFixture.
ComponentFixtureValidator Understands a validator of common objects used in component fixtures.
ContainerFixture<T extends Container> Understands lookup of Components contained in a Container.
Containers Understands utility methods related to Containers.
DialogFixture Understands functional testing of Dialogs: user input simulation state verification property value query
FontFixture Understands state verification of Fonts.
FrameFixture Understands functional testing of Frames: user input simulation state verification property value query
GenericComponentFixture<T extends Component> A generic component fixture providing basic keyboard and mouse input operations.
JButtonFixture Understands functional testing of JButtons: user input simulation state verification property value query
JCheckBoxFixture Understands functional testing of JCheckBoxes: user input simulation state verification property value query
JComboBoxFixture Understands functional testing of JComboBoxes: user input simulation state verification property value query The conversion between the values given in tests and the values being displayed by a JComboBox renderer is performed by a JComboBoxCellReader.
JFileChooserFixture Understands functional testing of JFileChoosers: user input simulation state verification property value query
JInternalFrameFixture Understands functional testing of JInternalFrames: user input simulation state verification property value query
JLabelFixture Understands functional testing of JLabels: user input simulation state verification property value query
JListFixture Understands functional testing of JLists: user input simulation state verification property value query The conversion between the values given in tests and the values being displayed by a JList renderer is performed by a JListCellReader.
JListItemFixture Understands functional testing of single rows in JLists: user input simulation state verification property value query
JMenuItemFixture Understands functional testing of JMenuItems: user input simulation state verification property value query
JOptionPaneFixture Understands functional testing of JOptionPanes: user input simulation state verification property value query
JPanelFixture Understands functional testing of JPanels: user input simulation state verification property value query
JPopupMenuFixture Understands functional testing of JPopupMenus: user input simulation state verification property value query
JProgressBarFixture Understands functional testing of JProgressBars: state verification property value query
JRadioButtonFixture Understands functional testing of JRadioButtons: user input simulation state verification property value query
JScrollBarFixture Understands functional testing of JScrollBars: user input simulation state verification property value query
JScrollPaneFixture Understands functional testing of JScrollPanes: user input simulation state verification property value query
JSliderFixture Understands functional testing of JSliders: user input simulation state verification property value query
JSpinnerFixture Understands functional testing of JSpinners: user input simulation state verification property value query
JSplitPaneFixture Understands functional testing of JSplitPanes: user input simulation state verification property value query
JTabbedPaneFixture Understands functional testing of JTabbedPanes: user input simulation state verification property value query
JTableCellFixture Understands functional testing of single cells in JTables: user input simulation state verification property value query Example: // import static org.fest.swing.data.TableCell.row; JTableCellFixture cell = dialog.
JTableFixture Understands functional testing of JTables: user input simulation state verification property value query The conversion between the values given in tests and the values being displayed by a JTable renderer is performed by a JTableCellReader.
JTableHeaderFixture Understands functional testing of JTableHeaders: user input simulation state verification property value query
JTextComponentFixture Understands functional testing of JTextComponents: user input simulation state verification property value query
JToggleButtonFixture Understands functional testing of JToggleButtons: user input simulation state verification property value query
JToolBarFixture Understands functional testing of JToolBars: user input simulation state verification property value query
JTreeFixture Understands functional testing of JTrees: user input simulation state verification property value query TreePaths can be specified using Strings.
JTreePathFixture Understands functional testing of single nodes, referenced by their paths, in JTrees: user input simulation state verification property value query
JTreeRowFixture Understands functional testing of single nodes, referenced by their row indices, in JTrees: user input simulation state verification property value query
WindowFixture<T extends Window> Understands functional testing of Windows: user input simulation state verification property value query
 

Enum Summary
JToolBarFixture.UnfloatConstraint Understands constraints used to unfloat a floating JToolBar.
 

Package org.fest.swing.fixture Description

The power and flexibility of FEST-Swing come from the fixtures in this package. Although you can use the BasicRobot directly, it is too low-level and requires, in our opinion, too much code. FEST fixtures can simplify creation and maintenance of functional GUI tests by:

  1. providing reliable lookup of GUI components (by component name or using custom criteria)
  2. simulating user events on GUI components
  3. providing assertion methods about the state of GUI components

The following example shows how easy is to use FEST fixtures. The test verifies that an error message is displayed if the user enters her username but forgets to enter her password.


  private FrameFixture window;  

  @BeforeMethod public void setUp() {
    window = new FrameFixture(new LoginWindow());
    window.show();
  }

  @AfterMethod public void tearDown() {
    window.cleanUp();
  }
  
  @Test public void shouldCopyTextInLabelWhenClickingButton() {
    window.textBox("username").enterText("some.user");
    window.button("login").click();
    window.optionPane().requireErrorMessage().requireMessage("Please enter your password");    
  }

The test uses a FrameFixture to launch the GUI to test (LoginWindow) and find the GUI components in such window. This is the recommended way to use FEST. We could also use individual fixtures to simulate user events, but it would result in more code to write and maintain:


  private BasicRobot robot;

  @BeforeMethod public void setUp() {
    robot = BasicRobot.robotWithNewAwtHierarchy();
    robot.showWindow(new LoginWindow());
  }

  @AfterMethod public void tearDown() {
    robot.cleanUp();
  }
  
  @Test public void shouldCopyTextInLabelWhenClickingButton() {
    new JTextComponentFixture(robot, "username").enterText("some.user");
    new JButtonFixture(robot, "login").click();
    new JOptionPaneFixture(robot).requireErrorMessage().requireMessage("Please enter your password");    
  }

Note: It is very important to clean up resources used by FEST (keyboard, mouse and opened windows) after each test; otherwise, the FEST robot will keep control of them and can make your computer pretty much unusable. To clean up resources call the method 'cleanUp' from BasicRobot, FrameFixture or DialogFixture.

Each fixture has the name of the GUI component it can control plus the word "Fixture" at the end. For example, JButtonFixture can simulate user events on JButtons.



Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.