import javax.swing.JButton; import javax.swing.JLabel; import student.GUITestCase; //------------------------------------------------------------------------- /** * An example test case that shows how to test a custom swing panel * class. Note that this test case is not intended to be complete. * Instead, it provides an example of just one test method, nothing more. * A real test set for the panel would probably exercise all of its * features more completely. * * @author Stephen Edwards * @version 2010.02.21 */ public class PushCounterPanelTest extends GUITestCase { //~ Test methods .......................................................... // ---------------------------------------------------------- /** * A simple example of a test method for exercising PushCounterPanel. */ public void testPushCounterPanel() { // You can test individual panels by themselves PushCounterPanel panel = new PushCounterPanel(); showInFrame(panel); // You can retrieve components by name JButton pushMe = getComponent(JButton.class, "button"); JLabel count = getComponent(JLabel.class, "count"); // You can invoke actions: click(pushMe); click(pushMe); // And check the state of components assertEquals("Pushes: 2", count.getText()); } // place other test methods here ... }