2012-05-11 58 views
5

我試圖讓單元測試在CI(Jenkins)中運行。我在網上遇到了這樣一些駭客,讓測試在命令行中運行。我嘗試了一個空的項目,默認的單元測試設置和那裏的指令工作得很好,但是當我嘗試在已經有單元測試設置的項目上做這件事時,我得到一個模棱兩可的錯誤:在命令行上運行iOS單元測試的問題(OCUnit + OCMock)

/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) 

忽略resinstall應用程序部分。這是從應用程序代碼。所以這告訴我它在運行時崩潰在某個點上。單元測試在Xcode 4中運行得很好,我只是無法讓它與命令行一起玩。如果有任何幫助,我在OCMock中使用OCUnit。謝謝!

+0

你有沒有找到這個解決方案?我也有同樣的問題。嘗試從命令行運行Cedar測試,並得到相同的「無法創建文件;代碼= 2」錯誤 – AFraser

+0

不幸的是,我從來沒有找到一個解決方案。我最終將測試(以前的應用測試)改爲邏輯單元測試,並且運行良好。 –

回答

0

最近我遇到了一個類似的問題,我正在使用一個應用程序。我繼承了代碼庫,它沒有測試設置,因此我必須構建這些代碼。我曾嘗試使用Apple的標準方法根據其示例iPhoneTests項目設置項目,但它沒有奏效。我轉而使用GHUnit,並且能夠讓工作更輕鬆。如果你在寫測試時不太感興趣,我會建議切換。

docs真的很不錯,爲我從命令行和詹金斯運行。 在我的應用程序中,我已經設置了第二個目標進行測試,方法是複製主目標,將GHUnitiOS.framework添加到構建中併爲我的單元測試類添加其他來源。

我知道這可能不是您正在尋找的答案,但我希望它有幫助!