我正在使用FEST来测试我的Java对话框,我需要测试是否创建了一个新的模态对话框。
@Before
public void setUp() throws Exception {
TestFrame testFrame = GuiActionRunner.execute(new GuiQuery<TestFrame>() {
@Override
protected TestFrame executeInEDT() throws Throwable {
panel = new CustomPanel();
return new TestFrame(panel);
}
});
frameFixture = new FrameFixture(testFrame);
frameFixture.show();
frameFixture.robot.waitForIdle();
}
注意:TestFrame是一个扩展JFrame的辅助类,用于单元测试。
在我的测试中,我点击一个按钮,使一个模态对话框出现。 我试图找到并验证对话框是否已创建,但是我所有的尝试都无法找到任何东西:
WindowFinder.findDialog("Window Title")).using(robot);
机器人的定义如下:
- 使用当前AWT层次结构的BasicRobot.robotWithCurrentAwtHierarchy();
- 使用新的AWT层次结构的BasicRobot.robotWithNewAwtHierarchy();
- 使用lookup范围指定frameFixture.robot (frameFixture => JFrame)
我也尝试指定机器人的查找范围:
robot.settings().componentLookupScope(ComponentLookupScope.ALL);
有很多关于FEST的例子可以在网上找到,这些例子都会调用robot()
函数,但是我不知道这个函数具体是什么或者应该是什么。
为什么我无法找到我新创建的弹出对话框?