<分区>
我正在为现有应用程序的功能编写单元测试。
我不知道如何编写单元测试
我有做上述事情的功能。 有些事情需要手动干预,例如第一项需要用户执行操作。
任何关于编写单元测试用例的想法都会对我有很大帮助。
最佳答案
据我所知,很难编写需要用户干预的单元测试用例。 Basically, unit tests are written to test the entire functionality of the application (mostly positive scenarios) and check whether you get expected result. It is the means by which you can ensure that your functionality works and used many a times while building the project.
也就是说,单元测试在项目部署之前执行,并且在开发阶段执行得更多,开发人员需要运行所有单元测试用例以确保他/她的更改不会影响应用程序的其余功能.
单元测试必须在它们自己的意义上是完整的,这意味着对于特定的测试用例,这是输入,这是收到的输出,期间!没有别的。
对于完整的自动化测试,您可以在其中合并动态用户 inputs you can maybe think of using Selenium or other frameworks or you will have to write wrappers for your own or can just simulate the user input while reading or writing the user input from certain external file or like that
.
例如,您可以在调用电话时从文件或语音记录中提供一些任意输入...或者从图库中选择一些预先确定的图像并测试您的应用程序是否按预期工作
我想从这个答案中提出的是,根据我的观点,单元测试的完整概念不同于需要用户干预的测试。我的假设可能是错误的!
关于ios - 如何使用 XCode 在 IOS 中进行单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38436545/