Functional Testing Types of Software Testing

What is Monkey Testing | Trivia, Types, Tools & Benefits

I first heard the term ‘Monkey Testing’ from a developer when I was 1 year old in IT industry. The developer was quite friendly & wasn’t confident enough about his code – “Hey, let’s do some Monkey Testing” he said. He sat with me and that was my first experience with practical Monkey Testing. Yeah! The name sounds funny, but this technique surely works (if you know the impacted areas). In this article let’s explore ‘Monkey Testing’ in detail.

What is Monkey Testing in Software Testing

“You never can predict how the user will use your product once they get it in their hands.”

What comes to your mind when you hear ‘Monkey’? Yeah! Mischief-maker. And why? Because his/her actions are ‘Random’. You cannot predict a monkey’s actions. Taking a cue from here, Monkey Testing is nothing but a technique where the user tests the application or system by providing random inputs and checking the behavior, or observe whether the application or system will crash. Randomness makes the monkey happy 🙂 Technically known as “Stochastic testing”, Monkey testing can be performed for desktop, web as well as mobile applications.

Note: Testers are NOT Monkeys 🙂 It’s just an effective Testing technique. There are no rules; this technique does not follows any predefined test cases or strategy and thus works on Tester’s gut feeling.

Types of Monkey testing

Just like humans, Monkeys too can be either smart or dumb. And both techniques are useful in Software Testing.

Smart Monkey tests

  • Have a brief idea about the application or system
  • Know its own location, where it can go and where it has been
  • Know its own capability and the system’s capability
  • Focus to break the system
  • Report bugs they find

Dumb Monkey tests

  • Have no knowledge about the application or system
  • Don’t know if their input or behavior is valid or invalid
  • Don’t know their or the system’s capabilities, nor the flow of the application
  • Can find fewer bugs than smart monkeys, but can unknowingly find important bugs that are hard to catch

Advantages of Monkey Testing

As you might have guessed,

  • Monkey testing can help to identify some out-of-the-box errors which your scripted or automated tests can’t. The intrinsic randomness of monkey testing also makes it a good way to find major bugs that can break the entire system.
  • Additionally the setup of monkey testing is easy, i.e. you can even start testing right-away without much preparation. Arranging random tests against random data is easy way to test the system.
  • It can discover some really good bugs like memory leaks or hardware crashing.
  • During regular testing we normally ignore many cases thinking that “this scenario” will never happen. Doing monkey testing can actually dig out these scenarios.
  • This technique works very well when doing load / stress testing when you try to break the application by proving non-stop random inputs. A good technique to test the reliability of the system.
  • Smart monkeys, if properly set up with an accurate state model, can be really good at finding various kinds of bugs.

But there are some drawbacks too,

  • The scenario may not be definable and may NOT be the correct business case.
  • The randomness of monkey testing often makes the bugs found difficult or impossible to reproduce.
  • Unexpected bugs found by monkey testing can be challenging and time consuming to analyze.
  • Additionally, it might happen that NO bugs are found during Monkey testing, then? Yeah! Though defects are not identified but still it will build some confidence in the system!

Don’t worry, we have Monkey tools

Tools can be used to make Monkey Testing automated, effective and efficient. How? Simple! Monkey tool will randomly perform actions in the application OR enter random inputs to the system and then capture the results. Programs / scripts that can generate random inputs and feed into the application under test and analyze the behavior. Though it will require some setup to be done, an automated monkey testing tool can be a means of efficiency if used properly. Since Monkey Testing is not yet established (or accepted) industry-wide, these tools have less identity unlike other automation tools.

  • Monkey Testing is also included in Android Studio as part of the standard testing tools for stress testing. The MonkeyRunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code. With MonkeyRunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation.
  • The Android SDK also has a UI Exerciser Monkey that handles most interface-level and system-level events. The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.

Pro Tip: It’s advisable to follow this technique (if at all) at the later phase of testing when all the functionalities are tested and there is some level of confidence on the effectiveness of the application. Additionally if we are using a program or script that generates valid and invalid random inputs, the analysis becomes a bit easier.

Trivia

“A thousand monkeys at a thousand typewriters will eventually type out the entire works of Shakespeare”

While the source of the name “monkey” is uncertain, it is believed by some that the name has to do with the Infinite Monkey theorem (stated above). Some others believe that the name comes from the classic Mac OS application “The Monkey” developed by Steve Capps prior to 1983. It used journaling hooks to feed random events into Mac programs, and was used to test for bugs in MacPaint.

The effectiveness of monkey testing is heavily dependent on the kind of instructions the testers have provided. It’s an established fact that a single testing tool or method cannot free a software of bugs and errors. The right combination of test methods and tools, based on error detection efficiency, cost and testing speed is the best guarantee that a product at its optimum condition is delivered to the end user.

Next time don’t just be a horse with a bridle around you – driven by the test cases, plans & strategies and controlled by the quality metrics. Try Monkey testing!

Leave a Reply

Your email address will not be published. Required fields are marked *