Thursday, September 26, 2013

How to perform monkey testing using Shell? (Monkey Testing in Android)

What comes to your mind when you hear the word monkey, Yes it is trouble :D so as tester we always need to think like a monkey while testing to stress the application. Manual Monkey testing mainly concentrates on randomly tapping on the screen without any sequence, using two fingers to tap two different buttons simultaneously, scroll several times in a loop and so on. Looks very monkeyish right :O Do try to think like a monkey while testing :)
But rather than manually executing the monkey test if you could automate it wouldn't it be great? Yes its possible for android applications through terminal. Android has Monkey program which generates a random events like touch, gestures and taps. I use this for stressing android applications and games.

How do you execute monkey test ?

- Open terminal and change directory to platform tools folder 
- Type adb shell (./adb for Mac OS)
- Type monkey -p com.your.package.name -v 5000( You can change values. More the value more the time it runs)
Ex: monkey -p com.zzepod -v 10000
- Observe the screen.

You would see your screen automatically performing touch, gesture and tap operation. If your application doesn't crash after performing this automation then your application is quite stable.