[英]How do I get code coverage for Xcode for my Objective-C app?
I need code coverage for my iPhone app.我的 iPhone 应用程序需要代码覆盖率。
How do I get code coverage for Xcode 4?如何获得 Xcode 4 的代码覆盖率?
I have an entry on my blog which covers this exact topic.我的博客上有一个条目,其中涵盖了这个确切的主题。
It provides a step-by-step guide on how to enable GCOV in Xcode 4 as well as how to use CoverStory for displaying the results.它提供了有关如何在 Xcode 4 中启用 GCOV 以及如何使用 CoverStory 显示结果的分步指南。
These steps will help.这些步骤将有所帮助。
Create a new build configuration ('Coverage'), duplicated from the 'Debug' configuration.创建一个新的构建配置(“Coverage”),从“调试”配置中复制。
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”
Compile application with Coverage mode.使用覆盖模式编译应用程序。
Check.gcno files from your application bundle folder. Check.gcno 来自您的应用程序包文件夹中的文件。
Coverage-iphonesimulator/applicationname.build/Objects-normal Coverage-iphonesimulator/applicationname.build/Objects-normal
open.gcno files with CoverStory.带有封面故事的 open.gcno 文件。 Download CoverStory from
下载封面故事从
http://code.google.com/p/coverstory/downloads/list http://code.google.com/p/coverstory/downloads/list
Reference Sites参考网站
I couldn't find a good example of this, so hopefully this will help someone else.我找不到一个很好的例子,所以希望这对其他人有帮助。
If you want to generate HTML from your code coverage (once you get your.gcda files generated), you can install lcov
and use these commands:如果你想从你的代码覆盖率中生成 HTML(一旦你生成了你的 .gcda 文件),你可以安装
lcov
并使用这些命令:
function generate-codecoverage-html() {
if [[ $1 == "-h" || ! $# -eq 2 ]]; then
echo " usage: $0 path/to/codecoverage/dir/ path/to/htmldir/"
return
fi
timestamp=$(date)
tmpfile="/tmp/codecoverage.info-$date"
lcov --no-checksum --directory "$1" --capture --output-file "$tmpfile"
genhtml --output-directory "$2" "$tmpfile"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.