当前位置:网站首页>Chapter IX app project test (3) test tools

Chapter IX app project test (3) test tools

2022-06-28 03:38:00 zhhzc

9.4.2  AAPT

AAPT yes Andriod Asset Packaging Tool Abbreviation , yes Aanriod Apply the resource packaging tool , It can be used AAPT Tool components APK file , It can also be used to list APK Details in the file , Including some group files and resource files AAPT Store in SDK Of build-tools Under the table of contents , When using, you need to set the environment variable path Add AAPT The path of . Because of the configuration adb Environment variables are added when , Or you could just say aapt.exe File copy to platform-tools Under the directory . Introduce to you AAPT Common subcommands for tools .

1、l-list

list List applications *.apk package The content of , Command format :aapt list*.apk;

Example :aapt listD:\notepad.apk   Show notepad.apk The contents of the bag .

commonly apk There's a lot in it , It is best to use redirection to direct the contents of the file to a text file , Convenient view . Such as :aapt list D:\notepad.apk>D:\apk.txt

2、d-dump

dump see apk Basic information command format :aapt d values*apk among values The value of... Can be selected .

(1)badging

Parameter description : List the basic information of the application , Include package name package name、 edition 、 Application name .

Example : see lmageViewer.apk Basic information commands for :aapt d badging D:\mageViewer.apk. If you just want to get the package name , You can use the following command aapt d badging D:\tenson.apk findstr"package" The package name obtained through this transmission is com.love-plusplus.demo.image.

(2)permissions

Parameter description : see apk Application permissions for

Example : see tenson.apk Authority ,aapt d permissions D:\tenson.apk.

(3)configurations

Parameter description : Show apk Configuration information , Such as version number , Resolution and other information .

Example : see tenson.apk Configuration information ,aapt d configurations D:\tenson.apk

(4)resources

Parameter description : List the resource information in the application

Example : see tenson.apk Resource information ,aapt d resources D:\tenson.apk

3、 The other parameters

p-package: Package and generate resource package

r-remove: from apk Delete the specified file in the package

a-add: Add files to apk In bag

These parameters can hardly be used for relative tests , If necessary, you can go to Android Official website .

9.4.3     Monkey Tool is introduced

yes Andriod A command-line tool included in , It can run in simulator or equipment . It sends a pseudo-random stream of user events to the system ( Click on 、 touch 、 Gestures, etc ) Implement stress testing on the developing application .Monkey On the surface, it runs on the equipment , Actually, it runs in the terminal of the device , function Monkey The command needs to be preceded by adb shell, You can also enter shell After the terminal, directly input the command to run .

Monkey There are many options , Roughly divided into the following 4 Categories:

1) Basic configuration options , For example, set the number of events

2) Run constraint options , If you set it to test only individual packages

3) Event type and frequency , Such as the proportion of click events and touch screen events and the interval between events .

4) Debugging options , If omitted crashes、ANR etc. .

Monkey The runtime generates events , And send the information to the system ; At the same time, the system under test is also tested , To the following 3 Special treatment for cases .

1) You can specify one or several packages to test

2) The application crashed or received an exception , You can specify the command to let Monkey Continue operation

3) The application is not responding (ANR),Monkey Will stop the application , You can specify the command to let Monkey Continue operation .

2、Monkey Test the usage process

Monkey It is a stability stress testing tool , Usually after the functional test is completed , Conduct stability pressure test . It is mainly used to detect whether the mobile phone is unresponsive 、 Flash back 、 Crash and crash . The main cause of these problems is memory leakage .Monkey The use process of the test , Pictured 9-7 Shown .

First, check the phone memory with commands or tools , And then run Monkey command , Check the phone memory again , If there is an increasing phenomenon , Indicates a memory leak , The problem needs to be solved immediately . At this time, we can use DDMS To analyze the positioning problem .

3、Monkey Basic use of

Basic grammar :  adb shell monkey[ Options ]COUNT.. Let's introduce Monkey Parameter options for

-help see monkey Help for . Enter the command at the command line :adb shell monkey-help The result of its operation , Pictured 9-8 Shown .

COUNT Set the number of times the event is executed .

  for example :adb shell monkey 1000.

Express monkey Simulate all applications on the device or simulator , Random execution 1000 Secondary user event .

【 Basic parameters 】 There are mainly -p、-v、-s、--throttle etc. .

(1)-p ALLOWED PACKAGE

