Phil Hassey - game dev blog
Phil Hassey as Snidely Whiplash
"You can't buy awesomeness.
You're born that way."

Archive for the 'PHP' Category

out of control!!!!

Tuesday, October 9th, 2007

Maybe it’s overkill… But I just wrote a class named “test_testtest” to test the “testtest” function which I will be using to test test generators that are for testing stuff.

TDD part 2

Wednesday, October 3rd, 2007

I’ve been using it for the past week to great success. I’ve found my test suite frequently finds tiny bugs that I add in by accident when adding in new features. It’s great having those bugs found and fixed immediately 🙂

I’m using TDD right now for building a PHP library which will be the core of a new medical records system. In the future it will be interesting to try it with a game. I don’t believe it would be useful for all aspects of game development, but if I rewrote the Galcon “core” or the Galcon network library, I think TDD would be quite useful in that case.

test driven development

Tuesday, September 25th, 2007

I’ve taken my first plunge into TDD today. Yesterday I read (skimmed) the book Test Driven Development by Example by Kent Beck. In the second section of the book Kent gave a step by step example of how to develop the xUnit testing framework in python. At the end of the section he recommended implementing your own version of xUnit for whatever language you will be testing so you can learn the methodology.

I considered using some of the existing PHP testing frameworks – but they were all rather large (>100k) and both included a lot of features I couldn’t see myself using. So I forged ahead with Kent’s advice and wrote my own testing framework, which I named “Testing”. The final results are:

testing.php – 2440 bytes – the Testing class
tests.php – 2508 bytes – the tests for testing the Testing class (say that 5x fast!)
run.php – 161 bytes – a couple lines of php to run the Testing tests

It was a challenging task, as I’ve not done TDD before, and I found it took me about 3-4 tries to actually “get it”. The first few times I just scrabbled at not knowing where to start. The 3rd time I ended up implementing the Testing class “the old fashioned way” – but then realized I was supposed to be using TDD – so I reimplemented it using TDD. The interesting bit is that by reimplementing it using TDD I was forced to make my testing framework testable – so I had to add in logging facilities early on in the process. I also uncovered several bugs while re-writing it.

All in all, it seems like TDD will be a useful tool in the project I’m working on – will keep you posted.