ios-testing
1
总安装量
1
周安装量
#49923
全站排名
安装命令
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-ios --skill ios-testing
Agent 安装分布
amp
1
opencode
1
kimi-cli
1
codex
1
github-copilot
1
Skill 文档
iOS Testing Skill
Build reliable iOS apps with comprehensive testing
Learning Objectives
By completing this skill, you will:
- Write effective unit tests with XCTest
- Create reliable UI tests
- Implement proper mocking strategies
- Debug efficiently with Instruments
- Achieve high code coverage
Prerequisites
| Requirement | Level |
|---|---|
| iOS Fundamentals | Completed |
| Swift | Intermediate |
| MVVM pattern | Basic |
Curriculum
Module 1: XCTest Fundamentals (4 hours)
Topics:
- XCTestCase structure
- Assertions library
- Test lifecycle (setUp/tearDown)
- Async testing
Code Example:
final class UserViewModelTests: XCTestCase {
private var sut: UserViewModel!
private var mockService: MockUserService!
override func setUp() {
super.setUp()
mockService = MockUserService()
sut = UserViewModel(service: mockService)
}
func test_loadUser_success() async {
mockService.result = .success(.mock())
await sut.loadUser(id: "123")
XCTAssertNotNil(sut.user)
XCTAssertFalse(sut.isLoading)
}
}
Module 2: Mocking & Test Doubles (4 hours)
Topics:
- Protocol-based mocking
- Spy, stub, fake patterns
- Dependency injection for testing
- Fixtures and factories
Module 3: UI Testing (5 hours)
Topics:
- XCUIApplication setup
- Element queries
- Accessibility identifiers
- Page Object pattern
- Handling flaky tests
Module 4: Debugging (4 hours)
Topics:
- LLDB commands
- Breakpoints (symbolic, conditional)
- View Debugger
- Memory Graph Debugger
Module 5: Performance Testing (3 hours)
Topics:
- XCTMetric usage
- Time Profiler
- Allocations instrument
- Leaks detection
Module 6: CI Integration (3 hours)
Topics:
- Xcode Cloud setup
- GitHub Actions
- Code coverage reports
- Test parallelization
Assessment Criteria
| Criteria | Weight |
|---|---|
| Unit test quality | 30% |
| Mock implementation | 20% |
| UI test reliability | 25% |
| Debugging skills | 15% |
| CI integration | 10% |
Coverage Targets
| Component | Target |
|---|---|
| ViewModels | 90%+ |
| Services | 85%+ |
| Utils | 95%+ |
| Views | 70%+ |
Common Mistakes
- Testing implementation â Test behavior instead
- Flaky UI tests â Use waitForExistence
- Missing tearDown â Clean up resources
- Slow tests â Use mocks, avoid network
Skill Validation
- Test Suite: 80% coverage on sample project
- Mock Library: Reusable mock implementations
- UI Test Flow: End-to-end login flow
- Performance Baseline: Measure scroll performance