Friday, August 27, 2010

Test This

If I had to write a script for testing an elevator, when I got to the section where I had to push buttons, I would write something like this:

def pushFloorButtons(floor)

for 1..10 do |floor|

My script would never have anticipated the elevator I got on today:

And yes, I did get off at 2.5. It looked a lot like 2. Just another parking garage.


  1. I remember that I once saw these kind of buttons on an overseas ferry with three or four parking decks. They had decks that could be split in case fewer trucks were on board. Very useful.

    I think I would have written the tests by iterating over the buttons rather than iterating over the model of the building. But your example shows that our internal model of the world influences how we test to a large extent.

  2. So, are you sure you got of at 2.5? Or do you trust what the elevator's telling you?

  3. ..and this is just another proof that automated tests should be data-driven, or, at least, parameterized :)

    Seriously, if you say "an elevator" why you hard-code so much stuff based on the elevator model of expectations?