在终端中使用模拟器进行 OCUnit 应用测试
是否可以使用终端命令启动在模拟器中运行的应用程序测试?
谢谢
Is it possible to start an application test that runs in the simulator with a terminal command(s)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,我让它工作了。我的解决方案有些粗糙,可能并不适合所有情况。
在 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests
替换
为
您可以将固定用户主页移动到其他位置,但我认为您需要移动 .app 和 .octest 捆绑包。
将
-RegisterForSystemEvents
添加到测试包的OTHER_TEST_FLAGS
构建设置中。确保您的测试包包含运行脚本构建阶段,其内容
为为您的测试创建新方案。
您应该能够使用标准 xcodebuild 从命令行运行测试:
xcodebuild -workspace $(WORKSPACE_NAME).xcworkspace -scheme $(TEST_SCHEME) -configuration debug -sdk iphonesimulator
模拟器不能是运行,当时你要运行什么测试。
我希望这些信息是完整的,如果某些内容未按预期工作,请询问。
Yes, I got it to work. My solution is somehow rough and might not be suitable in every case.
In
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests
replace
with
You may move the fixed user home to a different location, but I think you would need to move the .app and .octest bundles along.
Add
-RegisterForSystemEvents
to theOTHER_TEST_FLAGS
build setting of your test bundle.Make sure your test bundle contains a run script build phase with the contents
Create a new scheme for your tests.
You should be able to run the tests from the command line using the standard xcodebuild:
xcodebuild -workspace $(WORKSPACE_NAME).xcworkspace -scheme $(TEST_SCHEME) -configuration debug -sdk iphonesimulator
The simulator must not be running, at the time you what to run the tests.
I hope this information is complete, if something doesn't work as expected please ask.
您可以使用以下命令确保模拟器未运行:
osascript -e 'tell app "iPhone Simulator" to quit'
您可以使用以下命令确定模拟器是否处于活动状态:
sh -c 'ps -xaco 命令 | grep“iPhone模拟器”'
You can ensure that the Simulator isn't running with this:
osascript -e 'tell app "iPhone Simulator" to quit'
You can determine if the Simulator is active with this:
sh -c 'ps -xaco command | grep "iPhone Simulator"'
工作完美,谢谢!
自动化测试在我们的 Jenkins CI 服务器上恢复运行!
只需修复我的
TEST_HOST=${BUNDLE_LOADER}
。如果运行测试时出现“没有此类文件”的错误,请执行此操作。Worked perfectly, thanks!
Automated testing is back in action on our Jenkins CI-server!
Just had to fix my
TEST_HOST=${BUNDLE_LOADER}
. Do this if you get errors about "no such file" when running the tests.Xcode 4.5GM 似乎现在支持在模拟器中运行应用程序测试。
It seems that with Xcode 4.5GM, running application tests in the simulator is now supported.