Quick Testing Tips: Write Unit Tests Like Scenarios

Posted on by Matthias Noback

I'm a big fan of the BDD Books by Gáspár Nagy and Seb Rose, and I've read a lot about writing and improving scenarios, like Specification by Example by Gojko Adzic and Writing Great Specifications by Kamil Nicieja. I can recommend reading anything from Liz Keogh as well. Trying to apply their suggestions in my development work, I realized: specifications benefit from good writing. Writing benefits from good thinking. And so does design. Better writing, thinking, designing: this will make us do a better job at programming. Any effort put into these activities has a positive impact on the other areas, even on the code itself.

Where do types come from?

Posted on by Matthias Noback

In essence, everything is a string.

Well, you can always go one layer deeper and find out what a string really is, but for web apps I work on, both input data and output data are strings. The input is an HTTP request, which is a plain-text message that gets passed to the web server, the PHP server, the framework, and finally a user-land controller. The output is an HTTP response, which is also a plain-text message that gets passed to the client. If my app needs the database to load or store some data, that data too is in its initial form a string. It needs to be deserialized into objects to do something and later be serialized into strings so we can store the results.

Quick Testing Tips: Testing Anything; Better Than Testing Nothing?

Posted on by Matthias Noback

"Yes, I know. Our tests aren't perfect, but it's better to test anything than to test nothing at all, right?"

Let's look into that for a bit. We'll try the "Fowler Heuristic" first:

One of my favourite (of the many) things I learned from consulting with Martin Fowler is that he would often ask "Compared to what?"

  • Agile helps you ship faster!
  • Compared to what?

[...]

Often there is no baseline.

-- Daniel Terhorst-North