Monkey testing is a technique used in software testing to test the application or product by providing random data and observing if the system or application crashes or gives an error. Monkey testing is also called as Fuzz Testing sometimes.
- In Monkey Testing, random data is entered into the application to check the behaviour of the application and see if it gives an error
- In Monkey testing the tester or sometimes developer also is considered like a monkey assuming that if a monkey uses the computer then he will enter some random data without any knowledge or understanding
- Here the tests done are very random and it may not be correct
- Monkey tests do not follow any test case
- Because of such random testing the testers may not be able to recreate the issues or bugs
Table Of Contents
Origin of Monkey Testing
Monkey testing was first used in 1983 on the Mac to test MacWrite and MacPaint.
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 had to use buffers which were offscreen but 3 times the size of the screen in order operate. It was necessary to test these application in low memory conditions to check if they would crash.
However it was difficult to reproduce conditions that led to a crash.
So the Steve Capps and the team used “The Monkey” which was a program which 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.
This would 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.
As a testing apparatus, The Monkey was quite efficient and the team found it amusing to see the drawings produced by The Monkey even though the writings were gibberish.
At first The Monkey was good at crashing the applications but once the prominent defect were fixed, it made it harder for the monkey to find defects.
Advantages of Monkey testing
- Monkey testing is a very good approach to find out some new bugs which may not be possible from the stated scenarios.
- Monkey testing can also be a good way to perform stress testing and load testing since the scenarios tested are generally random and adhoc.
- It is very easy to execute because it just requires some random data to run against some random tests.
- Execution of test cases and setting up of environments expenses are very less in monkey testing.
- By using tools the process of Monkey testing can be automated.
- Monkey testing can be performed for desktop applications, web applications as well as mobile applications.
Disadvantages of Monkey testing
- The test carried out during monkey testing is so random that it is either not possible or very difficult to recreate any bug.
- It’s very difficult and time consuming to analyze the unexpected issues found during the monkey testing.
- Testers have difficulty in defining the exact test scenarios and they also cannot assure the accuracy of test cases.
- Monkey testing may consume lots of time before finding a bug because it does not have any predefined tests.
Examples / Types of Monkey testing
There are three types of Monkey testing:
Dumb monkey tests:
- In Dumb monkey tests the testers have no knowledge of the product or application.
- They do not have any idea about their inputs whether it’s valid or invalid.
- They are also known as ‘Ignorant monkeys’.
Smart monkey tests:
- In Smart monkey tests the testers have a good idea of the system or application.
- They know exactly the product’s functionality.
- They provide the valid inputs to perform testing.
Brilliant monkey tests:
- In Brilliant monkey tests the testers have fair idea as how the users are using the product.
- They carry out their testing with the user’s perspective.
Difference between Fuzz Testing and Monkey Testing
- Technically speaking, Monkey testing refers to random actions being performed while testing the application
- Fuzz Testing refers to the use to random data when testing the application to see if we get an error
- These are two distinct types of testing
- However, over a period of time the names have been used interchangeably and Monkey testing is used to refer to style of testing in general
How To Perform Monkey Testing
There are different ways in which Monkey testing can be performed. Some of the common techniques are given below.
Dumb Monkey Testing
In Dumb Monkey Testing the Test Manager / Test Lead assigns a tester who is not aware of the module / application to test the product. The tester is asked to test the application intuitively and enter random data which the tester feels is appropriate.
In this scenario, the tester’s behaviour may be like a user who is not very technically savvy but is trying to use the application.
- The tester can test the application as per their understanding and enter data which is not valid.
- The applications behaviour is then noted to see if it performs as expected.
- This type of testing is useful since testers who are aware of the application may tend to enter valid data when testing, follow proper steps and may not test conditions other than those they have thought of earlier.
Smart Monkey Testing
In Smart Monkey Testing, the Test Lead or Manager assigns a tester who understands the application, to test the application.
- Since they are aware of the product they will enter random data to test the application which they know is not valid and perform random actions.
- This is beneficial in testing the application quickly.
- This ensures that the application works as expected under valid conditions and handles invalid data properly.
Brilliant Monkey Testing
In Brilliant Monkey Testing, a tester who has domain knowledge of the domain, is assigned to test the application by the Lead or Manager.
The developer or tester who does not have domain knowledge may expect the sequence of steps to be executed in a certain way and they may have a specific understanding of the data that is being entered.
However, in the field/real life, the end user who has domain expertise may actually be performing tasks in a different sequence with different data. Example : A tester who has knowledge of Banking domain may be asked to enter random data to test a banking application.
Hence having the application tested by a person with knowledge of the domain is beneficial since they will enter random data from a domain perspective.
Uses Of Monkey Testing
- Monkey testing can also be automated using hardware or more preferably software to mimic the actions of a monkey entering random data.
- Data which is random and pre-compiled can be used to test the application for OWASP issues.
- It can be used for database testing by starting a transaction and entering random data or performing random actions and then rolling back to see if it crashed or if any corruption of database occurs.
Difference between Monkey testing and Adhoc testing
Monkey Testing is similar to Adhoc Testing and can be considered a type of adhoc testing. These are two different techniques of testing. When the coding is complete, the adhoc testing is done by the developer or tester based on their knowledge of the software.
There is no preparation or planning done before adhoc testing is performed. Test Cases are not referred to during adhoc testing.
They primarily check if the basic program works without crashing.
Monkey Testing | Ad hoc Testing |
Type – Test Cases are not used in Monkey Testing since this is random in nature | Type – Adhoc testing is also random and does not rely on or use Test Cases. |
Objective – Tests are executed randomly with random or invalid data to check if the application crashes | Objective – The aim of the tester in Adhoc testing is to crash the application or find a defect by using the application randomly |
Usually tester will not have knowledge of the application and they do not test in a specific path. They test randomly by clicking random objects and entering random data to check if the application give an error | The tester tests whatever they think is required as per their knowledge of the application, in Adhoc testing |
Monkey testing can be performed by anyone, even individuals who are not familiar with computers or the application. It is similar to giving a monkey a typewriter. | Adhoc testing is performed by a developer or tester who has good knowledge of the application. |
Monkey Testing Tools
There are several tools that help in automating the process of Monkey Testing. This helps in performing monkey testing efficiently.
Monkey testing tools are developed to generate random data or use pre-populated random data and enter it into the application. They are also programmed to be able to execute random actions. They then observe and report the output of the application.
Setting up a Monkey testing tool requires some amount of effort but once its setup, the automation will help make monkey testing efficient.
MonkeyRunner tool for Android
MonkeyRunner tool is used for monkey testing an Android application.
You can install, execute an Android program, send it data/keystrokes and record screenshots and store it on a computer – all this can be done through a Python program with MonkeyRunner.
You can control an android emulator or device using the API’s provided by the Monkeyrunner tool.
While the Monkeyrunner tool is 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.
UI/Application Exerciser Monkey on Android
The UI Exerciser Monkey is different from the monkeyrunner tool. MonkeyRunner tool controls the android device from outside the android code while UI Exerciser Monkey which runs in an ADB Shell inside the device or emulator.
The UI Exerciser Monkey can be used to generate system and user events in a pseudo random stream.
Monkey testing is not in widespread use across the industry due to various reasons like lack of time, resources, higher priority given to other forms of testing which give better results and return on investment.
Its advisable to execute other forms of testing first, to ensure the stability of the application before using Monkey Testing.
Other popular articles:
- Automation testing of Android application with Robolectric
- What is Adhoc testing? Types, Advantages and Disadvantages
- What is Exploratory testing in software testing? Examples, When/How to do, Agile
- What is Test data preparation tools in software testing?
- What is Load testing in software testing? Examples,How To Do,Importance, Differences