Test driven Development (TDD)
In
age of agile framework TDD is very important because what we are going to
implement is more valuable than how we are going to implement. It doesn’t mean
that I am advocating of missing the how, it is really important but when we
start to work on any feature/component/part/product we must know In and out of
that, and to ensure that I advise to go with TDD.
TDD is a grouping of TFD (Test First development)
and Re-factoring, so we can depict it as below:
Test à Code à
Re-factor
Now it’s easy to understand that in agile framework development
team (in agile known as feature team) job is to first write the tests before
writing the code. So before implementation all tests should fail and after
implementation tests should pass, and even if tests fails, code should be
re-factored and tests again to ensure it passes. They should add more tests
after re-factoring to make sure that it won’t miss any functional testing.
To go with TDD, feature team and any management
involved should have the mindset accordingly as quality of development is the
key agenda of this philosophy and need focused team who should understand well
the requirements.
Let me elaborate that how to approach of writing
tests before code modules exists.
In agile framework,
feature team members chooses the feature to implement and feature team is
getting involved to understand the requirement as well, so they know that what
feature they are going to implement. They should start writing Unit tests
considering that what input would be for your feature and what output feature
will produce. You can write all the possible tests considering the feature
module as a black-box (abstract). Since module is not implemented all tests
should fail, and now start writing the feature implementation code, and again
run all the tests and all should pass, re-factor the code if required and again
test and so on.
JUnit can be used for Java based development,
Selenium can be used for java based web development, DBUnit can be used for DB
development, Fitnesse can be use for User acceptance testing etc. You can use
mocking for unit testing as per your requirement.
Benefit:
The aim behind TDD is
to motivate feature team (development team) to understand the requirement well
before writing any code which ensures fast development and minimal bug. Another
aim is that it is always easy to trace any error or bug in initial stage as
number of lines of code is less and can be re-factored that time itself.
Find below blogs written for me for writing TDD:
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home