官术网_书友最值得收藏!

Building your first automatic unit test

If you have done some iOS development (or application development in general) already, the following example might seem familiar to you.

You are planning to build an app. You start collecting features, drawing some sketches, or your project manager hands the requirements to you. At some point, you start coding. After you have set up the project, you start implementing the required features of the app.

Let's say an app is an input form, and the values the user puts in have to be validated before the data can be sent to the server. The validation checks, for example, whether the email address looks like it's supposed to and the phone number has a valid format. You implement the form and check whether everything works. But before you can test, you need to write code that presents the form on the screen. Then, you build and run your app in the iOS simulator. The form is somewhere deep in the view hierarchy. So, you navigate to this view and put the values into the form. It doesn't work. Next, you go back to the code and try to fix the problem. Sometimes, this also means that you need to run the debugger, and build and run to check whether the code still has errors.

Eventually, the validation works for the test data you put in. Normally, you would need to test for all possible values to make sure that the validation not only works for your name and your data, but also for all valid data. But there is this long list of requirements on your desk, and you are already running late. The navigation to the form takes three taps in the simulator, and putting in all the different values just takes too long. You are a coder after all.

If only a robot could perform this testing for you.

主站蜘蛛池模板: 共和县| 密云县| 双辽市| 庆安县| 临朐县| 六安市| 辰溪县| 玉环县| 新野县| 乐山市| 竹溪县| 师宗县| 梁河县| 石城县| 八宿县| 安塞县| 靖远县| 溧水县| 葵青区| 肃宁县| 利辛县| 巴林左旗| 龙里县| 吉林市| 白河县| 桐梓县| 扶绥县| 西华县| 锦屏县| 汾西县| 巴青县| 塔城市| 库伦旗| 高州市| 新丰县| 阿瓦提县| 龙川县| 阿拉善右旗| 金昌市| 沂水县| 丁青县|