- Hands-On Design Patterns with React Native
- Mateusz Grzesiukiewicz
- 331字
- 2021-08-13 15:12:57
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:
- Write tests and watch them fail.
- Implement functionality until you see your tests passing.
- 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.
- iOS Game Programming Cookbook
- 測試驅(qū)動開發(fā):入門、實(shí)戰(zhàn)與進(jìn)階
- Mastering Selenium WebDriver
- JavaScript 網(wǎng)頁編程從入門到精通 (清華社"視頻大講堂"大系·網(wǎng)絡(luò)開發(fā)視頻大講堂)
- 深入淺出DPDK
- CKA/CKAD應(yīng)試教程:從Docker到Kubernetes完全攻略
- H5頁面設(shè)計:Mugeda版(微課版)
- Teaching with Google Classroom
- Julia高性能科學(xué)計算(第2版)
- CoffeeScript Application Development Cookbook
- C專家編程
- Flink技術(shù)內(nèi)幕:架構(gòu)設(shè)計與實(shí)現(xiàn)原理
- HTML5與CSS3權(quán)威指南
- Serverless從入門到進(jìn)階:架構(gòu)、原理與實(shí)踐
- OpenCV:Computer Vision Projects with Python