如何获得我的Objective-C应用程序的Xcode的代码覆盖率? [英] How do I get code coverage for Xcode for my Objective-C app?

查看:64
本文介绍了如何获得我的Objective-C应用程序的Xcode的代码覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序需要代码保护.

I need code coverage for my iPhone app.

如何获得Xcode 4的代码覆盖率?

How do I get code coverage for Xcode 4?

推荐答案

这些步骤将有所帮助.

These steps will help.

  1. 创建一个新的构建配置(覆盖"),该配置与调试"配置重复.

  1. Create a new build configuration (‘Coverage’), duplicated from the ‘Debug’ configuration.

打开主要目标的构建设置,确保选择了新配置,然后:

Open up build settings for the main target, make sure your new configuration is selected, and:

Enable "Generate Test Coverage Files"
Enable "Instrument Program Flow"
Add "-lgcov" to "Other Linker Flags"

  • 使用Coverage模式编译应用程序.

  • Compile application with Coverage mode.

    从应用程序捆绑包文件夹中检查.gcno文件.

    Check .gcno files from your application bundle folder.

    Coverage-iphonesimulator/applicationname.build/Objects-normal

    Coverage-iphonesimulator/applicationname.build/Objects-normal

    使用CoverStory打开.gcno文件.从
    下载CoverStory http://code.google.com/p/coverstory/downloads/list

    open .gcno files with CoverStory. Download CoverStory from
    http://code.google.com/p/coverstory/downloads/list

    参考站点

    • http://atastypixel.com/blog/unit-testing-and-coverage-with-xcode/
    • http://milesdennis.blogspot.co.uk/2011/04/code-coverage-in-xcode-4.html

    这篇关于如何获得我的Objective-C应用程序的Xcode的代码覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