GWT复合组件测试用例



我有一个GWT复合组件,有两个textBox,想为它写测试用例。每个组件都有一个更改处理程序,我想知道如何在复合组件类中触发一个更改事件来精确地指定组件。

编辑:我的测试代码看起来像这样,

    @Test
    public void testValueChangesToOutOfRange(){
        DvCountUI count = new DvCountUI(15, "place holder", true);
        count.specifyNormalRange(10, 30);
        TextBox magnitude =  GwtReflectionUtils.getPrivateFieldValue(count, "magnitude");
        assertTrue(true);
    }

,当我运行它与GWT Junit测试得到错误:在控制台

Validating units:
   Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[ERROR] Errors in 'file:/D:/TRANSFER/asclepian/workspace/UIBuilder/src/com/rubirules/uibuilder/client/DvCountUITest.java'
   [ERROR] Line 65: No source code is available for type com.googlecode.gwt.test.utils.GwtReflectionUtils; did you forget to inherit a required module?
[ERROR] Unable to find type 'com.rubirules.uibuilder.client.DvCountUITest'
   [ERROR] Hint: Previous compiler errors may have made this type unavailable
   [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly

and in junit

JUnitFatalLaunchException

我的gwt.xml文件如下:

<module rename-to='uibuilder'>
    <inherits name='com.google.gwt.user.User' />
    <inherits name='com.google.gwt.user.theme.clean.Clean' />
    <entry-point class='com.rubirules.uibuilder.client.UIBuilder' />
    <source path='client' />
    <source path='shared' />
</module>

怎么了?我还在项目库中添加了gwt-test-utils jar。

我不确定你对单元测试小部件的方法是否正确。

在这种情况下,您应该理想地设置值(触发内部更改事件)并测试在更改处理程序中编写的代码是否得到执行。

示例- TextBoxBaseTestBase.java
public void testValueChangeEvent() {}在http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/user/client/ui/TextBoxBaseTestBase.java

如果您坚持触发更改事件,您可以参考GWT示例CreateEventTest.java

public void testTriggerChangeEvent() {} inhttp://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/user/client/ui/CreateEventTest.java

我通过:扩展GwtTest而不是GWTTestCases并添加gwt-test-util。属性文件,值为"com.rubirules.uibuilder.UIBuilder = gwt-module",在test包内的META-INF文件夹中。

相关内容

  • 没有找到相关文章

最新更新