xcode XCTest - “测试失败”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19378922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XCTest - "Test failed"
提问by Tatarasanu Victor
I'm trying to add tests to a mac app. I'm using XCTest framework. When i run tests (cmd + U) i receive "Test failed" and in console I see :
我正在尝试向 mac 应用程序添加测试。我正在使用 XCTest 框架。当我运行测试(cmd + U)时,我收到“测试失败”并在控制台中看到:
2013-10-15 13:22:56.354 8tracks Radio[40560:303] Error loading /Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest/Contents/MacOS/MusicaTests: dlopen(/Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest/Contents/MacOS/MusicaTests, 262): no suitable image found. Did find:
/Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest/Contents/MacOS/MusicaTests: open() failed with errno=1IDEBundleInjection.c: Error loading bundle '/Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest'
Any ideas? Cheers!
有任何想法吗?干杯!
回答by Benjamin Smith
You need to disable code signing in order to run unit tests. This pageexplains how to create a configuration for testing so that your debug and release applications are code signed but your unit tests are not. Don't forget to do a full clean after changing the configuration.
您需要禁用代码签名才能运行单元测试。此页面解释了如何创建用于测试的配置,以便您的调试和发布应用程序经过代码签名,但您的单元测试没有。更改配置后不要忘记进行全面清理。
回答by mekarthedev
I had the same "no suitable image found" issue when was trying to add tests to an existing ios project. Try to go to Build Settings of your Tests target and set "Build Active Architecture Only" to "No". This solved my issue.
尝试向现有 ios 项目添加测试时,我遇到了相同的“找不到合适的图像”问题。尝试转到测试目标的构建设置并将“仅构建活动架构”设置为“否”。这解决了我的问题。
Also, make sure you have the same Architecture for both targets or you'll get strange linker errors.
另外,请确保两个目标的架构相同,否则会出现奇怪的链接器错误。
回答by cicerocamargo
I was facing a different issue but was seeing the same log. For the problem was that the deployment target of the tests target was higher than the iOS version of the simulator that I was trying to use.
我遇到了不同的问题,但看到了相同的日志。问题是测试目标的部署目标高于我尝试使用的模拟器的 iOS 版本。
I hope this helps someone.
我希望这可以帮助别人。