Monkey testing method and device, storage medium, and terminal

By obtaining and traversing the control tree, generating a list of click objects and driving precise control clicks, the problem of inefficiency of click events in the existing Monkey test methods is solved, and efficient and accurate software testing is achieved.

CN114218115BActive Publication Date: 2025-03-14SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111583060.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-22
Publication Date
2025-03-14
Estimated Expiration
2041-12-22

AI Technical Summary

Technical Problem

When testing the existing Monkey test methods, the Monkey tool, which comes with Android, is inefficient in click events, and cannot accurately control the click position and range, resulting in low testing efficiency and insufficient accuracy.

Method used

By obtaining the control tree of the software to be tested, traversing the control tree to obtain control position information, generating a click object list, and selecting the click object instance driver click action from the list, updating the current display interface, and realizing precise control click and range control.

Benefits of technology

Turn random full-screen clicks into accurate control clicks, reduce invalid clicks, significantly improve testing efficiency and accuracy, and meet the needs of rapid testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114218115B_ABST
    Figure CN114218115B_ABST
Patent Text Reader

Abstract

A Monkey test method and device, storage medium, and terminal, the method comprising: obtaining a control tree of software to be tested; traversing the control tree to obtain location information of multiple controls; for each of the multiple controls, generating a click object instance based at least on the location information of the control to determine a click object list containing multiple click object instances; selecting at least one click object instance from the click object list one by one, and driving a click action after the selection to click on the control corresponding to the selected click object instance, and updating the current display interface of the terminal according to the click. The present invention can improve the efficiency and test accuracy of Monkey testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a Monkey test method and device, a storage medium, and a terminal. Background Art

[0002] During the development process of application software (APP), or before release, Monkey testing will be carried out. Some people also call it weird testing, which is to use some strange operating methods to test the tested system in order to test the stability of the system. In principle, its Monkey automated testing is similar to a monkey tapping keys on the software. By sending a pseudo-random user event stream (such as key input, touch screen input, sliding, gesture input, etc.) to the system, the program on the device is tested to detect the long-term stability of the program and how long it will take for anomalies to occur.

[0003] Currently, Monkey testing has been widely used in the stability testing of the entire machine system and APP stability. When testing controls, the click event of the Monkey tool that comes with the Android system is inefficient. During the test, the entire screen is clicked randomly and disorderly, and the click position cannot be accurately controlled. The click range is too large, and the frequency of invalid clicks is too high, resulting in low test efficiency and failure to meet the needs of fast testing.

[0004] Therefore, there is an urgent need for a Monkey testing method that can convert random full-screen clicks into precise control clicks during software testing, control the click range, and improve test efficiency and accuracy. Summary of the invention

[0005] One of the purposes of the present invention is to provide a Monkey testing method and device, a computer-readable storage medium, and a terminal, which can convert random full-screen clicks into precise control clicks when performing software testing, and control the click range, thereby greatly improving test efficiency and test accuracy.

[0006] To achieve the above-mentioned purpose, an embodiment of the present invention provides a Monkey testing method, comprising the following steps: obtaining a control tree of the software to be tested, the control tree at least including the position information of multiple controls displayed by the software to be tested on the current display interface of the terminal; traversing the control tree to obtain the position information of the multiple controls; for each of the multiple controls, generating a click object instance based at least on the position information of the control to determine a click object list including multiple click object instances, wherein each control has a one-to-one correspondence with each click object instance; selecting at least one click object instance from the click object list one by one, and driving a click action after selection to click on the control corresponding to the selected click object instance, and updating the current display interface of the terminal according to the click; wherein, whenever the current display interface of the terminal is updated, selecting at least one click object instance from the click object list one by one, and driving a click action after selection to click on the control corresponding to the selected click object instance.

[0007] Optionally, before obtaining the control tree of the software to be tested, the method further includes: establishing a connection between the Android auxiliary function service class and the control information acquisition tool through an interface automatic connection class instruction.

[0008] Optionally, selecting at least one click object instance from the click object list one by one includes: selecting at least one click object instance from the click object list one by one by adopting a random selection method or an ordered selection method.

[0009] Optionally, the adopting of a random selection method or an orderly selection method to select at least one click object instance from the click object list one by one includes: the quotient of the number of the random selection method and the number of the orderly selection method satisfies a preset ratio.

[0010] Optionally, driving the click action after selection to click on the control corresponding to the selected click object instance includes: using an injection manager event function to drive the click action to click on the control corresponding to the selected click object instance.

[0011] Optionally, the Monkey test method also includes: each time the control corresponding to the selected click object instance is clicked, determining whether the click position is within a preset click area; if not, treating the click as an invalid click, and / or treating the click object instance as an invalid click object and deleting it from the click object list.

[0012] Optionally, the type of the control is selected from one or more of the following: button, radio button, drop-down list, edit box, multiple-select box.

[0013] The embodiment of the present invention further provides a Monkey test device, comprising:

[0014] A control tree acquisition unit, used to acquire a control tree of the software to be tested, the control tree at least including position information of multiple controls displayed by the software to be tested on the current display interface of the terminal; a traversal unit, used to traverse the control tree and acquire the position information of the multiple controls; a list determination unit, used to generate a click object instance for each of the multiple controls based at least on the position information of the control, so as to determine a click object list including multiple click object instances, wherein each control has a one-to-one correspondence with each click object instance; a control click unit, used to select at least one click object instance from the click object list one by one, and drive a click action after selection to click on the control corresponding to the selected click object instance, and update the current display interface of the terminal according to the click; wherein, whenever the current display interface of the terminal is updated, at least one click object instance is selected from the click object list one by one, and drive a click action after selection to click on the control corresponding to the selected click object instance.

[0015] An embodiment of the present invention further provides a storage medium on which computer instructions are stored. When the computer instructions are executed, the steps of the above-mentioned Monkey test method are executed.

[0016] An embodiment of the present invention further provides a terminal, including a memory and a processor, wherein the memory stores computer instructions that can be executed on the processor, and the processor executes the steps of the above-mentioned Monkey test method when executing the computer instructions.

[0017] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:

[0018] In an embodiment of the present invention, a control tree of the software to be tested is first obtained, and the control tree at least includes the location information of multiple controls; then the control tree is traversed, and a click object list including multiple click object instances is determined based on the location information of the multiple controls obtained; then at least one click object instance is selected from the click object list one by one, and the control corresponding to the selected click object instance is clicked, and then the current display interface is updated; wherein, each time the interface is updated, the step of selecting at least one click object instance from the click object list and clicking the corresponding control is repeated. Compared with the problem that the full-screen random click method is adopted in the Monkey test in the prior art, the click range cannot be controlled, the invalid click frequency is high, and the test efficiency is low and the test accuracy is insufficient, the embodiment of the present invention generates a click object list based on the location information of multiple controls, and selects at least one click object from the list one by one to drive the click of the corresponding control, thereby changing the random full-screen click of the prior art into an accurate control click, avoiding many invalid clicks, greatly reducing the test time, and improving the test accuracy.

[0019] Further, selecting at least one click object instance from the click object list one by one includes: selecting at least one click object instance from the click object list one by one by using a random selection method or an ordered selection method. In addition, the quotient of the number of the random selection method and the number of the ordered selection method can also satisfy a preset ratio. In this way, the ratio of random clicks of controls to ordered clicks of controls can be manually controlled according to the needs of different test scenarios, so as to flexibly meet the needs of various test scenarios.

[0020] Furthermore, each time the control corresponding to the selected click object instance is clicked, it is determined whether the click position is within the preset click area; if not, the click is regarded as an invalid click, and / or the click object instance is regarded as an invalid click object and deleted from the click object list. In this way, the click area can be preset so that only when the click position is within the preset click area, the click is regarded as a valid click, and the current interface is updated, and then the steps of selecting the click object instance from the click object list and driving the click on the corresponding control are repeated; otherwise, the click is regarded as an invalid click and / or the selected click object instance is deleted from the click object list, thereby achieving the effect of accurately controlling the click range according to the test needs and greatly improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 is a flow chart of a Monkey test method in an embodiment of the present invention;

