= Mockito = Unit tests mocks framework. * https://site.mockito.org/ * https://github.com/mockito/mockito * https://www.tutorialspoint.com/mockito/mockito_quick_guide.htm == methods purpose == * mock(): create a mock * when(): specify how a mock should behave * verify(): to check mocked/stubbed methods were called with given arguments == Example == {{{#!highlight java import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.junit.Assert; import org.junit.Test; import org.springframework.mock.env.MockEnvironment; public class TestX{ @Test public void testXyz() { MockEnvironment env = new MockEnvironment(); env.setProperty("intx", "1"); env.setProperty("intz", "10"); String rsp1="rsp1"; String rsp2="rsp2"; ClassX cx = mock(ClassX.class); when(cx.getURL(anyObject(), anyObject(), eq("aaaa"))).thenReturn(rsp1).thenReturn(rsp2); doCallRealMethod().when(cx).initialize(any(), any()); doCallRealMethod().when(cx).doStuff(any(), any()); cx.initialize(null, env); List responsex = cx.doStuff(null, "kkll")); Assert.assertEquals(123, responsex.size()); } } }}}