Description
All iOS unit tests in NexusClientURLSessionTests.swift are stub methods with TODO comments. No actual test logic has been implemented, resulting in 0% test coverage for iOS code.
Problem Location
jnexus-ios/Tests/Shared/NexusClientURLSessionTests.swift
All 8 test methods are TODOs:
testCacheHit() - line 29
testCacheMiss() - line 37
testCacheExpiry() - line 44
testRetryOnTimeout() - line 54
testNoRetryOn4xx() - line 61
testPagination() - line 70
testParseBasicResponse() - line 79
testParseMetadataResponse() - line 86
Impact
- Zero coverage: iOS HTTP client has no automated tests
- Regressions: Changes can break functionality without detection
- Platform parity: Android has 13 tests, Desktop has 155 tests, iOS has 0 real tests
- Trust: Cannot confidently release iOS app without test coverage
- Maintenance: Refactoring is risky without safety net
Test Implementation Blockers
The TODO comments mention needing URLProtocol mocking, which suggests the tests require:
- Mock URLSession responses
- Network interception/stubbing
- Time mocking for cache expiry tests
Recommended Approach
Use URLProtocol for network mocking:
class MockURLProtocol: URLProtocol {
static var requestHandler: ((URLRequest) throws -> (HTTPURLResponse, Data))?
override class func canInit(with request: URLRequest) -> Bool {
true
}
override class func canonicalRequest(for request: URLRequest) -> URLRequest {
request
}
override func startLoading() {
guard let handler = MockURLProtocol.requestHandler else {
fatalError("Handler not set")
}
do {
let (response, data) = try handler(request)
client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
client?.urlProtocol(self, didLoad: data)
client?.urlProtocolDidFinishLoading(self)
} catch {
client?.urlProtocol(self, didFailWithError: error)
}
}
override func stopLoading() {}
}
Example test implementation:
func testCacheHit() async throws {
// Configure mock
let config = URLSessionConfiguration.ephemeral
config.protocolClasses = [MockURLProtocol.self]
MockURLProtocol.requestHandler = { request in
let response = HTTPURLResponse(url: request.url!, statusCode: 200, httpVersion: nil, headerFields: nil)!
let json = "{\"items\": [], \"continuationToken\": null}"
return (response, json.data(using: .utf8)!)
}
// Test cache hit
let client = NexusClientURLSession(credentials: credentials, session: URLSession(configuration: config))
_ = try await client.listComponents(repository: "test", forceRefresh: false)
XCTAssertTrue(client.isCached("test"))
_ = try await client.listComponents(repository: "test", forceRefresh: false)
// Second call should use cache, not make HTTP request
}
Priority
High - iOS app has zero automated testing
Related
Acceptance Criteria
Description
All iOS unit tests in NexusClientURLSessionTests.swift are stub methods with TODO comments. No actual test logic has been implemented, resulting in 0% test coverage for iOS code.
Problem Location
jnexus-ios/Tests/Shared/NexusClientURLSessionTests.swift
All 8 test methods are TODOs:
testCacheHit()- line 29testCacheMiss()- line 37testCacheExpiry()- line 44testRetryOnTimeout()- line 54testNoRetryOn4xx()- line 61testPagination()- line 70testParseBasicResponse()- line 79testParseMetadataResponse()- line 86Impact
Test Implementation Blockers
The TODO comments mention needing URLProtocol mocking, which suggests the tests require:
Recommended Approach
Use URLProtocol for network mocking:
Example test implementation:
Priority
High - iOS app has zero automated testing
Related
Acceptance Criteria