Test Driven Development

I am very much attracted towards test driven development (TDD). A well made TDD makes sure that your code is solid and will pass the regression test. 30% to 40% project time can be saved using TDD.

JUnit philosophy is the key point here.

“At any point of time, when running a JUnit test code, always GREEN BAR should be displayed”

TDD process consists of

  • Write the test code
  • Run the test
  • Test will fail – RED
  • Now add the real code
  • Run the test
  • Test should pass – GREEN
  • Refactor the code.
  • Re-run the test code
  • Test code should pass – GREEN

Always use stubs and mock object in TDD. This helps for development in isolation and removes dependency on other modules for testing. TDD also makes integration easier.

Always try to follow interface depended development. Uphold the famous design principle “Program to interface and not to implementation”. This helps to replace stubs and mock objects during integration time.

This holds JUnit philosophy. The code will be cleaner and will always be working. Consider a project that is running for 1 year. If TDD is followed in such projects, it always make sure that none of the existing functionality is broken.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s