Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS 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!
Owner and Founder. Opencart
Unit testing is a basic way to check the first phase of your code , it will help to check your model classes & Network Call in the App . so it helps & saves lot of time
of manual testing. In this part we will provide , how to setup the unit testing in the App.
there is various way to add the Unit testing in the new App or Existing App.
a: In New App : Check on Unit test.
b: In Existing App:
You can take the Unit test File in various way
b.1 : Go to file section & take a Unit Test File
b.2 : Click on test navigator option then click on bottom + sign & take a Unit test file.
After Set the file now its time to write the code.
When you open the file you will get
func setUp() : This method will call at first when this class will load so any kind of setup you can do in this class like variable initialisation or model initialisation.
func tearDown(): This method will call ,when All your test method is executed so in this section you can free-up the memory .
func testExample() : This is Test method that will run after the setUp method , you will create your own but you need to append test on start of any method name
ex: testHomeAPI(), testMySample()
func testPerformanceExample(): this will give the total time of your test classes.
For Accessing the project in Test Class file you need to import your project module like this.
1: select your project target -> Build setting – > Product Module name
Write this way in your Test Class file:
Now you can access all the classes of your project ,
Here i have taken one example of my project model class .
Here we are accessing the model class of our project & do some checking .
Before running there is some method you need to know first here we have taken some method for example.
1: XCTAssertNil(responseError,“Message in String”) : if nil is passed then no issue other wise it show the error
2: XCTFail(“Error: \(error.localizedDescription)”) : if you want to fail the test use this method.
3:XCTAssertTrue(true) : if there is no issue then use this.
4:XCTAssertEqual(statusCode, 200,”Message write here”) : it will compare the value if equal then no issue other wise show the error.
Here we have taken few method
Now run the test cases
there is various way to run the test classes.
1: Long press on project run button then it will show test option
2: Go to Test App navigator option
here you can see All the test classes & their method as well so select which classes you have to run just tap on run button
Next Blog Link: https://mobikul.com/unit-testing-in-ios-using-swift-part-2/
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.