Extend ComponentFixture
Get a tester for the component we're testing.
Show the component in a frame.
"Type" text in the component with actionKeyString
package com.elharo.swing.test;
import com.elharo.swing.WholeNumberField;
import abbot.tester.ComponentTester;
import junit.extensions.abbot.ComponentTestFixture;
public class WholeNumberFieldTestCase extends ComponentTestFixture {
private ComponentTester tester;
private WholeNumberField field;
protected void setUp() {
tester = ComponentTester.getTester(WholeNumberField.class);
field = new WholeNumberField();
showFrame(field);
}
public void testOne() {
tester.actionKeyString(field, "1");
int result = field.getNumberValue();
assertEquals(1, result);
}
}