disclosure of Invention
The embodiment of the invention aims to provide a method for automatically testing a terminal program, which can realize unattended automatic operation of a mobile phone APP to meet the testing requirement, is effective for the APP of most mobile phones in the market and reduces the labor cost for enterprises.
in order to achieve the above object, an embodiment of the present invention provides a method for automatically testing a terminal program, including the following steps:
Acquiring equipment information of a terminal, and communicating with the terminal according to the equipment information;
acquiring parameter information of a target APP of the terminal, and extracting a target package name and a target entrance of the target APP from the parameter information;
Connecting with the terminal, starting the target APP according to the target package name and the target entry to acquire UI hierarchical information of the target APP, and displaying the UI hierarchical information in an XML mode;
and reading node information of the element nodes to be tested according to the test requirements, and testing the node information by adapting to a corresponding test tool.
Further, the testing tool comprises XCTest and UI Automator.
Further, the terminal comprises an Android terminal and an iOS terminal.
Further, when the terminal is an Android terminal, the node information is subjected to custom test by adopting an API (application program interface) provided by a UI (user interface) Automator;
and when the terminal is an iOS terminal, performing custom test on the target APP node information by adopting XCtest.
The embodiment of the invention also provides a device for automatically testing the terminal program, which comprises: the system comprises a communication module, a target data acquisition module, a display module and an automatic test module;
The communication module is used for acquiring equipment information of a terminal and communicating with the terminal according to the equipment information;
The target data acquisition module is used for acquiring parameter information of a target APP of the terminal and extracting a target package name and a target entrance of the target APP from the parameter information;
the display module is used for connecting with the terminal, starting the target APP according to the target package name and the target entry to acquire UI hierarchical information of the target APP, and displaying the UI hierarchical information in an XML mode;
The automatic test module is used for reading node information of the element nodes to be tested according to test requirements and testing the node information by adapting to corresponding test tools.
Further, the testing tool comprises XCTest and UI Automator.
Further, the terminal comprises an Android terminal and an iOS terminal.
further, when the terminal is an Android terminal, the node information is subjected to custom test by adopting an API (application program interface) provided by a UI (user interface) Automator;
And when the terminal is an iOS terminal, performing custom test on the target APP node information by adopting XCtest.
The present invention further provides, as a preferred embodiment of the present invention, an apparatus for automatically testing a terminal program, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, where the processor implements the method for automatically testing a terminal program according to the above embodiment of the present invention when executing the computer program.
another embodiment of the present invention provides a storage medium, where the computer-readable storage medium includes a stored computer program, where when the computer program runs, a device in which the computer-readable storage medium is located is controlled to execute the method for automatically testing a terminal program according to the above-described embodiment of the present invention.
compared with the prior art, the method has the following beneficial effects:
According to the method for automatically testing the terminal program, the terminal equipment information is obtained, communication is carried out with the terminal according to the terminal equipment information, the parameter information of the target APP of the terminal is obtained, the target package name and the target inlet of the target APP are extracted from the parameter information, then connection is carried out with the terminal, the target APP is started according to the target package name and the target inlet, the UI level information of the target APP is obtained, meanwhile, XML display is carried out on the UI level information, finally, the node information of the element node to be tested is read according to the testing requirement, and the node information is tested by adapting to the corresponding testing tool.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a schematic flow chart of an embodiment of a method for automatically testing a terminal program according to the present invention; the embodiment of the invention provides a method for automatically testing a terminal program, which comprises the steps of S1-S4;
and S1, acquiring the equipment information of the terminal, and communicating with the terminal according to the equipment information.
in this embodiment, the terminal includes an Android terminal and an iOS terminal, and both the Android terminal and the iOS terminal include, but are not limited to, a smart terminal that is a mobile phone, a tablet, or the like and can use an application.
s2, acquiring parameter information of the target APP of the terminal, and extracting the target package name and the target entry of the target APP from the parameter information.
And S3, connecting with the terminal, starting the target APP according to the target package name and the target entry to acquire the UI hierarchical information of the target APP, and displaying the UI hierarchical information in an XML mode.
and S4, reading the node information of the element node to be tested according to the test requirement, and testing the node information by adapting a corresponding test tool.
It should be noted that the test tools include XCTest and uiautomation.
As a preferred embodiment of the present invention, when the terminal is an Android terminal, the node information is subjected to a custom test by using an API provided by the uiautomation;
Specifically, an example of testing the QQ is described, and the exit function of the QQ is tested as follows:
In this embodiment, the API provided by the uiautomation is used for performing the custom test on the QQ, so that the corresponding test process can be automatically completed without manual operation, and a large amount of human resources are saved.
And when the terminal is an iOS terminal, performing custom test on the target APP node information by adopting XCtest.
Specifically, as an example of the network request class, the success or failure of get request of MWURLRequestManager is tested, and the following test procedure is as follows:
referring to fig. 2, in order to better illustrate the principle of the method for automatically testing a terminal program according to the embodiment of the present invention, the following steps are specifically performed to implement the present invention: firstly, target equipment information is obtained, the target equipment information is communicated with host equipment, then target APP information is obtained, package names and entries are recorded, the mobile equipment and the host are connected, the APP is started, target APP UI level information is obtained, XML display is carried out, finally element nodes to be operated are found through XML, node information is read, the actions such as clicking and pull-down are executed by utilizing an API provided by XCtest or UI Automator, and the control over the APP is realized and the test over the target APP is completed.
according to the method for automatically testing the terminal program, the terminal equipment information is obtained, communication is carried out with the terminal according to the terminal equipment information, the parameter information of the target APP of the terminal is obtained, the target package name and the target inlet of the target APP are extracted from the parameter information, then connection is carried out with the terminal, the target APP is started according to the target package name and the target inlet, the UI level information of the target APP is obtained, meanwhile, XML display is carried out on the UI level information, finally, the node information of the element node to be tested is read according to the testing requirement, and the node information is tested by adapting to the corresponding testing tool.
The embodiment provided by the invention has the following beneficial effects:
(1) The unattended operation is realized without manual intervention;
(2) the large-scale operation is realized, the flexibility is strong, and the expansion is easy;
(3) The automatic operation greatly reduces redundant operation and greatly reduces the operation error rate;
(4) Compared with manual single-person single-machine operation, the invention can be operated by multiple virtual machines in one physical machine, thereby greatly reducing the cost of enterprise equipment.
referring to fig. 3 as a preferred embodiment provided by the present invention, fig. 3 is a schematic structural diagram of an embodiment of an apparatus for automatically testing a terminal program provided by the present invention, including: the system comprises a communication module, a target data acquisition module, a display module and an automatic test module;
The communication module is used for acquiring equipment information of a terminal and communicating with the terminal according to the equipment information; the target data acquisition module is used for acquiring parameter information of a target APP of the terminal and extracting a target package name and a target entrance of the target APP from the parameter information; the display module is used for connecting with the terminal, starting the target APP according to the target package name and the target entry to acquire UI hierarchical information of the target APP, and displaying the UI hierarchical information in an XML mode; the automatic test module is used for reading node information of the element nodes to be tested according to test requirements and testing the node information by adapting to corresponding test tools.
In the embodiment of the invention, the test tool comprises XCTest and UI Automator.
preferably, the terminal includes an Android terminal and an iOS terminal.
It should be noted that, when the terminal is an Android terminal, the node information is subjected to a custom test by using an API provided by a UI automation;
And when the terminal is an iOS terminal, performing custom test on the target APP node information by adopting XCtest.
as can be seen from the above, the apparatus for automatically testing a terminal program according to an embodiment of the present invention obtains device information of a terminal through a communication module, communicates with the terminal according to the device information, obtains parameter information of a target APP of the terminal through a target data obtaining module, extracts a target package name and a target entry of the target APP from the parameter information, connects with the terminal through a display module, starts the target APP according to the target package name and the target entry to obtain UI level information of the target APP, displays the UI level information in an XML manner, reads node information of an element node to be tested according to a test requirement through an automatic test module, and tests the node information by adapting to a corresponding test tool, and according to an embodiment provided by the present invention, an unattended automatic operation of a mobile phone APP can be realized to solve the test requirement, and the APP of most mobile phones in the market is effective, and the labor cost is reduced for enterprises.
The embodiment of the invention also provides equipment for automatically testing the terminal program. The apparatus comprises: a processor, a memory, and a computer program stored in the memory and executable on the processor. The processor, when executing the computer program, implements the steps in the above-described method embodiments of the automated test terminal program, such as steps S1-S4 shown in fig. 1.
the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor being the control center of the automated test terminal program device, the various parts of the entire automated test terminal program device being connected by various interfaces and lines.
the memory may be used to store the computer programs and/or modules, and the processor may implement the various functions of the device of the automatic test terminal program by running or executing the computer programs and/or modules stored in the memory and calling the data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
wherein the device-integrated module/unit of the automatic test terminal program may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like.
it should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiment of the apparatus provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, and may be specifically implemented as one or more communication buses or signal lines. One of ordinary skill in the art can understand and implement it without inventive effort.
while the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.