WO2018171195A1 - 一种基于依赖注入的安卓应用半自动化测试方法 - Google Patents
一种基于依赖注入的安卓应用半自动化测试方法 Download PDFInfo
- Publication number
- WO2018171195A1 WO2018171195A1 PCT/CN2017/108455 CN2017108455W WO2018171195A1 WO 2018171195 A1 WO2018171195 A1 WO 2018171195A1 CN 2017108455 W CN2017108455 W CN 2017108455W WO 2018171195 A1 WO2018171195 A1 WO 2018171195A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- application
- dependency
- test
- injection
- user
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
Definitions
- the invention relates to the field of mobile application testing, and particularly relates to a semi-automated test method for Android applications based on dependency injection.
- the present invention provides a semi-automated test method for Android applications based on dependency injection, which can combine the advantages of manual testing and random testing to provide various dependencies required for the correct operation of the application during the testing process. Improve test coverage and efficiently detect bugs.
- the technical solution of the present invention is: a semi-automated test method for Android applications based on dependency injection, the method comprising the following steps:
- the package loaded by the Android system is continuously detected. After detecting that the package of the application to be tested is loaded, the Xdroid module starts the code insertion operation.
- test thread is activated and starts to generate an event. If the test thread does not traverse to the new Activity for a long time, the notification module sends a notification requesting user intervention.
- a floating window that can switch between manual and test modes at any time is provided on the device interface, and Activity coverage and defect information are collected during the test.
- the injection module performs automatic dependency injection. Through the hook function provided by the Xposed framework, the content and result of the request are judged, and if the content is missing, the related resource is generated.
- the notification module notifies the user to perform manual dependency injection.
- the Xposed framework is a framework service in the Android system that can affect the running of the program (modifying the system) without modifying the APK, and the root permission of the Android system is required to install the framework.
- the framework replaces the zygote program of Android with the file manager, performs reflection interception on the generated new process, and injects new code for the specific function.
- the Xdroid module is a Xposed module developed according to the present invention, which can be run in the Xposed framework to provide dependency injection and automatic test functions. After installing the module, it is necessary to select the enable module in the Xposed framework and restart the mobile phone activation.
- dependency related API in step A2 includes but is not limited to the dependency related interface identified in the list:
- the hook function is a helper function provided by the Xposed framework to add code to a particular function:
- className is the class name of the function
- classLoader is the specified class loader
- methodName is the name of the function to be replaced
- parameterTypesAndCallback is the parameter type list and Hook callback.
- the event generated in step B1 is a click, a button, a slide, a trackball, a navigation, a main navigation, a system, and a two-finger reduction event generated by the Monkey test tool, and the generation ratio is 20%, and the button 13 is respectively %, sliding 10%, trackball 15%, navigation 25%, primary navigation 15%, system event 1%, two fingers down 2%.
- the floating window refers to a system window developed by using WindowsManager provided by Android, which has a switch that can switch between manual testing and automatic testing, and the window can be always present in the device interface and accessed at any time once opened.
- the Activity coverage refers to the ratio of the number of activities traversed by the test tool to the total amount of activities during the test.
- the traversed Activity can be collected by hooking the Android.app.Activity.onCreate function, and the total Activity can be obtained through the package manager's getPackageInfo method.
- the defect refers to an error generated by the application during the test, including application crash and application non-response.
- Application crashes can get crash information by hooking the com.Android.server.am.ActivityManagerService.handleApplicationCrash function.
- Application no response can get information about non-response errors by hooking com.Android.server.am.ActivityManagerService.appNotResponding.
- the dependencies include content, permissions, device capabilities, user intervention, and other dependencies.
- Content refers to general data that can be stored in an Android device, including contact information, calendar events, media files, and the like.
- Permissions refer to the system permissions that an Android app needs to apply to users before using the relevant system data and features, including all permissions that can be listed in the AndroidManifest file, such as reading contacts and information.
- Device capabilities refer to the various device capabilities provided by Android devices, including GPS, network, camera, Bluetooth, and more.
- User intervention refers to valuable data and operations provided by the user, including opening a WIFI switch, username and password, and the like.
- Other dependencies refer to various special resources that the application may depend on during the running process, such as other devices to be connected.
- the content type dependency in step C2 refers to data and media files that can be automatically generated automatically by the program, such as GPS location and music files.
- content-based auto-injection generated data and the media files stored in Xdroid are written to the system for invocation.
- the user intervention in step C3 refers to a dependency that must be manually injected by the user, including connecting to the network, inputting a username and password, and the like.
- the user is informed of the user-dependent dependency and provides information related to the dependency, including the manual processing required by the dependency and the parameter information related to the dependency, such as opening a WIFI switch, a background server address, and the like.
- the present invention combines the advantages of manual testing and random testing.
- the user can stop the automatic testing process at any time, provide manual interaction, and exert the advantages and random tests of manual interaction to solve complex interactions and provide user dependence.
- the present invention automatically detects dependency requests in the application test process in a lightweight manner, and automatically provides resource-dependent dependencies, provides a convenient way for manual intervention for user dependencies, and solves the problem in the automatic test process.
- Dependence on missing issues increases the efficiency and quality of automated testing.
- the manual participation time is gradually reduced during the test, and generally does not exceed 10% of the total test time.
- the test automation tool of the present invention does not require any PC connection, and completely uses the processing capability of the smart phone, and can test on multiple mobile phones at any time and any place at the same time, greatly reducing the consumption of equipment, and providing The ability to test in parallel.
- the semi-automated test method of the Android application based on dependency injection of the present invention can combine the advantages of manual test and random test, and obtain the system dependency request related to the application call by using the Xposed framework, and provide the application to run correctly during the test process.
- Figure 1 is a flow chart of an embodiment of the present invention.
- FIG. 2 is a schematic diagram of a system architecture of the present invention.
- Figure 3 is a life cycle diagram of the test tool of the present invention.
- Figure 4 is a schematic view of a suspension window of the present invention.
- the invention provides an Android semi-automatic test method based on dependency injection, which enables the application to automatically detect relevant dependencies and provide resources during the test, so that the test program can better explore application functions and improve test efficiency.
- the Xposed framework is a framework service that can affect the running of a program without modifying the Android installation package (APK).
- the basic principle is to modify the system to affect the running of the program.
- the Xdroid is a dependency injection and automatic test module based on the Xposed framework developed according to the method provided by the present invention.
- the Xdroid module (202) includes a method hook, an injection module and a notification module.
- the semi-automatic test method based on dependency injection comprises a target program code insertion process, a random test process and a dependency injection process, and the specific steps are as follows:
- A1 Continuously detect the package loaded by the Android system, and start the code insertion operation after detecting that the package of the application to be tested is loaded.
- the corresponding type of dependency processing function registration is performed to prevent unnecessary processing and consumption.
- the registered dependent processing function types include device content, Bluetooth, location, network, and the like.
- the present embodiment uses a floating window as a switching mode.
- the floating window refers to the system window developed by WindowsManager provided by Android, and once opened, it can be always present in the device interface and can be accessed at any time.
- the floating window In the default mode (Fig. 401), the floating window can be dragged and docked on the border of the device.
- the floating window expands into a system window (Fig. 402), where the user can turn the test mode on or off.
- the random events generated in this embodiment are clicks, buttons, slides, trackballs, navigation, main navigation, system and two-finger reduction events generated by the Monkey test tool.
- the generation ratios are 20%, 13%, and sliding. 10%, trackball 15%, navigation 25%, main navigation 15%, system event 1%, two fingers down 2%.
- test thread's start condition consists of two switches.
- the test thread generates an event only if the application is in the foreground and the user turns on the test switch. This avoids meaningless performance consumption and improves test efficiency.
- the function called by the application to request the device content is ContentResolver.query.
- the processing method is to obtain the uri when the function is called, determine the type of the content requested, and the result list of the request, and generate related resources if the content is missing.
- Figure 101 shows specific content types such as pictures, contacts, music, videos, text messages, calls, etc.
- the notification module notifies the user to perform manual dependency injection.
- the function called when the application requests a Bluetooth device is BluetoothAdapter.getDefaultAdapter.
- the processing method is to obtain the result returned by the function, that is, the Bluetooth adapter. If the result is empty, the notification module notifies the user that the device has no Bluetooth. If the device is not turned on, the user is notified to turn on the Bluetooth switch.
- the function called when the application requests the current physical location is WifiManager.getScanResults, TelephonyManager.getCellLocation, LocationManager.requestLocationUpdates.
- the processing method is to judge the returned result list, and if the result is empty, the user is notified to open the corresponding switch, such as WIFI, 4G network, GPS switch, and the like. If the user allows the generation of fake location information, the randomly generated longitude and latitude information is returned.
- the functions called when the application requests network access are URL.Constructor, HttpURLConnection.getResponseCode, AndroidHttpClient.execute, WebView.loadUrl.
- the processing mode is to determine whether the network is open when the application accesses the network and whether the return code of the returned result is 400. If yes, the network request fails, and the user is notified to connect to the network.
- the notification module when it is detected that the GPS information cannot be read, the network cannot be accessed, and the photo cannot be automatically taken, such as a photo that cannot be automatically completed by the program, the notification module sends a ringtone notification and corresponding information (toast). ) to the user, let the user help the program to complete the dependency injection.
- the program cannot help the user to authorize, and the user needs to manually open the permission switch in the device.
- User data dependencies such as username and password cannot be used in the program Automatically fill in during the running process, notify the user when the application is not explored for a long time, and the user data dependency is not given when viewing.
- we set 500 event lengths and no new Activity Send a notification when you explore.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
一种依赖注入的安卓应用半自动化测试方法,能够结合人工测试和随机测试的优点,通过利用Xposed框架,获取应用调用相关的系统依赖请求,在测试的过程中提供应用正确运行所需要的各种依赖,提高测试覆盖率以及高效检测bug;包括Android手机预处理过程,目标程序代码插装过程,随机测试过程,依赖注入过程。利用该方法,可以一种轻量的方式自动检测在应用测试过程中的依赖请求,并自动提供资源型依赖,解决在自动测试过程中依赖缺失的问题,并且提出了一种结合人工方式能够解决复杂交互和提供用户依赖的优势和随机测试能够发现意想不到的缺陷的特点进行半自动化测试的方法,提高了自动化测试的效率和质量。
Description
本发明涉及移动应用测试领域,具体涉及的是一种基于依赖注入的安卓应用半自动化测试方法。
随着智能手机的流行,移动App逐渐成为我们日常生活的一部分,安卓系统由于其系统和设备的碎片化,导致目前很多App无法做到充分测试,我们可以从安卓市场的差评中看出很多应用存在缺陷。目前移动测试技术主要分为人工测试和自动测试,通常认为人工测试耗时耗力且容易出错,不过人类是智能的,能够产生有价值的测试用例,提升测试效果。安卓由于其开源特性以及巨大的市场份额吸引了一批研究者们研究并开发出了很多自动化测试工具,其中Monkey是安卓框架实现的随机测试工具,通过大量随机事件进行尝试,擅长发现普通操作下无法发现的错误,但效率不高,需要大量运行。
目前已有的测试工具主要聚焦于通过不同的测试策略探索应用功能并产生测试事件,但我们发现这些测试工具在一些特定的安卓应用下效果不尽如人意,其主要原因在于没有将测试依赖的问题考虑进去。安卓应用要正确运行需要很多的外部依赖,比如音乐播放器需要音乐文件才能播放,邮件客户端需要用户提供可用的邮箱账户才能访问其主要功能,如果不提供这些依赖,自动测试工具很难通过产生事件的方式到达真实用户可以轻易到达的应用状态,因而测试这些应用的主要功能也变得几乎不可能。
发明内容
针对现有技术存在的问题,本发明提供了一种基于依赖注入的安卓应用半自动化测试方法,能够结合人工测试和随机测试的优点,在测试的过程中提供应用正确运行所需要的各种依赖,提高测试覆盖率以及高效检测bug。
本发明的技术解决方案是:一种基于依赖注入的安卓应用半自动化测试方法,所述方法包括以下步骤:
A.首先对目标应用进行插装,在对目标程序代码插装时,执行如下操作:
A1.通过Xposed框架持续对Android系统载入的包进行检测,在检测到待测试应用程序的包被加载后,Xdroid模块开始进行代码插装操作。
A2.根据应用被批准的权限列表,使用Xposed提供的钩子函数进行依赖相关API的
处理函数注册,防止不必要的处理消耗。
A3.在应用的Application.onCreate方法被调用后,创建随机测试线程XMonkey。
B.在对应用进行随机测试过程时,执行如下操作:
B1.在Activity.onResume方法被调用后,测试线程被激活,开始产生事件,若测试线程长时间没有遍历到新的Activity则由通知模块发出通知,请求用户干预。在设备界面上提供可以随时切换人工和测试模式的悬浮窗,并在测试过程中收集Activity覆盖率和缺陷信息。
B2.在Activity.onPause方法被调用后,应用界面暂停,测试线程停止产生事件,等待下一次App处于前台的时刻。
B3.在应用被销毁后,应用进程被销毁,则处于应用进程中的测试线程也随之销毁。
C.当应用执行依赖相关函数时,执行依赖注入。在依赖注入过程中,执行如下操作:
C1.如果依赖没有缺失,则不做任何操作。
C2.如果被调用函数为内容型依赖,由注入模块进行自动依赖注入。通过Xposed框架提供的钩子函数,判断其请求的内容和结果,如果内容缺失则生成相关资源。
C3.如果被调用函数依赖需要用户进行干预,由通知模块通知用户进行手动依赖注入。
进一步的,步骤A1中,所述Xposed框架为安卓系统中一款可以在不修改APK的情况下影响程序运行(修改系统)的框架服务,安装该框架需要取得安卓系统的root权限。该框架通过文件管理器将安卓系统的zygote程序进行替换,对生成的新进程进行反射拦截,为特定的函数注入新的代码。
所述Xdroid模块为根据本发明所开发的Xposed模块,可运行在Xposed框架中,提供依赖注入以及自动化测试的功能,安装该模块后需要在Xposed框架中选中启用该模块并重启手机激活。
进一步的,步骤A2中所述依赖相关API包括但不限于列表中标识出的依赖相关接口:
所述钩子函数为Xposed框架提供的用于对特定函数添加代码的辅助函数:
public findAndHookMethod(String className,ClassLoader classLoader,String methodName,Object...parameterTypesAndCallback);
其中className为函数所在类名,classLoader为指定的类加载器,methodName为待替换函数名,parameterTypesAndCallback为参数类型列表和Hook回调。
进一步的,步骤B1中所述产生的事件为仿照Monkey测试工具生成的点击,按键,滑动,跟踪球,导航,主要导航,系统以及两指缩小事件,其生成比率分别是点击20%,按键13%,滑动10%,跟踪球15%,导航25%,主要导航15%,系统事件1%,两指缩小2%。
所述悬浮窗是指使用Android提供的WindowsManager开发的系统窗口,该窗口中含有可以切换人工测试和自动测试的开关,并且该窗口一经打开可以在设备界面中一直存在并且随时访问。
所述Activity覆盖率是指测试工具在测试期间遍历到的Activity的数量对Activity总量之间的比率。遍历到的Activity可以通过勾住Android.app.Activity.onCreate函数进行收集,总的Activity可以通过PackageManager的getPackageInfo方法获取。
所述缺陷是指应用在被测试过程中产生的错误,包括应用崩溃和应用无响应两种情况。应用崩溃可以通过勾住com.Android.server.am.ActivityManagerService.handleApplicationCrash函数获取崩溃信息。应用无响应可以通过勾住com.Android.server.am.ActivityManagerService.appNotResponding获取无响应错误的相关信息。
进一步的,步骤C中,所述依赖包括内容,权限,设备能力,用户干预和其他依赖。内容是指Android设备中可以存储的通用数据,包括联系人信息,日程事件,媒体文件等。权限是指安卓应用在使用相关系统数据和特性前需要向用户申请的系统权限,包括所有在AndroidManifest文件中可以列出来的所有权限,比如读取联系人和信息等权限。设备能力是指安卓设备提供的各种设备能力,包括GPS,网络,摄像头,蓝牙等。用户干预是指用户提供的有价值的数据和操作,包括打开WIFI开关,用户名密码等。其他的依赖是指应用在运行过程中可能依赖的各种特殊资源,比如其他要连接的设备等。
进一步的,步骤C2中内容型依赖是指可以通过程序自动自动产生的数据以及媒体文件,比如GPS位置和音乐文件等。对于内容型依赖自动注入生成的数据以及将存储在Xdroid中的媒体文件写入到系统中供调用。
进一步的,步骤C3中用户进行干预是指必须通过用户手动注入的依赖,包括连接网络,输入用户名密码等。对对于用户型依赖通知用户进行介入并提供与依赖相关的信息,包括该依赖所要求的人工处理方式以及与该依赖相关的参数信息,如需要打开WIFI开关,后台服务器地址等。
有益效果:与现有技术相比,本发明具有以下优点:
(1)本发明结合了人工测试和随机测试的优点,在应用测试的过程中用户能随时停止自动测试过程,提供人工交互,发挥了人工方式能够解决复杂交互和提供用户依赖的优势和随机测试能够发现意想不到的缺陷的特点,提高了代码的覆盖率以及有效寻找到应用的bug。
(2)本发明以一种轻量的方式自动检测在应用测试过程中的依赖请求,并自动提供资源型依赖,对于用户依赖,提供了方便的方式进行人工干预,解决了在自动测试过程中依赖缺失的问题,提高了自动化测试的效率和质量。在测试过程中人工参与时间逐渐减少,一般不超过总测试时间的10%。
(3)本发明中的测试自动化工具不需要任何PC机连接,完全使用智能手机的处理能力,可以在任何时间任何地点同时在多台手机上进行测试,大大减少了器材的消耗,并提供了并行测试的能力。
(4)本发明的基于依赖注入的安卓应用半自动化测试方法,能够结合人工测试和随机测试的优点,通过利用Xposed框架,获取应用调用相关的系统依赖请求,在测试的过程中提供应用正确运行所需要的各种依赖,提高测试覆盖率以及高效检测bug。
图1为本发明的实施例流程图。
图2为本发明的系统架构示意图。
图3为本发明的测试工具生命周期图。
图4为本发明的悬浮窗示意图。
下面对本发明技术方案结合附图进行详细说明,但是本发明的保护范围不局限于所述实施例。
本发明提供一种基于依赖注入的安卓半自动化测试方法,使得应用在被测试期间能够自动检测相关依赖并提供资源,使得测试程序能够更好的探索应用功能,提高测试效率。
在Android测试技术中,由于被测试应用没有被提供所依赖的资源,导致一些用户很容易进入的状态在自动化测试过程无法被覆盖。
Xposed框架是一款可以在不修改Android安装包(APK)的情况下影响程序运行的框架服务,基本原理是通过修改系统来影响程序运行。Xdroid是根据本发明提供的方法开发的基于Xposed框架的依赖注入以及自动测试模块,Xdroid模块(202)中包括方法钩子,注入模块以及通知模块。
本发明所提供的基于依赖注入的半自动测试方法包括目标程序代码插装过程,随机测试过程,依赖注入过程,具体步骤如下:
A.在安卓设备上运行选定要测试的应用,该Android程序作为待测试的目标程序,通过Xposed框架进行依赖相关代码(203)的插装,添加钩子函数;对目标程序进行插装时,执行如下操作:
A1.持续对Android系统载入的包进行检测,在检测到待测试应用程序的包被加载后,开始代码插装操作。
A2.根据应用被批准的权限列表进行相应类型的依赖处理函数注册,防止不必要的处理消耗,被注册的依赖处理函数类型包括设备内容,蓝牙,位置,网络等。
A3.在应用的Application.onCreate方法被调用后,创建随机测试线程XMonkey,我们处于应用进程内部,此时应用已经加载完毕并处于可用状态,此时我们创建随机测试线程,该测试线程通过获得的应用上下文对象获取应用信息。
B.被测应用打开时,在应用进程内部创建随机测试线程(201),开始生成各种随机事件进行测试,在设备界面上提供可以随时切换人工和测试模式的悬浮窗,并在测试过程中收集Activity覆盖率和缺陷信息;具体执行如下操作(如图3所示):
B1.在Activity.onResume方法被调用后,应用处于前台,测试线程被激活,如果用户打开了悬浮窗中的测试开关,则开始产生事件。
为了提供给用户最快捷的切换人工模式和测试模式的方式,本实施例使用悬浮窗作为切换方式。悬浮窗是指使用Android提供的WindowsManager开发的系统窗口,并且该窗口一经打开可以在设备界面中一直存在并且随时访问。在默认模式下(图401)悬浮窗可以被拖动并停靠在设备的边框,当用户点击后悬浮窗展开为一个系统窗口(图402),用户可以在这里开启或关闭测试模式。
本实施例中产生的随机事件为仿照Monkey测试工具生成的点击,按键,滑动,跟踪球,导航,主要导航,系统以及两指缩小事件,其生成比率分别是点击20%,按键13%,滑动10%,跟踪球15%,导航25%,主要导航15%,系统事件1%,两指缩小2%。
在原Monkey的实现中,其使用IWindowManager和IActivityManager实例来注入事件,但这两个实例都是系统对象,在普通应用中无法使用。因此在本实施例中我们使用Instrumentation测试框架来替换注入事件的方法,例如使用sendKeyDownUpSync方法来发送按键事件。
B2.在Activity.onPause方法被调用后,应用界面暂停,测试线程停止产生事件,等待下一次App处于前台的时刻。
注意测试线程的启动条件由两个开关组成,只有在应用处于前台并且用户打开了测试开关的情况下测试线程才会产生事件,这样可以避免无意义的性能消耗,提高测试效率。
B3.在应用被销毁后,应用进程被销毁,则处于应用进程中的测试线程也随之销毁。
C.在随机测试过程中,当应用执行依赖相关函数时,进行依赖请求的检测与注入;具体执行如下操作(如图1所示):
C1.如果依赖没有缺失,则不做任何操作。
C2.对于101中内容型依赖缺失,由注入模块进行自动依赖注入。
应用请求设备内容的依赖所调用的函数为ContentResolver.query。处理方式为获取该函数调用时的uri,判断其请求的内容的类型,以及请求的结果列表,如果内容缺失则生成相关资源。图101部分为具体的内容类型,如图片,联系人,音乐,视频,短信,电话等。
在本实施例中,如102所示,当检测到应用请求图片时,将存储在Xdroid中的3张JPG图像和3张PNG图像添加到系统的图库中去。当检测到应用读取联系人时,生成10个预先设置的联系人信息并插入到系统联系人列表中。当检测到应用读取音乐文件时,将存储在Xdroid中的3个MP3文件添加到系统的音乐库中。当检测到应用读取视频文件时,将存储在Xdroid的1个MP4文件添加到系统的媒体库中。当检测到应用读取短信息时,生成随机的10条短信息并插入到系统的信息列表中。当检测到应用读取电话记录时,生成随机的10条通话记录并插入到系统的通话记录列表中。
C3.对于103中的用户型依赖缺失,由通知模块通知用户进行手动依赖注入。
应用请求蓝牙设备时调用的函数为BluetoothAdapter.getDefaultAdapter。处理方式为获取该函数返回的结果即蓝牙适配器,如果该结果为空,则通知模块通知用户设备无蓝牙。如果设备没有被打开,则通知用户打开蓝牙开关。
应用请求当前物理位置时调用的函数为WifiManager.getScanResults,TelephonyManager.getCellLocation,LocationManager.requestLocationUpdates。处理方式为判断返回的结果列表,如果结果为空则通知用户打开对应的开关,比如WIFI,4G网络,GPS开关等。如果用户允许生成假的位置信息,则返回随机生成的经度和纬度信息。
应用请求网络访问时调用的函数为URL.Constructor,HttpURLConnection.getResponseCode,AndroidHttpClient.execute,WebView.loadUrl。处理方式为在应用访问网络的时候判断网络是否打开以及判断放回结果的返回码是否为400,如果是的话则网络请求失败,通知用户连接网络。
在本实施例中,如104所示,当检测到无法读取GPS信息,无法访问网络,无法自动拍摄照片等无法通过程序自动完成的依赖时,通知模块会发送铃声通知以及相应的信息(toast)给用户,让用户帮助程序完成依赖注入。对于权限的赋予,程序无法帮助用户进行授权,需要用户手工打开设备中的权限开关。对于用户名密码等用户数据依赖无法在程序
运行过程中自动填入,在应用很长时间后没有探索到新的应用状态时通知用户查看时候有用户数据依赖没有被赋予,在本实施例中我们设定500个事件长度仍无新的Activity探索到则发送通知。
需要注意的是,公布实施例的目的在于帮助进一步理解本发明,但是本领域的技术人员可以理解:在不脱离本发明及所附权利要求的精神和范围内,各种替换和修改都是可能的。因此,本发明不应局限于实施例所公开的内容,本发明要求保护的范围以权利要求书界定的范围为准。
Claims (10)
- 一种基于依赖注入的安卓应用半自动化测试方法,通过利用Xposed框架,获取应用调用相关的系统依赖请求,在测试的过程中提供应用正确运行所需要的各种依赖,提高测试覆盖率以及高效检测bug,其特征在于:包括目标程序代码插装过程,随机测试过程,依赖注入过程;具体步骤为:A.首先对目标应用进行插装,在对目标程序代码插装时,执行如下操作:A1.持续对Android系统载入的包进行检测,在检测到待测试应用程序的包被加载后,开始代码插装操作;A2.根据应用被批准的权限列表进行依赖相关API的处理函数注册,防止不必要的处理消耗;A3.在应用的Application.onCreate方法被调用后,创建随机测试线程XMonkey;B.在对应用进行随机测试过程时,执行如下操作:B1.在Activity.onResume方法被调用后,测试线程被激活,开始产生事件,若测试线程长时间没有遍历到新的Activity则由通知模块发出通知,请求用户干预;B2.在Activity.onPause方法被调用后,应用界面暂停,测试线程停止产生事件,等待下一次App处于前台的时刻;B3.在应用被销毁后,应用进程被销毁,则处于应用进程中的测试线程也随之销毁;C.当应用执行依赖相关函数时,执行依赖注入;在依赖注入过程中,执行如下操作:C1.如果依赖没有缺失,则不做任何操作;C2.如果被调用函数为内容型依赖,由注入模块进行自动依赖注入;通过Xposed框架提供的钩子函数,判断其请求的内容和结果,如果内容缺失则生成相关资源;C3.如果被调用函数依赖需要用户进行干预,由通知模块通知用户进行手动依赖注入。
- 如权利要求1所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤A1中待测试应用的包名通过用户从软件界面中选取,并存储到共享偏好SharedPreference中,该存储文件设置为全局可读的,由Xdroid在运行时读取。
- 如权利要求1所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤A2中被注册的依赖处理函数类型包括设备内容,蓝牙,位置,网络;对于ANR和崩溃相关的处理函数在“android”包被加载之后进行注册。
- 如权利要求1所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤A3中所创建的随机测试线程XMonkey在待测Android应用的进程内部创建,创建时间节点为应用已经加载完毕并处于可用状态。
- 如权利要求1所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤B1中需要应用处于前台,并且用户打开了悬浮窗中的测试开关才能产生事件;步骤B1中产生的事件包括点击,按键,滑动,跟踪球,导航,主要导航,系统以及两指缩小事件,其生成比率分别是点击20%,按键13%,滑动10%,跟踪球15%,导航25%,主要导航15%,系统事件1%,两指缩小2%。
- 如权利要求1所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤B2中测试线程每隔500ms检测一次应用是否处于前台且处于测试模式。
- 如权利要求1所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤C2中内容型依赖缺失后注入模块进行的注入方式为程序自动注入;自动注入方式包括将Xdroid中的媒体资源写入到系统的媒体库中以及生成生成伪造的数据插入到系统的内容提供者中;步骤C2中设备内容依赖具体的内容类型包括图片,联系人,音乐,视频,短信,电话。
- 如权利要求1所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤C3中用户型依赖缺失后通知模块进行的注入方式为通知用户,让用户手动帮助程序完成依赖注入。
- 如权利要求1至8之一所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤B1、C3中通知模块发出的通知包括一条包含依赖相关信息的Toast提示,并且伴随着一个简短的手机铃声以提示用户。
- 如权利要求1至8之一所述基于依赖注入的安卓应用半自动化测试方法,其特征在于:步骤C3中应用请求蓝牙设备相关的函数时,判断返回的结果,若为空通知用户进行处理;应用请求当前物理位置相关的函数时,判断返回的结果列表,若结果为空则通知用户打开对应的开关;如果用户允许生成假的位置信息,则返回随机生成的经度和纬度信息;应用请求网络访问相关的函数时,判断网络是否打开以及判断放回结果的返回码是否为400,如果是的话则网络请求失败,通知用户连接网络。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710166567.XA CN106951371B (zh) | 2017-03-20 | 2017-03-20 | 一种基于依赖注入的安卓应用半自动化测试方法 |
| CN201710166567.X | 2017-03-20 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018171195A1 true WO2018171195A1 (zh) | 2018-09-27 |
Family
ID=59473298
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/108455 Ceased WO2018171195A1 (zh) | 2017-03-20 | 2017-10-31 | 一种基于依赖注入的安卓应用半自动化测试方法 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN106951371B (zh) |
| WO (1) | WO2018171195A1 (zh) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114328245A (zh) * | 2021-12-30 | 2022-04-12 | 展讯通信(天津)有限公司 | 一种按键操作的测试方法、装置、存储介质和终端设备 |
| CN115809465A (zh) * | 2022-12-29 | 2023-03-17 | 杭州默安科技有限公司 | 一种安卓iast的实现方法、系统 |
| CN118427835A (zh) * | 2024-04-30 | 2024-08-02 | 南开大学 | 一种基于复合分析的安卓原生函数自动化测试方法 |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106951371B (zh) * | 2017-03-20 | 2019-07-09 | 南京大学 | 一种基于依赖注入的安卓应用半自动化测试方法 |
| CN108762815B (zh) * | 2018-05-16 | 2021-01-01 | 北京麟卓信息科技有限公司 | 一种基于非虚拟化体系架构的Android运行环境实现方法 |
| CN108984407A (zh) * | 2018-07-13 | 2018-12-11 | 南京大学 | 一种基于安卓应用层修改的有效测试框架 |
| CN111523097B (zh) * | 2020-04-09 | 2023-08-29 | 北京智慧章鱼科技有限公司 | 基于安卓系统的app刷子用户识别方法、设备及存储介质 |
| CN111782196A (zh) * | 2020-07-08 | 2020-10-16 | 上海乾臻信息科技有限公司 | 基于mvp架构的开发方法及装置 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102419727A (zh) * | 2011-09-30 | 2012-04-18 | 宇龙计算机通信科技(深圳)有限公司 | 一种自动化测试方法及装置 |
| US20150058826A1 (en) * | 2013-08-26 | 2015-02-26 | The Trustees Of Columbia University In The City Of New York | Systems and methods for efficiently and effectively detecting mobile app bugs |
| CN104850498A (zh) * | 2015-06-05 | 2015-08-19 | 上海斐讯数据通信技术有限公司 | 一种填充信息测试方法及系统 |
| CN105468529A (zh) * | 2015-12-15 | 2016-04-06 | 北京奇虎科技有限公司 | 一种安卓应用ui控件精准遍历方法和装置 |
| CN106951371A (zh) * | 2017-03-20 | 2017-07-14 | 南京大学 | 一种基于依赖注入的安卓应用半自动化测试方法 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101251796A (zh) * | 2008-03-31 | 2008-08-27 | 中国船舶重工集团公司第七〇九研究所 | 基于依赖注入的分布式构件依赖关系管理方法 |
| CN102708042A (zh) * | 2011-08-12 | 2012-10-03 | 华南理工大学 | 一种面向服务的嵌入式软件测试系统 |
| CN105320540A (zh) * | 2015-10-28 | 2016-02-10 | 深圳市创维电器科技有限公司 | 一种安卓应用的批量安装方法及系统 |
-
2017
- 2017-03-20 CN CN201710166567.XA patent/CN106951371B/zh not_active Expired - Fee Related
- 2017-10-31 WO PCT/CN2017/108455 patent/WO2018171195A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102419727A (zh) * | 2011-09-30 | 2012-04-18 | 宇龙计算机通信科技(深圳)有限公司 | 一种自动化测试方法及装置 |
| US20150058826A1 (en) * | 2013-08-26 | 2015-02-26 | The Trustees Of Columbia University In The City Of New York | Systems and methods for efficiently and effectively detecting mobile app bugs |
| CN104850498A (zh) * | 2015-06-05 | 2015-08-19 | 上海斐讯数据通信技术有限公司 | 一种填充信息测试方法及系统 |
| CN105468529A (zh) * | 2015-12-15 | 2016-04-06 | 北京奇虎科技有限公司 | 一种安卓应用ui控件精准遍历方法和装置 |
| CN106951371A (zh) * | 2017-03-20 | 2017-07-14 | 南京大学 | 一种基于依赖注入的安卓应用半自动化测试方法 |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114328245A (zh) * | 2021-12-30 | 2022-04-12 | 展讯通信(天津)有限公司 | 一种按键操作的测试方法、装置、存储介质和终端设备 |
| CN115809465A (zh) * | 2022-12-29 | 2023-03-17 | 杭州默安科技有限公司 | 一种安卓iast的实现方法、系统 |
| CN115809465B (zh) * | 2022-12-29 | 2025-07-25 | 杭州默安科技有限公司 | 一种安卓iast的实现方法、系统 |
| CN118427835A (zh) * | 2024-04-30 | 2024-08-02 | 南开大学 | 一种基于复合分析的安卓原生函数自动化测试方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN106951371B (zh) | 2019-07-09 |
| CN106951371A (zh) | 2017-07-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106951371B (zh) | 一种基于依赖注入的安卓应用半自动化测试方法 | |
| US9129058B2 (en) | Application monitoring through continuous record and replay | |
| US20190034317A1 (en) | Debug session management | |
| US20160092248A1 (en) | Hook framework | |
| CN109074278B (zh) | 验证移动应用中的有状态动态链接 | |
| WO2016095554A1 (zh) | 应用程序的测试方法、设备及系统 | |
| CN110879781B (zh) | 程序调试方法、装置、电子设备及计算机可读存储介质 | |
| CN110875858A (zh) | 应用测试数据抓取方法、系统、设备及存储介质 | |
| WO2020177519A1 (zh) | 在智能终端上执行的调试方法以及软件调试器 | |
| CN112650959B (zh) | 页面加载时长的统计方法、装置、设备及存储介质 | |
| CN113986679B (zh) | 基于配置信息热加载的性能分析方法及装置 | |
| CN107368406A (zh) | 测试应用程序的方法、装置及设备 | |
| CN107102937A (zh) | 一种用户界面测试方法和装置 | |
| CN104615662A (zh) | 一种处理数据的方法、装置及终端设备 | |
| CN106126419A (zh) | 一种应用程序的调试方法及装置 | |
| CN109710474A (zh) | 一种硬盘故障检测方法、装置、终端及可读存储介质 | |
| CN109614271A (zh) | 多个集群数据一致性的控制方法、装置、设备及存储介质 | |
| CN108563578A (zh) | Sdk兼容性检测方法、装置、设备及可读存储介质 | |
| CN112241373A (zh) | 自动化测试方法、测试装置、处理器和测试系统 | |
| CN110688245A (zh) | 信息获取方法、装置、存储介质及设备 | |
| CN110297625B (zh) | 应用的处理方法及装置 | |
| US12020039B2 (en) | Compute instance warmup operations | |
| CN120561918A (zh) | 文件外发管控方法、装置、计算机设备、可读存储介质和程序产品 | |
| CN114546556A (zh) | 应用中广告的处理方法、装置、电子设备及存储介质 | |
| WO2014067368A1 (zh) | 资源预览图的获取方法、装置以及设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17901896 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17901896 Country of ref document: EP Kind code of ref document: A1 |

