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

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.

主站蜘蛛池模板: 白山市| 阳谷县| 新营市| 石城县| 大厂| 清新县| 若羌县| 潼南县| 平乐县| 阳新县| 肇东市| 博爱县| 湘乡市| 乌鲁木齐县| 民乐县| 万年县| 巴林左旗| 重庆市| 滕州市| 平潭县| 花莲县| 辽中县| 全南县| 平安县| 包头市| 灌阳县| 伊春市| 沽源县| 河北省| 顺义区| 安阳市| 行唐县| 余干县| 武胜县| 泾源县| 石屏县| 苗栗市| 涿州市| 班玛县| 永平县| 新邵县|