Start Activity for testing

前端 未结 5 760
青春惊慌失措
青春惊慌失措 2020-12-30 22:12

I \'ve got a Quiz app using Realm db. Every time the user selects an answer she clicks a button and new text for Question appears. Thats it until she reaches the end where

5条回答
  •  醉梦人生
    2020-12-30 22:21

    First, see this question : Android Monkey Runner

    Then you can see these guides :Monkey Runner

    It makesyou usePython to test your android activity outside of your source. So, you can trigger things and get to specific activitiesl like this :

    #! /usr/bin/env monkeyrunner
    
    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
    from random import randint
    
    print "get device"
    device = MonkeyRunner.waitForConnection()
    package = 'my.packaget'
    activity = 'my.package.activity'
    runComponent = package + '/' + activity
    device.startActivity(component=runComponent)
    
    #use commands like device.touch and device.drag to simulate a navigation and open my activity
    
    #with your activity opened start your monkey test
    print "start monkey test"
    for i in range(1, 1000):
        #here i go emulate only simple touchs, but i can emulate swiper keyevents and more... :D
        device.touch(randint(0, 1000), randint(0, 800), 'DOWN_AND_UP')
    
    print "end monkey test"
    

    save it and then run : monkeyrunner test.py

提交回复
热议问题