Endo-testing: unit testing with mock objects
Extreme programming examined
Hi-index | 0.00 |
A simple alternative to MockObjects is presented. Given the interface of an object required by a class-under-test, a Pseudo-Class is created implementing all methods such that they immediately fail. A test-specific sub-class of the Pseudo-Class is created locally in the test (ex. as an anonymous inner-class in Java), over-riding only the methods required by the interaction between the object and the class-under-test for the test-scenario. Typically, the method implementations are extremely simple (a few lines, at most), and the number of methods overridden is small. This mechanism was found adequate for more than 90% of our unit-tests (in a 1000-class system with over 2000 test methods, we finally ended up with about four real MockObject classes and more than 40 Pseudo-Classes).