【发布时间】:2016-11-23 07:14:36
【问题描述】:
我在一个组中添加了三个单选按钮,当我从浏览器加载页面时它工作正常。
Java 代码:
@UiHandler({
"RadioButton1",
"RadioButton2",
"RadioButton3"
})
void radioButtonClickHandler(ClickEvent event){
if(RadioButton1.getValue()){
// do something
} else if(RadioButton2.getValue()) {
// do something
} else if (RadioButton3.getValue()){
// do something
}
}
我正在尝试为此功能编写测试用例。
public void TestRadio1ClickEvent(){
// all values set
// Value of Radiobutton2 set to true
view.RadioButton1.fireEvent(new ClickEvent() {});
assertTrue(view.RadioButton1.getValue());
assertFalse(view.RadioButton2.getValue());
assertFalse(view.RadioButton3.getValue());
}
当我触发点击事件时,单选按钮的值不会改变。 RadioButton1 的值保持为假,而 RadioButton2 保持为真。
我可以在点击处理程序中手动设置值,但我不想这样做。单击按钮与触发事件有何不同?点击是否改变单选按钮的值,然后调用点击处理程序?
【问题讨论】:
标签: java unit-testing gwt radio-button