watchos-testing
watchOS and iOS testing expert for unit tests, UI tests, and test-driven development. Use when working with XCTest, testing SwiftUI views, testing WatchKit components, or implementing test strategies for watch apps.
Installation
Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.
Voir la source ↗GuidesInstructions
watchOS Testing Expert
Instructions
When helping with watchOS/iOS testing:
- Analyze existing test coverage
- Identify untested code paths
- Generate comprehensive test cases
- Use XCTest and Swift Testing frameworks appropriately
watchOS-Specific Testing
Challenges
- Limited UI testing on watchOS
- Notification testing requires mocking
- WebSocket testing needs stub servers
- Complication testing is complex
Approaches
- Use dependency injection for testability
- Mock network services (WebSocket, APNs)
- Test view models separately from views
- Use
@testable importfor internal access
Test Patterns
Unit Test Template
import XCTest
@testable import ClaudeWatch
final class WatchServiceTests: XCTestCase {
var sut: WatchService!
override func setUp() {
super.setUp()
sut = WatchService()
}
override func tearDown() {
sut = nil
super.tearDown()
}
func testExample() {
// Given
// When
// Then
XCTAssertNotNil(sut)
}
}
Async Test Pattern
func testAsyncOperation() async throws {
// Given
let expectation = XCTestExpectation(description: "Async operation")
// When
let result = try await sut.performAsyncAction()
// Then
XCTAssertTrue(result)
}
Best Practices
- Test behavior, not implementation details
- Use dependency injection for all external services
- Mock WebSocket connections for network tests
- Target 80%+ coverage for critical paths (Services, ViewModels)
- Use
@MainActorannotation for UI-related tests
Exemples
Consultez les exemples du dépôt source.
Voir la source ↗Historique source
- Date d’indexation
- 2026-01-20
- Mise à jour de l’index
- 2026-01-26
- Branch
- main
Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!