[0022] Figure 2is a flow chart of another Monkey test method in an embodiment of the present invention;

[0023] Figure 3 It is a structural schematic diagram of a Monkey testing device in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] As mentioned above, in the existing Monkey testing technology, the Monkey tool that comes with the Android system clicks randomly and disorderly on the entire screen during testing. It is impossible to accurately control the click position, the click range is too large, and the frequency of invalid clicks is too high, which leads to low test efficiency and cannot meet the needs of fast testing.

[0025] Therefore, there is an urgent need for a Monkey testing method that can convert random full-screen clicks into precise control clicks during software testing, control the click range, and improve test efficiency and accuracy.

[0026] In an embodiment of the present invention, a control tree of the software to be tested is first obtained, and the control tree at least includes the location information of multiple controls; then the control tree is traversed, and a click object list including multiple click object instances is determined based on the location information of the multiple controls obtained; then at least one click object instance is selected from the click object list one by one, and the control corresponding to the selected click object instance is clicked, and then the current display interface is updated; wherein, each time the interface is updated, the step of selecting at least one click object instance from the click object list and clicking the corresponding control is repeated. Compared with the problem that the full-screen random click method is adopted in the Monkey test in the prior art, the click range cannot be controlled, the invalid click frequency is high, and the test efficiency is low and the test accuracy is insufficient, the embodiment of the present invention generates a click object list based on the location information of multiple controls, and selects at least one click object from the list one by one to drive the click of the corresponding control, thereby changing the random full-screen click of the prior art into an accurate control click, avoiding many invalid clicks, greatly reducing the test time, and improving the test accuracy.

[0027] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0028] Reference Figure 1 , Figure 1 1 is a flow chart of a Monkey test method in an embodiment of the present invention. The method may include steps S11 to S14:

[0029] Step S11: obtaining a control tree of the software to be tested, wherein the control tree at least includes position information of a plurality of controls displayed on a current display interface of the terminal by the software to be tested;

[0030] Step S12: traverse the control tree to obtain location information of the multiple controls;

[0031] Step S13: for each of the plurality of controls, generating a click object instance based at least on the position information of the control, so as to determine a click object list including the plurality of click object instances, wherein each control has a one-to-one correspondence with each click object instance;

[0032] Step S14: selecting at least one click object instance from the click object list one by one, and driving a click action after the selection to click a control corresponding to the selected click object instance, and updating the current display interface of the terminal according to the click;

[0033] Wherein, each time the current display interface of the terminal is updated, at least one click object instance is selected from the click object list one by one, and after the selection, a click action is driven to click on the control corresponding to the selected click object instance.

[0034] It is understandable that, in a specific implementation, the method can be implemented in the form of a software program, which runs in a processor integrated inside a chip or a chip module; or, the method can be implemented in the form of hardware or a combination of hardware and software.

[0035] In the specific implementation of step S11, the control tree is a specific tree data structure, which includes multiple nodes. Each node in the control tree of the software to be tested at least stores the location information of multiple controls displayed by the software to be tested on the current interface (Activity) of the terminal.

[0036] The position information of the control may be used to indicate the specific position of the control on the terminal display screen.

[0037] In some non-limiting embodiments, the position information may be a coordinate point in a coordinate system with the exact center of the screen as the coordinate origin, and the coordinate point may correspond to the center point of a certain control; the position information may also be represented by two coordinate points in the coordinate system, that is, a matrix formed by the two coordinate points.

[0038] Further, in some non-limiting embodiments, the type of the control can be selected from one or more of the following: button, radio button, drop-down list, edit box, multiple-choice box. The type of the control can also be other control types in the programming language. The specific control type is determined by the control type contained in the software to be tested. The embodiment of the present invention does not limit the control type.

