I've recently been learning how to write Unit Tests using GHUnit for the iPhone. However, I have no idea on how to set up code coverage to work with this, via xCode 4.
The googletubes have (somehow) not been particularly helpful in this matter.
I've recently been learning how to write Unit Tests using GHUnit for the iPhone. However, I have no idea on how to set up code coverage to work with this, via xCode 4.
The googletubes have (somehow) not been particularly helpful in this matter.
I covered how to get code coverage with GHUnit in this blog article (disclaimer: I am the author)
To summarize it briefly, for GHUnit you need to:
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, @"GHUnitIOSAppDelegate");
}
}
FILE *fopen$UNIX2003(const char *filename, const char *mode) {
return fopen(filename, mode);
}
size_t fwrite$UNIX2003(const void *ptr, size_t size, size_t nitems, FILE *stream) {
return fwrite(ptr, size, nitems, stream);
}
For more detailed explanations/screenshots, see the blog article above. The article is more exhaustive because it also covers Jenkins integration and OCUnit.
There's an answer here that claims to have gotten code coverage working in XCode 4, although I've not verified it: