我正在尝试学习 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 与我的项目相关联:
- 巨星-摇摆-testng-1.2
- 巨星摇摆-1.2
错误是:
MyFrame can not be resolved to a type.