[0039] Among them, button is the most common control type, which allows users to perform specific operations by clicking, such as the common "Open", "OK", "Submit", "Save", "Exit" and other buttons; RadioButton provides users with an option set consisting of two or more mutually exclusive options; Drop-down list (Spinner) is a control that provides users with a list-style selection box. Since the list is presented in a hidden-expanded manner, the drop-down list can save screen resources. For example, many applications can select time, city, occupation and other contents of the drop-down list; Editbox is a control that can implement text editing function, providing users with text input function, and then easily obtain the text for input; Multi-select box (Checkbox) corresponds to the radio button, and can provide users with multiple selection function. The difference between multi-select box and radio button is that when the user selects a radio button, other radio buttons in the same group cannot be selected at the same time; on the contrary, any number of multi-select boxes can be selected, that is, defining a radio button group will tell the user that one and only one option can be selected from the group of options.

[0040] Furthermore, before obtaining the control tree of the software to be tested, the method further includes: establishing a connection between the Android auxiliary function service class and the control information acquisition tool through an interface automatic connection class instruction.

[0041] In a specific implementation of the embodiment of the present invention, a connection between the Android Accessibility Service class android Accessibilityserivceserver and the control information acquisition tool can be established through the interface automatic connection class UiAutomationConnection.

[0042] In the specific implementation of step S12, the traversal is one of the most important operations on the tree data structure, which can be used to refer to the access to all node information in the tree, that is, to visit each node in the tree once and only once. Therefore, by traversing the control tree and visiting each node in the control tree once in turn, the location information of the multiple controls can be obtained. Different traversal methods have different order of accessing nodes. The embodiment of the present invention does not limit the traversal method.

[0043] In a specific implementation of step S13, for each of the multiple controls, a click object instance is generated based at least on the position information of the control to determine a click object list including multiple click object instances.

[0044] There is a one-to-one correspondence between each control and each click object instance.

[0045] Among them, the click object instance can be a position object (PointF), which is used to represent the position point in the (x, y) coordinate space, and x and y can be floating point (Float) data types, which are used to store single-precision floating point numbers or double-precision floating point numbers; the click object list can be a list class (List) in a computer programming language. In the programming language, the list class is a class in the standard class library, which can be simply regarded as a doubly linked list, which manages data sets of any data type in an ordered linear column, and elements therein can be added and deleted at any time.

[0046] In the specific implementation of step S14, at least one click object instance is selected from the click object list one by one, and after the selection, the click action is driven to click the control corresponding to the selected click object instance, and according to the click, the current display interface of the terminal is updated.

[0047] Wherein, each time the current display interface is updated, the next click object instance is selected one by one, and the driving click and updating interface in the above step S14 are repeatedly executed. In the embodiment of the present invention, the random full-screen click of the prior art is changed into a cyclic precise control click, which improves the problems of low test efficiency and insufficient test accuracy caused by complete reliance on random clicks, uncontrollable click range, and high frequency of invalid clicks in the prior art, greatly reduces the test time, and improves the test accuracy.

[0048] It should be pointed out that the termination condition for the control click executed in the above loop is to meet the preset Monkey test end condition, for example, the number of clicks can reach a preset number of times, the click duration can reach a preset duration, the clicks can continue until the Monkey test program is manually closed, or the clicks can continue until a preset number of bad pixels appear.

[0049] Further, selecting at least one click object instance from the click object list one by one includes: selecting at least one click object instance from the click object list one by one by adopting a random selection method or an orderly selection method.

[0050] Furthermore, the adopting of random selection method or orderly selection method to select at least one click object instance from the click object list one by one includes: the quotient of the number of times of the random selection method and the number of times of the orderly selection method satisfies a preset ratio.

[0051] In a specific implementation, the preset ratio can be realized by adding a click mode control parameter in the startup command of the Monkey program and assigning a value to the parameter, wherein the click mode control parameter can be -pct-uix.

