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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to