Friday, June 24, 2011

Using Android monkeyrunner to automate test steps

It is not unlikely that in writing your tests you discover that some simple steps are required by several tests.

monkeyrunner is a great tool in this respect because it offers a tremendously powerful and complete language like python.
You can write your tests using python but also you can build libraries containing primitives belonging to the test domain.
This example shows how you can lock and unlock the device screen. Usually this methods should be in a different class or module but for the sake of simplicity we are including lockDevice() and unlockDevice() here in the main script.