I have an application and connect database with a gateway module. And I write gui tests and I start to use mockito. I try to update an object with open gui. I set combobox, textfield parameters and change them new parameters too but then call save method. My problem starts with save method.
I load my controller with
Platform.runlater(() -> {
spyUpdate.loadItems(object1, object2);
});
I change object parameters and click to save button with
Button saveButton = find("#saveButton");
click(saveButton);
it calls save method. But this method goes to db so I write
Mockito.doNothing().when(spyUpdate).saveObjectToDb();
but this is not working? SaveObjectToDb
function is called. Is there any idea. Using TestFX and Mockito how can I test my gui?
UPDATED:
//Button saveButton = find("#saveButton");
//click(saveButton);
Mockito.doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable{
Platform.runLater(() ->){
AlertManager.setSUCCESS();
});
return null;
}).when(spyUpdate).saveObjectToDb();
spyUpdate.saveObjectToDb();