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

Test-driven development approach

You will often hear about the test-driven development (TDD) approach, which basically means writing tests first. To simplify this, let's summarize this in the following three steps:

  1. Write tests and watch them fail.
  2. Implement functionality until you see your tests passing.
  3. Refactor to the best practices (optional).

I must admit that I really love this approach. However, the truth is that most developers will glorify this approach and barely any will use it. This is usually because it's time-consuming and it is hard to predict what the thing you are about to test looks like.

Going further, you will find that one of the test types is against TDD. Snapshot tests can only be created if the component is implemented, as they rely on its structure. This is another reason why snapshot tests are more of an addition to your tests rather than a replacement.

This approach works best in huge applications that go on for years, where a team of tech architects plan the interfaces and patterns to be used. This is most likely in backend projects, and you will have a general idea of how all of the classes and patterns connect to each other. Then, you simply take the interface and write the tests. Next, you follow up with implementation. If you want to create interfaces in React Native, you will need to support TypeScript.

Some argue that TDD is great in small projects, and you may quickly find such threads on Stack Overflow. Don't get me wrong; I'm happy that some people are happy. However, small projects tend to be very unstable and are likely to change often. If you are building a Minimum Viable Product (MVP), it doesn't work very well with TDD. You are better off relying on the fact that the libraries you use are well-tested and deliver the project on time, while quickly testing it with snapshots.

To summarize: abandoning TDD should not mean writing less tests.

主站蜘蛛池模板: 杭锦旗| 普安县| 揭东县| 尼勒克县| 财经| 镇坪县| 德令哈市| 长顺县| 广州市| 同江市| 乐业县| 太仆寺旗| 凌云县| 正定县| 昌吉市| 吉首市| 慈利县| 元氏县| 嵊州市| 柳河县| 镇远县| 盐城市| 磴口县| 邓州市| 桂阳县| 冕宁县| 文山县| 巨鹿县| 宝坻区| 米脂县| 儋州市| 封丘县| 岗巴县| 简阳市| 华蓥市| 广州市| 英德市| 微山县| 眉山市| 历史| 南安市|