应用测试VS逻辑测试 [英] Application Tests VS Logic Tests

查看:59
本文介绍了应用测试VS逻辑测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

既然现在可以从Xcode在模拟器上运行应用程序测试,那么除了可能节省一点执行时间之外,将测试分为逻辑测试和应用程序测试还有什么好处?

Since application tests can now be run on the simulator from Xcode, what would the advantage be, apart from possibly a small saving in execution time, of still separating your tests into logic and application tests?

根据 Apple文档


  • 逻辑测试。这些测试在无尘室环境中检查代码的正确功能;也就是说,您的代码未在应用程序内部运行。逻辑测试使您可以组合非常具体的测试用例,以非常细粒度的级别(类中的单个方法)或作为工作流的一部分(一个或多个类中的多个方法)来执行代码。您可以使用逻辑测试对代码进行压力测试,以确保代码在运行中的应用程序不太可能出现的极端情况下正确运行。这些测试可帮助您生成健壮的代码,这些代码在以未预期的方式使用时可以正常工作。逻辑测试基于iOS Simulator SDK;但是,该应用程序未在iOS模拟器中运行:正在测试的代码在相应目标的构建阶段中运行。

  • Logic tests. These tests check the correct functionality of your code in a clean-room environment; that is, your code is not run inside an application. Logic tests let you put together very specific test cases to exercise your code at a very granular level (a single method in class) or as part of a workflow (several methods in one or more classes). You can use logic tests to perform stress-testing of your code to ensure that it behaves correctly in extreme situations that are unlikely in a running application. These tests help you produce robust code that works correctly when used in ways that you did not anticipate. Logic tests are iOS Simulator SDK–based; however, the application is not run in iOS Simulator: The code being tested is run during the corresponding target’s build phase.

应用程序测试。这些测试将检查正在运行的应用程序中代码的功能。您可以使用应用程序测试来确保用户界面控件(插座和动作)的连接保持在原位,并且在您处理应用程序时,控件和控制器对象可以与对象模型一起正常工作。由于应用程序测试仅在设备上运行,因此您还可以使用这些测试来执行硬件测试,例如获取设备的位置。

Application tests. These tests check the functionality of your code in a running application. You can use application tests to ensure that the connections of your user-interface controls (outlets and actions) remain in place, and that your controls and controller objects work correctly with your object model as you work on your application. Because application tests run only on a device, you can also use these tests to perform hardware testing, such as getting the location of the device.

推荐答案

与逻辑测试相比,应用程序测试实际上用于两种不同的事情:

Application tests compared to logic tests are really used for two different things:

逻辑测试 /单元测试用于测试一种或几种方法的很小的行为,例如鉴于我这样创建对象,某个属性的值是我期望的值吗?

Logic tests/unit tests are used to test very small behavior for one or a few methods, e.g. "Given that I create my object like this, is the value of a certain property what I expect it to be?"

应用测试用于测试全局,例如当我点击某个表视图单元格时,是否可以在详细视图中获得正确的数据?

Application tests however are used to test the big picture, e.g. "Do I get the right data in my detail view when I tap on a certain table view cell?"

这篇关于应用测试VS逻辑测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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