xcode4 - GHUnit Code Coverage on iPhone -


i've been learning how write unit tests using ghunit iphone. however, have no idea on how set code coverage work this, via xcode 4.

the googletubes have (somehow) not been particularly helpful in matter.

i covered how code coverage ghunit in this blog article (disclaimer: author)

to summarize briefly, ghunit need to:

  • enable 2 build settings ‘generate test coverage files’ , ‘instrument program flow’ in test target of project in xcode
  • add code fopen$unix2003 , fwrite$unix2003 functions in main.m file of test target, not in appdelegate. how main.m file looks like:
      #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);     }  
  • edit test target .plist , add property ‘application not run in background’ value ‘yes’. notice useful because coverage files written when application exits.

for more detailed explanations/screenshots, see blog article above. article more exhaustive because covers jenkins integration , ocunit.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -