简单问题:Cocoa 单元测试和 MVC
我是单元测试的新手,我了解基本概念,并且能够在我的 Cocoa 项目中正确设置单元测试;然而,让我感到困难的是我到底应该编写单元测试。例如,我知道您应该为模型对象编写测试,但这就是我应该编写测试的全部目的吗?我还应该为控制器和视图编写测试吗?那我到底要测试什么?有人可以尝试澄清一下您应该编写单元测试的内容以及我应该测试的内容吗?
I am new to unit testing, I understand the basic concepts, and I am able to get unit testing setup correctly in my Cocoa projects; however the thing that is giving me a hard time is what exactly I should be writing unit tests for. For example, I know that you should write tests for model objects, but is that all I should be writing tests for? Should I also be writing tests for controllers, and views? What exactly would I be testing then? Could somebody please try and clarify what you should write unit tests for and what I should be testing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通常遵循的规则是所有公共接口都需要测试。到底要测试什么始终取决于您,但是测试覆盖范围越大,出现一些令人讨厌的错误的可能性就越小。
顺便说一句,为了测试视图,我建议使用 Google Toolbox,它可以让您进行比较截图。
The rule I generally follow is that all public interface needs to be tested. It's always up to you what exactly to test however the bigger your test coverage the less possibility there is for some nasty bug to creep out.
BTW for testing views I suggest Google Toolbox which allows you to compare screenshots.