【发布时间】:2013-06-08 11:47:52
【问题描述】:
我正在努力学习 Java Fest。我从:http://docs.codehaus.org/display/FEST/Getting+Started
import org.testng.annotations.*;
import org.fest.swing.fixture.FrameFixture;
public class FirstGUITest {
private FrameFixture window;
@BeforeClass public void setUpOnce() {
FailOnThreadViolationRepaintManager.install();
}
@BeforeMethod public void setUp() {
MyFrame frame = GuiActionRunner.execute(new GuiQuery<MyFrame>() {
protected MyFrame executeInEDT() {
return new MyFrame();
}
});
window = new FrameFixture(frame);
window.show(); // shows the frame to test
}
@AfterMethod public void tearDown() {
window.cleanUp();
}
@Test public void shouldCopyTextInLabelWhenClickingButton() {
window.textBox("textToCopy").enterText("Some random text");
window.button("copyButton").click();
window.label("copiedText").requireText("Some random text");
}
}
在 Eclipse 中,此代码显示一些错误。我必须导入
import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
尽管这部分显示错误:
@BeforeMethod public void setUp() {
MyFrame frame = GuiActionRunner.execute(new GuiQuery<MyFrame>() {
protected MyFrame executeInEDT() {
return new MyFrame();
}
});
它在 Myframe 上显示错误。谁能解释一下这是什么原因?提前致谢。
编辑:我将以下 jar 与我的项目相关联:
- fest-swing-testng-1.2
- fest-swing-1.2
错误是:
MyFrame can not be resolved to a type.
【问题讨论】:
-
您应该发布实际的错误消息。
-
错误是“MyFrame 无法解析为类型。”
-
这表明您可能缺少导入或类。 MyFrame 是 fest 库的核心类型吗?如果是这样,你导入它吗?如果不是,它是您创建的类吗?
-
fest 是否带有 API?我会检查一下,因为它应该告诉您 MyFrame 类的完全限定名称,可能还有它的 jar 文件。
-
Swing GUI 对象应仅在event dispatch thread上构造和操作。
标签: java swing testing applet fest