• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: file fixtures for unit testing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >file fixtures for unit testing (From: "Brent Hargrave" <email@hidden>)

  • Prev by Date: NSNetService connection difficulty
  • Next by Date: Re: Play Playlist in iTunes
  • Previous by thread: Re: file fixtures for unit testing
  • Next by thread: Customize NSScroller
  • Index(es):
    • Date
    • Thread