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

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.

主站蜘蛛池模板: 延川县| 西城区| 彰化市| 武陟县| 安吉县| 宁海县| 铜鼓县| 淳安县| 陇川县| 阳信县| 将乐县| 天峻县| 合阳县| 海门市| 松桃| 墨竹工卡县| 枣庄市| 菏泽市| 衢州市| 荔浦县| 襄汾县| 安泽县| 晋州市| 类乌齐县| 龙里县| 驻马店市| 泸西县| 自贡市| 南乐县| 富源县| 贡嘎县| 淮安市| 贡山| 孝感市| 蓬安县| 曲周县| 赞皇县| 岱山县| 独山县| 额尔古纳市| 乌鲁木齐县|