Disclosure of Invention
Due to the fact that the method for manually generating the test cases is low in efficiency, the embodiment of the invention provides a method and a device for generating the test cases of a user interface.
In one aspect, an embodiment of the present invention provides a method for generating a test case of a user interface, including:
Acquiring a user interface;
Identifying image characteristics of the user interface by adopting an image identification model, and determining control modules in the user interface, wherein each control module comprises control type information and control position information;
and generating a test case of the user interface according to each control module and preset control operation.
Optionally, the generating the test case of the user interface according to each control module and a preset control operation includes:
Decoding control type information and control position information of each control module by adopting a cyclic neural network model, and generating a test code corresponding to the user interface;
compiling the test codes corresponding to the user interface and preset control operation to generate a test case of the user interface.
Optionally, the method further comprises:
And executing the test case of the user interface to obtain a test result of the user interface.
Optionally, the method further comprises:
Generating a test case set according to the test cases of the plurality of user interfaces;
and executing the test case set to obtain test results of a plurality of user interfaces.
Optionally, the image recognition module is used for recognizing the image features of the user interface, determining a control module in the user interface, and further comprising:
Comparing the user interface with a history version interface of the user interface;
and when the difference degree between the user interface and the historical version interface is larger than a preset threshold, adopting an image recognition model to recognize the image characteristics of the user interface, and determining a control module in the user interface.
Optionally, the method further comprises:
and updating the test cases of the history version interface by adopting the test cases of the user interface.
In one aspect, an embodiment of the present invention provides a test case generating device for a user interface, including:
the acquisition module is used for acquiring a user interface;
the identification module is used for identifying the image characteristics of the user interface by adopting an image identification model, and determining control modules in the user interface, wherein each control module comprises control type information and control position information;
And the processing module is used for generating the test case of the user interface according to each control module and the preset control operation.
Optionally, the processing module is specifically configured to:
Decoding control type information and control position information of each control module by adopting a cyclic neural network model, and generating a test code corresponding to the user interface;
compiling the test codes corresponding to the user interface and preset control operation to generate a test case of the user interface.
Optionally, the processing module is further configured to:
And executing the test case of the user interface to obtain a test result of the user interface.
Optionally, the processing module is further configured to:
Generating a test case set according to the test cases of the plurality of user interfaces;
and executing the test case set to obtain test results of a plurality of user interfaces.
Optionally, the identifying is specifically used for:
Comparing the user interface with a history version interface of the user interface;
and when the difference degree between the user interface and the historical version interface is larger than a preset threshold, adopting an image recognition model to recognize the image characteristics of the user interface, and determining a control module in the user interface.
Optionally, the system further comprises an updating module;
The updating module is specifically configured to:
and updating the test cases of the history version interface by adopting the test cases of the user interface.
In one aspect, an embodiment of the present invention provides a computer device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of a test case generation method of a user interface when the program is executed.
In one aspect, embodiments of the present invention provide a computer-readable storage medium storing a computer program executable by a computer device, which when run on the computer device, causes the computer device to perform the steps of a test case generation method of a user interface.
In the embodiment of the invention, the image recognition model is adopted to recognize the image characteristics of the user interface, the control modules in the user interface are determined, each control module comprises control type information and control position information, and then the test case of the user interface is generated according to each control module and the preset control operation. And the control in the user interface is not required to be identified manually and the code is written to generate the test case, so that the efficiency of generating the test case is improved, the test efficiency of the user interface is further improved, and the test cost of the user interface is reduced.
Detailed Description
In order to make the objects, technical solutions and advantageous effects of the present invention more apparent, the present invention will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
For ease of understanding, the terms involved in the embodiments of the present invention are explained below.
UI (User Interface), medium for interaction and information exchange between system and User.
CNN (Convolutional Neural Networks, convolutional neural network), a feed-forward neural network, consists of one or more convolutional layers and top fully connected layers (corresponding to classical neural networks) and also includes associated weights and pooling layers. Convolutional neural networks have excellent performance in terms of image processing.
RNNs (Recurrent Neural Network, recurrent neural networks), a class of neural networks with short-term memory capabilities. In the recurrent neural network, neurons can receive not only information of other neurons but also information of the neurons themselves, and a network structure with loops is formed.
DSL (domain-specific language, domain specific language).
The test case generation method of the user interface in the embodiment of the invention can be applied to an application scene shown in fig. 1, wherein the application scene comprises front-end equipment 101 and a test system 102. The front-end device 101 may be a smart phone, tablet or portable personal computer, etc. The front-end equipment 101 pre-installs the application software related to the financial industry, the front-end equipment 101 runs the application software, intercepts the user interface of the application software and sends the user interface to the test system 102. The test system 102 includes a continuous integrated test platform 1021, an update test platform 1022. The continuous integrated test platform 1021 adopts an image recognition model to recognize image characteristics of a user interface, determines control modules in the user interface, each control module comprises control type information and control position information, then generates test cases of the user interface according to each control module and preset control operation, and then generates test case sets according to the test cases of a plurality of user interfaces. The continuous integrated test platform 1021 executes the test case set to obtain test results of a plurality of user interfaces. The update detection platform 1022 compares the user interface with the historical version interface of the user interface, and when the difference degree between the user interface and the historical version interface is determined to be greater than a preset threshold value, the test case of the historical version interface is updated by using the test case of the user interface.
Based on the application scenario diagram shown in fig. 1, the embodiment of the present invention provides a flow of a method for generating a test case of a user interface, where the flow of the method may be executed by a test case generating device of the user interface, and the test case generating device of the user interface may be the test system 102 in fig. 1, as shown in fig. 2, and includes the following steps:
Step S201, a user interface is acquired.
Specifically, the user interface is an image taken from application software executing on the front-end device. Illustratively, in the user interface shown in FIG. 3, a switch, an add button, a slider bar are included.
Step S202, the image recognition model is adopted to recognize the image characteristics of the user interface, and a control module in the user interface is determined.
Specifically, the image recognition model may be a convolutional neural network model, a forward neural network model, or the like. Because different controls have different image features, the image recognition model recognizes the image features of the user interface, and the user interface can be divided into a plurality of control modules, each of which includes control type information and control position information. Illustratively, as shown in fig. 4, the image features of the user interface shown in fig. 3 are identified by using a convolutional neural network model, the user interface shown in fig. 3 is divided into 3 control modules, which can be divided into a switch control module, an add button control module and a slider control module according to control types, the switch control module includes position information of the switch control, the add button control module includes position information of the add button, and the slider control module includes position information of the slider control.
Step S203, a test case of the user interface is generated according to each control module and the preset control operation.
Specifically, the control operations include clicking, inputting, sliding, and the like.
In the embodiment of the invention, the image recognition model is adopted to recognize the image characteristics of the user interface, the control modules in the user interface are determined, each control module comprises control type information and control position information, then the test case of the user interface is generated according to each control module and the preset control operation, and the control in the user interface is not required to be manually recognized and the code is written to generate the test case, so that the efficiency of generating the test case is improved, the test efficiency of the user interface is further improved, and the test cost of the user interface is reduced.
Optionally, in the step S203, embodiments of the present invention provide at least the following two implementations of test cases for generating a user interface:
In one possible implementation, the control type information and the control position information of each control module are decoded by using a cyclic neural network model, and a test code corresponding to the user interface is generated. Compiling the test codes corresponding to the user interface and preset control operation to generate a test case of the user interface.
Specifically, the cyclic neural network model decodes the control type information and the control position information of each control module, each hidden state of the cyclic neural network model contains the context information of the control module, and then generates test codes according to the context information and the corresponding control module, wherein the test codes can be DSL codes. The DSL codes corresponding to the control module are generated by decoding control type information and control position information of the switch control module by adopting a cyclic neural network model, wherein the label is a label, the switch is a switch, x and y are coordinates of the control, l is the length of the control, and w is the width of the control. DSL codes corresponding to other control modules in the user interface can be generated by adopting the same method, and finally the DSL codes of the user interface are obtained by adopting the context information of the control module identified by the cyclic neural network model and the DSL codes corresponding to the control module. Compiling the DSL code and the preset control operation corresponding to each control module in the user interface to generate a test case of the user interface. The control module in the user interface image is converted into the test code by adopting the cyclic neural network model, and then the test code and the control operation are compiled into the test case, so that the test code does not need to be manually written and maintained, and the efficiency of generating the test case is improved.
In one possible implementation, the test code corresponding to each control module is generated according to the control type information and the control position information of each control module. And combining the control position information of each control module with the test codes corresponding to all the control modules to generate the test codes corresponding to the user interface. Compiling the test codes corresponding to the user interface and preset control operation to generate a test case of the user interface.
When testing the user interface, the embodiment of the invention at least provides the following two testing modes:
In one possible implementation manner, after the test case of the user interface is generated, the test case of the user interface may be executed to obtain the test result of the user interface, and further, the test result of the user interface may be sent to the related tester to implement the test on the user interface.
In another possible implementation manner, after the test cases of the user interfaces are generated, a test case set is generated according to the test cases of the plurality of user interfaces, and then the test case set is executed to obtain test results of the plurality of user interfaces. Further, a test report may be generated based on the test results of the plurality of user interfaces and sent to a tester, thereby enabling testing of the batch of user interfaces.
Optionally, in step S202, after the user interface is obtained, the user interface may be compared with a historical version interface of the user interface, and when it is determined that the difference between the user interface and the historical version interface is greater than a preset threshold, an image recognition model is used to recognize image features of the user interface, and a control module in the user interface is determined.
Specifically, with the update of the version of the application software, the corresponding user interface may or may not be updated, so that when the version of the application software is updated, whether the user interface is updated can be judged first, and then whether the test case of the user interface needs to be generated can be further determined. The degree of difference between the user interface and the historical version interface may be determined using an average hash (dhash) algorithm, a perceptual hash (phash) algorithm, a difference value hash (dhash) algorithm, or the like. When the difference is larger than the preset threshold, the user interface of the current version is changed compared with the user interface of the historical version, and when the user interface of the current version is tested by adopting the test cases of the historical version interface, the test results deviate, so that the test cases need to be regenerated. When the difference degree is not greater than the preset threshold value, the user interface of the current version is basically unchanged compared with the user interface of the historical version, the user interface of the current version can be tested by adopting the test cases of the interface of the historical version, and the test cases of the user interface do not need to be repeatedly generated.
Further, after the test cases of the user interface are generated, the test cases of the history version interface may be updated by using the test cases of the user interface. For example, the test cases of the user interface may be directly replaced with the test cases of the history version interface. And judging whether the user interface is updated or not by comparing the difference degrees of the user interfaces of different versions, and if so, regenerating the test cases of the user interface to update the test cases of the historical version interface without manually updating and maintaining, thereby improving the updating efficiency of the test cases of the user interface.
In order to better explain the embodiment of the present invention, the method for generating a test case of a user interface according to the embodiment of the present invention is described below in conjunction with a specific implementation scenario, where the method is executed by a test case generating device of the user interface, as shown in fig. 5, and includes the following steps:
Step S501, a user interface is acquired.
Step S502, a difference value hash algorithm is adopted to determine the difference degree between the user interface and the historical version interface of the user interface.
Step S503, judging whether the difference degree between the user interface and the history version interface is larger than a preset threshold, if yes, executing step S504, otherwise executing step S511.
Specifically, a variability test report is generated between the user interface and a historical version interface of the user interface.
Step S504, adopting a convolutional neural network model to identify the image characteristics of the user interface, and determining a control module in the user interface.
Each control module includes control type information and control location information.
And step S505, decoding the control type information and the control position information of each control module by adopting the cyclic neural network model, and generating a test code corresponding to the user interface.
Step S506, compiling the test codes corresponding to the user interface and the preset control operation to generate the test case of the user interface.
Step S507, the test cases of the history version interface are updated by adopting the test cases of the user interface.
Step S508, generating test case sets according to the test cases of the plurality of user interfaces.
Step S509, executing the test case set to obtain test results of a plurality of user interfaces.
Step S510, generating a test report and sending the test report to a tester.
Step S511, executing the test cases of the history version interface to obtain the test result of the user interface.
In the embodiment of the invention, the image recognition model is adopted to recognize the image characteristics of the user interface, the control modules in the user interface are determined, each control module comprises control type information and control position information, then the test case of the user interface is generated according to each control module and the preset control operation, and the control in the user interface is not required to be manually recognized and the code is written to generate the test case, so that the efficiency of generating the test case is improved, the test efficiency of the user interface is further improved, and the test cost of the user interface is reduced. And the control in the user interface image is converted into a test code by adopting a cyclic neural network model, and then the test code and the control operation are compiled into the test case, so that the test code does not need to be manually written and maintained, and the efficiency of generating the test case is improved. And judging whether the user interface is updated or not by comparing the difference degrees of the user interfaces of different versions, and if so, regenerating the test cases of the user interface to update the test cases of the historical version interface without manually updating and maintaining, thereby improving the updating efficiency of the test cases of the user interface.
In order to better explain the embodiment of the present invention, a method for testing a user interface of financial application software is described below by taking the user interface as an example, where the method is interactively performed by a front-end device and a testing system, and includes:
The front-end equipment is provided with financial application software to be tested and runs the financial application software, the front-end equipment intercepts a user interface of the financial application software and sends the user interface to the testing system, and the intercepted user interface comprises a login interface, a financial business operation interface and the like. Aiming at a login interface, a testing system adopts a convolutional neural network model to identify image characteristics of the login interface, a control module in the login interface is determined, the control module in the login interface comprises a user name input box module, a password input box module and a login button module, and each control module comprises control type information and control position information. And then, decoding the control type information and the control position information of each control module by adopting the cyclic neural network model, and generating a test code corresponding to the login interface. Compiling the test codes corresponding to the login interface and preset control operation to generate a test case of the login interface. Test cases of other user interfaces such as the financial business operation interface are generated according to the same method, and are not repeated here. And generating test case sets from the test cases of the plurality of user interfaces intercepted by the financial application software, then executing the test cases, generating a user interface test report of the financial application software and sending the test report to a tester.
Based on the same technical concept, an embodiment of the present invention provides a test case generating device of a user interface, as shown in fig. 6, the device 600 includes:
an obtaining module 601, configured to obtain a user interface;
The identification module 602 is configured to identify image features of the user interface by using an image identification model, and determine control modules in the user interface, where each control module includes control type information and control position information;
And the processing module 603 is configured to generate a test case of the user interface according to each control module and a preset control operation.
Optionally, the processing module 603 is specifically configured to:
Decoding control type information and control position information of each control module by adopting a cyclic neural network model, and generating a test code corresponding to the user interface;
compiling the test codes corresponding to the user interface and preset control operation to generate a test case of the user interface.
Optionally, the processing module 603 is further configured to:
And executing the test case of the user interface to obtain a test result of the user interface.
Optionally, the processing module 603 is further configured to:
Generating a test case set according to the test cases of the plurality of user interfaces;
and executing the test case set to obtain test results of a plurality of user interfaces.
Optionally, the identification module 602 is specifically configured to:
Comparing the user interface with a history version interface of the user interface;
and when the difference degree between the user interface and the historical version interface is larger than a preset threshold, adopting an image recognition model to recognize the image characteristics of the user interface, and determining a control module in the user interface.
Optionally, an update module 604 is also included;
the update module 604 is specifically configured to:
and updating the test cases of the history version interface by adopting the test cases of the user interface.
Based on the same technical concept, an embodiment of the present invention provides a computer device, as shown in fig. 7, including at least one processor 701, and a memory 702 connected to the at least one processor, where a specific connection medium between the processor 701 and the memory 702 is not limited in the embodiment of the present invention, and in fig. 7, the processor 701 and the memory 702 are connected by a bus, for example. The buses may be divided into address buses, data buses, control buses, etc.
In the embodiment of the present invention, the memory 702 stores instructions executable by the at least one processor 701, and the at least one processor 701 can execute the steps included in the test case generating method of the user interface by executing the instructions stored in the memory 702.
The processor 701 is a control center of a computer device, and may use various interfaces and lines to connect various parts of the computer device, and generate test cases by executing or executing instructions stored in the memory 702 and invoking data stored in the memory 702. Alternatively, the processor 701 may include one or more processing units, and the processor 701 may integrate an application processor and a modem processor, wherein the application processor primarily processes an operating system, a user interface, and application programs, etc., and the modem processor primarily processes wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 701. In some embodiments, processor 701 and memory 702 may be implemented on the same chip, or they may be implemented separately on separate chips in some embodiments.
The processor 701 may be a general purpose processor such as a Central Processing Unit (CPU), digital signal processor, application SPECIFIC INTEGRATED Circuit (ASIC), field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or a combination thereof, that may implement or perform the methods, steps, and logic blocks disclosed in embodiments of the invention. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present invention may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in the processor for execution.
The memory 702 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The Memory 702 may include at least one type of storage medium, and may include, for example, flash Memory, hard disk, multimedia card, card Memory, random access Memory (Random Access Memory, RAM), static random access Memory (Static Random Access Memory, SRAM), programmable Read-Only Memory (Programmable Read Only Memory, PROM), read-Only Memory (ROM), charged erasable programmable Read-Only Memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory, EEPROM), magnetic Memory, magnetic disk, optical disk, and the like. Memory 702 is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 702 in embodiments of the present invention may also be circuitry or any other device capable of performing storage functions for storing program instructions and/or data.
Based on the same technical idea, an embodiment of the present invention provides a computer-readable storage medium storing a computer program executable by a computer device, which when run on the computer device, causes the computer device to execute the steps of a test case generating method of a user interface.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, or as a computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.