标签: fest

如何读取PNG文件中的像素?

我知道如何使用Robot,Windowtester或FEST捕获屏幕截图.我也知道如何使用机器人从屏幕上读取像素.

int x = 10;
int y = 10; 
Color px = getPixelColor(int x, int y);
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何从已捕获的图像中读取像素.我打算将当前图像与文件中的图像进行比较.可以说两者都是PNG.是否有任何框架可用于逐像素地比较图像?

java image-capture pixel awtrobot fest

11
推荐指数
3
解决办法
3万
查看次数

如何在没有在FEST-SWING中显示的情况下进行gui测试

在我的项目中,我们使用FEST进行GUI测试.我们已经说服FEST是强大的,但每次显示帧都是浪费时间.我们也使用连续体,而FEST不能用于连续体,因为连续体的maven无法打开GUI(我们也使用maven的方式,我们的测试在我们的本地机器上传递maven).

我怎么解决这个问题?

如果不可能,请通知我.

java gui-testing fest

10
推荐指数
2
解决办法
4711
查看次数

从java中的任意char获取VK int

你如何从一个字母的字母中获取VK代码?看起来你应该能够做类似的事情javax.swing.KeyStroke.getKeyStroke('c').getKeyCode(),但这不起作用(结果为零).如果您已经拥有KeyEvent,每个人都知道如何获取密钥代码,但如果您只想将字符转换为VK整数,该怎么办?我对获取奇怪字符的FK代码不感兴趣,只有[AZ],[az],[0-9].

这个问题的背景--------我见过的所有机器人教程都假设程序员喜欢通过发送带有VK代码的按键来拼出单词:

int keyInput[] = {
      KeyEvent.VK_D,
      KeyEvent.VK_O,
      KeyEvent.VK_N,
      KeyEvent.VK_E
  };//end keyInput array
Run Code Online (Sandbox Code Playgroud)

叫我懒惰,但即使使用Eclipse,也无法在GUI上使用TDD.如果有人碰巧知道一个类似于机器人的类,它接受字符串,然后模拟这些字符串的用户输入(我正在使用FEST),我很想知道.

java keyboard unit-testing awtrobot fest

8
推荐指数
2
解决办法
8962
查看次数

使用WindowFinder查找模态对话框

我正在使用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();
}
Run Code Online (Sandbox Code Playgroud)

注意:TestFrame是一个辅助类,它扩展了JFrame以用于单元测试.

在我的测试中,我单击一个按钮,显示模式对话框.我试图找到并验证对话框是否已创建,但是我的所有尝试都无法找到任何内容:

WindowFinder.findDialog("Window Title")).using(robot);
Run Code Online (Sandbox Code Playgroud)

机器人=

  1. BasicRobot.robotWithCurrentAwtHierarchy();
  2. BasicRobot.robotWithNewAwtHierarchy();
  3. frameFixture.robot(frameFixture => JFrame)

我也尝试过指定机器人的查找范围:

robot.settings().componentLookupScope(ComponentLookupScope.ALL);
Run Code Online (Sandbox Code Playgroud)

网上有很多FEST例子可以调用,robot()但是我无法知道这个机器人函数应该是什么或者是什么.

为什么我找不到新创建的弹出对话框?

java swing unit-testing fest

6
推荐指数
1
解决办法
730
查看次数

FEST中isSameAs()和isEqualTo()有什么区别?

两个方法isSameAs()和isEqualTo()有什么区别?

文件说:

验证实际值是否等于给定值.

验证实际值是否与给定值相同.

(http://fest.easytesting.org/assert/apidocs/index.html)

/罗杰

fest

5
推荐指数
1
解决办法
4038
查看次数

如何使用FEST声明列表不包含某些内容?

我正在使用FEST在JUnit中编写断言.

断言列表包含一些元素很容易:

assertThat(list).contains(2,4);
Run Code Online (Sandbox Code Playgroud)

但是如何断言列表中没有包含某些内容?喜欢:

assertThat(list).doesnotContain(3); // !!! no such method
Run Code Online (Sandbox Code Playgroud)

java testing fest

5
推荐指数
1
解决办法
3092
查看次数

GUI测试应该以默认外观运行吗?

我正在开发一个具有自定义外观的应用程序.对于GUI测试,我使用的是FEST-Swing.目前,GUI测试使用默认的Java外观运行.因此,有些测试失败,但是我应该将其视为GUI中的错误,还是使用我的自定义外观进行测试?

稍后编辑:

谢谢Andrew Tompson的快速回答.但我认为这个问题仍然存在,因为流程布局的工作方式.这是一个发生了什么的模型:

在此输入图像描述

标准LAF使用比我使用的字体更大的字体,这导致其中一个按钮退出布局.我不能使用pack(),因为该容器有一个大小要求.如果您没有在该示例中调用frame.pack(),我认为您会遇到同样的问题.

java testing swing look-and-feel fest

4
推荐指数
1
解决办法
223
查看次数

Android测试java.lang.NoClassDefFoundError由于Fest-Android导致的错误

我目前正在为我的项目实现Android的Fest,但我似乎遇到了依赖问题.如果我在没有包含Fest库的情况下运行测试,测试将正常运行.一旦我添加了Fest库,那么测试就不再运行了.而是抛出异常.

我的项目使用以下依赖项:

compile files('libs/robotium-solo-5.1.jar')
androidTestCompile 'com.squareup:fest-android:1.0.8'
androidTestCompile 'com.google.code.gson:gson:2.2.4'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
androidTestCompile 'com.google.mockwebserver:mockwebserver:20130706'
androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
androidTestCompile('com.google.dexmaker:dexmaker-mockito:1.0') {
    exclude module: 'hamcrest-core'
    exclude module: 'objenesis'
    exclude module: 'mockito-core'
}
androidTestCompile 'org.mockito:mockito-all:+'
Run Code Online (Sandbox Code Playgroud)

我已经尝试排除我在下面列出的Fest Android依赖项,但它对测试的运行没有影响.

androidTestCompile ('com.squareup:fest-android:1.0.8') {
    exclude group: 'com.google.android', module: 'android'
    exclude group: 'com.google.android', module: 'support-v4'
    exclude group: 'org.easytesting', module: 'fest-assert-core'
}
Run Code Online (Sandbox Code Playgroud)

这是在包含Fest库的情况下运行测试时发生的异常.

junit.framework.AssertionFailedError: Exception in constructor: testClickActionBarItems (java.lang.NoClassDefFoundError: com.example.android.activities.SectionsActivity
at com.example.android.test.activities.SectionsEspressoTests.<init>(SectionsEspressoTests.java:21)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:118)
at android.test.AndroidTestRunner.getTest(AndroidTestRunner.java:148)
at android.test.AndroidTestRunner.setTestClassName(AndroidTestRunner.java:56)
at android.test.suitebuilder.TestSuiteBuilder.addTestClassByName(TestSuiteBuilder.java:80)
at android.test.InstrumentationTestRunner.parseTestClass(InstrumentationTestRunner.java:444)
at android.test.InstrumentationTestRunner.parseTestClasses(InstrumentationTestRunner.java:425)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:370)
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onCreate(GoogleInstrumentationTestRunner.java:114) …
Run Code Online (Sandbox Code Playgroud)

android fest android-testing android-studio android-gradle-plugin

3
推荐指数
1
解决办法
1292
查看次数

在Fest中实现matcher的Groovy闭包

我正在尝试使用Groovy(2.1.6)为Fest创建一个闭包匹配器,如下所示:

def matcherLabel = [ isMatching: { JLabel label -> /* do something */ } ] as GenericTypeMatcher<JLabel>
Run Code Online (Sandbox Code Playgroud)

GenericTypeMatcher是一个抽象类,只有一个方法可以实现(isMatching(T t))

但我得到这个错误:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Error casting map to org.fest.swing.core.GenericTypeMatcher, Reason: null
at org.codehaus.groovy.runtime.DefaultGroovyMethods.asType(DefaultGroovyMethods.java:7562)
Run Code Online (Sandbox Code Playgroud)

有可能我想做什么?

groovy swing fest cucumber-jvm

2
推荐指数
1
解决办法
853
查看次数