我正在努力学习Java节。我从: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上显示了错误。有人能解释一下这是什么原因吗?提前谢谢。
编辑:我将以下jars与我的项目关联起来:
错误是:
MyFrame can not be resolved to a type.发布于 2015-07-23 17:39:44
首先,您应该使用AssertJ Swing;FEST已经过时,不再维护了。但是,由于AssertJ Swing具有类似的语法,所以转换将很容易。
MyFrame不是FEST/AssertJ-Swing的一部分。这是你写申请的框架。因此,可以使用JFrame或任何框架的实现。
查看一下AssertJ实例 (很抱歉发布了关于AssertJ的文章,但是如果您想继续使用FEST,应该可以根据您的目的对代码进行修改)。它包含编译版本中的示例--这样您就可以查看它,并在周围播放一下,看看AssertJ Swing/FEST是否是适合您的工具。
https://stackoverflow.com/questions/16999212
复制相似问题