Search code examples
androidtestingfunctional-testingmonkeyrunner

Send command-line arguments to MonkeyRunner script


I am starting to explore writing MonkeyRunner scripts as part of my test suite. I am testing two apps: a free version and a paid version. I would like to write a single test script which I can run against either of these two apps. Is it possible to send command-line arguments to my MonkeyRunner script? For example, I imagine providing the Android package name in this way. Or perhaps is there another solution to my problem? I'm certainly open to suggestions.


Solution

  • Yes, it's possible. sys.argv contains the command line options and arguments you may have passed to the script. In this regard there's no difference with other python interpreters. The only thing you should avoid is to use command line options -u, -s, -p, -v and -plugin as they are used by monkeyrunner itself, albeit some of them not documented.