Shorter Syntax for Creating Stubs with Mockito

As part of my efforts to create more concise Unit Tests in Java, Steve McLarnon and I recently added the ability to create a stub and stub one method with only one line.

The implementation relies entirely on Mockito, so my example assumes you were already using Mockito to create the stub.

The Mockito documentation has the following example for stubbing:LinkedList mockedList = mock(LinkedList.class);
when(mockedList.get(0)).thenReturn("first");Using the code Steve and I put together you can...
 •  0 comments  •  flag
Share on Twitter
Published on February 24, 2010 05:30
No comments have been added yet.