[0052] In the first specific implementation of the embodiment of the present invention, the value of -pct-uix can be preset to 0, then the ratio of the number of random selection methods to the number of ordered selection methods is 0, which means that all selection methods are ordered selections, thereby achieving that all control click methods are ordered clicks.

[0053] In a second specific implementation of the embodiment of the present invention, the value of -pct-uix can be preset to 60%, and the ratio of the number of random selection methods to the number of ordered selection methods is 60%, thereby achieving a ratio of 60% between the number of random control clicks and the number of ordered control clicks. For example, if the number of ordered control clicks is 50 times in a complete test, the number of random control clicks is 50×60%=30 times.

[0054] In the embodiment of the present invention, a click object instance is selected from the click object list by adopting a random selection method or an ordered selection method, and the ordered click times and the unordered click times can also be allocated according to a preset percentage. In this way, the ratio of random clicks of controls and ordered clicks of controls can be manually controlled according to different test scenarios, so as to flexibly meet the needs of various test scenarios.

[0055] Furthermore, the driving of the click action after the selection to click on the control corresponding to the selected click object instance includes: using an injection manager event function to drive the click action to click on the control corresponding to the selected click object instance.

[0056] Specifically, the click action can be driven by the injection event (injectInputEvent) of the injection manager (InputManager). The injection manager is a class for managing the entire input unit of the computer system, including inputs from the keyboard, mouse, touch screen, etc.

[0057] Furthermore, the Monkey test method also includes: each time the control corresponding to the selected click object instance is clicked, determining whether the click position is within a preset click area; if not, treating the click as an invalid click, and / or treating the click object instance as an invalid click object and deleting it from the click object list.

[0058] In a specific implementation, the preset click area range can be used to indicate a specific area on the terminal display screen. Therefore, it can be understood that the size of the preset click area range should not exceed the size of the terminal display screen. The setting of the click area range can be achieved by adding a click range control parameter in the startup command of the Monkey program and assigning a value to the parameter, wherein the click range control parameter can be -range.

[0059] In a first specific implementation of the embodiment of the present invention, the click range control parameter is not set in the start command of the Monkey program, and the Monkey program defaults to full-screen click.

[0060] In a second specific implementation of the embodiment of the present invention, a -range parameter is set in the startup command of the Monkey program, specifically -range(100, 300, 500, 800), and the click range is within the rectangle formed by points A(100, 300) and B(500, 800).

[0061] In an embodiment of the present invention, by presetting the click area range, the click is regarded as a valid click only when the click position is within the preset click area range, and the current interface is updated. Then, the steps of selecting a click object instance from the click object list and driving the click on the corresponding control are repeated, thereby achieving precise control of the click range according to test needs and greatly improving the test efficiency.

[0062] It should be pointed out that, in a specific implementation, the Monkey test program of the embodiment of the present invention can be developed using the computer programming language Java. Specifically, taking the Android system as an example, in order to be compatible with the original Monkey test program (Android Monkey.jar) in the Android system, the Monkey test program of the embodiment of the present invention can be based on the architecture of the original Monkey test program. By adding a smart Monkey (SmartMonkey) module to implement new functions, the newly developed Monkey test program retains the functions of the original Monkey test program while having new functions such as orderly clicks and proportional control of click methods. After the development is completed, the newly developed Monkey test program is compiled into a Jar file to replace the original Monkey test program. Among them, taking the Android system as an example, the Jar file can be stored in the UE / system / framework / directory, for example.

[0063] Reference Figure 2 , Figure 2 1 is a flow chart of another Monkey test method in an embodiment of the present invention. The another Monkey test method may include steps S21 to S25, and each step is described below.

[0064] In step S21, a connection is established between the Android auxiliary function service class and the control information acquisition tool through the interface automatic connection class instruction.

[0065] In step S22, a control tree of the software to be tested is obtained, wherein the control tree at least includes position information of a plurality of controls displayed on a current display interface of the terminal by the software to be tested.

[0066] In step S23, the control tree is traversed to obtain the location information of the multiple controls.

