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

Duplicating fields

The Git tag for this section is duplicating-fields.

We've written a set of tests that fully define the firstName text field. We now want to add two more fields, which are essentially the same as the firstName field but with different id and labels.

Before you reach for the copy and paste, stop and think about the duplication you could be about to add to both your tests and your production code. We have six tests that define the first name. We'll end up with 18 tests to define three fields. That's a lot of tests without any kind of grouping or abstraction.

So, let's do both. Let's group our tests and abstract out a function that generates our tests for us.

主站蜘蛛池模板: 宿迁市| 兰西县| 南岸区| 江源县| 双鸭山市| 温泉县| 扶沟县| 双江| 灵武市| 玉山县| 江永县| 阿尔山市| 鱼台县| 红河县| 万州区| 佛坪县| 册亨县| 太康县| 英吉沙县| 高清| 大足县| 克拉玛依市| 独山县| 金昌市| 高清| 民和| 萨嘎县| 东乌珠穆沁旗| 县级市| 津南区| 濮阳市| 嘉祥县| 休宁县| 霍城县| 历史| 五原县| 海门市| 镇坪县| 兖州市| 泗水县| 嘉禾县|