使用KIF进行功能性iOS UI测试

开始使用KIF

从Github下载KIF源资产并将其放置在可以轻松找到的地方。或者,可以使用 Git 的子模块来获取本地使用的源代码:

$ git 初始化$ git submodule 添加 https://github.com/kif-framework/KIF.git文件夹/这里

这需要添加到iOS项目文件夹中(=Folder/Here 应该在 iOS 项目下)。

为了安装 KIF,需要将libKIF static library直接链接到应用程序。此外,在KIF存储库下有一个现成的 Swift 示例。

在Xcode工作

要在iOS应用程序中使用KIF,现在已将其项目、源代码和测试模板放在iOS项目下。还可以KIF.xcodeproj在项目导航器中打开并检查安装中包含的以下文件:

安装中的 kif 文件

现在,单击MainStoryboard.storyboard打开(在 Test Host 文件夹下),以下场景应该是打开的并可编辑的:

xcode 中的主故事板

添加测试目标

根据使用的Xcode,可以通过不同的途径创建新的测试目标。

在 xcode 中测试目标

在 File -> New -> Target 下,可以找到测试目标向导:

xcode 中的 uitesting 和单元测试

配置参数并创建测试目标(单击完成):

在 xcode 中创建一个新的测试目标

配置iOS 项目。在 Project Navigator 上单击项目名称,将在右侧看到“Build Phases”。打开“Link Binary With Libraries”并找到libKIF.a并单击“添加”。KIF 现在将添加到项目中,并且库作为二进制文件与应用程序链接。

libKIF.a 配置

最后,KIF 需要 IOKit,因此可以在“Build Settings”-> Linking 和“Other Linker Flags”下将其添加到项目中。只需在那里添加“-framework IOKit”作为参数,一切都应该很好:

在 xcode 中添加 iokit 框架

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
iOS集成测试框架kif-framework,源码kif-framework,KIF的全称是“Keep It Functional”,是一款iOS集成测试框架,来自square。KIF使用了苹果非公开的API,很多iOS测试框架都使用了非公开API,出于测试目的还是安全的,KIF并不使用非公开的API生成代码,所以苹果不会拒绝你的应用。 注意: KIF 2.0并不兼容KIF 1.0,并且使用了不同的测试执行机制。 功能: 1.KIF用Objective C写成,最大化集成代码的同时还可以最小化层级数目。 2.配置简单。KIF可直接集成进你的Xcode项目中,无需运行额外的网络服务器或者安装任何额外的包。 3.OS覆盖范围广泛。KIF测试套件可以运行iOS 5.1以上系统,甚至更低Testing Framework的版本也能运行。 4.向用户一样进行测试KIF可以模仿用户的输入,点击事件等。 5.可自动集成Xcode 5测试工具。 KIF iOS Integration Testing Framework KIF, which stands for Keep It Functional, is an iOS integration test framework. It allows for easy automation of iOS apps by leveraging the accessibility attributes that the OS makes available for those with visual disabilities. KIF builds and performs the tests using a standard ocunit testing target. Testing is conducted synchronously in the main thread (running the run loop to force the passage of time) allowing for more complex logic and composition. This also allows KIF to take advantage of the Xcode 5 Test Navigator, command line build tools, and Bot test reports. Find out more about Xcode 5 features. KIF uses undocumented Apple APIs. This is true of most iOS testing frameworks, and is safe for testing purposes, but it is important that KIF does not make it into production code, as it will get your app submission denied by Apple. Follow the instructions below to ensure that KIF is configured correctly for your project. Note: KIF 2.0 is not API compatible with KIF 1.0 and uses a different test execution mechanism. KIF 1.0 can be found in the Releases section or on CocoaPods.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值