Test Driven Development – All You Need to Know About


Test Driven Development is widely used for Agile Development that relies on very short development cycles. Agile development is basically an evolutionary approach to development where the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test and finally refactors the new code to acceptable standards.

The basic steps followed to achieve Test Driven Development are mentioned below

Identify and analyze what is required to achieve:
Analysis of ‘what’ is to be achieved is an important aspect for starting the activity. It involves a lot of pre-assessments and in-depth understanding. The time and effort spent on this activity greatly influences the budget of the program. As development advances the analysis done initially become more and more valuable as many functionalities get added to the existing code on top of the existing code.

Create a test that will fail:
Write the test as if the code already exists.

This will ensure that the code fails at all times. But this is a meaningful failure that is used to achieve a desired functionality and it is always expected to fail

Write code that will pass:
Now as the test is identified that has already failed then develop the code such that the test will pass. Keeping the code simple and independent is an essential aspect while creating the code. Once sure that the code is written sufficiently correct that the failing test will pass, proceed to running all the earlier tests that have passed to ensure that the existing code is not impacted by addition of the new code.

Refactor the code:
Once completely satisfied, identify the repetition and update the code to optimize it.

Crudely written code needs to be upgraded to smart, smooth and flawless code. Once done rerun all the passing tests that will ensure that they still pass as before and code changes have not disturbed any of the existing functionalities. Proceed in this way till the required is achieved

Benefits of Test Driven Development can be highlighted as below

– Debugging of the code is highly reduced
– This approach drives the design of the program as this includes pre-assessment and in-depth understanding of the achievement
– Because of the step-by-step approach the code becomes shorter, manageable and be easily maintained.
– Modularization is increased with reduction in the interdependencies so a lesser chance of untoward errors occurring.
– The test cases written and completed get very thorough developed automatically.
– Shortcomings of the Test Driven Development approach.
– Test Driven Development falls short where full functional tests are required to determine the success or failures.
– The quality and the coverage of the Unit tests indirectly determine the project budget and the maintainability.
– Heavily relying on the unit tests may possibly have impacts on the integration aspects.
– Without the proper structure of implementation the efforts spent using this approach themselves become a burden on the organization.
–  Add on functional testing services and performance-testing services from various departments will have to be brought in to the cycle to achieve complete coverage.

The article above is a bird’s view of the Test Driven Development Approach. Also discussed are the benefits and shortcomings for the same. It is left on individual discretion to weight the pros and cons against the development approach feasible enough to achieve maximum benefits.

View the original article here

Send your news stories to [email protected] and via WhatsApp on +233 244244807
Follow News Ghana on Google News


Please enter your comment!
Please enter your name here