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

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.

主站蜘蛛池模板: 民丰县| 邮箱| 平和县| 成都市| 广丰县| 都兰县| 广灵县| 海阳市| 肃南| 缙云县| 灵石县| 察哈| 改则县| 叙永县| 寿光市| 罗山县| 宁城县| 肃宁县| 许昌县| 衡水市| 天峨县| 孝感市| 东山县| 新民市| 普宁市| 万源市| 西盟| 安徽省| 郁南县| 神池县| 建水县| 昌乐县| 手机| 沐川县| 兴义市| 咸阳市| 浦江县| 南平市| 施秉县| 柞水县| 丰县|