Wednesday, 15 June 2011

Benefits of Test Driven Development for Startups

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first 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.


Enough has been said and written about Test Driven Development (TDD) and Behaviour Driven Development (BDD). However, I still find a lot of startups (especially small startups) not investing in TDD/BDD because they think its too much extra effort that slows down their development. In fact I am guilty of thinking the same way in the past and having switched over to the the TDD/BDD camp earlier this year, I wanted to put down my thoughts on why I think the extra effort is worth its while.


Test coverage helps you iterate faster


As any wise person would tell you, startups are all about execution. Your ability to execute on your ideas and iterate based on the feedback you get from your customers determines the success of your startup. Having a good test coverage gives you the confidence to change things in your codebase and not worry about breaking something unintentionally. I would even argue that if you don’t have test coverage, as your code base grows, you may come to a point where you may not want to make changes for the fear of breaking something.


Also writing tests (or behavior) first helps you in writing more modular and hence reusable code. Its easier to refactor or to add functionality to it. You should not consider tests simply as tests. You should think of them as specifications that help you drive your development. In fact thats what BDD is all about.


Manual Testing is not fun


One big reason I started looking at TDD was because I had gotten really bored of testing things manually. To give you an example, everytime I modified the payment logic for Muziboo, I would setup the paypal sandbox and test all the steps manually. If something failed, I would repeat the entire process. I found the entire thing very demotivating and also error prone. Automated testing frees you up and lets you focus on more exciting things.


Specs for your non Tech Founder


Tools such as cucumber help you specify what you are trying to achieve/test in plain english. They execute plain-text functional descriptions as automated tests. Here is an example:




Feature: Search courses
In order to ensure better utilization of courses
Potential students should be able to search for courses
 
Scenario: Search by topic
Given there are 240 courses which do not have the topic "biology"
And there are 2 courses A001, B205 that each have "biology" as one of the topics
When I search for "biology"
Then I should see the following courses:
| Course code |
| A001 |
| B205 |



These feature files can help even your non tech founder understand whats going on and what exactly the system does. Also, six months down the line, even you are gonna find it useful :)


Testing is Easy


The final point I want to make is that TDD/BDD is actually very easy and fun given the resources available. Right from awesome books to great tools, there are tons of resources to help you get started. There is a learning curve but once you are used to it, things can be very fast and productive. So do yourself a favor and adopt BDD




Generated by BlogIt

BlogIt - Auto Blogging Software for YOU!

BlogIt - autoblogging software for YOU

BlogIt - autoblogging software for YOU

No comments:

Post a Comment