lundi 24 septembre 2018

The method 'call' was called on null with mockito testing

Very new when it comes to mocking objects and I'm not sure why this error pops up.

The following NoSuchMethodError was thrown running a test:
The method 'call' was called on null.
Receiver: null
Tried calling: call(Instance of 'Group')

MockAddGroupViewModel viewModel = new MockAddGroupViewModel();
Group temp = new Group(
    groupName: "GroupName",
    groupPassword: "Password",
    groupAdminPassword: "AdminPassword");
await tester.tap(find.text("Ok"));
await tester.pumpAndSettle(Duration(seconds: 1));
verifyNever(viewModel.onSaveCallback(temp));

Context:

The viewmodel has a function which should be called when the user taps on a button.

This widget test is supposed test the fact that the save function should not be called since no input has been entered but I keep getting the error posted.

This is also using redux so in this case the container is passing a viewmodel which knows how to handle properly saving a new Group once a button is pressed.

Aucun commentaire:

Enregistrer un commentaire