Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Code Coverage for Xcode 5 & iOS 7

4,002 views

Published on

Published in: Technology, Business
  • Be the first to comment

Code Coverage for Xcode 5 & iOS 7

  1. 1. Xcode 5 & iOS 7 でも コードカバレッジとか 取りたい! @tokorom Wednesday, December 11, 13
  2. 2. これのiOS 7版 Wednesday, December 11, 13
  3. 3. Xcode 4.x 以前の テスト実行 xcodebuild -project $(PROJECT) -target $(TEST_TARGET) -sdk iphonesimulator -configuration Debug TEST_AFTER_BUILD=YES TEST_HOST= Wednesday, December 11, 13
  4. 4. Xcode 5 以降の テスト実行 xcodebuild test -scheme $(SCHEME) -destination $(DESTINATION) Wednesday, December 11, 13
  5. 5. Xcode 5 の xcodebuild は 大幅パワーアップ! Wednesday, December 11, 13
  6. 6. コードカバレッジ Wednesday, December 11, 13
  7. 7. xxx.gcno & xxx.gcda GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES Wednesday, December 11, 13
  8. 8. iOS 6 ではうまくいくのに Wednesday, December 11, 13
  9. 9. iOS 7 では xxx.gcda が 出ない!? Wednesday, December 11, 13
  10. 10. 自分でこれを呼ばないと ダメらしい extern void __gcov_flush(void); __gcov_flush(); Wednesday, December 11, 13
  11. 11. いつ呼ぶの? Wednesday, December 11, 13
  12. 12. 今... ではなくて テストが全部 実行し終わった後 Wednesday, December 11, 13
  13. 13. XCTestObserver Wednesday, December 11, 13
  14. 14. XCTestObserver NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:@"XCTestLog,XXXObserver" forKey:XCTestObserverClassKey]; [defaults synchronize]; Wednesday, December 11, 13
  15. 15. XCTestObserver @interface TKRGcovFluserTestObserver : XCTestObserver @end @implementation XXXObserver - (void)stopObserving { [super stopObserving]; extern void __gcov_flush(void); __gcov_flush(); } @end Wednesday, December 11, 13
  16. 16. 現状の悩み ■ 普通にやると .gcno しか出ない ■ __gcov_flush() すると .gcda しか出ない ■ 今は、普通にテスト走らせて、 次に__gcov_flush()付きで走らせてる(無駄) Wednesday, December 11, 13
  17. 17. 動いているサンプル http://github.com/tokorom/ReplaceImageCategoryForXcode Wednesday, December 11, 13

×