Introduction


In test-before-code environments, writing many quick and efficient unit tests helps projects adapt to change with high quality. One of the obstacles to getting good unit testing coverage occurs when the code starts touching external objects that have side effects. This problem is frequently solved by using mock objects.

We demonstrate a lightweight approach to mock objects and describe a tool that does most of the code generation work for you. Our focus is on simplicity and ease of implementation. Tests with simple architecture are easier to understand and modify and are more likely to be written.

Automated code generation takes the pain out of writing mock objects. Also it allows multiple mock objects for the same underlying system object. Each test can have its own custom-tailored mock object specialized for testing precisely the assertions made by the test.

We can create this rich family of mock objects without writing much code. The final impact on the code base is minimal, which keeps the tests comprehensible and minimizes code pollution.



Extreme Programming Perspectives
Extreme Programming Perspectives
ISBN: 0201770059
EAN: 2147483647
Year: 2005
Pages: 445

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net