I created a minimum project to test pre-actions script. In our UI Test cases, I want to perform the script before each test run. But I found the prescript only run before the 1st test case.
我创建了一个最小的项目来测试操作前脚本。在我们的UI测试用例中,我希望在每次测试运行之前执行脚本。但我发现处方只在第一个测试用例之前使用。
It is proved by say "Pre build scripts running."
. Could I know what is the reason?
这一点可以通过说“预编译脚本运行”来证明。我能知道原因是什么吗?
Xcode 14.3.1
Xcode 14.3.1
更多回答
优秀答案推荐
Because that's what it was designed to do: give you a chance to run something once before any tests run. It's completely external to the tests.
因为这就是它的设计目的:让您有机会在任何测试运行之前运行一次某些东西。它完全是测试之外的东西。
To run something before each test case, create an XCTestCase
subclass that executes what you want in its set-up. Then for each of your test suites, subclass this. (If any test suite has its own set-up, it should call the super
set-up first.)
要在每个测试用例之前运行一些东西,请创建一个XCTestCase子类,它执行您在其设置中想要的东西。然后,对于您的每个测试套件,将其细分为子类。(如果任何测试套件有自己的设置,它应该首先调用超级设置。)
更多回答
Yeah, I think that is by design too. Because in some scenarios, we want to uninstall / reinstall app before each tests, and that is unable to achieved in XCTest script, aka setup() or teardown(). So I think may be we could use shell command to do it. Well I would leave those tests to QA for manual run.
是的,我想这也是故意的。因为在某些情况下,我们希望在每次测试之前卸载/重新安装APP,而这在XCTest脚本中是无法实现的,也就是setUp()或tearDown()。所以我想我们可以使用外壳命令来做这件事。好吧,我会把这些测试留给QA进行手动运行。
我是一名优秀的程序员,十分优秀!