April 2015
Intermediate to advanced
556 pages
17h 47m
English
In ScheduleFetcherTests, you currently only have a single test (testResultFromValidHTTPResponseAndValidData(_:)) against ScheduleFetcher’s method resultFromData(_:response:error:). This test verifies the behavior of the method when it is passed valid JSON data and an OK (200) HTTP response.
Write two more tests against resultFromData(_:response:error:). In the first test, call the method with a 404 response and no data. In the second test, call the method with a 200 response and invalid JSON data.
Invalid JSON data here means data that cannot be used by NSJSONSerialization. One way to create invalid JSON data is by turning a string into data:
let invalidJsonDataString = "This ...
Read now
Unlock full access