What's new? | Help | Directory | Sign in
Google
mockito
Mocking java simpler & better
  
  
  
  
    
Search
for
Updated Jun 18, 2008 by szczepiq
Labels: Featured
ReleaseNotes  

Changed in 1.4

Added new stubbing feature: different return values for consecutive method calls (like mocking iterators). This feature is to be used judiciously. Mocking iterators can be avoided by preferring Iterables/collections which results in simpler and cleaner code.

stub(mock.getStuff())
  .toReturn(1)
  .toReturn(2)
  .toThrow(new RuntimeException());

Changed anyX() matchers to treat nulls as a valid 'anything' value.

Added few handy matchers: anyCollection(), anyList(), anyMap().

Started using cglib 2.2 stable.

Fixed  issue 13  (anyObject() matcher with varargs problem).

Added more descriptive exception message based on reported typical misuse (Added comment that the user might forget to call initMocks() when annotation @Mock is used).

Javadoc enhancements based on comments.

Changed in 1.3

Started using cglib 2.1.3 to sort out maven dependencies.

Started using field names of annotated (@Mock) mocks for printing failed interactions. That gives better readability and also promotes good names for fields. For example following mock:

  @Mock private LinkedList listOfArticles;

  //in case of verification error, will be printed like that: 

  "Wanted but not invoked: listOfArticles.clear();"

  //In previous version, it would be like that:

  "Wanted but not invoked: LinkedList.clear();"

To be more consistent with previous feature, invocations are printed with lowercase first letter. For example if you happened to mock a LinkedList then the verification error will show linkedList.clear() instead of LinkedList.clear().

Tuned verification messages when arguments don't match. Arguments are automatically broken to vertical list if printed invocation is too long.

Default return values for primitive wrapper classes are now consistent with primitives. E.g: an int method returns 0 but an Integer method also return 0 instead of null.

Enabled stubbing toString() because 'why not' and it may be useful for debugging purposes

Exposed configuration of default return values to enable custom 'mocking style'. Helpful for legacy code. For more information read this thread or look at examples here or here.

Fixed issue with reporting errors related to  issue #7 

Added some examples to the test code, e.g. using JUnit runner to take advantage on @Mock annotation and avoid infamous base class for tests.

Javadoc changes to reflect feedback from users

Changed in 1.2

Changed in 1.1

  verify(mock, never()).someMethod();

Changed in 1.0

Since beta version, matchers were refactored into hamcrest matchers. Hence another jar dependency. Also, if you created custom argument matchers in beta you will have to change them after moving to 1.0. CustomMatcher became an ArgumentMatcher which is an implementation of hamcrest Matcher.

Changed in 1.0

Changed in 0.91

Changed in 0.9


Sign in to add a comment