… with software testing. Yes, we’re serious. All those years you were told to stop messing around on the computer are finally going to pay off.
Monkey testing is an ad-hoc technique in software testing used to check the behavior of an application by inputting sets of randomly generated data. Imagine a monkey sitting at a computer hitting the keyboard and arbitrarily typing letters. Given enough time (and a lot of it), it will spell a word, phrase, or even a sentence that is understandable. Now imagine this style of process in the context of testing where the tester inputs random sets of data into the application. The tester might eventually input something that exploits an edge case that will cause the application to crash, cause a load test to fail, or illuminate a bug that wasn’t captured through a structured process.
End user behavior is unpredictable, and not every single unique scenario can be tested by using a regimented, structured process. Funny sounding name aside, “monkey testing” is actually a crucial testing technique that attempts to simulate the various unknown yet real situations which a customer might engage with a piece of software.
The worst scenario would be your customers stumbling upon these bugs or crashes, which could ultimately lead to application abandonment, diminished brand equity, forgone profits. Monkey testing helps you find unique bugs before they become an issue, and that is why it’s crucial to integrate this into your development lifecycle.
Types of Monkeys:
While monkey testing seems chaotic, it does have a distinct purpose and can be broken down into two types:
- In smart monkey testing, the application functionality is known. Thus, the testing process relies on purposefully attempting to break the application by providing inputs that are known to be invalid. When the application is broken, there will be enough background knowledge to successfully log the bug.
- In dumb monkey testing (hey, we didn’t come up with the name) the application functionality is unknown. The process relies on a tester without prior knowledge of the system workflow to break the application by providing inputs not known to be valid or invalid. Although this process makes it tough to affirm the validity of the test cases, it can still identify software failures. Unsystematic testing like this is excellent for finding bugs and crashes you never thought possible.
Monkey Testing vs. Exploratory Testing
The spontaneous nature of monkey testing can seem very similar to other testing techniques, such as exploratory testing. However, there are a few key differences between the two.
Exploratory testing is also conducted without pre-defined test cases, but is a more formal approach to testing that measures the production readiness of a piece of software. While monkey testing is non-methodical, exploratory testing requires the tester to document their actions and to make intuitive decisions on what to test. In scripted testing, you design tests cases first and then later run those tests. In exploratory testing, these steps are executed simultaneously, so you’ll need an experienced tester that can think outside the box to adapt their tests as they go. This means they need to be a skilled test designer with an in-depth understanding of the application.
Depending on the framework of your testing process, you can conduct exploratory testing at either the beginning or the end of the cycle, but it is usually focused on testing the UI of an application and is always conducted manually. Monkey testing typically focuses on the unit level of an application and can be conducted with automated testing tools to optimize the amount of time being spent.
While monkey testing and exploratory testing are implemented differently and require separate skill sets, they are ultimately two different techniques that can be used to approach the same problem.
Advantages & Disadvantages of Monkey Testing
Both techniques give testers plenty of room to improvise, but the outcome of monkey testing is more unpredictable. Due to its nature, it has a few key advantages and disadvantages.
- Doesn’t Require Specialized Skills: Monkey testing, does not always require very specialized testers.
- Easy to execute: You’ll spend less time setting up and executing monkey tests because there is no need to design test cases ahead of time and arranging random data sets is easy. You also won’t need to take the time to ensure the tester is up to speed and familiar with the product.
- Lower costs: Since you’re cutting down on the required resources like skill and time, you’ll lower your costs.
- Unique Bugs Uncovered: Due to the random nature of the tests, you’ll be able to identify new bugs and errors you weren’t expecting.
- Hard to Reproduce Bugs: There are no pre-defined test cases in monkey testing and the data generated is random. Since testers don’t usually keep in-depth documentation for each step they take, it becomes very challenging to reproduce bugs when they are found.
- Less Accuracy: Test scenarios are often random and may not even be viable business cases, making the tests less accurate.
- Time consuming: It could take days for bugs to be discovered, especially if the input data is generated manually. Without a defined path, monkey testing could take much longer than planned.
Automated Monkey Testing:
Since monkey testing is a less formal testing technique, it can result in more strenuous work if not implemented with the right tools. The bugs can be harder fix because they are harder to find and reproduce. With manual execution, this could end up taking your team more time than initially planned and can end up slowing down your testing cycle.
Executed with an automated testing tool like TestComplete, monkey testing can be conducted in less time with more accuracy and found bugs can easily be reproduced.
The best automated testing tools will give you record-and-replay capabilities. With this feature, any random actions you take that generate a bug can be tracked– making it easy for you to reproduce the issue. All you have to do is watch the saved video logs or analyze the screen shots to figure out what caused the exception. With capabilities like data-driven testing, you can automate the process of generating random sets of data, speeding up the entire process. This will also give you the ability to run more tests in less time, effectively improving your test coverage and minimizing the impact of inaccurate tests.
With the right tool, monkey testing can be a strong testing aide that will help you find and fix unique issues before they reach your customers.