Getting started with Android testing

1. Android test newcomer practice - installation and file transfer

[Pre-class preparation] Android test environment construction

1. Download and install JDK:

 

http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR

During the download process, you need an account to register yourself.

 

2. After the installation is complete, configure the environment variables of the JDK:

 

JAVA_HOME is set to the Java installation address, for example "D:\Program Files\java\jdk1.6.0_45"

PATH increase ";%JAVA_HOME%\bin"

CLASSPATH is set to ".;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar"

 

To verify the environment variables, run "java -version" in a Windows command window.

 

3. Download and unzip the Android SDK:

 

http://developer.android.com/sdk/index.html

 

(Note: If the ADT Bundle is downloaded, only the sdk part is needed after decompression)

 

Here are the main directories and files in the Android SDK:

<DIR>      platform-tools

<DIR>      platforms

<DIR>      tools

  357,814 AVD Manager.exe

  357,814 SDK Manager.exe

 

Directory and file description:

- AVD Manager.exe for creating Android emulator;

- Install Android tools and API SDK Manager.exe;

- Commonly used tools are in two directories: platform-tools and tools.

 

For example, there is adb.exe in the platform-tools directory;

For example, there is ddms.bat in the tools directory.

[Classroom Exercise] Android App Installation

Four commonly used methods:

1. Release channel

Google Play, App Store, Samsung Market, 91 Market, 360 Market, Amazon, Android Market, Anzhi Market, Baidu, Wandoujia, etc.

2. Download the apk from the official website

3. Installation command

# adb install filename.apk (install)

# adb install -r filename.apk (overwrite installation)

# adb uninstall com.tencent.mobileqq (installation packages with different App signatures cannot be overwritten and must be uninstalled first; the package name com.tencent.mobileqq can be viewed through the installation package/running process information/log, etc.)

4. Testing and internal experience: RDM secretary

        http://rdm.wsd.com/

 

[Class Exercise] Android Log Extraction

1. UI tools

DDMS、Monitor

Filtering: Specify the package name of the application, and the error level log can obtain crash information

2. Command tool

# adb logcat

# adb logcat -c && adb logcat (clear historical logs and view new logs)

# adb logcat *:E (Error level log)

# adb logcat | findstr "mobileqq" (filter logs by name)

 

[Classroom Exercise] Android upload and download files

1. UI tools

Tencent Mobile Manager, 91 Mobile Assistant, etc.

2. Command tool

# adb push pc_file mobile_file (upload file to Android phone)

# adb pull mobile_file pc_file (get logs from mobile)

 

[Classroom Exercise] Android Tool Software Installation

1. First you need ROOT

2. Upload tool software (take tcpdump as an example)

> adb push tcpdump /data/local (upload files to install)

> adb shell

$ your

# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system (make the partition writable)

# cat /data/local/tcpdump > /system/xbin/tcpdump (there is no mv, cp command, use cat instead)

# chmod 755 /system/xbin/tcpdump (modify file permissions to make it executable)

# mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system (turn off writable properties)

# exit

$ exit





Second, Android test newcomer exercise 2 - using adb and shell commands



BusyBox is a single-executable implementation of standard Linux tools, typically used in stripped-down embedded systems. BusyBox includes some simple tools such as cat and echo; also includes some larger and more complex tools such as grep, find, mount and telnet; and integrates some simple servers such as dnsd, ftpd, httpd, telnetd and tftpd.

Download and install Busybox:

l  http://www.cnblogs.com/xiaowenji/archive/2011/03/12/1982309.html

l Or search and install Busybox through Google Play

l or download address: https://play.google.com/store/apps/details?id=stericson.busybox

 

If you want to enter and execute shell commands on your mobile terminal, you can install the Terminal Emulator app.

l Search and install Terminal Emulator through Google Play

l or download address: https://play.google.com/store/apps/details?id=jackpal.androidterm

[Pre-class preparation] ADB tool under Windows

The full name of ADB is Android Debug Bridge, that is, Android Debug Bridge, which is mainly used to manage devices or emulators. The ADB tools under Windows are mainly three files in the platform-tools directory of the Android SDK: adb.exe, AdbWinApi.dll and AdbWinUsbApi.dll.

 

[Class Exercise] adb command

View devices                # adb devices

Get device serial number # adb get-serialno

Specify the device to execute the command # adb -s [device serial no] [command]

 

Shut down the ADB service     # adb kill-server

Start ADB service     # adb start-server

 

Install app                # adb install [apk-file]

Override install                # adb install -r [apk-file]

Uninstall app                # adb uninstall [com.*.*]

 

USB connection mapping port # adb forward tcp:[port-local] tcp:[port-mobile]

Upload file to device      # adb push <source-local> <destination-mobile>

Copy files from device      # adb pull <source-mobile> <destination-local>

View bug reports       #adb bugreport

View logs                # adb logcat

 

[Class Exercise] adb shell command

Enter device or emulator shell # adb shell

Execute shell commands directly     # adb shell [command]

 

show directories and files # ls

Enter directory                # cd [path]

Create directory                # mkdir [dir-name]

Delete empty directory           # rmdir [dir-name] (delete a directory containing files available rm -r)

Example: View the app apk file name installed on the device (after su privilege escalation, # ls /data/app)

 

delete file      # rm [file-name]

Move or rename # mv [path-src] [path-dst] (Android system can use this command in the same partition)

View file      # cat [file-name]

Copy files      # cat [file-src] > [file-dst]

Modify file attributes # chmod [???] [file-name] (4 read 2 write 1 execute, read + write 6, read + execute 5)

Edit text file # echo “line of content” > [file-name] (> means new, >> means append at the end of the text)

Search file content # grep "search content" [file-name]

Filter command content # ps | grep mobileqq

 

network connectivity # ping [IP-addr]

View network status # netstat -an

View network port information # ifconfig eth0

View System Properties # getprop

 

View running processes # ps

Kill an allowed process # kill [pid or process-name]

View process resource information# top

View CPU information      # cat /proc/cpuinfo

View RAM info    # cat /proc/meminfo

View ROM Occupancy    #df

 

[Class Exercise] busybox command

See the list of busybox commands # busybox

Create empty file           # busybox touch [file-name]

Copy file                # busybox cp [file-src] [file-dst]

Search for files                # busybox find /mnt/sdcard -name mobileqq

 

View RAM usage information # busybox free

View network port information      # busybox ifconfig -a

View routing information      # busybox route

 

Example: use telnet connection in freewifi environment

Open the remote login service on the mobile phone# busybox telnetd -l /system/bin/sh

Check the access IP address on the mobile phone # busybox ifconfig

Computer access # telnet ipaddr

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324975131&siteId=291194637