Preface
1 Testing In Xcode
2 Continuous Integration test with Xcode
3 iOS UI Automation test with Instruments
4 Reference Resources
1-1 Why Unit Test
It is very convenient to test interface for somebody who supply interface
Measure time consumption
1-2 XCTest (Xcode’s framework for testing)
Subclass XCTestCase
Implement test methods
• - (void)testThatMyFunctionWorks
Use assertion APIs to report failures
• XCTAssertEqual(value, expectedValue);
1-3 Test Targets
Tests targets build bundles
• Test code
• Resources
Automatically included in new projects Existing projects can add test targets
1-4 The Principles of Testing
Test bundles are executed by a host process
• Injected into your app
• Hosting process provided by Xcode Resources for tests are not in the main bundle • Don’t use ti[NSBundle mainBundle]
• Use ti[NSBundle bundleForClass:[MyTest class]]
CommandGU Bu_ons in the Source Editor side bar Bu_ons in the Test Navigator xcodebuild
xcodebuild test
-
Gproject ~/Documents/MyApp.xcodeproj
-
Gscheme MyApp
-
Gdestination ‘pladorm=iOS, name=iPhone’
1-6 Asynchronous Testing
More and more APIs are asynchronous • Block invocations
• Delegate callbacks
• Network requests
• Background processing Unit tests run synchronously
1-7 Asynchronous Testing API
[self expectationWithDescription:@”Open Doc"];
[UIDocument openWithCompletionHandler:^(BOOL success) { XCTAssert(success);
[self fulfill]; }];
[self waitForExpectationsWithTimeout:2 handler:nil];
- (void)measureBlock: (void (^) (void)) block;
2-1 Why Continuous Integration?
• Enhances collaboration
• Improves sooware quality
• Catches problem quickly and automatically
• Broadens test coverage
• Gathers build and test history for your project
• Easily distributes builds IPA package to your team
2-2 OS X Server
Application that hosts the Xcode server
Hosted repositories
Devices
• Add and remove devices from your team
• Automatic device provisioning for testing
Remote login
• Support new a bot
• View the test results
2-3 Xcode Server Features
Easy setup with Xcode and OS X Server
Integrates with the Apple Developer program
Builds iOS and Mac projects
Runs tests on multiple devices and simulators
Produces IPA and PKG files
Issue tracking
2-4 What is a Bot?
Defining the schedule details to build
• Project and SCM information
When to build it
• Periodic, onGcommit, or manual
How to build it
• Shared scheme
• Static analysis
• Testing and devices
• Archives
Notifications
3-1 Why UI Automation Test
• Find bugs while you sleep
• Repeatable regressions tests
• Conveniently pressure test
3-2 What is UI Automation
• Automates UIKit based applications
• Integrated in Instruments
• JavaScript automation scripts
• The Principle
• Through code, isAccessibilityElement& accessibilityLabel
4-1 Reference Apple Docs
306__automating_user_interface_testing_with_instruments
Accessibility Programming Guide for iOS
intro_ui_automation
Testing_with_Xcode
UI Automation JavaScript Reference
4-2 Reference Books
Test iOS Apps with UI Automation.pdf
You also can refer the Demos in this Book:
4-3 Reference Demos
iPhoneCoreDataRecipes
google resource for KIF: http://www.oschina.net/translate/ios-ui-testing-with-kif