https://kotlinlang.org logo
#android
Title
# android
j

Joan Colmenero

06/24/2019, 2:55 PM
Tried something like this
Mockito.when(view.hideKeyboard()).then(doNothing())
l

louis993546

06/24/2019, 2:57 PM
verify(view).hideKeyboard()
j

Joan Colmenero

06/24/2019, 2:58 PM
But I get this error : However, there were exactly 2 interactions with this mock: view.hideKeyboard();
l

louis993546

06/24/2019, 2:59 PM
If that is expected: verify(view, times(2)).hideKeyboard()
j

Joan Colmenero

06/24/2019, 3:06 PM
But I have to mock the view.hideKeyboard, right?
Because I have inside mView?.showProgressBar(true) mView?.hideKeyboard()
Any idea @louis993546
l

louis993546

06/24/2019, 3:22 PM
yes, you have to mock or spy the
view
r

Rok Koncina

06/24/2019, 3:23 PM
I think you already have it mocked - otherwise you wouldn't get that error
👆 1
j

Joan Colmenero

06/24/2019, 3:24 PM
But I'm getting this error :
Copy code
However, there were exactly 2 interactions with this mock:
view.hideKeyboard();
view.showProgressBar(true);
r

Rok Koncina

06/24/2019, 3:27 PM
Post the code, it's hard to figure it out without seeing what you're doing...