Whenever I TDD a project with XUnit style tools, I have difficulty getting my head in the right spot. I find that using tools designed for Behaviour Driven Development or "Specification by example" makes it easier for me to do TDD right -- i.e. focus on design, exposing intent and describing behaviour in specific contexts. Not testing.
That said, I would like to introduce pecs into the conversation. From the readme on the project site.
pecs is a tiny behavior-driven development library for PHP 5.3, a la RSpec or JSpec.
If you've used JSpec or better yet, Jasmine-BDD (for JavaScript) the pecs style of describing behaviour should be really familiar. I find this style great for component level specs. If you are looking for a PHP tool for feature level specifications (stories or user acceptance tests) consider Behat.
Going back to pecs, here's an example culled from the pecs project site:
describe("Bowling", function() {
it("should score 0 for a gutter game", function() {
$bowling = new Bowling();
for ($i=0; $i < 20; $i++) {
$bowling->hit(0);
}
expect($bowling->score)->to_equal(0);
});
});
Yes that is a PHP spec. Looking through the pecs source, it looks like the author is able to pull this off by leveraging the new hotness in PHP 5.3+, Lambdas and closures. So I guess this means that you cannot use pecs in any project based on PHP < 5.3 (just FYI).
Also, pecs is not as mature as PHPUnit or SimpleTest. However, I think the proponents of BDD in the PHP community should support the growth of tools like pecs that encourage "Specification by example" or BDD without the confusion brought on by having to use legacy XUnit testing tools.
These days I work more in Python than PHP. However, the next time I pick up a PHP project, I'll be extremely happy if I have a mature, community supported tool like pecs to craft the specifications for the software.