"Monkey testing" is a technical term often applied to early software test automation systems, which approximated monkeys banging on the keyboard. Although it had a bad reputation at one time, monkey testing is once again gaining in popularity, because it is so cheap to implement.
It is of course hard to resist posting a Perl Monk-ey test script here. =)
This script randomly performs one of five actions every second: left mouse down or up; right mouse down or up; move mouse. Point it at the MS Paint program for a few minutes to get a good idea of what it does.
One note: something about this script plays havoc with anything running under Java. Be sure to save your work before you start the Perl Monkey Test script.
Another note: this script often ignores CTRL-C. And it takes over your cursor. Don't plan on getting any work done while the Perl Monkey Test is running. And be prepared to be quick with Task Manager...
#!/usr/bin/perl
use warnings;
use strict;
use Win32::GuiTest qw(FindWindowLike GetWindowText
SetForegroundWindow SendKeys MouseMoveAbsPix
SendLButtonDown SendLButtonUp SendRButtonDown SendRButtonUp);
$|=1;
$Win32::GuiTest::debug = 0; # Set to "1" to enable verbose mode
#set screen size
my @x = (1 .. 1024);
my @y = (1 .. 768);
my $xcoord;
my $ycoord;
my @commands = ("MouseMoveAbsPix", "SendLButtonDown()", "SendLButtonUp
+()", "SendRButtonDown()", "SendRButtonUp()");
print "Enter the name of the window for monkey testing, i.e untitled -
+ Paint :\n";
my $winName = <STDIN>;
chomp $winName;
print "You have 10 seconds to bring that window to the forefront befor
+e PerlMonkeyTest takes over your machine!\n";
print "Use Task Manager to kill processes if your mouse is out of cont
+rol.\n";
my @windows = FindWindowLike(0, "^$winName" );
#my @windows = FindWindowLike(0, "^untitled - Paint" );
# my @windows = FindWindowLike(0, "^Microsoft Excel", "^XLMAIN\$");
for (@windows) {
print "$_>\t'", GetWindowText($_), "'\n";
SetForegroundWindow($_)
or die "what window?";
sleep 10;
while (1) {
#set random $x, $y, 1024, 768
my $xcoord = $x[rand @x];
my $ycoord = $y[rand @y];
#choose random from @commands
my $command = $commands[rand @commands];
if ($command =~ "Send") {
eval $command;
}
else {
eval "$command($xcoord,$ycoord)";
}
sleep 1;
}
}