-
Unit Test 를 이용해서 Async API Call 테스트카테고리 없음 2022. 8. 9. 16:20
source Code
func test_duplicateCheck() { var result:[String:Any]? let expectation = self.expectation(description: "calling duplicate check") APIManager.shared.requestDuplicateCheck(phoneNumber: "010-9041-7421", email: "dmammmm@naver.com") { response in result = response print("returned something from api call") expectation.fulfill() // Marks the expectation as having been met } waitForExpectations(timeout: 10, handler: nil) XCTAssertNotNil(result) }
참고 자료: https://www.swiftbysundell.com/articles/unit-testing-asynchronous-swift-code/