title: How to test a static method using mock() and spy()
body: <p>the below posted method in the code section contains a static method which is "with()". I want to test the code in below, so I coded the test of this method
  as shown in the testing section.</p>
  
  <p>i tried to test the method using both of "spy()" and "mock()" but the test fails alwyas.</p>
  
  <p>please let me know how can I test a method returns void?</p>
  
  <p><strong>code</strong></p>
  
  <pre><code> public RequestCreator requestCreatorFromUrl(String picUrl) {
      return Picasso.with(mCtx).load(picUrl);
  }
  </code></pre>
  
  <p><strong>testing</strong>:</p>
  
  <pre><code>public class ValidationTest {
  @Mock
  private Context mCtx = null;
  @Rule
  public MockitoRule mockitoRule = MockitoJUnit.rule();
  
  @Before
  public void setUp() throws Exception {
      mCtx = Mockito.mock(Context.class);
      Assert.assertNotNull("Context is not null", mCtx);
  }
  
   @Test
  public void whenRequestCreatorFromUrlTest() throws Exception {
      Picasso picasso = Picasso.with(mCtx);
      Picasso spyPicasso = spy(picasso);
      Uri mockUri = mock(Uri.class);
      RequestCreator requestCreator = Picasso.with(mCtx).load(mockUri);
      RequestCreator spyRequestCreator = spy(requestCreator);
  
      doReturn(spyRequestCreator).when(spyPicasso.load(mockUri));
      //when(spyPicasso.load(mockUri)).thenReturn(spyRequestCreator);
      RequestCreator actual = spyPicasso.load(mockUri);
  
      Assert.assertEquals(requestCreator, actual);
  }
  </code></pre>