iosアプリケーションの unit test

51
iPhone SDK 勉強会 iOSアプリケーションの Unit Test

Upload: katsumi-kishikawa

Post on 22-May-2015

11.859 views

Category:

Technology


0 download

DESCRIPTION

iOSアプリケーションの Unit Testフレームワークについて

TRANSCRIPT

  • 1. iPhone SDK iOS Unit Test

2. iPhone SDK URLiOS App Development Workow Guidehttp://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/ios_development_workow/135-Unit_Testing_Applications/unit_testing_applications.html 3. iPhone SDK 4. iPhone SDK (UI) iPhoneetc. 5. iPhone SDK / 6. iPhone SDK (etc) 7. iPhone SDK ( 8. iPhone SDK - (id)init {self = [super init];if (self) {service = [[LDRService alloc] init];service.delegate = self;}return self;[self init] nil }100% 9. iPhone SDK / 10. iPhone SDK 11. iPhone SDK OCUnit (aka SenTestingKit)GHUnit 12. iPhone SDK OCUnit (aka SenTestingKit)GHUnit GHUnit 13. iPhone SDK OCUnit GHUnit 14. iPhone SDK OCUnit GHUnitXcode XcodeXCodeUI UIAssert AssertsetUpClass OCUnit View 15. iPhone SDK OCUnit GHUnit CI CI 16. iPhone SDK (OCUnit) 17. XcodeiPhone SDK 18. iPhone SDK (GHUnit) 19. iPhone SDK 20. iPhone SDK 21. iPhone SDK 22. iPhone SDK 23. iPhone SDK (OCUnit) 24. iPhone SDK 25. iPhone SDK 26. iPhone SDK 27. iPhone SDK (GHUnit) 28. iPhone SDK 29. iPhone SDK Assert (OCUnit) 30. iPhone SDK STFailSTAssertEqualObjectsSTAssertEqualsSTAssertEqualsWithAccuracySTAssertNilSTAssertNotNilSTAssertTrueSTAssertFalseSTAssertThrowsSTAssertThrowsSpecificSTAssertThrowsSpecificNamedSTAssertNoThrowSTAssertNoThrowSpecificSTAssertNoThrowSpecificNamedSTAssertTrueNoThrowSTAssertFalseNoThrow 31. iPhone SDK Assert (GHUnit) 32. GHAssertNoErr(a1, description, ...)GHAssertErr(a1, a2, description, ...)iPhone SDK GHAssertNotNULL(a1, description, ...)GHAssertNULL(a1, description, ...)GHAssertNotEquals(a1, a2, description, ...)GHAssertNotEqualObjects(a1, a2, desc, ...)GHAssertOperation(a1, a2, op, description, ...)GHAssertGreaterThan(a1, a2, description, ...)GHAssertGreaterThanOrEqual(a1, a2, description, ...)GHAssertLessThan(a1, a2, description, ...)GHAssertLessThanOrEqual(a1, a2, description, ...)GHAssertEqualStrings(a1, a2, description, ...)GHAssertNotEqualStrings(a1, a2, description, ...)GHAssertEqualCStrings(a1, a2, description, ...)GHAssertNotEqualCStrings(a1, a2, description, ...)GHAssertEqualObjects(a1, a2, description, ...)GHAssertEquals(a1, a2, description, ...)GHAbsoluteDifference(left,right) (MAX(left,right)-MIN(left,right))GHAssertEqualsWithAccuracy(a1, a2, accuracy, description, ...)GHFail(description, ...)GHAssertNil(a1, description, ...)GHAssertNotNil(a1, description, ...)GHAssertTrue(expr, description, ...)GHAssertTrueNoThrow(expr, description, ...)GHAssertFalse(expr, description, ...)GHAssertFalseNoThrow(expr, description, ...)GHAssertThrows(expr, description, ...)GHAssertThrowsSpecific(expr, specificException, description, ...)GHAssertThrowsSpecificNamed(expr, specificException, aName, description, ...)GHAssertNoThrow(expr, description, ...)GHAssertNoThrowSpecific(expr, specificException, description, ...)GHAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...) 33. iPhone SDK SetupClass/tearDownClass (GHUnit) 34. implementation MyTest//iPhone SDK - (void)setUp { }//- (void)tearDown { }//- (void)setUpClass { }//- (void)tearDownClass { }// Tests are prefixed by test and contain no arguments and no returnvalue- (void)testA { }// Another test; Tests are run in lexical order- (void)testB { }// Override any exceptions; By default exceptions are raised, causing atest failure- (void)failWithException:(NSException *)exception { }@end 35. iPhone SDK (GHUnit) 36. #import iPhone SDK @interface LDRLoginTest : GHAsyncTestCase {SEL currentTest;}@end@implementation LDRLoginTest- (void)testLoginSucceeded {[self prepare];currentTest = _cmd;LDRService *service = [LDRService service];service.delegate = self;service.username = @"kishikawakatsumi";service.password = @"password1234";[service login]; [self waitForStatus:kGHUnitWaitStatusSuccess timeout:10.0];} 37. - (void)serviceLoginSucceeded:(LDRService *)service {if (service.APIKey != nil) { iPhone SDK [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testLoginSucceeded)];} else {[self notify:kGHUnitWaitStatusFailure forSelector:@selector(testLoginSucceeded)];}}- (void)service:(LDRService *)serviceloginFailedWithError:(NSError *)error { [self notify:kGHUnitWaitStatusFailureforSelector:@selector(testLoginSucceeded)];}@end 38. iPhone SDK OCUnit (GHUnit) 39. OCUnit iPhone SDK OCUnit 40. iPhone SDK View (GHUnit) 41. #import iPhone SDK @interface LoginViewTest : GHViewTestCase@end#import "LoginViewTest.h"#import "LoginViewController.h"@implementation LoginViewTest- (void)testLoginViewController {LoginViewController *viewController = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil];GHVerifyView(viewController.view);}@end 42. iPhone SDK 43. iPhone SDK iOS OCUnit GHUnitGHUnit 44. iPhone SDK GHUnit 45. iPhone SDK 46. iPhone SDK 47. iPhone SDK 48. iPhone SDK 49. iPhone SDK 50. iPhone SDK 51. iPhone SDK #import #import "AppDelegate.h"int main(int argc, char *argv[]){@autoreleasepool {return UIApplicationMain(argc, argv, nil, @"GHUnitIOSAppDelegate");}}