Home Page - 2005-04-15

Post date: Nov 29, 2008 4:27:19 AM

JUnit, beyond doubt is a remarkable paradigm. Yes, not a small and almost trivial piece of code, but a way to think about testing itself. What is testing after all? Testing is just asserting your expectations! And that is just what JUnit does. It just calls/uses the code to be tested, and asserts if the return value and the expected value matches as we expect. This much is clear. And hence the apt quote from JUnit.org, Never in the field of software development was so much owed by so many to so few lines of code.

Martin Fowler

...And hence comes the revelation, that the Unit Tests and the Mock Objects, both are mocks. Where Mock Objects mocks the Library, Unit Tests mock the client! So what to test? Mock the clients! That is, create a dream client that will use your component fully, and assert. By the way, this also sheds light on using asserts. Use asserts profusely in your component! Because after all, every component that uses its dependencies, act as a Unit Test for them, as a Mock Client. Maybe assert can merit more exploration in the DBC direction, but it seems its nexus with testing is clear.