the LIFT library is included in the student.jar.
import student.*;
create your GUI test class as an extension of the GUITestCase class (part of student.jar)
... public class GUITest extends GUITestCase { // code goes here... }
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... } }
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()); }