Writing Integration Tests for Your Network Layer Using URLProtocol | by Karthik Shiva | Mar, 2022

Picture by Vojtech Bruzek on Unsplash
  1. Create a URLProtocol subclass and implement the above given obligatory strategies
  2. Register your URLProtocol subclass with the system in your AppDelegate’s software (_:didFinishLaunchingWithOptions:) technique.
  3. Assign the kind of your URLProtocol subclass to the protocolClasses property of URLSession. Don’t create an occasion of your subclass since that is taken care of by the system mechanically.

1. Community layer

2. View Mannequin

3. View Controller



Static properties on URLSessionProxy

  1. contactedURLs: [URL]
  1. Create a view mannequin delegate and fulfill an expectation on the delegate technique name, in order that we all know that its time to examine the view mannequin for the mock posts [String]
  2. Configure URLSessionProxy to return a mock response
  3. Name viewDidLoad() on the view mannequin to start out the method

More Posts