Test Driven Development For Software Developers

Introduction

In the current trend of software development, the developers are also taking part in testing activities;  not the final testing or QA support provided by the development team. In the software industry the client is looking for more quality, because the end user of each software application needs a quality product, so if you compromise with quality then the project will be closed and competitor may take up the deal.

What a developer should do, whenever application codes are developed, is test at the final stage and when they find some issue try to fix the issues and this phase is usually called “Bug Fix Phase” and we normally charge the client. Nowadays client questions are not ready to pay for the Bug fixing phase since the issues are created by a development organization, so everyone is looking for the trend of “FBQC – First Best Quality Code” concept.

Whenever a developer codes they are responsible to give their Best quality of code in the first time of writing code and minimize code rework or bug fixing by 99 percent --  can this be achieved? Is that your question?

My answer is “YES”, when you do test at each and every point of code then there won’t be any chances for bugs or quality issues.

Source: torontopubliclibrary.com

Note: “FBQC” – The Terminology is coined by me and I implemented it in our project for better quality in my organization.

Is there any Process for FBQC Concept?

Yes, there is a process which is usually suggested in the Agile Methodology of software development and that is called “TDD - Test-driven development”.

This will help to drive your software development with quality check points in each point of time and make sure the code is error free.

How is this possible, to check for Quality each moment?

Yes, many people won’t believe when I say, even most of you feel it's a joke, let me briefly give  an example and then at end of that example you say if  that is possible or not.

Please draw a line which is perfectly straight using pencil

You may feel this is what a perfect circle that you can draw to maximum perfection, but for a client “circle” is actually the rounded and smooth edged one.

                                   Source: brianlemay.com

Please draw a circle, but use a perfect circle using pencil

Now, I am using same Paper and Pencil to draw, also using equipment [Compass], which confirms 100% quality in each moment of time.
                           Source: brianlemay.com

Now, can you accept the tool looks small but how it helped to make the result clear as per expectation, the effort may be less or more compared to free hand drawing however  100% quality is guaranteed, this is how the TDD can give you quality delivery if the process is followed perfectly.

What is TDD

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.
               Source: istqbexamcertification.com

Steps of TDD Approach

TDD approach has the following sequence of steps,

1. Add a test

2. Run all tests and see if the new one fails

3. Write some code

4. Run tests

5. Refactor code

6. Repeat

               Source: agiledata.org

Test driven approach Sample

No Class/Method Implementation

First write test method and then develop the coding for application logic, Test method implemented, actual Class not implemented, Error generated.

 

Class available - No Methods Available

Test method implemented, actual Class implemented, but Method not implemented, Error generated,

 
 
Class/Methods Available

Class, Method implemented and Test verified, No Error Build Succeeded,

 

Test Results

Results, Executed and the Result is “Pass”,

code

Conclusion

TDD many feel has double the work, but once you start following it and get used to it then you feel the quality of code has improved from your previous deliverables, which can be witnessed in a span of six months and the time period will differ based on client, project, software and team members and other factors also.

All the best and try this approach and comment with your feedback.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now