Re: file fixtures for unit testing
Re: file fixtures for unit testing
- Subject: Re: file fixtures for unit testing
- From: Timothy Reaves <email@hidden>
- Date: Sat, 4 Oct 2008 09:50:20 -0400
On Oct 4, 2008, at 1:01 AM, Brent Hargrave 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?
Put the file into the Resources folder, and add it to the test
target. This insures that the file gets copied into the .app during
the build. In the test, you do this:
NSString *filename = [[NSBundle bundleForClass:[self class]]
pathForResource:@"TestXML1" ofType:@"xml"];
Now, having said that, I'll also say that you do not need to read in
XML files to test an XML parser, and that in general, it's a bad idea
for tests to rely on files. My ID3 parser has 100% test coverage, and
doesn't require a single file.
_______________________________________________
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