How to start TDD/BDD PHP CodeIgniter

I have been reading about TDD/BDD for quite a while now but I could never figure out how to implement it in a project.

This is a simplified version of the project I am currently working :
A website that lets people signup, post used books for sale. People that needs these books can search for books posted for sale close-by and send an email message to the seller via the website.

This is being written in CodeIgniter with me as the only developer working on it. For this scenario, can you please tell me how exactly would I go about testing - where to begin with and what would be tested.

I've been wanting to do this for quite a while, I kind of understand the concept, but the actual implementation eludes me, many thanks!


The unit tester that shipped with the last version of CI I used was poor, it just checked true or not.

I found this interesting project which seemed to be maintained up to last year at least:

http://jensroland.com/projects/toast/

Maybe there is something there to help you get started, maybe in the readme files - if not here is the original post where this idea seems to have emanated from.

http://codeigniter.com/forums/viewthread/76703

You could start off by checking your models bring back an expected set of values. ie assert true that "get first 10 books" actually brings back 10 records - this means setting up a test database however, and being able to set up (fill with test data) and tear down that database at will. That is a bit of a bind, but in an MVC situation when starting with TDD it might be the easiest to get your head round.

TDD (ie the idea of developing test/code in that order) makes the most sense when creating your own classes - which you might think of as "helpers" in a typical CI setup.

链接地址: http://www.djcxy.com/p/7976.html

上一篇: JSMin使用问题

下一篇: 如何启动TDD / BDD PHP CodeIgniter