|
JMock vs. EasyMockMarch 2006
asyMock 2.0 requires: cglib
2.1
http://prdownloads.sourceforge.net/cglib/cglib-nodep-2.1_3.jar?use_mirror=easynews
Note: Comments from Fowler below are based on EasyMock 1.x, the 2.0 version is simpler and more flexible ..ajm.
"EasyMock uses a record/replay metaphor for setting expectations. For each
object you wish to mock you create a control and mock object. The mock
satisfies the interface of the secondary object, the control gives you
additional features. To indicate an expectation you call the method, with
the arguments you expect on the mock. You follow this with a call to the
control if you want a return value. Once you've finished setting
expectations you call replay on the control - at which point the mock
finishes the recording and is ready to respond to the primary object. Once
done you call verify on the control.
It seems that while people are often fazed at first sight by the record/replay metaphor, they quickly get used to it. It has an advantage over the constraints of jMock in that you are making actual method calls to the mock rather than specifying method names in strings. This means you get to use code-completion in your IDE and any refactoring of method names will automatically update the tests. The downside is that you can't have the looser constraints. " Fowler |
|
© Teton Cay Group, Inc 2006. Some rights reserved. |