iOS 的单元测试与 UI 测试
我有一个 iPhone 应用程序。我应该进行单元测试还是 UI 测试,或者两者都是必要的。
如果 UI 测试足以测试模型,我将使用 Instruments。
如果进行单元测试,我计划使用 OC 单元测试。我是新手。我浏览了一些教程,但似乎都很模糊。我对此没有什么疑问。
我的前屏幕是一个包含用户名和密码的登录页面。如何验证用户是否输入了两个文本字段或没有输入?我使用界面生成器来创建屏幕。我的 IBAction 方法 [ -(void)login:(id) sender] 验证用户名和密码。 那么如何使用这个方法,针对各种场景进行单元测试呢?测试时应该传递什么来代替 (id) 发件人?
成功登录后,页面导航到另一个具有表格视图的视图。 tableview需要进行哪些单元测试?
提前致谢。
I have an iphone application. Should i do unit testing or UI tesitng or is both necessary.
If UI testing is sufficient to test the models I will use Instruments.
If unit testing I'm planning to use OC Unit test. I'm new to it. I went through some tutorials but all seem to be very vague. I have few doubts in that.
My front screen is a login page that has username and password. How to verify if the user has entered both the textfields or none?? Im using interface builder to create the screen. My IBAction method [ -(void)login:(id) sender] verifies the username and password.
Now how to use this method and perform unit testing for various scenarios? What should be passed in place of (id) sender while testing?After succesful login the page navigates to another view which has table view. What unit testing to be done for tableview?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如,请观看使用 Xcode 进行单元测试上的这组视频。
您面临的麻烦之一是当您没有连接或响应时从服务器获取响应。
解决方案是使用模拟(例如 OCMock)来假装您有这些响应,或者调用响应直接调用的方法。
至于测试多少——尽可能多地进行。自己测试并让其他人为您测试,因为他们不会以与您相同的方式使用它。尽可能自动化测试,使用运行您的应用程序功能的脚本来测试应用程序。随机测试它,做错误的事情以确保您的应用程序正常失败。
没有必要询问我们您是否进行过测试,这由您决定。但请考虑一下,如果您问“我测试得足够多了吗?”,您的应用程序的用户会给您什么反应。
For examples have a look at this set of videos on Unit Testing With Xcode.
The trouble you are facing is one of getting responses from a server when you do not have a connection or a response.
The solution is to use mocks, such as OCMock to pretend you have those responses, or to call the methods that would have been called by responses directly.
As for how much testing - do as much as you can. Test it yourself and get others to test it for you because they won't be using it the same way as you. Automate testing where you can, test the app with a script that runs you through the functionality of your app. Test it randomly, doing the wrong thing to make sure that your app fails gracefully.
There's no point asking us if you have performed testing, that's for you to decide. But think about the response the user of your app will give you if you ask - "Have I tested enough?".