I am not sure why but I am not able to read a json file in my Swift Unit Testing Project. What am I missing. the url is empty object and it is just jumping to the completion(nil) line 20.
See Question&Answers more detail:osI am not sure why but I am not able to read a json file in my Swift Unit Testing Project. What am I missing. the url is empty object and it is just jumping to the completion(nil) line 20.
See Question&Answers more detail:osYour code is using Bundle.main
, but you put the file in your test target(/bundle in the code context).
I'm not sure how to get the test bundle, but according to this question, you should be able to do this:
guard let url = Bundle(for: MockWeatherService.self).url(forResource: "openweathermap-response", withExtension: "json"),
and then the rest of your guard
statement