Disclosure of Invention
The embodiment of the disclosure provides an automatic testing method and device.
In a first aspect, an embodiment of the present disclosure provides an automated testing method, including: obtaining an operation list of a test case, wherein each row in the operation list comprises operation and calling parameters; acquiring a parameter list of a test case, wherein each line in the parameter list comprises a parameter name and at least one parameter value; selecting a parameter value from each row in the parameter list, and combining the parameter values selected from each row into test data; and executing the operation in the operation list by taking the test data as the calling parameter of the test case to obtain a test result.
In some embodiments, selecting a parameter value from each row in the parameter list, and combining the selected parameter values in each row into test data comprises: and selecting one parameter value from each row in the parameter list every time according to a combination algorithm to obtain a group of test data, and finally obtaining all combined test data.
In some embodiments, the action list and the parameter list are edited via a web page.
In some embodiments, before selecting a parameter value from each row in the parameter list, the method further comprises: and for each parameter name in the parameter list, if the parameter name is not referred by the called parameter, filtering out the parameter value corresponding to the parameter name which is not referred.
In some embodiments, the method further comprises: and outputting and displaying the test data and the test result together.
In some embodiments, the executing the operation in the operation list by using the test data as the call parameter of the test case to obtain the test result includes: replacing the calling parameters in the test cases with parameter values; executing the operation in the operation list; after the execution of each step is finished, the execution correctness of each step is evaluated, and a corresponding execution result is returned; and summarizing the execution results of all the steps into a test result.
In some embodiments, the method further comprises: each group of test data is selected and distributed with a test case ID; for each set of test data, a test case named test case ID of the test data is generated according to the test data.
In a second aspect, an embodiment of the present disclosure provides an automated testing device, including: the test case testing system comprises a first obtaining unit, a second obtaining unit and a testing unit, wherein the first obtaining unit is configured to obtain an operation list of a test case, and each row in the operation list comprises operation and calling parameters; the second acquisition unit is configured to acquire a parameter list of the test case, wherein each line in the parameter list comprises a parameter name and at least one parameter value; the parameter selecting unit is configured to select a parameter value from each row in the parameter list and combine the selected parameter values of each row into test data; and the execution unit is configured to execute the operation in the operation list by taking the test data as the calling parameter of the test case to obtain a test result.
In some embodiments, the parameter selection unit is further configured to: and selecting one parameter value from each row in the parameter list every time according to a combination algorithm to obtain a group of test data, and finally obtaining all combined test data.
In some embodiments, the action list and the parameter list are edited via a web page.
In some embodiments, the parameter selection unit is further configured to: before selecting a parameter value from each row in the parameter list, for each parameter name in the parameter list, if the parameter name is not referred by the called parameter, filtering out the parameter value corresponding to the parameter name which is not referred.
In some embodiments, the apparatus further comprises a presentation unit configured to: and outputting and displaying the test data and the test result together.
In some embodiments, the execution unit is further configured to: replacing the calling parameters in the test cases with parameter values; executing the operation in the operation list; after the execution of each step is finished, the execution correctness of each step is evaluated, and a corresponding execution result is returned; and summarizing the execution results of all the steps into a test result.
In some embodiments, the apparatus further comprises an allocation unit configured to: each group of test data is selected and distributed with a test case ID; for each set of test data, a test case named test case ID of the test data is generated according to the test data.
In a third aspect, an embodiment of the present disclosure provides an automated testing electronic device, including: one or more processors; storage means having one or more programs stored thereon which, when executed by the one or more processors, cause the one or more processors to carry out the method according to any one of the first aspects.
In a fourth aspect, embodiments of the present disclosure provide a computer readable medium having a computer program stored thereon, wherein the program when executed by a processor implements the method according to any one of the first aspect.
The automatic testing method and device provided by the embodiment of the application reduce the labor force and improve the human efficiency under the condition of not influencing the effect. And recombining the test cases by the parameter values, and analyzing and executing. The existing automatic test can only show the execution error of a certain case, but the effect of correct execution cannot be shown, and by the mode, the correct errors can be listed, so that the report display is convenient.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 to which embodiments of the automated test method or automated test apparatus of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a test-type application, a web browser application, a shopping-type application, a search-type application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server that provides various services, such as a background test server that provides support for test cases edited on the terminal devices 101, 102, 103. The background test server can analyze and process the received related data of the test case, and feed back the test result to the terminal equipment.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be noted that the automated testing method provided by the embodiment of the present application is generally executed by the server 105, and accordingly, the automated testing apparatus is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of an automated testing method according to the present application is shown. The automatic testing method comprises the following steps:
step 201, an operation list of the test case is obtained.
In this embodiment, an execution subject (for example, a server shown in fig. 1) of the automated testing method may obtain an operation list of the test case from the terminal device. The user can fill in the operation list of the test case on the webpage and then upload the operation list to the server. And editing operations such as adding, modifying, deleting and the like can be carried out on the operation list and the parameter list through the webpage. The specific implementation of the operation list of the test case may be as shown in the execute operation part of fig. 3 a. Wherein, each row in the operation list comprises an operation (such as an input operation, a click operation, a double click operation, a sliding operation, etc.), and a calling parameter (such as $ { userName }, $ { passWord }, etc.). A call parameter ID (e.g., [ ID ] ═ userdettext, [ ID ] ═ passedtesttext, etc.) may also be included in the operation list.
Step 202, a parameter list of the test case is obtained.
In this embodiment, an execution subject (for example, a server shown in fig. 1) of the automated testing method may obtain a parameter list of the test case from the terminal device. The user can fill in a parameter list of the test case on the webpage and then upload the parameter list to the server. The terminal can upload the operation list and the parameter list of the test case to the server together. The operation list and the parameter list can be edited by different users and then uploaded to the server respectively. For example, the user 1 designs an operation list. User 2 designs a parameter list. The parameter list may also have parameter values added by more users. As shown in the parameterized data section of FIG. 3a, each row in the parameter list includes a parameter name (e.g., userName, passWord, etc.) and at least one parameter value (e.g., jwg1, jwg2, jwg3 for the parameter name userName).
Step 203, selecting a parameter value from each row in the parameter list, and combining the parameter values selected from each row into test data.
In this embodiment, the test case shown in fig. 3a uses a plurality of parameters, userName, pasword, orderNo, etc. Normally this use case is executed only once, without taking the parameter values into account. In a general testing method, the same number of parameter values are required to be configured for the userName, pasword and orderNo so as to be executed by taking values one by one. The technical scheme of the application is that the value of each parameter is set at will, the number is not limited, and the parameters do not need to be in one-to-one correspondence. For example, jwg3 was extracted from userName, pass2 was extracted from passWord, and order1 was extracted from orderNo. The randomly drawn parameters are combined into test data and not necessarily jwg1, pass1, order no 1. The present application does not limit that each parameter must have the same number of parameter values.
Alternatively, all parameters can be combined completely by an algorithm, and by this combination all possibilities of parameters can be performed, i.e. all scenarios can be covered, as shown in fig. 3b, for a total of 4 combinations. In the execution process, the test cases can be recombined according to the permutation and combination of the parameters to generate the cases with the quantity equal to the permutation and combination, and then the cases are executed.
Optionally, before selecting one parameter value from each row in the parameter list, the method further includes: and for each parameter name in the parameter list, if the parameter name is not referred by the called parameter, filtering out the parameter value corresponding to the parameter name which is not referred. Judging the validity of each parameter, wherein the validity is used in the step of the test case, and if the parameter is not used, the parameter in the test case is considered to be invalid; the effective parameter is judged by a regular mode to judge whether the quoting is similar to $ { userName }, which is a rule used when the parameter is quoted, and if the quoting is not of the userName, the userName can be considered to be unused.
Optionally, the filtered parameters are recombined, after the parameters are completely arranged, the use cases are reassembled according to the arrangement, how many groups of use cases are assembled according to the arrangement, the name of the use case is renamed, and the ID of the test use case is specially processed, so that the difficulty in distinguishing when the use cases are executed is avoided.
And 204, executing the operation in the operation list by taking the test data as the calling parameter of the test case to obtain a test result.
In this embodiment, a parameter called in a test case is replaced by a parameter value, then corresponding operations such as inputting and clicking are performed, the accuracy of execution of each step is evaluated after the step is executed, then a corresponding execution result is returned, for example, jwg3 is replaced by $ { userName }, and then the inputting operation is performed.
With further reference to FIG. 4, a flow 400 of yet another embodiment of an automated testing method is illustrated. The process 400 of the automated testing method includes the following steps:
step 401, an operation list of the test case is obtained.
Step 402, a parameter list of the test case is obtained.
Step 403, selecting a parameter value from each row in the parameter list, and combining the parameter values selected from each row into test data.
And step 404, executing the operation in the operation list by taking the test data as the calling parameter of the test case to obtain a test result.
The steps 401 and 404 are substantially the same as the steps 201 and 204, and therefore, the description thereof is omitted.
And step 405, outputting and displaying the test data and the test result together.
In this embodiment, a corresponding test result is output for each set of test data. The test case ID may also be output. And the test results can be displayed in a classified manner, and the test data with the successful test result and the test data with the failed test result are respectively output. The positioning of the tester is facilitated. And further analyzing the test data with the test result of failure to determine the common parameter value.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the automated testing method in this embodiment represents a step of displaying the testing result. Therefore, the scheme described by the embodiment can more conveniently and quickly locate the problem.
With further reference to fig. 5, as an implementation of the method shown in the above figures, the present application provides an embodiment of an automated testing apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which can be applied to various electronic devices.
As shown in fig. 5, the automated testing apparatus 500 of the present embodiment includes: a first acquisition unit 501, a second acquisition unit 502, a parameter selection unit 503, and an execution unit 504. The first obtaining unit 501 is configured to obtain an operation list of a test case, where each row in the operation list includes an operation parameter and a call parameter; a second obtaining unit 502, configured to obtain a parameter list of the test case, where each row in the parameter list includes a parameter name and at least one parameter value; a parameter selecting unit 503 configured to select a parameter value from each row in the parameter list, and combine the selected parameter values of each row into test data; the execution unit 504 is configured to execute the operation in the operation list by using the test data as the call parameter of the test case, so as to obtain a test result.
In this embodiment, the specific processing of the first acquiring unit 501, the second acquiring unit 502, the parameter selecting unit 503 and the executing unit 504 of the automatic testing apparatus 500 may refer to step 201, step 202, step 203 and step 204 in the corresponding embodiment of fig. 2.
In some optional implementations of this embodiment, the parameter selection unit 503 is further configured to: and selecting one parameter value from each row in the parameter list every time according to a combination algorithm to obtain a group of test data, and finally obtaining all combined test data.
In some optional implementations of the present embodiment, the operation list and the parameter list are edited by a web page.
In some optional implementations of this embodiment, the parameter selection unit 503 is further configured to: before selecting a parameter value from each row in the parameter list, for each parameter name in the parameter list, if the parameter name is not referred by the called parameter, filtering out the parameter value corresponding to the parameter name which is not referred.
In some optional implementations of this embodiment, the apparatus further comprises a presentation unit (not shown in the drawings) configured to: and outputting and displaying the test data and the test result together.
In some optional implementations of this embodiment, the execution unit 504 is further configured to: replacing the calling parameters in the test cases with parameter values; executing the operation in the operation list; after the execution of each step is finished, the execution correctness of each step is evaluated, and a corresponding execution result is returned; and summarizing the execution results of all the steps into a test result.
In some optional implementations of this embodiment, the apparatus further comprises a distribution unit (not shown in the drawings) configured to: each group of test data is selected and distributed with a test case ID; for each set of test data, a test case named test case ID of the test data is generated according to the test data.
Referring now to fig. 6, a schematic diagram of an electronic device (e.g., the server or terminal device of fig. 1) 600 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The terminal device/server shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 6 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of embodiments of the present disclosure. It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: obtaining an operation list of a test case, wherein each row in the operation list comprises operation and calling parameters; acquiring a parameter list of a test case, wherein each line in the parameter list comprises a parameter name and at least one parameter value; selecting a parameter value from each row in the parameter list, and combining the parameter values selected from each row into test data; and executing the operation in the operation list by taking the test data as the calling parameter of the test case to obtain a test result.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a first acquisition unit, a second acquisition unit, a parameter selection unit, and an execution unit. The names of these units do not in some cases form a limitation on the unit itself, and for example, the first obtaining unit may also be described as a "unit that obtains an operation list of test cases".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.