|
|
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
- added better verification message when the difference is only about arguments. Arguments are now listed vertically and exception/message is more explicit. It is particularly useful if custom/hamcrest matchers are used.
- ArgumentMatcher has now better default description (describeTo() method). It decamelizes class name, e.g: in case of failure, StringWithStrongLanguage matcher will describe itself as 'String with strong language'.
- fixed bug with mocking in java main (thanks to bug report by Paweł Jagus).
Changed in 1.1
- added never() method which is an alias to times(0). It makes the test code explicit and nicely communicates an intent (thanks to Liz Keogh for this suggestion).
verify(mock, never()).someMethod();
- if times(0) or never() fails the exception is explicit (NeverWantedButInvoked).
- fixed bug with @Mock: mocks annotated in base classes weren't initialized with initMocks() method (thanks to bug report by Vitaly Berov).
- javadoc tuning according to comments/mailing list feedback.
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
- integrated with hamcrest for argument matching.
- minor javadoc/error messages fixes
Changed in 0.91
- made verification in-order relaxed so that I can leave out some unimportant interactions from the middle of chain.
Changed in 0.9
- added @Mock annotation to eliminate some boilerplate.
- added refEq() matcher for reflection-based equals.
Sign in to add a comment
