Re: Capturing STDOUT from unit test
Re: Capturing STDOUT from unit test
- Subject: Re: Capturing STDOUT from unit test
- From: Wincent Colaiuta <email@hidden>
- Date: Wed, 25 Jul 2007 11:19:59 +0200
El 25/7/2007, a las 0:41, Andrew Farmer escribió:
On 24 Jul 07, at 15:31, Jason Sallis wrote:
Perfect! Thanks, Nick.
Ok, that gets me to the point where I can redirect to a file.
Ideally, I'd
like to redirect to an in-memory buffer instead to avoid the
overhead of a
file. Can anyone provide an example to accomplish that with
freopen? Or is
that even possible (or necessary)? Unfortunately, my Unix
programming
experience is all but nonexistant. :-(
Redirect stdout to a pipe of which you hold both ends. Check the
man pages
for pipe() and fdopen(). (You'll need to specifically ask for `man
2 pipe`,
as there's also an unrelated command called "pipe".)
A question just like this came up a few months ago on the RSpec
mailing list. Now, RSpec is a Behaviour-Driven Development framework
written in Ruby, but I've found that I've learnt *a lot* about
testing "best practice" from working with it. This is the thread:
<http://rubyforge.org/pipermail/rspec-users/2007-April/001166.html>
In the thread they recommend using dependency injection combined with
mocks. The basic idea is that you can modify your designs a little to
make them more testable. Now, not all the things you learn in the
RSpec/Ruby world are always directly translatable to the world of
Objective-C, but I still find that they often provide food for thought.
Cheers,
Wincent
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden