From: Tim Pease Date: 2006-10-27T03:18:58+09:00 Subject: Re: Unit testing questions On 10/26/06, Patrick Hurley wrote: > I have been working on a msg4r wrapper that provides a number of > messaging clients (i.e. Websphere MQ, ActiveMQ, Stomp) to ruby all > with that same API. I have some simple unit tests in place that > require the actual messaging systems to be available - this mean that > there is significant work required to setup the test, but when they > run I know that they are actually working. I am considering some sort > of mock approach, but I fear that I will be missing out on testing the > specifics of the wire protocols, timing etc. > > I am not sure if there is a "right" answer, but I was wondering if > there were any ideas/hints other developers might have. > If you have tests that work, why change them? Here are my reasons for using mock objects: 1) fixture is too complex to configure for unit testing 2) you do not have control over the entire system (i.e. talking to a remote web service) 3) you are controlling an external device that could be damaged Mock objects are great, but they require work to maintain. If you can test without them, great! One less thing to modify when the system needs to change. If you are constrained by 1, 2, or 3, then you cannot live without mock objects. I've used Jim Weirich's FlexMock, and I'd highly recommend it. A fellow rubyist has recommended MockFS for mocking out the entire file system. Blessings, TwP http://onestepback.org/software/flexmock/ http://rubyforge.org/projects/mockfs/