iOS??????????????
???????????? ???????[ 2015/9/14 14:05:21 ] ??????????????? ??????????
????????lcov-1.11???CodeCoverage4iOS
????iOS code coverage test tool.
????????lcov-1.11??iOS???????????????????????iOS????????????
???????????
????Mac OS X :10.8.5+ ????10.9
????Xcode :5.0+ ????6.1
????Xcode????????
????????CodeCoverage4iOS??????????????????${your_proj.xcworkspace}??????
??????Xcode???????????? NT_COVERAGE=1??????????????????????????·?? iOSProj —> TARGTS -> MyApp -> Build Settings -> Preprocessor Macros -> Debug?????NT_COVERAGE=1
???????????????????????Build Settings??????????:
????Generate Debug Symbols ???ó?YES
????Generate Test Coverage Files ???ó?YES
????Instrument Program Flow ???ó?YES
????????:iOSProj —> TARGTS -> MyApp -> Build Settings -> Generate Debug Symbols
???????????y??????Debug???????YES?????????Release???
??????AppDelegate.m????????′???:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
...
#if NT_COVERAGE
#if !TARGET_IPHONE_SIMULATOR
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory?? NSUserDomainMask?? YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
setenv("GCOV_PREFIX"?? [documentsDirectory cStringUsingEncoding:NSUTF8StringEncoding]?? 1);
setenv("GCOV_PREFIX_STRIP"?? "13"?? 1);
#endif
extern void __gcov_flush(void);
__gcov_flush();
#endif
...
}
????????????????????????__gcov_flush()????.gcda???????????м???????????????__gcov_flush()?????????????????д??
????iOS Simulator : .gcda?????????????·??~/Library/Developer/Xcode/DerivedData/iOSProj-cndbgdtazzzhaebuyvgjsqmkvwdr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386·??
????iPhone : .gcda?????????????App???Document/${CURRENT_ARCH}/??
??????Build Phases???????н??:
??????TARGTS -> MyApp -> Build Phases -> New Run Script Phase?б?Run Script ??? CodeCoverage4iOS/exportenv.sh
??????? : ?????????????????????????????????????????·??????·??????????????????????????????????????????·?????????·??../CodeCoverage4iOS/exportenv.sh
?????????????????
???????????????????Xcode??????й??????????Xcode???app????CodeCoverage4iOS????envs.sh????????
??????? : ??????BuildCommand+B?????envs.sh?????????Build??????????envs.sh?????????Command+R?????envs.sh??????build??????????????
???????????????
????APP??????????????????????????????????????Home????????????????.gcda????????????
????????????????:
????iOS Simulator : ????????豸?iOS???????????????CodeCoverage4iOS/getcov
????iPhone : ????????豸?iPhone?????????????????Document/${CURRENT_ARCH}?????.gcda?????CodeCoverage4iOS/gcda?£??????CodeCoverage4iOS/getcov
???????CodeCoverage4iOS/getcov?????л?????CodeCoverage4iOS/coverage??????coverage.info?????????coverage.info???????????檔PS:????????????????????????????
???????????????·??:CodeCoverage4iOS/report/index.html
??????????
???????????????????????????й?????????CodeCoverage4iOS/getcov?е????exclude_data()
????exclude_data()
????{
????LCOV --remove $COVERAGE_INFO_DIR/${LCOV_INFO} "Developer/SDKs/*" -d "${OBJ_DIR}" -o $COVERAGE_INFO_DIR/${LCOV_INFO}
????LCOV --remove $COVERAGE_INFO_DIR/${LCOV_INFO} "main.m" -d "${OBJ_DIR}" -o $COVERAGE_INFO_DIR/${LCOV_INFO}
????# Remove other patterns here...
????}
??????????Coverage.info??????????????:
??????Coverage.info???????????CodeCoverage4iOS/coverage?£??? Coverage1.info??Coverage2.info??Coverage3.info
???????CodeCoverage4iOS/mergecov ????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11