How to import a py file function in monkeyrunner test file

1.2k Views Asked by At

I want to create test cases for my Android application in Monkeyrunner.

I am thinking to create a sub tests case file to do before actual test case. like a install , uninstall functions in a separate py file. How can i call these install/uninstall apk or any other function in my monkeyrunner test case?

I have a successful experiment of calling a function from other imported py file in my py file in PYTHON. but same function cannot called while running through monkeyrunner.

import new
print new.foo()

this is working while running through python but not working in monkeyrunner. Any solution?

1

There are 1 best solutions below

2
On

monkeyrunner (jython) and python should import modules exactly the same way, the only difference might be the content of the module search path. To verify it try:

   import sys
   print sys.path

in both python and monkeyrunner and see if there are any differences. If you want to include some path, do

   sys.path.append("/path/to/my/new/module")
   import new
   print new.foo()

and should work.