[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN105740144B - A kind of automated testing method and system of Android mobile terminal - Google Patents

A kind of automated testing method and system of Android mobile terminal Download PDF

Info

Publication number
CN105740144B
CN105740144B CN201610057107.9A CN201610057107A CN105740144B CN 105740144 B CN105740144 B CN 105740144B CN 201610057107 A CN201610057107 A CN 201610057107A CN 105740144 B CN105740144 B CN 105740144B
Authority
CN
China
Prior art keywords
activity components
activity
mobile terminal
android mobile
corresponding trigger
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.)
Active
Application number
CN201610057107.9A
Other languages
Chinese (zh)
Other versions
CN105740144A (en
Inventor
王莹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Beijing Electronic Information Industry Co Ltd
Original Assignee
Inspur Beijing Electronic Information Industry Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Inspur Beijing Electronic Information Industry Co Ltd filed Critical Inspur Beijing Electronic Information Industry Co Ltd
Priority to CN201610057107.9A priority Critical patent/CN105740144B/en
Publication of CN105740144A publication Critical patent/CN105740144A/en
Application granted granted Critical
Publication of CN105740144B publication Critical patent/CN105740144B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

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)
  • Mobile Radio Communication Systems (AREA)
  • Telephone Function (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种Android移动终端的自动化测试方法,该方法包括:当接收到测试人员输入的测试启动指令时,自动遍历并确定所述Android移动终端的所有Activity组件;按照预设的触发内容,对每个Activity组件执行相应的触发操作,得到每个Activity组件响应与其相应的触发操作而产生的UI控件信息;根据所有Activity组件的UI控件信息实现对Android移动终端的自动化测试。可见,只需测试人员预先设定好触发内容,在需要测试的时候,直接下达测试启动指令即能够实现对Android移动终端进行高效、可靠的自动化测试,后续不需要测试人员的参与,测试人员腾出时间去完成其它事情。

The invention discloses an automated testing method for an Android mobile terminal. The method includes: automatically traversing and determining all Activity components of the Android mobile terminal when receiving a test start instruction input by a tester; , perform corresponding trigger operations on each Activity component, and obtain UI control information generated by each Activity component in response to its corresponding trigger operation; realize automated testing of Android mobile terminals according to the UI control information of all Activity components. It can be seen that only the tester needs to pre-set the trigger content, and when the test is required, the test start command can be issued directly to realize efficient and reliable automated testing of the Android mobile terminal. Make time to get other things done.

Description

一种Android移动终端的自动化测试方法及系统An automated testing method and system for an Android mobile terminal

技术领域technical field

本发明涉及软件测试技术领域,特别是涉及一种Android移动终端的自动化测试方法及系统。The invention relates to the technical field of software testing, in particular to an automated testing method and system for an Android mobile terminal.

背景技术Background technique

当今,移动终端产品出货周期快,生命周期短,为保证移动终端出货快速并且性能稳定,通常会花费极大的人力和较长的时间来对移动终端的测试,具体地,对于Android移动终端而言,人们会利用Android模拟器来进行性能测试,其中,Android模拟器为AndroidSDK自带一个移动模拟器,它是一个可以运行在电脑上的虚拟设备。Android模拟器可以让人们不需使用物理设备即可预览、开发和测试Android应用程序。Today, mobile terminal products have a fast delivery cycle and a short life cycle. In order to ensure fast delivery and stable performance of mobile terminals, it usually takes a lot of manpower and a long time to test mobile terminals. Specifically, for Android mobile As far as the terminal is concerned, people will use the Android emulator to perform performance testing. The Android emulator comes with a mobile emulator for the AndroidSDK, which is a virtual device that can run on a computer. The Android emulator allows people to preview, develop and test Android applications without using a physical device.

现有的测试方法通常是由测试人员手工一步一步进行测试,比如测试人员手动依次遍历Activity路径、在需要的时候手动输入触发相关内容等,就机械的重复性而言,耗时耗力,测试效率低。同时,由于移动终端软件系统较复杂,手工测试难以将Activity路径实现全覆盖,这样使得测试结果的可靠性和准确度得不到保障。Existing testing methods are usually manually tested step by step by the tester, for example, the tester manually traverses the Activity path one by one, manually enters the trigger related content when needed, etc. In terms of mechanical repeatability, it is time-consuming and labor-intensive. low efficiency. At the same time, due to the complexity of the mobile terminal software system, manual testing is difficult to fully cover the Activity path, which makes the reliability and accuracy of the test results unguaranteed.

还有,在实际生活中,一般企业虽然有专门的软件测试团队,但开发人员与测试人员的比例大约为10:1,远无法达到业界的4:1,或者开发测试最优配置1:2。人力不足的长期困扰使得该行业加班现象严重,因此,更是亟需一种高效的测试方法。Also, in real life, although a general enterprise has a dedicated software testing team, the ratio of developers to testers is about 10:1, which is far from reaching the industry's 4:1, or the optimal configuration of development and testing at 1:2. . The long-term problem of insufficient manpower has caused serious overtime in this industry. Therefore, an efficient testing method is urgently needed.

其中,Activity是Android组件中最基本也是最为常见用的四大组件(Activity,Service服务,Content Provider内容提供者,BroadcastReceiver广播接收器)之一。Activity中所有操作都与用户密切相关,是一个负责与用户交互的应用程序组件。在一个android应用中,一个Activity通常就是一个单独的屏幕,它上面可以显示一些控件也可以监听并处理用户的事件做出响应。Among them, Activity is one of the most basic and most commonly used four components in Android components (Activity, Service service, Content Provider content provider, BroadcastReceiver broadcast receiver). All operations in the Activity are closely related to the user, and it is an application component responsible for interacting with the user. In an android application, an Activity is usually a separate screen on which some controls can be displayed and can also listen to and process user events to respond.

发明内容Contents of the invention

有鉴于此,本发明提供了一种Android移动终端的自动化测试方法及系统,以对Android移动终端进行高效、可靠的测试。In view of this, the present invention provides an automated testing method and system for an Android mobile terminal, so as to efficiently and reliably test the Android mobile terminal.

为解决上述技术问题,本发明提供一种Android移动终端的自动化测试方法,该方法包括:In order to solve the above technical problems, the present invention provides an automated testing method for an Android mobile terminal, the method comprising:

当接收到测试人员输入的测试启动指令时,自动遍历并确定所述Android移动终端的所有Activity组件;When receiving the test start command input by the tester, automatically traverse and determine all Activity components of the Android mobile terminal;

按照预设的触发内容,对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的UI控件信息;Perform a corresponding trigger operation on each of the Activity components according to the preset trigger content, and obtain UI control information generated by each of the Activity components in response to its corresponding trigger operation;

根据所有所述Activity组件的所述UI控件信息实现对所述Android移动终端的自动化测试。The automated testing of the Android mobile terminal is realized according to the UI control information of all the Activity components.

上述方法中,优选地,所述按照预设的触发内容,对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的UI控件信息,包括:In the above method, preferably, the corresponding trigger operation is performed on each of the Activity components according to the preset trigger content, and the UI control information generated by each of the Activity components in response to its corresponding trigger operation is obtained, including :

获取各所述Activity组件间的跳转路径;Obtain the jump paths between the Activity components;

按照所述跳转路径的顺序,依次对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的所述UI控件信息。According to the order of the jump path, the corresponding trigger operation is performed on each of the Activity components in turn, and the UI control information generated by each of the Activity components in response to its corresponding trigger operation is obtained.

上述方法中,优选地,在所述使用相应的触发内容触发每个所述Activity组件之前,还包括:In the above method, preferably, before using the corresponding trigger content to trigger each of the Activity components, it further includes:

控制预设Android模拟器启动每个所述Activity组件。Controls the default Android emulator to start each of the Activity components.

上述方法中,优选地,在所述自动遍历并确定所述Android移动终端的所有Activity组件之前,还包括:In the above method, preferably, before the automatic traversal and determination of all Activity components of the Android mobile terminal, it also includes:

从预设shell接口接收所述测试启动指令。The test start command is received from a preset shell interface.

上述方法中,优选地,在所述按照预设的触发内容,对每个所述Activity组件执行相应的触发操作之后,还包括:In the above method, preferably, after performing the corresponding trigger operation on each of the Activity components according to the preset trigger content, it further includes:

在每个所述Activity组件响应与其相应的触发操作的过程中,对每个所述Activity组件调用预设敏感行为函数时输入的参数信息进行记录,并将记录的参数信息以日志形式输出。In the process of each of the Activity components responding to their corresponding trigger operations, record the input parameter information when each of the Activity components call the preset sensitive behavior function, and output the recorded parameter information in the form of a log.

本发明还提供了一种Android移动终端的自动化测试系统,该系统包括:The present invention also provides a kind of automatic testing system of Android mobile terminal, and this system comprises:

遍历单元,用于当接收到测试人员输入的测试启动指令时,自动遍历并确定所述Android移动终端的所有Activity组件;The traversal unit is used to automatically traverse and determine all Activity components of the Android mobile terminal when receiving the test start instruction input by the tester;

触发单元,用于按照预设的触发内容,对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的UI控件信息;A trigger unit, configured to perform a corresponding trigger operation on each of the Activity components according to a preset trigger content, and obtain UI control information generated by each of the Activity components in response to its corresponding trigger operation;

测试单元,用于根据所有所述Activity组件的所述UI控件信息实现对所述Android移动终端的自动化测试。A testing unit, configured to realize automated testing of the Android mobile terminal according to the UI control information of all the Activity components.

上述系统中,优选地,所述触发单元包括:In the above system, preferably, the trigger unit includes:

获取子单元,用于获取各所述Activity组件间的跳转路径;Obtaining subunits, used to obtain jump paths between the Activity components;

触发子单元,用于按照所述跳转路径的顺序,依次对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的所述UI控件信息。The triggering subunit is configured to perform corresponding triggering operations on each of the Activity components in sequence according to the order of the jump path, and obtain the UI control information generated by each of the Activity components in response to its corresponding triggering operation .

上述系统中,优选地,还包括:In the above system, preferably, it also includes:

启动单元,用于在所述使用相应的触发内容触发每个所述Activity组件之前,控制预设Android模拟器启动每个所述Activity组件。The starting unit is configured to control the preset Android emulator to start each of the Activity components before the corresponding trigger content is used to trigger each of the Activity components.

上述系统中,优选地,还包括:In the above system, preferably, it also includes:

接收单元,用于在所述自动遍历并确定所述Android移动终端的所有Activity组件之前,从预设shell接口接收所述测试启动指令。The receiving unit is configured to receive the test start instruction from a preset shell interface before the automatic traversal and determination of all Activity components of the Android mobile terminal.

上述系统中,优选地,还包括:In the above system, preferably, it also includes:

记录单元,用于在所述按照预设的触发内容,对每个所述Activity组件执行相应的触发操作之后,在每个所述Activity组件响应与其相应的触发操作的过程中,对每个所述Activity组件调用预设敏感行为函数时输入的参数信息进行记录,并将记录的参数信息以日志形式输出。The recording unit is configured to, after performing the corresponding trigger operation on each of the Activity components according to the preset trigger content, and record each of the Activity components in the process of responding to the corresponding trigger operation. Record the parameter information input when the Activity component calls the preset sensitive behavior function, and output the recorded parameter information in the form of a log.

以上本发明提供的一种Android移动终端的自动化测试方法及系统中,当接收到测试人员输入的测试启动指令时,本发明系统能够自动遍历并确定所述Android移动终端的所有Activity组件;按照测试人员预设的触发内容(并不需要测试人员守在旁边手动输入触发相关内容),对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的UI控件信息;根据所有所述Activity组件的所述UI控件信息实现对所述Android移动终端的自动化测试。可见,只需测试人员预先设定好触发内容,在需要测试的时候,直接下达测试启动指令即能够实现对Android移动终端进行高效、可靠的自动化测试,后续不需要测试人员的参与,测试人员腾出时间去完成其它事情。In the automated testing method and system of a kind of Android mobile terminal provided by the present invention above, when receiving the test start instruction that tester inputs, the system of the present invention can traverse automatically and determine all Activity components of described Android mobile terminal; According to test The trigger content preset by the personnel (the tester does not need to manually input the trigger related content), executes the corresponding trigger operation on each of the Activity components, and obtains the response of each of the Activity components to its corresponding trigger operation. UI control information; realize the automated test to the Android mobile terminal according to the UI control information of all the Activity components. It can be seen that only the tester needs to pre-set the trigger content, and when the test is required, the test start command can be issued directly to realize efficient and reliable automated testing of the Android mobile terminal. Make time to get other things done.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only It is an embodiment of the present invention, and those skilled in the art can also obtain other drawings according to the provided drawings without creative work.

图1为本发明实施例提供的一种Android移动终端的自动化测试方法的流程图;Fig. 1 is the flowchart of the automated testing method of a kind of Android mobile terminal that the embodiment of the present invention provides;

图2为本发明实施例提供的一种Android移动终端的自动化测试系统的结构框图示意图。FIG. 2 is a schematic structural block diagram of an automated testing system for an Android mobile terminal provided by an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.

本发明的核心是提供一种Android移动终端的自动化测试方法及系统,以对Android移动终端进行高效、可靠的测试。The core of the present invention is to provide an automated testing method and system for an Android mobile terminal, so as to efficiently and reliably test the Android mobile terminal.

为了使本技术领域的人员更好地理解本发明方案,下面结合附图和具体实施方式对本发明作进一步的详细说明。In order to enable those skilled in the art to better understand the solution of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.

参考图1,图1示出了本发明实施例提供的一种Android移动终端的自动化测试方法的流程图,该方法具体可以包括如下步骤:With reference to Fig. 1, Fig. 1 has shown the flowchart of the automated testing method of a kind of Android mobile terminal that the embodiment of the present invention provides, and this method specifically can comprise the following steps:

步骤S100、当接收到测试人员输入的测试启动指令时,自动遍历并确定Android移动终端的所有Activity组件。Step S100, when receiving the test start instruction input by the tester, automatically traverse and determine all the Activity components of the Android mobile terminal.

本发明实施例主要针对Android移动终端中的Android软件进行自动化测试,每个Android软件包括多个Activity组件(当然,不排除一个的情况),这样,对于Android移动终端中所有Android软件来说,其是一个许多Activity组件组成的大集合。因此,本发明主要从Activity组件来对Android软件的动态行为进行实时监测。The embodiment of the present invention mainly carries out automated testing for the Android software in the Android mobile terminal, and each Android software includes a plurality of Activity components (certainly, does not rule out one situation), like this, for all Android software in the Android mobile terminal, its It is a large collection of many Activity components. Therefore, the present invention mainly monitors the dynamic behavior of the Android software from the Activity component in real time.

目前,Monkeyrunner为Android系统常用的一个测试工具,有助于开发人员通过脚本部署较大规模的自动化测试。具体地,本发明可以有效利用Monkeyrunner工具提供的API编写出python程序,这个python程序能够在自动遍历并确定所有Activity组件之后控制Android模拟器启动Activity组件,进而实现后续的触发操作等等。Currently, Monkeyrunner is a commonly used testing tool for the Android system, which helps developers deploy large-scale automated tests through scripts. Specifically, the present invention can effectively utilize the API provided by the Monkeyrunner tool to write a python program, and this python program can control the Android emulator to start the Activity component after automatically traversing and determining all Activity components, and then implement subsequent trigger operations and the like.

进一步地,可以通过在linux下执行shell脚本来调用并执行python程序,其中,shell是人机交互的接口,是包在Linux内核外的一个“壳”,翻译Linux用户输入的指令(shell命令)并交由内核执行。有点类似DOS。本发明中,在需要测试的时候,测试人员开启预设的能够调用并执行python程序的shell脚本,通过该shell脚本提供的shell接口将测试启动指令传递至测试系统,当测试系统从预设shell接口接收到该测试启动指令时,自动遍历并确定Android移动终端的所有Activity组件。Further, the python program can be invoked and executed by executing a shell script under linux, wherein, the shell is an interface for human-computer interaction, a "shell" wrapped outside the Linux kernel, and translates instructions (shell commands) entered by Linux users and handed over to the kernel for execution. A bit similar to DOS. In the present invention, when a test is needed, the tester opens a preset shell script that can call and execute the python program, and the test start command is passed to the test system through the shell interface provided by the shell script. When the test system starts from the preset shell When the interface receives the test start command, it will automatically traverse and determine all the Activity components of the Android mobile terminal.

步骤S101、按照预设的触发内容,对每个Activity组件执行相应的触发操作,得到每个Activity组件响应与其相应的触发操作而产生的UI控件信息。Step S101 , according to the preset trigger content, perform a corresponding trigger operation on each Activity component, and obtain UI control information generated by each Activity component in response to its corresponding trigger operation.

本发明中,上述触发内容由测试人员根据实际需求进行预先设定,这样,在整个测试过程中,并不需要测试人员守在旁边手动输入触发相关内容。实际应用中,每个Activity组件对应一个触发内容,每个触发内容可以根据需求包含一个或多个触发动作,这一个或多个触发动作组成一个触发操作。比如,Activity组件A为显示图库,图库包括图片文件夹,Activity组件A对应的触发内容为点击某个图片文件夹(比如文件夹F)以查看里面的图片,则其包含的触发操作为点击“文件夹F”控件;Activity组件B为显示文件夹F中的所有图片,Activity组件B对应的触发内容为选择某个图片(比如图片P)并删除该图片P,则其包含的触发操作为选中“图片P”控件并点击“删除”控件。以此类推。In the present invention, the above-mentioned triggering content is preset by the tester according to actual needs, so that during the whole testing process, the tester does not need to manually input the relevant triggering content. In practical applications, each Activity component corresponds to a trigger content, and each trigger content may contain one or more trigger actions according to requirements, and the one or more trigger actions constitute a trigger operation. For example, Activity component A is to display a gallery, and the gallery includes picture folders. The trigger content corresponding to Activity component A is to click a certain picture folder (such as folder F) to view the pictures in it, and the trigger action contained in it is to click " Folder F" control; Activity component B is to display all pictures in folder F, and the trigger content corresponding to Activity component B is to select a certain picture (such as picture P) and delete the picture P, then the trigger operation contained in it is selected "Picture P" control and click on the "Delete" control. and so on.

实际应用中,各Activity组件间存在相互跳转的路径(可参考现有技术),可以在静态分析中获取Activity跳转路径,通过分析apk反编译后的AndroidManifest.xml文件、samli代码文件获得Activity跳转路径,这些文件对Android四大组件进行了声明。其中,广播组件名称用于在动态触发部分设置触发环境,Service组件名称用于在动态触发部分启动后台服务,Activity跳转路径则给出了Activity的启动顺序。In practical applications, there are mutual jump paths between the various Activity components (refer to the existing technology), and the Activity jump path can be obtained in the static analysis, and the Activity can be obtained by analyzing the AndroidManifest.xml file and the samli code file decompiled from the apk Jump path, these files declare the four major components of Android. Among them, the broadcast component name is used to set the trigger environment in the dynamic trigger part, the Service component name is used to start the background service in the dynamic trigger part, and the Activity jump path gives the startup sequence of the Activity.

通过对APK反编译的文件进行分析,从AndroidManifest.xml文件中提取到组件名称以及Activity组件的转换路径,其中,得到的组件名称可以用Monkeyrunner工具提供的API写出python程序。By analyzing the APK decompiled file, the component name and the conversion path of the Activity component are extracted from the AndroidManifest.xml file. The obtained component name can be used to write python programs using the API provided by the Monkeyrunner tool.

对于步骤S101,具体地,先获取各Activity组件间的跳转路径,然后按照跳转路径的顺序,依次对每个Activity组件执行相应的触发操作得到每个Activity组件响应与其相应的触发操作而产生的UI(用户界面)控件信息。其中,对于UI控件信息的产生过程可参考现有技术。For step S101, specifically, first obtain the jump path between the various Activity components, and then perform corresponding trigger operations on each Activity component in turn according to the order of the jump paths to obtain each Activity component in response to its corresponding trigger operation. UI (User Interface) control information. Wherein, for the generation process of UI control information, reference may be made to the prior art.

可以理解的是,要想对Activity组件实现触发,前提是这个Activity组件必须是处于启动状态的,因此,在当前Activity组件做出响应时,由Android模拟器根据上述跳转路径启动下一跳的Activity组件。本发明中,通过记录Android软件对系统应用框架层次的函数调用关系,对Android进行动态行为监测。对Android软件读取通信录、短信等用户隐私信息需要调用的函数输入的相关参数进行HOOK时,并将行为信息以日志文件的形式输出。在具体实施过程中,在每个Activity组件响应与其相应的触发操作的过程中,对每个Activity组件调用预设敏感行为函数时输入的参数信息进行记录,并将记录的参数信息以日志形式输出。It is understandable that in order to trigger the Activity component, the premise is that the Activity component must be in the startup state. Therefore, when the current Activity component responds, the Android emulator starts the next jump according to the above jump path. Activity components. In the present invention, the dynamic behavior monitoring of Android is carried out by recording the function calling relationship of the Android software to the system application framework level. When HOOKing the relevant parameters of the function input that the Android software needs to call to read the address book, SMS and other user privacy information, the behavior information is output in the form of a log file. In the specific implementation process, during the process of each Activity component responding to its corresponding trigger operation, record the parameter information input when each Activity component calls the preset sensitive behavior function, and output the recorded parameter information in the form of a log .

步骤S102、根据所有Activity组件的UI控件信息实现对Android移动终端的自动化测试。Step S102 , realizing automated testing of the Android mobile terminal according to the UI control information of all Activity components.

在每一个Activity组件上,测试系统会调用UI获取部件来获取当前Activity组件的UI控件信息,每一个Activity组件都是一组UI元素的布局集合,Android提供ViewServer服务,通过它来获取Activity信息,在具体实施过程中,向ViewServer发送“DUMP-1”命令,便可以获取到当前Activity的UI层次信息(即UI控件信息)。每一个UI控件用一行字符串进行属性说明,每一行开头的空格则表示该控件在当前界面的层次信息。系统调用python编写的解析脚本获取到了所需要的UI控件信息,包括控件类型、控件上的文字、控件哈希值、控件的id值等等,而这些信息正好可以用来唯一锁定控件进行自动化的UI交互。On each Activity component, the test system will call the UI acquisition component to obtain the UI control information of the current Activity component. Each Activity component is a layout collection of UI elements. Android provides ViewServer service to obtain Activity information. In the specific implementation process, the UI layer information (that is, the UI control information) of the current Activity can be obtained by sending the "DUMP-1" command to the ViewServer. Each UI control uses a line of strings to describe its properties, and the space at the beginning of each line indicates the level information of the control in the current interface. The system calls the parsing script written in python to obtain the required UI control information, including control type, text on the control, control hash value, control id value, etc., and these information can be used to uniquely lock the control for automation UI interaction.

以上本发明采用静态代码分析与动态触发相结合的方式,根据Android软件的静态分析结果来设置触发环境(由所有触发内容形成),预设Andriod模拟器,按照Activity组件跳转顺序针对Activity组件进行触发,以及获取到当前Activity的UI控件信息进行UI自动化交互处理,以此来实现对移动终端的UI自动化测试。Above the present invention adopts the mode that static code analysis combines with dynamic triggering, set up triggering environment (formed by all triggering content) according to the static analysis result of Android software, preset Andriod emulator, carry out according to Activity component jump order for Activity component Trigger, and obtain the UI control information of the current Activity to perform UI automation interaction processing, so as to realize the UI automation test of the mobile terminal.

可见,只需测试人员预先设定好触发内容,在需要测试的时候,直接下达测试启动指令即能够实现对Android移动终端进行高效、可靠的自动化测试,后续不需要测试人员的参与,测试人员腾出时间去完成其它事情。It can be seen that only the tester needs to pre-set the trigger content, and when the test is required, the test start command can be issued directly to realize efficient and reliable automated testing of the Android mobile terminal. Make time to get other things done.

基于上述本发明实施例提供的Android移动终端的自动化测试方法,本发明实施例还提供了一种Android移动终端的自动化测试系统,参考图2,该系统200可以包括如下内容:Based on the automated testing method for the Android mobile terminal provided by the above-mentioned embodiments of the present invention, the embodiment of the present invention also provides an automated testing system for an Android mobile terminal. Referring to FIG. 2, the system 200 may include the following:

遍历单元201,用于当接收到测试人员输入的测试启动指令时,自动遍历并确定Android移动终端的所有Activity组件;The traversal unit 201 is used to automatically traverse and determine all Activity components of the Android mobile terminal when receiving the test start instruction input by the tester;

触发单元202,用于按照预设的触发内容,对每个Activity组件执行相应的触发操作,得到每个Activity组件响应与其相应的触发操作而产生的UI控件信息;The trigger unit 202 is configured to perform a corresponding trigger operation on each Activity component according to preset trigger content, and obtain UI control information generated by each Activity component in response to its corresponding trigger operation;

测试单元203,用于根据所有Activity组件的UI控件信息实现对Android移动终端的自动化测试。The testing unit 203 is configured to realize the automated testing of the Android mobile terminal according to the UI control information of all Activity components.

本发明中,上述触发单元202具体可以包括如下内容:In the present invention, the above-mentioned triggering unit 202 may specifically include the following content:

获取子单元,用于获取各Activity组件间的跳转路径;Obtain subunits, which are used to obtain the jump paths between the Activity components;

触发子单元,用于按照跳转路径的顺序,依次对每个Activity组件执行相应的触发操作,得到每个Activity组件响应与其相应的触发操作而产生的UI控件信息。The triggering subunit is configured to perform corresponding triggering operations on each Activity component in sequence according to the order of the jump path, and obtain UI control information generated by each Activity component in response to its corresponding triggering operation.

本发明中,上述系统200还可以包括启动单元,用于在使用相应的触发内容触发每个Activity组件之前,控制预设Android模拟器启动每个Activity组件。In the present invention, the above-mentioned system 200 may further include a starting unit, configured to control a preset Android emulator to start each Activity component before using corresponding trigger content to trigger each Activity component.

另外,上述系统200还可以包括接收单元,用于在自动遍历并确定Android移动终端的所有Activity组件之前,从预设shell接口接收测试启动指令。In addition, the above-mentioned system 200 may further include a receiving unit, configured to receive a test start instruction from a preset shell interface before automatically traversing and determining all Activity components of the Android mobile terminal.

本发明中,上述系统200还可以包括记录单元,用于在按照预设的触发内容,对每个Activity组件执行相应的触发操作之后,在每个Activity组件响应与其相应的触发操作的过程中,对每个Activity组件调用预设敏感行为函数时输入的参数信息进行记录,并将记录的参数信息以日志形式输出。In the present invention, the above-mentioned system 200 may further include a recording unit, which is used to, after performing the corresponding trigger operation on each Activity component according to the preset trigger content, during the process of each Activity component responding to its corresponding trigger operation, Record the parameter information input when each Activity component calls the preset sensitive behavior function, and output the recorded parameter information in the form of a log.

需要说明的是,本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。对于系统类实施例而言,由于其与方法实施例基本相似,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. For the same and similar parts in each embodiment, refer to each other, that is, Can. As for the system embodiment, because it is basically similar to the method embodiment, the description is relatively simple, and for the related parts, please refer to the part of the description of the method embodiment.

以上对本发明所提供的一种Android移动终端的自动化测试方法及系统进行了详细介绍。本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以对本发明进行若干改进和修饰,这些改进和修饰也落入本发明权利要求的保护范围内。The above describes in detail the automatic testing method and system for an Android mobile terminal provided by the present invention. In this paper, specific examples are used to illustrate the principle and implementation of the present invention, and the descriptions of the above embodiments are only used to help understand the method and core idea of the present invention. It should be pointed out that for those skilled in the art, without departing from the principles of the present invention, some improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

Claims (8)

1.一种Android移动终端的自动化测试方法,其特征在于,该方法包括:1. an automated testing method for an Android mobile terminal, characterized in that the method comprises: 当接收到测试人员输入的测试启动指令时,自动遍历并确定所述Android移动终端的所有Activity组件;When receiving the test start command input by the tester, automatically traverse and determine all Activity components of the Android mobile terminal; 按照预设的触发内容,对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的UI控件信息;Perform a corresponding trigger operation on each of the Activity components according to the preset trigger content, and obtain UI control information generated by each of the Activity components in response to its corresponding trigger operation; 根据所有所述Activity组件的所述UI控件信息实现对所述Android移动终端的自动化测试;Realize the automated testing of the Android mobile terminal according to the UI control information of all the Activity components; 其中,在每个所述Activity组件响应与其相应的触发操作的过程中,对每个所述Activity组件调用预设敏感行为函数时输入的参数信息进行记录,并将记录的参数信息以日志形式输出。Wherein, during the process of each of the Activity components responding to its corresponding trigger operation, record the parameter information input when each of the Activity components call the preset sensitive behavior function, and output the recorded parameter information in the form of a log . 2.如权利要求1所述的方法,其特征在于,所述按照预设的触发内容,对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的UI控件信息,包括:2. The method according to claim 1, wherein, according to the preset trigger content, a corresponding trigger operation is performed on each of the Activity components, so that each of the Activity components responds to its corresponding trigger operation The generated UI control information includes: 获取各所述Activity组件间的跳转路径;Obtain the jump paths between the Activity components; 按照所述跳转路径的顺序,依次对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的所述UI控件信息。According to the order of the jump path, the corresponding trigger operation is performed on each of the Activity components in turn, and the UI control information generated by each of the Activity components in response to its corresponding trigger operation is obtained. 3.如权利要求2所述的方法,其特征在于,在使用相应的触发内容触发每个所述Activity组件之前,还包括:3. The method according to claim 2, further comprising: before using the corresponding trigger content to trigger each of the Activity components: 控制预设Android模拟器启动每个所述Activity组件。Controls the default Android emulator to start each of the Activity components. 4.如权利要求1所述的方法,其特征在于,在所述自动遍历并确定所述Android移动终端的所有Activity组件之前,还包括:4. The method according to claim 1, wherein, before the automatic traversal and determination of all Activity components of the Android mobile terminal, further comprising: 从预设shell接口接收所述测试启动指令。The test start command is received from a preset shell interface. 5.一种Android移动终端的自动化测试系统,其特征在于,该系统包括:5. an automated testing system for an Android mobile terminal, characterized in that the system comprises: 遍历单元,用于当接收到测试人员输入的测试启动指令时,自动遍历并确定所述Android移动终端的所有Activity组件;The traversal unit is used to automatically traverse and determine all Activity components of the Android mobile terminal when receiving the test start instruction input by the tester; 触发单元,用于按照预设的触发内容,对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的UI控件信息;A trigger unit, configured to perform a corresponding trigger operation on each of the Activity components according to a preset trigger content, and obtain UI control information generated by each of the Activity components in response to its corresponding trigger operation; 测试单元,用于根据所有所述Activity组件的所述UI控件信息实现对所述Android移动终端的自动化测试;A test unit, configured to implement automated testing of the Android mobile terminal according to the UI control information of all the Activity components; 记录单元,用于在所述按照预设的触发内容,对每个所述Activity组件执行相应的触发操作之后,在每个所述Activity组件响应与其相应的触发操作的过程中,对每个所述Activity组件调用预设敏感行为函数时输入的参数信息进行记录,并将记录的参数信息以日志形式输出。The recording unit is configured to, after performing the corresponding trigger operation on each of the Activity components according to the preset trigger content, and record each of the Activity components in the process of responding to the corresponding trigger operation. Record the parameter information input when the Activity component calls the preset sensitive behavior function, and output the recorded parameter information in the form of a log. 6.如权利要求5所述的系统,其特征在于,所述触发单元包括:6. The system according to claim 5, wherein the trigger unit comprises: 获取子单元,用于获取各所述Activity组件间的跳转路径;Obtaining subunits, used to obtain jump paths between the Activity components; 触发子单元,用于按照所述跳转路径的顺序,依次对每个所述Activity组件执行相应的触发操作,得到每个所述Activity组件响应与其相应的触发操作而产生的所述UI控件信息。The triggering subunit is configured to perform corresponding triggering operations on each of the Activity components in sequence according to the order of the jump path, and obtain the UI control information generated by each of the Activity components in response to its corresponding triggering operation . 7.如权利要求6所述的系统,其特征在于,还包括:7. The system of claim 6, further comprising: 启动单元,用于在使用相应的触发内容触发每个所述Activity组件之前,控制预设Android模拟器启动每个所述Activity组件。The starting unit is used to control the preset Android emulator to start each of the Activity components before using the corresponding trigger content to trigger each of the Activity components. 8.如权利要求5所述的系统,其特征在于,还包括:8. The system of claim 5, further comprising: 接收单元,用于在所述自动遍历并确定所述Android移动终端的所有Activity组件之前,从预设shell接口接收所述测试启动指令。The receiving unit is configured to receive the test start instruction from a preset shell interface before the automatic traversal and determination of all Activity components of the Android mobile terminal.
CN201610057107.9A 2016-01-27 2016-01-27 A kind of automated testing method and system of Android mobile terminal Active CN105740144B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610057107.9A CN105740144B (en) 2016-01-27 2016-01-27 A kind of automated testing method and system of Android mobile terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610057107.9A CN105740144B (en) 2016-01-27 2016-01-27 A kind of automated testing method and system of Android mobile terminal

Publications (2)

Publication Number Publication Date
CN105740144A CN105740144A (en) 2016-07-06
CN105740144B true CN105740144B (en) 2018-11-23

Family

ID=56247808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610057107.9A Active CN105740144B (en) 2016-01-27 2016-01-27 A kind of automated testing method and system of Android mobile terminal

Country Status (1)

Country Link
CN (1) CN105740144B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106357670A (en) * 2016-10-17 2017-01-25 成都知道创宇信息技术有限公司 Simulator-based android application server side Web vulnerability detection method
CN107329893A (en) * 2017-06-21 2017-11-07 广州酷狗计算机科技有限公司 Traversal method, device and the storage medium of application interface
CN107368422A (en) * 2017-08-02 2017-11-21 网易有道信息技术(北京)有限公司 A kind of method of testing of application APP, device and medium
CN109522201A (en) * 2017-09-18 2019-03-26 北京京东尚科信息技术有限公司 A kind of method and apparatus of application program stability test
CN109634831A (en) * 2017-10-09 2019-04-16 飞狐信息技术(天津)有限公司 A kind of Android application program GUI traverses test method and system automatically
CN108520063B (en) * 2018-04-11 2020-12-25 Oppo广东移动通信有限公司 Event log processing method and device and terminal equipment
CN111382424A (en) * 2018-12-27 2020-07-07 全球能源互联网研究院有限公司 Mobile application sensitive behavior detection method and system based on controlled environment
CN109857386B (en) * 2018-12-30 2022-06-21 贝壳技术有限公司 Page skipping method and device
CN112180189A (en) * 2020-09-09 2021-01-05 杭州涂鸦信息技术有限公司 An automatic detection method, device and system based on multi-category intelligent modules
CN113360373A (en) * 2021-05-26 2021-09-07 上海蛮犀科技有限公司 Test method for full traversal of Activity page of mobile application

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103336742A (en) * 2013-07-18 2013-10-02 北京航空航天大学 Automation software black box testing system and method based on Android
CN103530221A (en) * 2012-07-02 2014-01-22 北京大学 Method for mapping procedure behavior and interface operation in Android system
CN104050076A (en) * 2013-03-12 2014-09-17 阿里巴巴集团控股有限公司 Testing method, device and system of application software on mobile terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3722206B2 (en) * 2000-06-30 2005-11-30 日本電気株式会社 Software test work support method, apparatus, and recording medium recording software test work support program
JP4154289B2 (en) * 2003-06-20 2008-09-24 富士通株式会社 Defect detection method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530221A (en) * 2012-07-02 2014-01-22 北京大学 Method for mapping procedure behavior and interface operation in Android system
CN104050076A (en) * 2013-03-12 2014-09-17 阿里巴巴集团控股有限公司 Testing method, device and system of application software on mobile terminal
CN103336742A (en) * 2013-07-18 2013-10-02 北京航空航天大学 Automation software black box testing system and method based on Android

Also Published As

Publication number Publication date
CN105740144A (en) 2016-07-06

Similar Documents

Publication Publication Date Title
CN105740144B (en) A kind of automated testing method and system of Android mobile terminal
CN108595329B (en) Application testing method and device and computer storage medium
US10853232B2 (en) Adaptive system for mobile device testing
CN103186740B (en) A kind of automated detection method of Android malware
Kaasila et al. Testdroid: automated remote UI testing on Android
Lam et al. Record and replay for android: Are we there yet in industrial cases?
Azim et al. Targeted and depth-first exploration for systematic testing of android apps
CN104699616B (en) The method of a kind of application test, Apparatus and system
US9336127B2 (en) Exposing method related data calls during testing in an event driven, multichannel architecture
CN104598380B (en) A control-based automated testing method and system
US9268670B1 (en) System for module selection in software application testing including generating a test executable based on an availability of root access
WO2018010552A1 (en) Test method and device
CN110013672B (en) Method, device, apparatus and computer-readable storage medium for automated testing of machine-run games
CN103729294B (en) Method and device for testing performance script of application software
US10296444B1 (en) Methods and systems for testing mobile applications for android mobile devices
CN103530221B (en) A mapping method between program behavior and interface operation in Android system
CN105468529A (en) Accurate traversal method and apparatus for UI controls of android application
CN104461898A (en) Application testing method, center control server, test terminal and system
CN106844136A (en) The collection method and system of a kind of program crashing information
CN110716853A (en) A test script recording method, application program testing method and related device
US8752027B2 (en) Injecting faults into program for testing software
KR102105753B1 (en) Method and system for automatic configuration test case generation of mobile application
WO2018108041A1 (en) Remote debugging method and device, and computer storage medium
Moran et al. On-device bug reporting for android applications
CN115658529A (en) Automatic testing method for user page and related equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant