#1 How To Implement Your First Unit Test Case In IOS

ยท

2 min read

#1  How To Implement Your First Unit Test Case In IOS

Let's talk about Unit Test

What Unit Test ?

Every Smallest Testable Part of Application it's Called Unit, Simply Unit Test functionality for Every unit in your App

Why Unit Test ?

Advantage :

  • Debugging Process becomes easier ๐Ÿฅณ
  • Catch Problem Early ๐Ÿ˜
  • Make Change In Code Base ๐Ÿ‹๐Ÿปโ€โ™‚๏ธ
  • Makes you self-confident ๐Ÿง‘๐Ÿปโ€๐Ÿ’ป

file.jpeg

DisAdvantage :

  • Unit Test Will Not Cover Bug In Your App
  • Will Not Catch Error In an integration test

unit_tests.jpg

Let's Talk about Unit Test Pyramid

1_6M7_pT_2HJR-o-AXgkHU0g.jpeg

  • Pyramid Base: Unit Test It's Fast Because it runs in fake Http Request Or Dummy data
  • Pyramid Middle: Integration Test it Tests Your Web Service OR Test individual modules

  • Pyramid Top: UI testing is an important element of the software testing cycle. To validate whether applications have the desired functionalities

Main Topic In Article How To Implement Your First Unit Test in Xcode :

1# First Open Your Xcode And Create New Project

1-
Screen Shot 2022-03-19 at 5.41.11 PM.png

2- Screen Shot 2022-03-19 at 5.41.38 PM.png

3- Screen Shot 2022-03-19 at 5.42.23 PM.png

On the third Screen, We can See The Unit Test class All I Need is two function

  1. setup()
  2. tearDown()

I Will Talk About these two functions in another Article Screen Shot 2022-03-19 at 5.48.02 PM.png

Now We Can Write Our First Unit test Case

There is a way to write a test case function Screen Shot 2022-03-19 at 5.56.05 PM.png func test[YOUR CLASS NAME][YOUR TEST CASE] [What Should Return] () {}

I will Talk More about Unit Tests in other articles, Now You Can Implement Unit Test In Your Project and How-To implement Your First Test Case Thanks,

ย