Simple 6 step process to Test Driven Development
- Jun 23, 2022
- 2 min read
Updated: Aug 10, 2022
What is TDD?
Test Driven Development is a process whereby you would test first, then implement. Unit tests come first, actual implementation code next, followed by integration tests. Tests which ‘drive’ implementation is the basis of TDD.

Process Of TDD
TDD methodology follows a very simple 6 step process:
Write a test case: Based on the requirements, write an automated test case.
Run all the test cases: Run these automated test cases on the currently developed code.
Develop the code for that test case: If the test case fails, then, write the code to make that test-case work as expected.
Run test cases again: Run the test cases again and check if all the test cases developed so far are implemented.
Refactor your code: This is an optional step. However, it’s important to refactor your code to make it more readable and reusable.
Repeat the steps 1- 5 for new test cases: Repeat the cycle for the other test cases until all the test cases are implemented.

R – G – R – R
Red – write a failing test
Green – make it pass
Refactor – remove wasteful code and ensure that the test you wrote still passes – this promotes leaner code
Repeat until your task is completed.
Advantages
In essence, the development cycle quickens, as developers have much quicker feedback on mistakes and bugs.
Tests can serve as documentation to new coming developers.
Increasing returns - At first, learning and applying TDD will be challenging, but in the long run it will be a benefit.
Bugs will pop up at development time rather than after a deploy, or worse, when the user gets the system.
There are frameworks which allow mocking of exterior components or libraries, allowing you to focus solely on what you are creating.
Supports agile principles 100%.
Disadvantages
Initial ‘cost’ is generally high.
It is quite a mind shift for waterfall developers.
Agile software testing
TDD facilitates Agile. Smaller pieces of functionality are taken on in sprints. Unit tests are written upfront. Implementation is done, and system testing is performed. These system tests can be completely automated.
What is Behaviour Driven Development (BDD)?
BDD is a flavour of TDD.
Behaviour driven development.
Scenario. Walking to this very room. With TDD we have assertions to cover each point of significance, with BDD we only care about the result of the operation.
So, a TDD solution for getting to this room would be getting up from your chair, then walking in the direction of the meeting room. Each turn can be placed into a test on its own. In fact, every single move can be an assertion or test.
TDD Vs BDD – Key Differences
Create unit tests to help keep your code working correctly through incremental code changes. There are several frameworks that you can use to write unit tests, including some developed by third parties. Some test frameworks are specialized for testing in different languages or platforms. Test Explorer provides a single interface for unit tests in any of these frameworks. More Here:
Vishav Premlall
Innovation & IOT Consultant







Comments