Модульное тестирование UIImage с URL - PullRequest
0 голосов
/ 24 апреля 2018

Я пытаюсь проверить функцию, которая создает изображение из URL.Мой юнит-тест выглядит так:

func testImageFromURL() {

    //when testing callbacks use a testExpectation
    let testExpectation = expectation(description: "Format function timed out")

    //1.Given
    let dictPhotoData = ["isfriend":false, "farm": 1, "id":"40946679254", "server":"875", "secret":"c6e491e979", "owner":"138560875@N08", "title":"Is it spring yet? Eastern garter snake (Thamnophis sirtalis)", "ispublic":true, "isfamily":false] as [String : Any]

    //2.When
    let thisPhotoObj = FF_PhotoObject(dictPhotoData)
    if let thisPhotoURL = thisPhotoObj?.photoUrl as? URL {

        myAPIManager.getImageFromData(thisPhotoURL, completion: { (_ thisImage:UIImage) in

            //3. Then
            //-->Not sure what to test for here.
            testExpectation.fulfill()

        })
    }

    waitForExpectations(timeout: 7) { error in
        if let error = error {
            XCTFail("waitForExpectationsWithTimeout errored: \(error)")
        }
    }
}

Я просто не уверен, что тестировать UIImage.

...