Parameter description : Specify the application package name to be tested ,monkey Only those in the startup package are allowed Activity, First you can command adb shell ls/data/data/ To see these Activity.

for example :adb shell monkey-pcom.android.calendar 100.

Express monkey On the simulator com.android.calendar application , Random execution 100 Secondary user event .

If you want to specify multiple packages , Need to use multiple -p Options , Every -p Option can only specify one package .

(2)-v

Parameter description : Increase the level of feedback . It is divided into the following 3 A level

-v:Lecel 0: The default value is , Except start prompt 、 Test completion and final results , Provide less information .

-v-v:Lecel 1: Test information that provides information , Such as sending applications one by one Activity Events .

-v-v-v:Lecel 2: Need detailed logs , Including... Selected in the test / Unselected Activity Information .

Example :adb shell monkey-pcom.freshO2O-v-v-v:100

The command is given by 3 individual V, The level of information displayed is Level 2.

(3)-s<seed>

Parameter description : Specifies the seed value of a random number seed, If you use the same seed Run again Monkey The same chronological order will be generated if the seed value is not specified , The system will randomly generate a seed value , In the presence of Bug The seed value will be the same as Bug The information is output together , This is also to facilitate the reproduction of the Bug.

Example :adb shell monkey-pcom.android.music-s 10100

If you run 2 This example , The final result is the same . Because the specified random seed values are 10, The simulated user operation sequence is the same . So the sequence of operations is pseudo-random .

(4)--throttle<ms>

Parameter description : In the event ( The user action ) Insert a fixed delay between , In milliseconds . With this option, you can slow down Monkey Execution speed of . If you don't specify this option ,Monkey Will not be delayed .

Example :adb shell monkey-pcom.android.music--throttle 300100

explain : Specifies that the delay between events is 300ms

【 Debugging options 】 There are mainly --ignore-crashes、--ignore-timeouts、--pkg-blacklist-file、--pkg-whitelist-file、--ignore-security-exceptions--monitor-native-crashes、--kill-process-after-error、--hprof etc. .

(1)--ignore-crashes

Parameter description : Used to specify when an application crashes (crash, perhaps FC),monkey Whether to stop operation . If you use this parameter , Even if the application crashes ,Monkey Events will still be sent , Until the event count is complete .

Example :adb shell monkey-pcom.android.settings--ignore-crashes 1000

During the test , Even if settings Procedure crashes ,monkey Events will continue to be sent , Until the number of events reaches 1000 Mainly .

(2)--ignore-timeouts

Parameter description : Used to specify when an application occurs ANR( The application does not have a corresponding ) when ,monkey Whether to stop operation . If you use this parameter , Even if using the program ANR error ,monkey Events will still be sent , Until the event count is complete .

Example ::adb shell monkey-pcom.android.settings--ignore-timeouts 1000

During the test , Even if the application does not respond ,monkey Events will continue to be sent , Until the number of events reaches 1000 Mainly .

(3)--ignore-security-exceptions

Parameter description : Used to specify when a license error occurs in an application ( If the certificate permits 、 Network license, etc )monkey Whether to stop operation . If you use this parameter , Even if the application has a license error ,monkey Events will still be sent , Until the event count is complete .

adb shell monkey-pcom.android.music--ignore-security-exceptions 1000
During the test , If an application has a licensing error ,monkey Events will continue to be sent until the number of events reaches 1000 until .

(4)--pkg-blacklist-file PACKAGEBLACKLIST FILE

Parameter description : Set application test blacklist , The application packages in the blacklist settings do not participate in the test .

Usage method : stay --Pkg-blacklist-file Followed by the path of the file , This file contains a list of applications that did not participate in the test , You need to put this file push After arriving at the device or simulator , Before you can test . This option is generally used to test the stability of the mobile phone .

(5)--pkg-whitelist-file PACKAGEWHITELIST FILE

Parameter description : Set the test whitelist , Only these applications can be tested , If there are many application packages for testing , You can put these application packages into a file , Test by setting the white list .

(6)-monitor-native-crashes

Parameter description : Local code used to specify whether to monitor and report application crash . If the application itself has a local code base , You can take this parameter .

Example :adb shell monkey-pcom.android.calendar-monitor-native-crashes 1000

During the test , If calendar The application itself comes with a local code base ,monkey The local code... Will be reported in the display information .

原网站

版权声明
本文为[zhhzc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/179/202206280240091732.html