Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I prefer mockito which uses a different paradigm for mocking out classes. You don't have to subclass everything like you do with easymock.</p> <p><a href="http://code.google.com/p/mockito/" rel="nofollow">http://code.google.com/p/mockito/</a></p> <p>The javadoc itself has a ton of information about how to utilize the library</p> <p><a href="http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#2" rel="nofollow">http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#2</a></p> <p>Her is a short example from their documentation.</p> <pre><code>//You can mock concrete classes, not only interfaces LinkedList mockedList = mock(LinkedList.class); //stubbing when(mockedList.get(0)).thenReturn("first"); when(mockedList.get(1)).thenThrow(new RuntimeException()); //following prints "first" System.out.println(mockedList.get(0)); //following throws runtime exception System.out.println(mockedList.get(1)); //following prints "null" because get(999) was not stubbed System.out.println(mockedList.get(999)); //Although it is possible to verify a stubbed invocation, //usually it's just redundant //If your code cares what get(0) returns then something else //breaks (often before even verify() gets executed). //If your code doesn't care what get(0) returns then it should not be stubbed. Not convinced? See here. verify(mockedList).get(0); </code></pre> <p>So with this library you setup your tests and stub out the methods that you are interested in testing.</p> <p>Hope you found this useful.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload