- 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.
- 認(rèn)識(shí)編程:以Python語言講透編程的本質(zhì)
- 學(xué)Python也可以這么有趣
- Learning DHTMLX Suite UI
- 組態(tài)軟件技術(shù)與應(yīng)用
- Visual Basic程序設(shè)計(jì)
- C和C++游戲趣味編程
- ASP.NET程序開發(fā)范例寶典
- Learning Node.js for .NET Developers
- 并行編程方法與優(yōu)化實(shí)踐
- MyBatis 3源碼深度解析
- 深度學(xué)習(xí)程序設(shè)計(jì)實(shí)戰(zhàn)
- 計(jì)算機(jī)組裝與維護(hù)(第二版)
- Software-Defined Networking with OpenFlow(Second Edition)
- Mastering Leap Motion
- SQL Server 2014 Development Essentials