Start trefwoorden te typen om de site te doorzoeken. Druk enter om te verzenden.
Generative AI
Cloud
Testing
Artificial intelligence
Security
Test-Driven Development, or TDD, is one of the best practices of eXtreme Programming (XP). Test-driven development is a development method for software in which tests are written first and then the code. The name test-driven development is derived from Kent Beck, who put this technique on paper in 2002 and is credited for rediscovering the technique [Beck 2002]. The original description of TDD was written by D.D. McCracken in 1957 [McCracken 1957].
TDD has a lot of impact on the way in which development testing is organised these days. It is an iterative and incremental method of software development, in which no code is written before automated tests have been written for that code. The aim of TDD is to achieve fast feedback on the quality of the unit.
TDD is a design method. Design is superadditive (the whole is greater than the sum of its parts) and Test Driven Development (TDD) is about designing a solution to a problem.
One of the biggest problems with software development, is not knowing what will happen, when things interact. Our code might be used in scenarios we didn’t expect, and therefore our code might not be able to handle it. Applying TDD helps in identifying these unsuspected interactions.
[Reference: Uncle Bob]
At first glance these 3 laws might seem very unproductive, since it will require the developer to switch between writing unit-tests and code. But there are many benefits of doing that, which we will make clear in the following section.
The development cycle below is based on the book of Kent Beck. This cycle can be repeated as many times as needed to make the code fully functional according to the requirements.
The application of TDD has a number of big advantages. It leads to:
The theory of TDD sounds simple, but working in accordance with the TDD principles demands great discipline, as it is easy to backslide: writing functional code without having written a new test in advance. One way of preventing this is the combining of TDD and Pair Programming; the developers then keep each other alert.
TDD also has its limitations. One area where automated unit tests are difficult to implement is the Graphical User Interfaces (GUI). However, in order to make use of the advantages of TDD, the following strategy may be adopted:
TDD has the following conditions:
TDD can be amplified by Specification and Example (SaE) approaches, for example Acceptance Test Driven Development (ATDD) and Behavior Driven Development (BDD). The difference between ATDD and BDD is in the area that ATDD scenarios focus on the “what” question and BDD gives substance to the “how” question. These two also complement each other.
The figure shows how SaE approaches interact with TDD. SaE is shown on the left and TDD on the right.
Looking at the Agile testing quadrants, one sees that SaE and TDD apply to the left side of the quadrants. SaE is Business facing and involves the business analyst (BA) and testing roles. TDD is Technology focusing and fits within a Developer role, i.e. part of creating code. However, both have the goal of “Guiding the team”, in other words to help the team building the right system.
From a BA perspective, ATDD and BDD scenarios can be created which serve as input for performing Development tasks. The value of SaE scenarios in combination with TDD (and unit tests/component tests) is that they cover scenarios that comprise two or more units. A higher coverage at unit level can be pursued combined with a limited number of SaE scenarios. Consider, for example, a business process in which two sub-processes run parallel to each other. The separate sub-processes can be tested at unit level, but the interaction between the two can be covered at BDD and ATDD level.
By combining the different approaches, we can generate an effective and balanced set of scenarios. These scenarios can additionally be identified using test design techniques. Consider, for example, performing a boundary value analysis.
Building Blocks
Related wiki’sRisk PokerPlanning PokerRoot Cause Analysis (RCA) Specification and Example (SaE)Test-Driven Development (TDD)Clean Code-architectureCode MaintenancePair programmingPairingTest design techniquesCode reviewUnit Testing PrinciplesCode coverageFeature togglesMonitoring of product quality Parallel testingMutation testingPath Testing (algorithm test)