1. import the student.jar

the LIFT library is included in the student.jar.

import student.*;

2. create your GUI Test Case

create your GUI test class as an extension of the GUITestCase class (part of student.jar)

...
public class GUITest extends GUITestCase {

  // code goes here...
}

3. create your GUI as a fixture

in your setUp(), create your GUI objects and show them in the testing frame.

showInFrame() is defined in the student.jar

...
public class GUITest extends GUITestCase {

  private PushCounterPanel aPanel;     // fixture to be used for testing

  public void setUp() {
    aPanel = new PushCounterPanel();
    showInFrame(aPanel);    // to test it...
  }
}

4. find the object and interact with it

in your test cases, find an object from your interface using getComponent() and the component filters defined in LIFT.

interact with your interface by clicking or typing or using the mouse, under test control

then check that your application is in the correct state.

public void testPushCounterPanel()
{
    // You can retrieve components by name
    JButton pushMe = getComponent(JButton.class, "button");
    JLabel count = getComponent(JLabel.class, where.nameIs("count"));

    // Interact with your interface, click the button
    click(pushMe);
    click(pushMe);

    // Then, check the state of components
    assertEquals("Pushes: 2", count.getText());
}

References and Notes

  1. JUnit.org has more information on how to use the package.
  2. Documentation for the asserts in JUnit http://www.junit.org/apidocs/org/junit/Assert.html