I have been wanting to learn TDD
for a long time now and finally took the plunge and bought a book over
it. It is “Test Driven Development in Microsoft .NET.” I have only
started the book, but already I understand TDD
a little more than what I did before and most of that has to do with a
few steps it laid out quite simply. It is basically the process you
go through when writing your code.
- Write the Test Code
- Compile the Test code (It should fail since you haven’t implemented anything yet)
- Implement just enough to compile
- Run the Test to see it fail
- Implement just enough to make it pass
- Run test to see it pass
- Refactor for clarity and eliminate duplication
- Repeat from top
For me I understood this, even though it was till hard to
figure out, but what I didn’t “get” that was ok to have happen was step
2 which is in bold. It is ok for your compiled test to not compile.
The great thing about TDD is that it is one of those things you can do in almost any language I mean heck you can do TDD with PHP. PHPunit.