2016年8月29日 星期一

018.1 Android Radio Button Example (monkey test by adb shell)

Monkey testing! This article tells how to do simple "dumb monkey test" on Android App.

From wiki https://en.wikipedia.org/wiki/Monkey_testing

Dumb monkey tests
Dumb monkeys, also known as "ignorant monkeys", are usually identified by the following characteristics:
  • Have no knowledge about the application or system
  • Don't know if their input or behavior is valid or invalid
  • Don't know their or the system's capabilities, nor the flow of the application
  • Can find fewer bugs than smart monkeys, but can also find important bugs that are hard to catch by smart monkeys
Let's Monkey ~ \m/



open command line within Android Studio and Android emulator
adb -s emulator-5554 shell monkey -p com.blogspot.rulesare.helloworld_radiobutton 5000



Scenario 1

C:\usr\Android_Studio\HelloWorld_radiobutton>adb -s emulator-5554 shell monkey -p com.blogspot.rulesare.helloworld_radiobutton 5000                            
    // Injection Failed                                          
    // Injection Failed                                          
    // Injection Failed                                          
    // Injection Failed                                          
Events injected: 5000
## Network stats: elapsed time=69331ms (0ms mobile, 0ms wifi, 69331ms not connected)

Scenario 2



C:\usr\Android_Studio\HelloWorld_radiobutton>adb -s emulator-5554 shell monkey -p com.blogspot.rulesare.helloworld_radiobutton -v 5000
...
:Sending Touch (ACTION_UP): 0:(404.94278,362.41693)
:Sending Touch (ACTION_DOWN): 0:(158.0,125.0)
    //[calendar_time:2016-08-29 13:13:56.551  system_uptime:3041879]
    // Sending event #4900
:Sending Touch (ACTION_UP): 0:(92.470085,203.96457)
:Sending Touch (ACTION_DOWN): 0:(321.0,685.0)
:Sending Touch (ACTION_UP): 0:(311.293,687.77673)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-4.0)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,0.0)
:Sending Touch (ACTION_DOWN): 0:(95.0,644.0)
:Sending Touch (ACTION_UP): 0:(115.98125,614.1623)
:Sending Touch (ACTION_DOWN): 0:(264.0,622.0)
:Sending Touch (ACTION_UP): 0:(260.8156,626.4569)
:Sending Trackball (ACTION_MOVE): 0:(0.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,-4.0)
:Sending Touch (ACTION_DOWN): 0:(338.0,61.0)
Events injected: 5000
:Sending rotation degree=0, persist=false
:Dropped: keys=2 pointers=17 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=65902ms (0ms mobile, 0ms wifi, 65902ms not connected)
// Monkey finished



Follow-Up:


1. How to interpret the testing result (shown in console)

tba

2. How to get more detail

    Ans: -v (https://developer.android.com/studio/test/monkey.html)
Each -v on the command line will increment the verbosity level. Level 0 (the default) provides little information beyond startup notification, test completion, and final results. Level 1 provides more details about the test as it runs, such as individual events being sent to your activities. Level 2 provides more detailed setup information such as activities selected or not selected for testing.
   

3. How to get repeatable/reproducible monkey testing steps

    Ans: -s <seed>
Seed value for pseudo-random number generator. If you re-run the Monkey with the same seed value, it will generate the same sequence of events.

Command Line Help


adb devices
Prints a list of all attached emulator/device instances.

adb
-s <serialNumber>
Direct an adb command a specific emulator/device instance, referred to by its adb-assigned serial number (such as "emulator-5556").

shell monkey
-p <allowed-package-name>
  If you specify one or more packages this way, the Monkey will only allow the system to visit activities within those packages. If your application requires access to activities in other packages (e.g. to select a contact) you'll need to specify those packages as well. If you don't specify any packages, the Monkey will allow the system to launch activities in all packages. To specify multiple packages, use the -p option multiple times — one -p option per package.


Reference

https://developer.android.com/studio/command-line/adb.html
http://sunmr.blogspot.tw/2015/08/android-monkey-test.html
https://developer.android.com/studio/test/monkey.html

沒有留言:

張貼留言