[0067] In step S24, for each of the multiple controls, a click object instance is generated based at least on the position information of the control to determine a click object list containing multiple click object instances.

[0068] There is a one-to-one correspondence between each control and each click object instance.

[0069] In step S25, at least one click object instance is selected from the click object list one by one by a random selection method or an ordered selection method, and after the selection, the injection manager event function is used to drive the click action to click the control corresponding to the selected click object instance, and based on the click, the current display interface of the terminal is updated.

[0070] Among them, whenever the current display interface of the terminal is updated, a random selection method or an orderly selection method is adopted to select at least one click object instance from the click object list one by one, and the injection manager event function is used to drive the click action to click the control corresponding to the selected click object instance.

[0071] The quotient of the number of random selections and the number of ordered selections satisfies a preset ratio.

[0072] In the specific implementation, for more details about steps S21 to S25, please refer to the above and Figure 1 The steps described in the procedure are executed and will not be repeated here.

[0073] Reference Figure 3 , Figure 3 It is a structural schematic diagram of a Monkey testing device in an embodiment of the present invention.

[0074] The Monkey test device may include:

[0075] A control tree acquisition unit 31 is used to acquire a control tree of the software to be tested, wherein the control tree at least includes position information of a plurality of controls displayed on a current display interface of the terminal by the software to be tested;

[0076] A traversal unit 32, configured to traverse the control tree and obtain location information of the multiple controls;

[0077] A list determining unit 33, configured to generate a click object instance for each of the plurality of controls based at least on the position information of the control, so as to determine a click object list including the plurality of click object instances, wherein each control has a one-to-one correspondence with each click object instance;

[0078] A control click unit 34, used to select at least one click object instance from the click object list one by one, and drive a click action after the selection to click the control corresponding to the selected click object instance, and update the current display interface of the terminal according to the click;

[0079] Wherein, each time the current display interface of the terminal is updated, at least one click object instance is selected from the click object list one by one, and after the selection, a click action is driven to click on the control corresponding to the selected click object instance.

[0080] In a specific implementation, the Monkey test device may correspond to a chip with a Monkey test function; or correspond to a chip module with a Monkey test function in a terminal, or correspond to a terminal.

[0081] For the principle, specific implementation and beneficial effects of the Monkey test device, please refer to the previous article and Figure 1 to Figure 2 The relevant description about the Monkey test method shown is not repeated here.

[0082] The embodiment of the present invention further provides a storage medium on which computer instructions are stored, and when the computer instructions are executed, the steps of the above-mentioned Monkey test method are executed. The computer-readable storage medium may include a non-volatile memory or a non-transitory memory, and may also include an optical disk, a mechanical hard disk, a solid-state hard disk, etc.

[0083] Specifically, in the embodiment of the present invention, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0084] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM) and direct rambus RAM (DR RAM).

[0085] The embodiment of the present invention further provides a terminal, including a memory and a processor, wherein the memory stores computer instructions that can be run on the processor, and the processor executes the steps of the above Monkey test method when running the computer instructions. The terminal may include but is not limited to terminal devices such as mobile phones, computers, and tablet computers, and may also be a server, a cloud platform, etc.

[0086] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer program may be stored in a computer-readable storage medium, or may be transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means.

[0087] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0088] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units. For example, for each device or product applied to or integrated in a chip, each module / unit contained therein may be implemented in the form of hardware such as circuits, or at least part of the modules / units may be implemented in the form of software programs, which run on a processor integrated inside the chip, and the remaining (if any) modules / units may be implemented in the form of hardware such as circuits; for each device or product applied to or integrated in a chip module, each module / unit contained therein may be implemented in the form of hardware such as circuits, and different modules / units may be located in the same component (such as a chip, circuit module, etc.) or different components of the chip module, or at least part of the modules / units may be implemented in the form of software programs. The element can be implemented in the form of a software program, which runs on a processor integrated inside the chip module, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits; for various devices and products applied to or integrated in the terminal, the various modules / units contained therein can be implemented in the form of hardware such as circuits, and different modules / units can be located in the same component (for example, chip, circuit module, etc.) or in different components in the terminal, or, at least some modules / units can be implemented in the form of a software program, which runs on a processor integrated inside the terminal, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits.

