Cutting Teeth - Mock Objects

by Erik Lane 22. August 2006 16:27

This is something I've been meaning to use and Jean-Paul's post put the pressure on.  Plus, I really have an issue glaring at me in the face that I need to get rid of by using mock objects.  I'm working against a web service and all of my tests are written using the actual web service.  I see now that this is a total no-no.  When I began working with the web service I didn't know it very well and part of my tests were to verify the results being returned.  Now that I'm intimately familiar with it, I feel comfortable with implementing a mock object in its place.

I went looking around for examples and/or opinions on testing web services using TDD.  Almost all that I read were on testing a web service that you are writing - not a web service that you are using and dependent on.  If you are looking for that kind of info then this post by Peter Provost has you covered.

I just ran through the Quickstart and Tutorial over at NMock.org and I think I am armed and dangerous. 

As my brain is churning on what I could do and I think Jamie has the right idea by extracting an interface from the web service and then implementing it in my tests.  We shall see in the next day or so how this goes.  If it goes as I expect, I'll wonder how I ever got along without mock objects.

Tags:
Comments are closed