Nikola Milovic
02/24/2020, 1:41 PMRaul Tunduc
02/24/2020, 1:42 PMwhen
and then
Raul Tunduc
02/24/2020, 1:43 PMval mockBookService = Mockito.mock(BookService::class.java)
Mockito.`when`(mockBookService. inStock(100)).thenReturn(true)
Nikola Milovic
02/24/2020, 1:46 PMfun a() {
If(logic) {b()}
}
}
The both methods are in the SUT which is not mocked
The b() contains logic and dont want to execute it just to confirm its calledNikola Milovic
02/24/2020, 1:46 PMRaul Tunduc
02/24/2020, 1:48 PMa()
you can write smth like this:
Mockito.`when`(b()).thenReturn(true)
and that’s all.
That method will not be executed, only it will return true 🤷♂️Nikola Milovic
02/24/2020, 1:48 PMNikola Milovic
02/24/2020, 3:14 PMRaul Tunduc
02/24/2020, 3:15 PM