You gotta be kidding me!!! I’m writing some code TDD style for a change. I’m trying to do this in an X-Code iPhone project, knowing all too well the pain of Objective-C verbosity. I get to the point where I wanna load a test resource. Because there’s no getClass().getResourceAsStream in Obj-C iPhone land I’m reduced to this:
NSRange range = [resourceName rangeOfString:@"." options:NSBackwardsSearch];
NSString *file = [resourceName substringToIndex:range.location];
NSString *ext = [resourceName substringFromIndex:range.location + 1];
NSString *path = [[NSBundle bundleForClass:[MyTestSupport class]] pathForResource:file ofType:ext];
return [NSData dataWithContentsOfFile:path];
There has got to be justice here! I miss the days when I could post a question on Nabble saying, “Is there a groovy way to do this? [code-snipet]” At any rate, I’m really upset because I can’t get CoverStory gcov stuff working with my iPhone projects. I don’t particularly care about test coverage but I did find some good usage for coverage tools. Do you do iPhone stuff? Have you used CoverStory? Can you help?