Unit testing questions

P

Patrick Hurley

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.

Thanks
pth
 
T

Tim Pease

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top