- Learning Behavior:driven Development with JavaScript
- Enrique Amodeo
- 402字
- 2021-07-23 20:52:34
Summary
The test-first approach appeared as an engineering practice to back up the agile methodologies. It supports the notion of incremental design and implementation of the codebase in order to be able to deliver software fast, incrementally, and in short iterations.
The test-first approach tells us to first write the most simple failing test that we can think of, fix it with the smallest change of code possible, and finally, clean the code, changing the design if necessary and taking advantage of the fact that we have tests as a safety net. Repeat the cycle until there is no new failing test to write.
There are two main approaches to test-first: traditional TDD and BDD. In traditional TDD, or component unit testing, we test components (classes, functions, and so on) in isolation from other components. In BDD, we test simple user actions on the system, also known as features, in isolation from other features. Both are forms of unit testing, but due to historic reasons, we reserve the term "unit testing" for component unit testing.
In my opinion, the BDD approach is superior, because it relates the tests with the actual behavior of the system, making the progress of the project more visible, focusing the team on what really matters and decoupling the tests themselves from the specific details of the technical design. However, in big systems, it can be difficult to diagnose which components should be fixed when a feature fails, so some degree of traditional TDD is still useful.
Tests should be isolated to avoid coupling between them and enable fast detection of which feature/component must be fixed. They should also be fast to get a quick feedback cycle during development. Furthermore, tests should be repeatable; if not, we cannot trust their result, and they become a waste of time and money.
To make tests isolated, fast, and repeatable, we can use test doubles. They replace and impersonate third-party systems or components in our test suite. They can be used both to set up the system in a predictable way, hence achieving repeatability and quick execution, and to check the side effects produced by the system under test. In traditional unit testing, we can use them to isolate the component under test from other components.
This concludes the first chapter. Fortunately, it is the only one devoted to theory in this book. In the next chapter we will start coding!
- C語言程序設(shè)計案例教程
- Learning Cython Programming(Second Edition)
- Building a Home Security System with Raspberry Pi
- 編程卓越之道(卷3):軟件工程化
- 程序員面試算法寶典
- Data Analysis with IBM SPSS Statistics
- Building Serverless Applications with Python
- 西門子S7-200 SMART PLC編程從入門到實踐
- 深度學(xué)習(xí):Java語言實現(xiàn)
- Go語言精進(jìn)之路:從新手到高手的編程思想、方法和技巧(2)
- Learning Continuous Integration with TeamCity
- Spring Security Essentials
- Django 5企業(yè)級Web應(yīng)用開發(fā)實戰(zhàn)(視頻教學(xué)版)
- ROS機(jī)器人編程實戰(zhàn)
- Offer來了:Java面試核心知識點精講(框架篇)