单元测试 Objective-C 代码的最佳方法是什么? [英] What is the best way to unit test Objective-C code?

查看:29
本文介绍了单元测试 Objective-C 代码的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有哪些框架可以对 Objective-C 代码进行单元测试?我想要一个与 Apple Xcode 完美集成的框架.

What frameworks exist to unit test Objective-C code? I would like a framework that integrates nicely with Apple Xcode.

推荐答案

Xcode 包含 XCTest,类似于 OCUnit,一个 Objective-C 单元测试框架,完全支持运行基于 XCTest 的单元测试作为项目构建过程的一部分.Xcode 概述:使用单元中描述了 Xcode 的单元测试支持测试.

Xcode includes XCTest, which is similar to OCUnit, an Objective-C unit testing framework, and has full support for running XCTest-based unit tests as part of your project's build process. Xcode's unit testing support is described in the Xcode Overview: Using Unit Tests.

回到 Xcode 2 天,我写了一系列关于如何使用 Xcode 单元测试执行一些常见任务的博客文章:

Back in the Xcode 2 days, I wrote a series of weblog posts about how to perform some common tasks with Xcode unit testing:

尽管使用 OCUnit 而不是 XCTest,但概念基本相同.

Despite using OCUnit rather than XCTest, the concepts are largely the same.

最后,我还写了几篇关于如何为 Cocoa 用户界面编写测试的帖子;Cocoa 的结构方式使它相对简单,因为在大多数情况下您不必旋转事件循环或类似的东西.

Finally, I also wrote a few posts on how to write tests for Cocoa user interfaces; the way Cocoa is structured makes it relatively straightforward, because you don't have to spin an event loop or anything like that in most cases.

这使得不仅可以对模型级代码进行测试驱动开发,还可以对控制器级甚至视图级代码进行测试驱动开发.

This makes it possible to do test-driven development for not just your model-level code but also your controller-level and even view-level code.

这篇关于单元测试 Objective-C 代码的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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