Wednesday, February 8, 2023
HomeiOS Developmentios - Unit Check requestAuthorization for HealthKit

ios – Unit Check requestAuthorization for HealthKit


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)
    }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments