- Mastering React Test:Driven Development
- Daniel Irvine
- 125字
- 2021-06-24 14:45:09
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.
推薦閱讀
- JSP網絡編程(學習筆記)
- Power Up Your PowToon Studio Project
- Ext JS Data-driven Application Design
- Learning ASP.NET Core 2.0
- Python金融數據分析
- 編譯系統透視:圖解編譯原理
- AppInventor實踐教程:Android智能應用開發前傳
- Mastering JavaScript Design Patterns(Second Edition)
- RSpec Essentials
- 動手學數據結構與算法
- 大話Java:程序設計從入門到精通
- Android Development Tools for Eclipse
- Hacking Android
- Drupal Search Engine Optimization
- Mastering PowerCLI