Mocking Classes
A few days ago I run to the following problem - in order to prepare test case for one of my classes, I needed to build a mock object. However, due to design issues I needed to mock not an interface, but a class. I quickly tried EasyMock and jMock but both of them failed, complaining that they cannot mock classes. I very briefly googled for a solution, but didn’t see any and was almost ready to start writing My Own Ultimate Mocking Library… Unfortunately, a second later I was brought back to earth. Both those libraries offer extensions capable of dealing with this kind of problems (i.e. ClassExtension for the first one and CGLIB for the other)
. Well, tomorrow will be better!