GWT复合组件测试用例?
我有一个GWT复合组件,有两个文本框,我想为它编写测试用例。他们每个人都有变更处理程序,我想知道如何在复合组件类中触发一个变更事件,使组件精确 编辑: 我的测试代码如下所示GWT复合组件测试用例?,gwt,junit,gwttestcase,Gwt,Junit,Gwttestcase,我有一个GWT复合组件,有两个文本框,我想为它编写测试用例。他们每个人都有变更处理程序,我想知道如何在复合组件类中触发一个变更事件,使组件精确 编辑: 我的测试代码如下所示 @Test public void testValueChangesToOutOfRange(){ DvCountUI count = new DvCountUI(15, "place holder", true); count.specifyNormalRange(10, 3
@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
在朱尼特
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测试utils jar。我不确定您对单元测试小部件的方法是否正确 在这种情况下,理想情况下,您应该设置值(触发内部更改事件)并测试在更改处理程序中编写的代码是否得到执行 示例-TextBoxBaseTestBase.java
中的public void testValueChangeEvent(){} 如果您坚持触发更改事件,可以参考GWT示例CreateEventTest.java 中的公共void testTriggerChangeEvent(){} 我通过以下方式解决了问题: 扩展GwtTest而不是gwttestcase
并在test包中的META-INF文件夹中添加一个值为“com.rubirules.uibuilder.uibuilder=gwt module”的gwt-test-util.property文件 谢谢,SSR,我试着编写测试用例,如中所示,现在我在测试类中得到com.google.gwt.junit.JUnitFatalLaunchException编译错误。理想情况下,您应该使用gwt test utils重新标记(如果可用),或者在问题中提到这一点。请参阅此处的最新文档。这不是理想的情况。坚持基本单元测试策略和“Follo GWT团队”。另外,我更愿意依赖Selenium+GWTTestCase策略,而不是任何其他第三方工具。请您查看更新的问题,我没有解决它。您可能缺少com.googlecode.gwt.test.utils.GwtReflectionUtilsi的继承标记,我尝试过,但结果是,在类路径上找不到“com/googlecode/gwt/test/utils/GwtReflectionUtils.gwt.xml”;可能是输入错误,也可能是您忘了为源代码包含类路径条目?处理元素“继承”时出现意外异常可以通过接受您自己的答案来结束问题。:)