How to run a fresh install of the application every time unit tests are run?

人走茶凉 提交于 2019-12-03 16:06:32

问题


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?


回答1:


Maybe this works, but only for Simulator.

In Product > Scheme > Edit Scheme...

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 :(




回答2:


In addition to @rintaro's answer, if you set "Provide build settings from" to your app, you can add a generic command, which will keep working when your bundle id changes:

xcrun simctl uninstall booted ${PRODUCT_BUNDLE_IDENTIFIER}


来源:https://stackoverflow.com/questions/26185341/how-to-run-a-fresh-install-of-the-application-every-time-unit-tests-are-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!