我想用TestFX测试我编写的JavaFX GUI。第一步,我要测试一些ChoiceBox。
到目前为止,我已经尝试了以下代码:
this.step("fill creation view", () -> {
this.clickOn("#receiverChoiceBox").clickOn("Max Mustermann");
verifyThat("#receiverChoiceBox",
ComboBoxMatchers.hasSelectedItem(this.userInformationMap.get(2)));
});
但是,这将导致以下错误消息:
java.lang.AssertionError:
Expected: ComboBox has selection "xxx.model.dto.UserInformationDto@d84f7f5d"
but: was a xxx.gui.control.xxxChoiceBox (<xxxChoiceBox[id=receiverChoiceBox, styleClass=choice-box]>)
Expected :ComboBox has selection "xxx.model.dto.UserInformationDto@d84f7f5d"
Actual :a xxx.gui.control.xxxChoiceBox (<xxxChoiceBox[id=receiverChoiceBox, styleClass=choice-box]>)
我知道我正在使用ComboBox Matcher,但是之前我尝试过其他选项,但它们也不起作用。 ChoiceBox是否有类似的Matcher?
答案 0 :(得分:0)
我现在已经解决了以下问题:
verifyThat("#receiverChoiceBox", node -> this.userInformationMap.get(2).equals(((ChoiceBox)node).getValue()));