5

我正在尝试让单元测试在 CI (Jenkins) 中运行。我在网上看到了这篇文章,其中有一些技巧可以让测试在命令行中运行。我在一个具有单元测试默认设置的空项目上进行了尝试,并且那里的说明工作得很好,但是当我尝试在具有单元测试设置的现有项目上执行此操作时,我遇到了一个模棱两可的错误:

/bin/sh -c /Users/jzhwu/smule/magicpiano/build/MagicPiano.build/Debug-iphonesimulator/MagicPianoTest.build/Script-7C0B24BE155310BE001AC942.sh
/Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:266: note: Started tests for architectures 'i386'
Run unit tests for architecture 'i386' (GC OFF)
/Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:273: note: Running tests for architecture 'i386' (GC OFF)
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
UIPasteboard - failed to launch pasteboardd. Make sure it's installed in UIKit.framework/Support
2012-05-11 15:10:39:247 MP-Debug[24398:17003] loading model magic
2012-05-11 15:10:39:250 MP-Debug[24398:17003] loading model magic-analytics
2012-05-11 15:10:39.264 MP-Debug[24398:17003] Unresolved error Error Domain=NSCocoaErrorDomain Code=512 "The operation couldn’t be completed. (Cocoa error 512.)" UserInfo=0xa2c5ce0 {reason=Failed to create file; code = 2}, {
reason = "Failed to create file; code = 2";
}
2012-05-11 15:10:39.264 MP-Debug[24398:17003] Try deleting and reinstalling the app to fix this issue
/Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include: line 269: 24398 Abort trap: 6           "${TEST_HOST}" ${TEST_HOST_FLAGS} ${OTHER_TEST_FLAGS}
/Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:339: error: Test host '/Users/jzhwu/smule/magicpiano/build/Debug-iphonesimulator/MP-Debug.app/MP-Debug' exited abnormally with code 134 (it may have crashed).



** BUILD FAILED **


The following build commands failed:
        PhaseScriptExecution "Run Script" build/MagicPiano.build/Debug-iphonesimulator/MagicPianoTest.build/Script-7C0B24BE155310BE001AC942.sh
(1 failure)

忽略重新安装应用程序部分。那是来自应用程序代码。所以这告诉我它在运行时在某个时候崩溃了。单元测试在 Xcode 4 中运行得很好,我只是无法让它与命令行很好地配合。如果有任何帮助,我将 OCUnit 与 OCMock 一起使用。谢谢!

4

1 回答 1

0

我最近在使用我正在处理的应用程序时遇到了类似的问题。我继承了代码库,它没有测试设置,所以我必须构建它们。我曾尝试使用 Apple 的标准方法来根据他们的示例 iPhoneTests 项目设置项目,但它不起作用。我切换到 GHUnit,我能够让它更轻松地工作。如果您在编写测试方面不太远,我建议您切换。

文档非常好,对我来说可以从命令行和 Jenkins 运行。在我的应用程序中,我通过复制主目标、将 GHUnitiOS.framework 添加到构建并为我的单元测试类添加其他源来设置第二个测试目标。

我知道这可能不是您正在寻找的答案,但我希望它有所帮助!

于 2012-06-06T15:24:15.120 回答