Home > Articles > Programming

  • Print
  • + Share This
From the author of

From the author of

Smart Monkeys

Moving up on the evolutionary scale is the smart monkey. Such a monkey takes the effectiveness of random testing from his less-intelligent brothers and adds to that an awareness of his surroundings. He doesn't just pound on the keyboard randomly—he pounds on it with a purpose.

A true smart monkey knows

  • Where he is

  • What he can do there

  • Where he can go

  • Where he's been

  • If what he's seeing is correct

Does this list sound familiar? It should. A smart monkey can read the software's state transition map, a formalized diagram that breaks the software into basic states, or conditions, and shows the means for moving from one state to the next). If the monkey can read all the state information that describes the software, it could bounce around the software just like a user would, only much more quickly, and be able to verify things as it went.

A smart monkey testing the Windows Calculator (see Figure 2) would know what buttons are available to press, what menu items are present, and where to type in the numbers. If it clicked the Help menu's About Calculator option, it would know that the only ways out were to click OK or the Close button. It wouldn't randomly click all over the screen, eventually stumbling onto one of them.

Figure 2

A smart monkey would know how to close the Calculator About dialog box.

A smart monkey isn't limited to just looking for crashing bugs, either. It can examine data as it goes, checking the results of its actions and looking for differences from what it expects. If you programmed in your test cases, the smart monkey could randomly execute them, look for bugs, and log the results. Very cool!

Figure 3 shows a smart monkey called Koko, named after the gorilla that could speak in sign language. To program Koko, you feed it the table that describes your software by defining each state, the actions that can be performed in that state, and claims that determine whether the result of executing an action is right or wrong.

Figure 3

The Koko smart monkey can be programmed to know where it is and what it can do.

When Koko runs, it drives the software to a known state, randomly selects an action based on a weighting that simulates real-world likelihood, performs that action, and then checks the result. If the action results in the software changing states, Koko knows that and uses a new set of actions that apply to that new state.

With such a system, you could simulate real-world usage of your software, compressing thousands of hours of use into just a few hours. Smart monkeys are truly bug-finding machines!

  • + Share This
  • 🔖 Save To Your Account