= 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<String> responsex = cx.doStuff(null, "kkll"));
        Assert.assertEquals(123, responsex.size());
    }
}
}}}

== BDDMockito ==
Behavior Driven Development style of writing tests uses //given //when //then comments as fundamental parts of your test methods. 
 * https://en.wikipedia.org/wiki/Behavior-driven_development
{{{
import static org.mockito.BDDMockito.*;

 Dummy dummy = mock(Dummy.class);
 Foo foo = new Foo(dummy);

 public void doStuff() throws Exception {
   //given
   given(dummy.getObj()).willReturn(new Obj());

   //when
   PlentyStuff ps = shop.getObj();

   //then
   assertThat(ps, containObj());
 }
}}}