首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么这段来自Fest的代码显示错误?

为什么这段来自Fest的代码显示错误?
EN

Stack Overflow用户
提问于 2013-06-08 11:47:52
回答 1查看 577关注 0票数 0

我正在努力学习Java节。我从:http://docs.codehaus.org/display/FEST/Getting+Started获取了一段代码

代码语言:javascript
复制
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中,这段代码显示了一些错误。我必须进口

代码语言:javascript
复制
import org.fest.swing.edt.FailOnThreadViolationRepaintManager;

尽管如此,它在这部分显示了错误:

代码语言:javascript
复制
  @BeforeMethod public void setUp() {
    MyFrame frame = GuiActionRunner.execute(new GuiQuery<MyFrame>() {
        protected MyFrame executeInEDT() {
          return new MyFrame(); 
        }
    });

它在Myframe上显示了错误。有人能解释一下这是什么原因吗?提前谢谢。

编辑:我将以下jars与我的项目关联起来:

  1. fest-swing-testng-1.2
  2. fest-swing-1.2

错误是:

代码语言:javascript
复制
MyFrame can not be resolved to a type.
EN

回答 1

Stack Overflow用户

发布于 2015-07-23 17:39:44

首先,您应该使用AssertJ Swing;FEST已经过时,不再维护了。但是,由于AssertJ Swing具有类似的语法,所以转换将很容易。

MyFrame不是FEST/AssertJ-Swing的一部分。这是你写申请的框架。因此,可以使用JFrame或任何框架的实现。

查看一下AssertJ实例 (很抱歉发布了关于AssertJ的文章,但是如果您想继续使用FEST,应该可以根据您的目的对代码进行修改)。它包含编译版本中的示例--这样您就可以查看它,并在周围播放一下,看看AssertJ Swing/FEST是否是适合您的工具。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16999212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档