See: Description
Interface | Description |
---|---|
ComponentContainerFixture |
Looks up AWT or Swing
Component s in a Container . |
EditableComponentFixture<S> |
Verifies the state of editable
Component s. |
FrameLikeFixture<S> |
Supports functional testing of frame-like components (not necessarily subclasses of
java.awt.Frame ). |
ItemFixture<S> |
Supports functional testing of single items inside
JComponents (e.g. |
ItemGroupFixture<S> |
Supports functional testing of
Component s that contains or display a group of items. |
JComponentFixture<S> |
Supports functional testing of
JComponent s. |
JPopupMenuInvokerFixture |
Simulates user input on
JComponent s capable of invoking JPopupMenu s. |
JTreeNodeFixture<S> |
Supports functional testing of single nodes in
JTree s |
MouseInputSimulationFixture<S> |
Simulates mouse input on an AWT or Swing
Component . |
TextDisplayFixture<S> |
Supports functional testing of
Component s that display text. |
TextInputFixture<S> |
Simulates user events on
Component s that accept text input from the user. |
WindowLikeContainerFixture<S> |
Supports functional testing of window-like containers (not necessarily subclasses of
Window ). |
Class | Description |
---|---|
AbstractButtonFixture<S,T extends AbstractButton> |
Supports functional testing of
AbstractButton s. |
AbstractComponentFixture<S,C extends Component,D extends ComponentDriver> |
Supports functional testing of AWT and Swing
Component s. |
AbstractContainerFixture<S,C extends Container,D extends ComponentDriver> |
Looks up AWT or Swing
Component s contained in a Container . |
AbstractJComponentFixture<S,T extends JComponent,D extends JComponentDriver> |
Supports functional testing of
JComponent s. |
AbstractJPopupMenuInvokerFixture<S,T extends JComponent,D extends JComponentDriver> |
Supports functional testing of
JComponent s capable of invoking JPopupMenu s. |
AbstractSwingContainerFixture<S,C extends JComponent,D extends JComponentDriver> |
Supports functional testing of Swing
Container s. |
AbstractTwoStateButtonFixture<S,T extends AbstractButton> |
Supports functional testing of
AbstractButton s that have 2 states ("checked" and "unchecked.") |
AbstractWindowFixture<S,C extends Window,D extends WindowDriver> |
Supports functional testing of
Window . |
ColorFixture |
Verifies the state of
Color s. |
ComponentFixtureExtension<C extends Component,F extends AbstractComponentFixture<?,C,?>> |
An "extension method" for implementations of
AbstractContainerFixture . |
Containers |
Utility methods related to
Container s. |
DialogFixture |
Supports functional testing of
Dialog s. |
FontFixture |
Verifies the state of
Font s. |
FrameFixture |
Supports functional testing of
Frame s. |
JButtonFixture |
Supports functional testing of
JButton s. |
JCheckBoxFixture |
Supports functional testing of
JCheckBox es. |
JComboBoxFixture |
Supports functional testing of
JComboBox es. |
JFileChooserFixture |
Supports functional testing of
JFileChooser s. |
JInternalFrameFixture |
Supports functional testing of
JInternalFrame s |
JLabelFixture |
Supports functional testing of
JLabel s. |
JListFixture |
Supports functional testing of
JList s. |
JListItemFixture |
Supports functional testing of single items in
JList s. |
JMenuItemFixture |
Supports functional testing of
JMenuItem s. |
JOptionPaneFixture |
Supports functional testing of
JOptionPane s. |
JPanelFixture |
Supports functional testing of
JPanel s. |
JPopupMenuFixture |
Supports functional testing of
JPopupMenu s |
JProgressBarFixture |
Supports functional testing of
JProgressBar s. |
JRadioButtonFixture |
Supports functional testing of
JRadioButton s. |
JScrollBarFixture |
Supports functional testing of
JScrollBar s. |
JScrollPaneFixture |
Supports functional testing of
JScrollPane s. |
JSliderFixture |
Supports functional testing of
JSlider s. |
JSpinnerFixture |
Supports functional testing of
JSpinner s: |
JSplitPaneFixture |
Supports functional testing of
JSplitPane s. |
JTabbedPaneFixture |
Supports functional testing of
JTabbedPane s. |
JTableCellFixture |
Supports functional testing of single cells in
JTable s. |
JTableFixture |
Supports functional testing of
JTable s. |
JTableHeaderFixture |
Supports functional testing of
JTableHeader s. |
JTextComponentFixture |
Supports functional testing of
JTextComponent s. |
JToggleButtonFixture |
Supports functional testing of
JToggleButton s. |
JToolBarFixture |
Supports functional testing of
JToolBar s. |
JTreeFixture |
Supports functional testing of
JTree s. |
JTreePathFixture |
Supports functional testing of single nodes, referenced by their paths, in
JTree s. |
JTreeRowFixture |
Supports functional testing of single nodes, referenced by their row indices, in
JTree s. |
Enum | Description |
---|---|
JToolBarFixture.UnfloatConstraint |
Constraints used to unfloat a floating
JToolBar s. |
Public API, source of AssertJ-Swing's power and flexibility. Although you can use the
BasicRobot
directly, it is too low-level and requires, in our opinion, too much code.
AssertJ-Swing fixtures can simplify creation and maintenance of functional GUI tests by:
The following example shows how easy is to use AssertJ-Swing 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;
@Before
public void setUp() {
window = new FrameFixture(new LoginWindow());
window.show();
}
@After
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 AssertJ-Swing. We could also use
individual fixtures to simulate user events, but it would result in more code to write and maintain:
privateBasicRobot
robot; @Before public void setUp() { robot = BasicRobot.robotWithNewAwtHierarchy(); robot.showWindow(new LoginWindow()); } @After public void tearDown() { robot.cleanUp(); } @Test public void shouldCopyTextInLabelWhenClickingButton() { newJTextComponentFixture
(robot, "username").enterText("some.user"); newJButtonFixture
(robot, "login").click(); newJOptionPaneFixture
(robot).requireErrorMessage().requireMessage("Please enter your password"); }
Note: It is very important to clean up resources used by AssertJ-Swing (keyboard, mouse and opened
windows) after each test; otherwise, the AssertJ-Swing 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 JButton
s.
Copyright © 2014–2020 AssertJ. All rights reserved.