OCUnit iPhoneã§ãã¹ããã¡ã¼ã¹ã UnitTestã使ã (iPhone cocoa)
ãã¡ããããªãåèã«ãã¾ããâ
OCUnitのTestCase作成 - /var/log/seiji
ãã®æ¥è¨ã¯ãã¦ããããã¹ãã®çµé¨è
ã対象ã«æ¸ãã¦ãã¾ãã
ã¦ããããã¹ãã«ã¤ãã¦ã¯ããã¡ãã®ãã¼ã¸ã®æ¬ãã¨ã¦ãåèã«ãªãã¾ããâ
CppUnitの使い方 - かえるカウンセラーの日記
OCUnitã®ã¤ã³ã¹ãã¼ã«
http://www.sente.ch/software/ocunit/
âãã¡ãããOCUnitããã¦ã³ãã¼ããã¾ãã
ä»åã®æ¥è¨ã¯ãOCUnitRoot-v41.dmgããã¦ã³ãã¼ããã¦æ¸ãã¦ãã¾ãã
ãã¦ã³ãã¼ããããã¤ã³ã¹ãã¼ã«ãå§ã¾ãã¾ãã
ä»åã¯æ¨æºçãªè¨å®ã§ã¤ã³ã¹ãã¼ã«ãã¾ãããï¼æ¬¡ã¸ãã¿ã³é£æï¼
ã¤ã³ã¹ãã¼ã«ãçµãã£ããã念ã®ããåèµ·åãã¾ãããã
ããã¸ã§ã¯ãã®ä½æ
ã¾ããæ®éã«iPhoneã¢ããªã±ã¼ã·ã§ã³ã®ããã¸ã§ã¯ããä½æãã¾ãã
Window-Based Applicationã§ãããã¸ã§ã¯ãåã¯UnitTestJikkenã¨ãã¦ä½ã£ã¦ã¿ã¾ãããã
UnitTestç¨ã®ã¿ã¼ã²ããã®ä½æ
ãã°ã«ã¼ãã¨ãã¡ã¤ã«ãããã¿ã¼ã²ãããå³ã¯ãªãã¯ãã¾ãã
ã追å ãâãæ°è¦ã¿ã¼ã²ããããé¸ã³ã¾ãã
Mac OS Xã®ä¸ã«ããCoCoaãé¸æã
Unit Test Bundleãé¸æããã次ã¸ããã¿ã³ãæ¼ãã¾ãã
ã¿ã¼ã²ããåããUnitTestTargetã¨ãããå®äºããã¿ã³ãæ¼ãã¾ãã
ããã¨ããã¿ã¼ã²ãã "UnitTestTarget"ã®æ
å ±ããéãã¾ãã
ä¸ã«ããããã«ãããé¸ã³ã¾ãã
å·¦ä¸ã®ã表示ãã®ãªã¹ãããã¯ã¹ããããã¹ã¦ã®è¨å®ããé¸ã³ã¾ãã
ãâ¼ãªã³ã¯ãâãä»ã®ãªã³ã«ãã©ã°ãã
-framework Foundation -framework SenTestingKit
ã¨å¤æ´ãã¾ããï¼CocoaãFoundationã«å¤æ´ããï¼
å·¦ä¸ã®ã表示ãã®ãªã¹ãããã¯ã¹ãããã¦ã¼ã¶å®ç¾©è¨å®ããé¸ã³ã¾ãã
GCC_DYNAMIC_NO_PICããGCC_PREFIX_HEADERã¾ã§ãåé¤ã
ï¼ä»¥ä¸ã®ãã®ãæ®ãã¾ããï¼
GCC_C_LANGUAGE_STANDARD
GCC_WARN_ABOUT_RETURN_TYPE
GCC_WARN_UNUSED_VARIABLE
ãã¿ã¼ã²ãã "UnitTestTarget"ã®æ å ±ããéãã¾ãã
ãã¹ãã±ã¼ã¹ã®ä½æ
ãã°ã«ã¼ãã¨ãã¡ã¤ã«ãããUnitTestJikkenãå³ã¯ãªãã¯ãã¾ãã
ã追å ãâãæ°è¦ã°ã«ã¼ããã§ãTestCasesã¨ããã°ã«ã¼ããä½ãã¾ãããã
TestCasesãå³ã¯ãªãã¯ããã追å ãâãæ°è¦ãã¡ã¤ã«ããé¸ã³ã¾ãã
Mac OS Xã®Cocoaãé¸æããObjective-C test case classãé¸æãã¾ãã
ã次ã¸ããã¿ã³ãæ¼ãã¾ãã
ãã¡ã¤ã«åã«HogeTest.mã¨ã¤ãã¾ãããã
ãã¿ã¼ã²ãããã®ã¨ããã§ãUnitTestJikkenã®ãã§ãã¯ãå¤ãã
UniteTestTargetã«ãã§ãã¯ãå
¥ãã¾ãã
ãå®äºããã¿ã³ãããã¾ãã
ããã¦ãHogeTest.mã以ä¸ã®ããã«ç·¨éãã¾ãããã
#import "HogeTest.h" @implementation HogeTest - (void)testHoge { STAssertEquals(0, 0, @"å¼ã£ããããªã"); STAssertEquals(0, 1, @"å¼ã£ããã"); } @end
ãã¹ãã®å®è¡
ãã°ã«ã¼ãã¨ãã¡ã¤ã«ãã®ãã¿ã¼ã²ãããâãUnitTestTargetããå³ã¯ãªãã¯ã
ã"UnitTestTarget"ããã«ãããé¸æã
ããã¨ãã¨ã©ã¼ä¸è¦§ã«ã
Line Location HogeTest.m:17ï¼ error: -[HogeTest testHoge] : '0' should be equal to '1': å¼ã£ããã
ãã®ããã«è¡¨ç¤ºããã¾ãã
è¦äºã«ã¦ããããã¹ããå®è¡ããã¾ããã
ãªãããã°ã«ã¼ãã¨ãã¡ã¤ã«ãã®ãã¿ã¼ã²ãããâãUnitTestTargetãããã©ãã°ãã¦ããã¿ã¼ã²ãããâãUnitTestJikkenãã®ä¸ã«ãããããããã¨ãåºæ¥ã¾ãã
ããããã¨ãUnitTestJikkennãããã«ããã¦é²è¡ãããã ãã§ãã¦ããããã¹ããå®è¡ããããªã«ãå¼ã£ããããªããã°ããã°ã©ã ãå®è¡ãããããã«ãªãã¾ãã
iUnitTest iPhoneã§ãã¹ããã¡ã¼ã¹ãã使ã (iPhone cocoa)
æ©éå®é¨ãã¦ã¿ã¾ããã
http://github.com/katsuyoshi/iunittest/tree/master
âãã¡ããããã¦ã³ãã¼ããã¾ãã
ã¤ã³ã¹ãã¼ã«ã¯ã¿ã¼ããã«ããè¡ãã¾ãã
詳ããã¯ReadMe.txtãåç
§ã
ã¤ã³ã¹ãã¼ã«ããæ°è¦ããã¸ã§ã¯ããé¸æããã¨ã
UserTemplatesã®ä¸ã«ãiUnitTestApplicationãå¢ãã¦ãã¾ãã
ãã£ããããã§ããã¸ã§ã¯ããä½æã
ããã¦ãæ°è¦ãã¡ã¤ã«è¿½å ãé¸æããã¨ã
UserTemplatesã®ä¸ã«ãiUnitTestã¨ããã®ãããã
IUTTest subclassã¨ããã®ãé¸ã¹ã¾ãã
ãã¡ãã§åºæ¥ä¸ãã£ãã¹ã±ã«ãã³ãè¦ãã°ã
ã¦ããããã¹ãçµé¨è
ãªããåé¡ãªã使ããã§ãããã
ã¹ã±ã«ãã³ãç·¨éãããã®ã¾ã¾ãã«ããã¦é²è¡ãé¸ã¶ã¨ã
1 failure Test1.m:40 -[Test1 test1] not implemented
ã¨ã°ã©ãã£ã«ã«ã«è¡¨ç¤ºããã¾ãã
ã¾ããiPhoneä¸ã§åä½ããã®ããè©ä¾¡ãé«ãã§ãã
åé¡ã¯ãã¢ããªã±ã¼ã·ã§ã³ã¨ãã¦ã¦ããããã¹ããåä½ãã¦ãããã¨ã
main.mãMainWindow.xibããã£ã¬ã¯ããªã®ä¸ã«åå¨ãã¦ãã¾ã£ã¦ãã¾ãã
å®éã«ä½ãä¸ããã¢ããªã±ã¼ã·ã§ã³ã®ããã¸ã§ã¯ãã¨ãåããã£ã¬ã¯ããªã«
ç½®ã訳ã«ã¯ãããªãã®ã§ããã®è¾ºãã©ãããããèããå¿
è¦ãããã¾ãã
ã¨ã¯ãã£ã¦ããXcodeã¯è¤æ°ããã¸ã§ã¯ããç«ã¡ä¸ãããããã
ã½ã¼ã¹ã¯ããã¸ã§ã¯ããã¡ã¤ã«ã¨ã¯å¥ã®å ´æã«ãã£ã¦ã大ä¸å¤«ãªã®ã§ã
ãã¾ãåé¡ã¯ãªãããããã¾ããã