test driven development

Published 02-09-2006 3:41 AM | jokiz
i have long wanted to do test-driven development and currently i've been reading a number of articles about it (before implementing it of course).  i've just read the Test-Driven Development in .NET article of Peter Provost in CodeProject and what struck me was the use of mock objects.

One of the biggest challenges you will face when writing units tests is to make sure that each test is only testing one thing. It is very common to have a situation where the method you are testing uses other objects to do its work. If you write a test for this method you end up testing not only the code in that method, but also code in the other classes. This is a problem. Instead we use mock objects to ensure that we are only testing the code we intend to test. A mock object emulates a real class and helps test expectations about how that class is used

The concept of mock objects appealed to me since it was a brilliant idea to just interact with the interface of the real objects just to reduce dependency conflicts.
Filed under: , ,

Comments

# dehran ph said on February 9, 2006 5:28 AM:

And so to make our codes testable and benefit mock objects we need to code into into interfaces. btw joey, codebetter also have great articles and posts on testdriven and mock objects.

# cruizer said on February 9, 2006 10:09 AM:

i think one of the trickiest stuff to test is database interaction. try doing mock objects on that one!

mocking a DAL/DAO is easy, but mocking a database connection raises a lot of hairy issues.

# smash said on February 9, 2006 3:29 PM:

back in the old days we just code, debug and refine. frankly it still works. the real problem really is when we start coding without really fully understanding the parameters of the problem we are trying to solve.

# jokiz said on February 9, 2006 4:24 PM:

i got that bookmarked rodel and try to read more when i have time. thanks for that comment cruizer.

# Where is ephedra legal. said on April 9, 2008 2:35 PM:

Ephedra yellow bullets.