Fitting in regression testing by a Monkey: Strengthening Testing Practices

Rashmi Sandarekha
4 min readJun 19, 2020

--

Have you ever heard of a monkey in testing?

money testing
Monkey in testing

Before I deep dive into explaining what is monkey testing, I’ve often had new engineers asked why some tests are executed in ad-hoc methods. Also, they ask why do you execute random, unplanned scenarios into the test suites. Well, my direct answer for them was can you predict the user utterance always?

When you hand over your product to the user, will they handle it with care as you did? User utterance can never predict. Planned regression test execution won’t catch all the bugs. There we have to think of fuzzy testing but needs to be unique in handling the test methodology.

Assuming that if a monkey user a computer then what will happen? Monkey will surely enter millions of random inputs with no knowledge or any understanding of the product.

So it's always good sometimes to think like a monkey and make sure any monkey behavior won't crash your system! TADA.

When did monkey come?

In 1983 this was first used during the developments of Mac. The original Macintosh had 128K bytes of memory and after allocating memory for system and display only 90K of memory was left for the applications. “MacWrite” and “MacPaint” applications had to use buffers that were offscreen but 3 times the size of the screen in order to operate. It was necessary to test these applications in low memory conditions to check if they would crash. However even they tested creating the same required infrastructure condition, it was difficult to reproduce the issue that led to a crash. So Steve Capps and the team used “The Monkey” which was a program that they came up with to enter random events to “MacWrite” and “MacPaint”. The Monkey could be run side by side / concurrently with other programs, enter data, and perform actions in other programs.

“The Monkey” could perform faster than a regular user. This was similar to a monkey banging on the keyboard pushing random keys, clicking, and dragging the mouse randomly.

The team developed it to generate a specific percentage of commands, menu clicks, window events, etc out of all the random events so that they could target the testing as per their requirements.

There the monkey testing concept introduced.

Monkey MUST?

Is monkey testing a must in regression?

No, it isn’t! But if you have occupied with some time until you get the next deployment, it’s always nice to hunt for bugs thinking as to how would it break if any monkey behavior is gonna be there with the system. Of course, it’s always nice to crash the system before your end-user utters! Monkey testing helps to track new bugs which may not be possible to find out from the stated test cases.

Genre

Not every monkey is the same. There are different monkeys in their behaviors. Based on that we categorize the monkey testing into three types.

  1. Dumb Monkey

Testing can proceed as a “Dumb monkey” test. Here the tester doesn’t need any knowledge of the product domain or the testing process. Simply the tester can keep entering the inputs without considering its validity.

For instance, when an application has given for testing without mentioning any requirement details, the tester starts playing with the system in so many peculiar inputs. From the errors which occur based on those peculiarities, it can find the cause and amend the necessary fixes.

2. Smart Monkey

Testers have a certain idea of the system or application domain before he/she executes a smart monkey testing. They know exactly the product’s functionalities but keeping in that mind they provide valid and invalid inputs to perform testing. Even though they add peculiarities, and concentrate to crash, the requirement is lead.

3. Brilliant Monkey

Brilliant monkey tests the testers have a thorough idea as to how the users are using the product. They carry out all random testing with the user’s perspective.

How?

Monkey testing tools have been developed to generate random data for pre-populating the random data in the application.

“Monkey Runner” is one of them! This was developed to perform functional testing and framework level testing of the application or device, it can be used to run test suites and for random testing. https://developer.android.com/studio/test/monkeyrunner

“The UI Exerciser Monkey” also generates user events in a random stream. https://developer.android.com/studio/test/monkey

And nowadays there are so many online hosters that can perform random streams of user front end events in the application. E.g. https://monkeytest.it/

Challenges!

Of course, this is challenging! At a glance, someone might think that this might be one of the easiest testing techniques. Performing is easy as there are no complex logics to think about and in the traceability matrix, but when you track a bug, it’s hard to reproduce!

The accuracy of the bugs cannot be highly ensured.

However, monkey testing might not be the one and only way of the best test approach since it’s chaotic but always good to perform in a later phase in regression.

Happy Monkey Testing!

--

--

Rashmi Sandarekha
Rashmi Sandarekha

Written by Rashmi Sandarekha

Software Quality Assurance Lead fascinated in Test Automation. Storyteller and a technical writer.

No responses yet