I attempted writing unit take a look at for requestAuthorization by producing a mock for HKHealthStore. However I acquired an error. Asynchronous wait failed: Exceeded timeout of two seconds, with unfulfilled expectations: “Efficiently examined requestAuthorization by returning true.”.
func testRequestAuthorization_CanReturnTrue() {
let expectation = expectation(description: "Efficiently examined requestAuthorization by returning true.")
sut?.requestAuthorization { licensed, error in
if error != nil {
print(error!)
}
guard let licensed = licensed else { return }
XCTAssertTrue(licensed)
expectation.fulfill()
}
wait(for: [expectation], timeout: 2)
}