TDD (Test Driven Development) is most important for a developer

Importance of TDD(Test Driven Development):


TDD (Test-Driven Development) starts with designing and developing tests for every small functionality of an application. In TDD approach, first, the test is developed which specifies and validates what the code will do.

In the normal Software Testing process, we first generate the code and then test. Tests might fail since tests are developed even before the development. In order to pass the test, the development team has to develop and refactors the code. Refactoring a code means changing some code without affecting its behavior.

Being a developer my objective is always deliver defect less code.Now question is how can i achieve this? There is no silver bullet tool in this world that promises you that your code is 100% defect less.You need to adopt and implement certain process that may not 100% guarantee you that your code is defect less but also makes sure you that your code is 100% tested, verified and bug free. As per my opinion TDD ( Test Driven Development) methodology is one of the best development practices to achieve this.

TDD Approach:

Step-1 Break your requirement into smaller unit.
Step-2 Then write small unit test case to fail for each of the small requirement.
Step-3 Then write code to correct fail test case and make it pass.
Step-4 Then refactor passed unit test case again to improve code quality until you or your boss satisfied.
Then repeat Step2...

What you have achieved at the end ?

  1. You actually fixed the bugs in very early stage before QA team introduce that and you maintain a very good code quality.
  2.  You felt more confident on your code by getting fast feedback from your own unit test result and you are now out of fear of ‘breaking’.
  3.  You've tested single responsibility of each of the unit and that will not fail in future by adding more units those have different responsibilities.
  4.  You saved lots of time to fix the bugs in QA cycle and become more productive. Indirectly you cut down lots of maintenance overhead from your organization and show them confident about painless roll-out of new software in production.

TDD Example

Step 1:  My requirement is to word "jyoti" is present in a HashMap with key '1'. The first test case will fail as "jyoti" is associated with key '2'.


Step 2: Then i made the correction to pass the test case. Now "jyoti" is asscociated with key '1' and test passed!

But this code need refactoring..


Step 3: Refactoring code.Now I am not using any Iterator, Map.Entry and Set




 Step 4: Ran the code coverage to check all code tested or not. Seems 100%


To learn about more Framework Technique click on link Behat Javascript Framework

Web Hosting

Jyoti Ranjan on EmailJyoti Ranjan on FacebookJyoti Ranjan on Linkedin
Jyoti Ranjan
13 years of working experience in using cutting edge technologies and well versed with Objects Oriented Software Design Patterns, Principles and best practices - SOLID, DRY, KISS, GRASP
Working knowledge in Java8, SpringBoot, Microservices, Spring Cloud, Kafka, CQRS, Netflix Api, Redis Cache, AWS, GCP, Junit, Mockito, Cobertura, Findbugs, Sonarqube, PMD.
Experience in RESTApi development using Spring Framework, RestTemplate, Consumer Contract Driven Testing (CDC) and Swagger.
Experience in CI/CD using Jenkins Pipeline, Github, Nexus, Docker, Kubernetes.
Experience in fixing security vulnerability issue using Checkmarx code scanner.
Proficient in writing the automation scripts using TestNG, Silk4j
Conduct performance test using Silk Performer, Jmeter and SoapUI
Experience in finding and fixing JVM memory leak issue using Jmeter, VisualVm and Eclipse-MAT
Very good team player with ability to work in a fast-paced agile development environment as well as individual contributor.

LinkedIn Profile:
Skype: jyoti.ranjan.gahan |

Specialties: #Java, #J2ee, #SpringBoot, #REST Api, #Microservices, #SpringCloud, #Netflix, #Kafka, #AWS, #Docker, #Kubernetes, #Hibernate, #Maven, #Git, #DesignPatterns, #DesignPrinciples, #CICD, #OOPSPrinciples, #SOLIDPrinciples, #CQRS, #TDD, #BDD, #TestNG, #Junit, #Cucumber, #Silk

Leave a Reply

Your email address will not be published. Required fields are marked *