[0089] It should be understood that the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship.

[0090] The "plurality" appearing in the embodiments of the present application refers to two or more.

[0091] The first, second, etc. descriptions appearing in the embodiments of the present application are only used for illustration and distinction of the description objects. There is no order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.

[0092] It should be pointed out that the serial numbers of the steps in this embodiment do not limit the execution order of the steps.

[0093] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.

Claims

1. A Monkey test method, characterized in that: include: Acquire a control tree of the software to be tested, wherein the control tree at least includes position information of a plurality of controls displayed on a current display interface of the terminal by the software to be tested; Traversing the control tree to obtain location information of the multiple controls; For each of the plurality of controls, generating a click object instance based at least on the position information of the control to determine a click object list including the plurality of click object instances, wherein each control has a one-to-one correspondence with each click object instance; Selecting at least one click object instance from the click object list one by one, and driving a click action after the selection to click a control corresponding to the selected click object instance, and updating the current display interface of the terminal according to the click; Wherein, each time the current display interface of the terminal is updated, at least one click object instance is selected from the click object list one by one, and after the selection, a click action is driven to click on the control corresponding to the selected click object instance; The method further comprises: Each time the control corresponding to the selected click object instance is clicked, it is determined whether the clicked position is within the preset click area; If not, the click is regarded as an invalid click, and / or the click object instance is regarded as an invalid click object and deleted from the click object list.

2. The method according to claim 1, characterized in that Before obtaining the control tree of the software to be tested, the method further includes: Through the interface automatic connection class instruction, a connection is established between the Android auxiliary function service class and the control information acquisition tool.

3. The method according to claim 1, characterized in that Selecting at least one click object instance from the click object list one by one comprises: At least one click object instance is selected from the click object list one by one by adopting a random selection method or an orderly selection method.

4. The method according to claim 3, characterized in that The randomly selecting method or the ordered selecting method to select at least one click object instance from the click object list one by one comprises: The quotient of the number of random selection methods and the number of ordered selection methods satisfies a preset ratio.

5. The method according to claim 1, characterized in that The driving of the click action after the selection to click the control corresponding to the selected click object instance includes: The injection manager event function is used to drive the click action to click the control corresponding to the selected click object instance.

6. The method according to claim 1, characterized in that The type of the control is selected from one or more of the following: Button, radio button, drop-down list, edit box, multiple-select box.

7. A Monkey test device, characterized in that: include: A control tree acquisition unit, used to acquire a control tree of the software to be tested, wherein the control tree at least includes position information of a plurality of controls displayed on a current display interface of the terminal by the software to be tested; A traversal unit, used for traversing the control tree to obtain position information of the multiple controls; a list determining unit, configured to generate a click object instance for each of the plurality of controls based at least on the position information of the control, so as to determine a click object list including the plurality of click object instances, wherein each control has a one-to-one correspondence with each click object instance; A control click unit, used to select at least one click object instance from the click object list one by one, and drive a click action after the selection to click the control corresponding to the selected click object instance, and update the current display interface of the terminal according to the click; Wherein, each time the current display interface of the terminal is updated, at least one click object instance is selected from the click object list one by one, and after the selection, a click action is driven to click on the control corresponding to the selected click object instance; The Monkey testing device also executes: each time the control corresponding to the selected click object instance is clicked, it is determined whether the click position is within the preset click area; if not, the click is regarded as an invalid click, and / or the click object instance is regarded as an invalid click object and deleted from the click object list.

8. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the Monkey test method according to any one of claims 1 to 6 are performed.

9. A terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor runs the computer program, the steps of the Monkey test method according to any one of claims 1 to 6 are performed.

Citation Information

Patent Citations

  • Method and device for Monkey testing

    CN105512023A

  • Application interface control traversal test method and application interface control traversal test devices

    CN108628732A