Test Doubles | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/8458722-testing-in-ios/lessons/15

Hi Jessy

Thank you for the tutorial. I noticed the tests in the final project for this episode crash.
Below is the error message -

DogPatch[54511:2941039] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[_TtCFVFC13DogPatchTests20AsynchronousTestCase11test_clientFzT_T_L_17FakeDataTaskMaker8dataTaskFT4withV10Foundation3URL17completionHandlerFTGSqVS2_4Data_GSqCSo13NSURLResponse_GSqPs5Error___T__CSo20NSURLSessionDataTaskL_12FakeDataTask _onqueue_resume]: unrecognized selector sent to instance 0x7ff42012a510’

Could you please help with this?
Thank You

Sorry, this initializer was already deprecated, but since this course came out, it has become truly broken.

final class FakeDataTask: URLSessionDataTask {
  override init() { }
}
return FakeDataTask()

You can replace it with any sort of URLSessionDataTask. For example:

return URLSession.shared.dataTask(with: Self.dummyURL)