Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 18.104.22.168 release ready!
In the previous part, we have already know how to set up the unit testing in Xcode project & some basic functionality.
In this blog, we will discuss how to test the Network Call (Asynchronous function).
In-Network call we have to wait until the data will come to its totally Asynchronous function so that we have to wait in method until the result will come for that swift provide “expectation”
With the help of this, we can handle Network call.
Here are Some Steps you need to follow this
here we have taken the example through “URLSession”
Valid URL: https://itunes.apple.com/search?media=music&entity=song&term=abba
here we are checking the URL response is valid or not.
Here we have taken the “expectation” class to hold the network call response.
We have taken two Test checking method
1: XCTAssertNil(responseError,”Any String Value”) . if responseError returns nil then there is no issue.
2: XCTAssertEqual(statusCode, 200) if statusCode == 200 then no issue
if any matches fail then you will get the test fail result.
For checking the error case you just change the URL’s string or Invalid URL & check.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.