In my current project ,it seems impossible to write a Unit test case without using Mocks.And i don’t know why but i don’t like mock objects per se.I don’t know why but writing a test case with all those Mocks flying around gives me feeling that i am not actually testing the code but just the call hierarcy.
Their are places where mocks find their use but for me they are very few .So if you find yourself using lot’s of Mock objects and its difficult to test classes then its time you start looking at dependency injection (Spring).It really helps in making your system modular and certainly testing friendly.
Coming back to the work at hand , here ojbects dependency is specified in code and if you just need to test one method you have added then Jmock and PowerMock are your friends.