Re: file fixtures for unit testing
Re: file fixtures for unit testing
- Subject: Re: file fixtures for unit testing
- From: "Brent Hargrave" <email@hidden>
- Date: Sun, 5 Oct 2008 11:38:07 -0700
Thank you all. As I'm new to testing, would someone mind expanding on
Timothy's point re: using real files as test fixtures? What works better
and why?
Many thanks,
JB
On Sat, Oct 4, 2008 at 12:30 PM, Chris Hanson <email@hidden> wrote:
> On Oct 4, 2008, at 3:59 AM, Colin Barrett wrote:
>
> On Fri, Oct 3, 2008 at 10:01 PM, Brent Hargrave <email@hidden>
>> wrote:
>>
>>> To unit test an XML parsing method, I would like keep a dummy XML file in
>>> a
>>> project directory and import it into my FooTests class as a fixture of
>>> sorts. What is the right way to do this sort of thing?
>>>
>>
>> Add it to the project, and then add it to the test's target. You
>> should then be able to reference it using -[NSBundle
>> pathForResource:ofType:]. I'm not 100% that's the way OCUnit/SenTest
>> targets work, but it would surprise me if they worked otherwise.
>>
>
> That is the way they work.
>
> Remember that in a non-main bundle, you'll probably want to use something
> like [NSBundle bundleForClass:[self class]] rather than [NSBundle
> mainBundle] to get the bundle to load a resource from.
>
> -- Chris
>
>
_______________________________________________
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