如何在每次运行单元测试时运行全新安装的应用程序? [英] How to run a fresh install of the application every time unit tests are run?

查看:132
本文介绍了如何在每次运行单元测试时运行全新安装的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的应用程序设置了一些 XCTest 单元测试,并希望每次运行测试时都要在全新安装的应用程序中运行。目前,当我运行后续测试时,它会在之前运行的同一个应用程序中运行测试,之前的测试已经更改了很多状态信息。

I've setup some XCTest unit tests for my application and would like every time I run tests for it to run in a brand new install of the application. Currently when I run subsequent tests it runs the tests in the same application that was run before which has a lot of state information already changed by the previous tests.

是否有方式表明当你运行单元测试它应该在你的应用程序的新版本上运行测试?

Is there a way to indicate that when you run unit tests that it should run the tests on a fresh version of your application?

推荐答案

也许这个但只能用于模拟器。

Maybe this works, but only for Simulator.

产品> Scheme > 编辑方案...

xcrun simctl 是命令行实用程序控制iOS模拟器。
这会在运行测试之前从启动模拟器中卸载 com.yourcompany.AppName 应用程序。

xcrun simctl is command line utility to control the iOS Simulator. This uninstalls com.yourcompany.AppName application from booted simulator before running tests.

我不知道如何为真实设备做这样的事情:(

I don't know how to do like this for real device :(

这篇关于如何在每次运行单元测试时运行全新安装的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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