Applet
anを aにロードする方法については、こちらFramFixture
で説明しています。これを実行するには、Next-Button のタイプを から に変更する必要があります。これは、FEST が AWT コンポーネントではなく SWING コンポーネントでのみ機能するためです。さらに、FEST がテストケース内のボタンを識別できるように、ボタンの名前を設定する必要があります。これを行うには、次の行を追加します。Button
JButton
JButton nextButton = new JButton("next");//sets the visible Label
nextButton.setName("nextButton");//sets a name invisible for the User.
これで、テストケースで Button を見つけることができます。私はこの TestCase を使用しましたが、うまくいきました:
public class FestTestApplet extends TestCase{
private AppletViewer viewer;
private FrameFixture applet;
@Override
public void setUp() {
final Applet app = new GraphicsTest();
viewer = AppletLauncher.applet(app).start();
applet = new FrameFixture(viewer);
applet.show();
}
public void testNextButtonClick() {
applet.button("nextButton").click();//finds the button by the name
applet.robot.waitForIdle();//give the GUI time to update
//start your asserts
}
@Override
public void tearDown() {
viewer.unloadApplet();
applet.cleanUp();
}
}