iOS UT coverage

本文介绍如何在Xcode 4.2中使用Clang/LLVM进行代码覆盖率测试。教程覆盖了从配置编译参数到运行测试的具体步骤,并提供了必要的链接资源。

http://www.infinite-loop.dk/blog/

需要测试代码覆盖率的问题

This tutorial is just a small follow-up on one of my earlier posts about how to set up code coverage in Xcode.

With the release of Xcode 4.2 code coverage is finally supported using Clang / LLVM. Opposed to what I described in the earlier post you no longer need to force the use of GCC to get code coverage metrics in your unit tests. Since Apple has also decided to drop support for GCC you are more or less forced to switch to Clang / LLVM anyway.

In Xcode 4.2 it’s fairly simple to set up code coverage. If you have defined a custom build setting or build rule that enforces GCC 4.2 you will need to remove those first.

Next you’ll need to enable the two build settings “Generate Test Coverage Files” and “Instrument Program Flow” as shown below:


Introduction

CoverStory is a GUI tool for analyzing which lines of your code have actually been executed when you run you test your code. It requires a little set up to use effectively, you must make some target changes in your Xcode project.

Project Settings

Xcode 4.3 with LLVM Compiler

Unfortunately it appears that code coverage is broken again for iOS using llvm. libprofile_rt has not been compiled with i386, and doesn't even appear in the iOS SDK.

Xcode 4.2 with LLVM Compiler

With Xcode 4.2 (4C139 aka iOS 5 beta 4) code coverage appears to be working with LLVM. To get it working you need to do the following:

  1. Add -fprofile-arcs and -ftest-coverage to Other C Flags
  2. Link /Developer/usr/lib/libprofile_rt.dylib into your app
  3. Build and run

http://code.google.com/p/coverstory/wiki/UsingCoverstory
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值