mockito
Table of Contents
Mockito
Mocks
Spies
Argument Matchers
- we can configure our mocked methods with argument matchers
when(flowerService.analyze(anyString())).thenReturn("Flower");
- We can't use argument matchers as a return value, an exact value is required when stubbing calls
- we can't use argument matchers outside of verification or stubbing
BDDMockito
Links:
- BDDMockito - JavaDoc
BDD-phases:
- given
- when
- then
import static org.mockito.BDDMockito.*; Seller seller = mock(Seller.class); Shop shop = new Shop(seller); public void shouldBuyBread() throws Exception { //given given(seller.askForBread()).willReturn(new Bread()); //when Goods goods = shop.buyBread(); //then assertThat(goods, containBread()); }
mockito.txt · Last modified: by kalaschnikow
