Tetris and Software Testing

Jack Witham recently observed:

It’s hard to test software: even simple software!

He writes:

Tetris is one of the best-known computer games ever made. It’s easy to play but hard to master, and it’s based on a NP-hard problem.

But that’s not all that’s difficult about it. Though it’s a simple game that can be implemented in one line of BBC BASIC, it’s complex enough to be really hard to thoroughly test.

Ideally, a game tester has to try every possible action, in order to be sure that the game works correctly whatever the player does. But even in a simple game, there is so much to test!

Recently my employer Rapita Systems released a tool demo in the form of a modified game of Tetris. Unlike “normal” Tetris, the goal is not to get a high score by clearing blocks, but rather to get a high code coverage score. Tetris RapiCoverTo get the perfect score, you have to cause every part of the game’s source code to execute. When a statement or a function executes during a test, we say it is “covered” by that test.

I like it!

It’s a game and a tool.