PHP in Action Rotating Header Image

Posts under ‘Testing’

Don’t refactor without unit tests

Image by niallkennedy via Flickr Brandon Savage is writing a series on code improvement using a code example (starting with Peer Review: Taking Code And Making It Better). In other words, it’s about refactoring, which is practically my favorite subject. Although I don’t agree with all of it, it’s mostly good advice. I recommend it. [...]

One behavior != one assertion

Image by libbyrosof via Flickr The debate on the “one assertion” principle continues. Pádraic Brady and I agree on the general principle, but since he is so categorical in his second article, I needed to inspect his reasoning more closely. It’s clear that our disagreement is more than superficial. The more I think about it, [...]

One assertion per test—always?

Image via Wikipedia Pádraic Brady pleads for the principle that a unit test method should have only one assertion. His point is perfectly valid; there are several good reasons why one assertion per method is a smart guideline when writing unit tests. But since he drags up the term “lazy”, I feel the need for [...]

How to test everything

They say there’s no free lunch, but at least there’s free breakfast. Last week I attended a “breakfast seminar” with Robert C. Martin (Uncle Bob). There really was free food. Anyway, Uncle Bob held an extremely entertaining and useful introduction to the FitNesse testing tool. He got me hooked on it, but I’m even more [...]

Zend_Test

I admit I don’t follow Zend Framework very closely, since I haven’t been using it for any serious work. But I did write a piece about testing a Zend Framework action controller with View Helpers. This might need updating, since the testing capabilities of the Zend Framework have grown substantially since then. In particular, there [...]

More beautiful code

I got some interesting comments to my previous post on “beautiful code”. Some were pretty strong disagreements. So am I wrong? Did I get carried away? Did my critical faculty go on vacation somewhere nice and sunny? I admit that sometimes I deliberately look at the positive and ignore the negative. (And sometimes I do [...]

Beautiful code

Max Horwath has published his slides on Making Selenium Test Writing easier using a DSL onlinefrom IPC 2008. Let me quote the whole short description: Implementing automated tests by using Seleniums API methods has several drawbacks. Selenium is great for what it does, providing a generic framework for testing a generic application. Using the Testing_SeleniumDSL [...]

Many test methods versus custom assertions

This is something I posted to the Sitepoint PHP Application Design Forum with a little bit of added background. The background is the idea that unit test methods, for the sake of readability, should test only one single behavior. This may mean several tests for one method under test, since one method may have several [...]

Testing a Zend Framework action controller with View Helpers

I came across a Zend Framework (ZF) example I wanted to refactor. You really have to have unit test coverage to refactor effectively, and since there were no tests, I started trying to find out how to test it. There didn’t seem to be a wealth of information available on the web, so I’ve tried [...]

The psychology of test-driven development

Silvan Mühlemann has written an excellent piece titled Unit testing makes coding more fun. I keep saying that sort of thing, too. I also say it raises your IQ. But when I attended a presentation by Uncle Bob (Robert C. Martin) last summer, I was mildly shocked to see that he described TDD as tedious [...]