CN115422079A - Test case generation method and device and electronic equipment - Google Patents
Test case generation method and device and electronic equipment Download PDFInfo
- Publication number
- CN115422079A CN115422079A CN202211148207.4A CN202211148207A CN115422079A CN 115422079 A CN115422079 A CN 115422079A CN 202211148207 A CN202211148207 A CN 202211148207A CN 115422079 A CN115422079 A CN 115422079A
- Authority
- CN
- China
- Prior art keywords
- test case
- node
- nodes
- generating
- interface
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 287
- 238000000034 method Methods 0.000 title claims abstract description 69
- 238000010586 diagram Methods 0.000 claims abstract description 59
- 238000004590 computer program Methods 0.000 claims description 24
- 230000008569 process Effects 0.000 claims description 20
- 230000004048 modification Effects 0.000 claims description 8
- 238000012986 modification Methods 0.000 claims description 8
- 238000000605 extraction Methods 0.000 claims description 2
- 238000012545 processing Methods 0.000 description 13
- 238000004891 communication Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 4
- 238000013461 design Methods 0.000 description 2
- 235000019800 disodium phosphate Nutrition 0.000 description 2
- 230000008676 import Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000013522 software testing Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000001174 ascending effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 239000002346 layers by function Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000010998 test method Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The application provides a method and a device for generating a test case and electronic equipment, wherein the method for generating the test case comprises the steps of extracting a plurality of interface parameters from an interface document of a target interface and at least one value corresponding to the interface parameters; constructing a test case network graph based on the interface parameters and the values, wherein the test case network graph comprises a plurality of nodes, the nodes are used for representing the values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows; and generating a plurality of test cases according to the test case network diagram, wherein each test case comprises values corresponding to at least two interface parameters, and any two test cases comprise different node paths. The method and the device can generate a plurality of test cases which are more universal and wider in coverage.
Description
Technical Field
The present application relates to the field of mobile interface testing technologies, and in particular, to a method and an apparatus for generating a test case, and an electronic device.
Background
Interface testing is a test that tests the interface between components of a device. The interface test is mainly used for detecting interaction points between external devices and between each internal sub-device. The key points of the test are to check the correctness of the interface parameter transmission, the correctness of the interface function realization, the correctness of the output result and the integrity and the rationality of the fault-tolerant processing of various abnormal conditions.
The current common interface test method is to adopt a marginal value analysis method and an equivalence class division method to interface parameters, select typical values, and then randomly select a group of test cases in the value combinations, or screen out values according to actual service scenes to be used as the test cases.
Disclosure of Invention
The embodiment of the application provides a method and a device for generating a test case and electronic equipment, and aims to solve the problem that the test case of the current interface test has subjective tendency, so that the interface test is not universal.
A first aspect of the present application provides a method for generating a test case, including: extracting a plurality of interface parameters and at least one value corresponding to the interface parameters from an interface document of a target interface; constructing a test case network graph based on the interface parameters and the values, wherein the test case network graph comprises a plurality of nodes, the nodes are used for representing the values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows; and generating a plurality of test cases according to the test case network diagram, wherein each test case comprises values corresponding to at least two interface parameters, and any two test cases comprise different node paths.
In an embodiment of the present application, generating a plurality of test cases according to the test case network diagram includes: circularly executing the following steps: in the process of generating the current test case, determining a node in the Nth row of the test case network graph as a target node of the test case, wherein a node path between the first target node determined in the Nth row and the target node determined in the N-1 th row does not exist in the generated test case; and generating a current test case according to the plurality of target nodes.
In an embodiment of the present application, a node has a node number, where the node number indicates a row position and a column position of the node in a test case network diagram, and then a plurality of test cases are generated according to the test case network diagram, where the method includes: and generating a plurality of test cases according to the test case network diagram and the node numbers of the nodes.
In an embodiment of the present application, generating a plurality of test cases according to a test case network diagram and a node number of a node includes: circularly executing the following steps: in the process of generating the current test case, key nodes are selected line by line in a test case network diagram according to the sequence of increasing line numbers; generating a current test case according to the plurality of key nodes; when the key node of the current test case is selected, the node number of the determined key node is transmitted in series to the key node of the next row and is connected in series with the node number of the key node of the next row, a node path between the key node determined by the current row and the key node determined by the next row does not appear in the determined test case, and the node number which is output by the finally determined key node and is connected in series is the current test case.
In one embodiment of the application, a plurality of test cases cover a path between any two nodes of adjacent rows.
In an embodiment of the present application, constructing a test case network diagram based on interface parameters and values includes: displaying the interface parameters and corresponding values; and receiving modification operation aiming at the value, and constructing a test case network diagram based on the interface parameter and the modified value.
A second aspect of the present application provides a device for generating a test case, including:
the extraction module is used for extracting a plurality of interface parameters and at least one value corresponding to the interface parameters from the interface document of the target interface;
the test case network graph comprises a plurality of nodes, the nodes are used for representing values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows;
and the generating module is used for generating a plurality of test cases according to the test case network diagram, wherein each test case comprises values corresponding to at least two interface parameters, and any two test cases comprise different node paths.
In an embodiment of the present application, the generating module is specifically configured to: circularly executing the following steps: in the process of generating the current test case, determining a node in the Nth row of the test case network graph as a target node of the test case, wherein a node path between the first target node determined in the Nth row and the target node determined in the N-1 th row does not exist in the generated test case; and generating a current test case according to the plurality of target nodes.
In an embodiment of the application, the generating module is specifically configured to: and generating a plurality of test cases according to the test case network diagram and the node numbers of the nodes.
In an embodiment of the present application, when the generating module generates a plurality of test cases according to the test case network diagram and the node numbers of the nodes, the generating module is specifically configured to: circularly executing the following steps: in the process of generating the current test case, key nodes are selected line by line in a test case network diagram according to the sequence of increasing line numbers; generating a current test case according to the plurality of key nodes; when the key node of the current test case is selected, the node number of the determined key node is serially transmitted to the key node of the next row and is serially connected with the node number of the key node of the next row, a node path between the key node determined by the current row and the key node determined by the next row does not appear in the determined test case, and the serial node number output by the finally determined key node is the current test case.
In one embodiment of the application, a plurality of test cases cover a path between any two nodes of adjacent rows.
In an embodiment of the application, the building module is specifically configured to: displaying the interface parameters and corresponding values; and receiving modification operation aiming at the value, and constructing a test case network diagram based on the interface parameter and the modified value.
A third aspect of the present application provides an electronic device comprising a memory and a processor; wherein,
the memory is used for storing program codes;
the processor is used for calling the program codes to realize the generation method of the test case of any one of the above items.
A fourth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program causes an electronic device to execute any one of the above-mentioned test case generation methods.
A fifth aspect of the present application provides a computer program product, a computer program product comprising: the test case generation method includes the steps of storing a computer program in a readable storage medium, reading the computer program from the readable storage medium by at least one processor of the electronic device, and executing the computer program by the at least one processor to enable the electronic device to execute the test case generation method of any one of the first aspect.
According to the technical scheme, the plurality of interface parameters and the at least one value corresponding to the interface parameters are extracted from the interface document of the target interface; constructing a test case network graph based on the interface parameters and the values, wherein the test case network graph comprises a plurality of nodes, the nodes are used for representing the values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows; and generating a plurality of test cases according to the test case network diagram, wherein each test case comprises at least two values corresponding to the interface parameters, and any two test cases comprise different node paths, so that a plurality of test cases with universality and wider coverage can be generated.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic view of an application scenario of a test case generation method provided in the present application;
FIG. 2 is a flowchart illustrating steps of a method for generating test cases according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a network diagram of test cases provided by an embodiment of the present application;
FIG. 4 is a flowchart illustrating steps of a method for generating test cases according to another embodiment of the present application;
fig. 5 is a block diagram of a structure of a test case generation apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
Software testing is a main way for improving software quality, and the core of the software testing is to adopt a targeted theory and method to test whether software meets a set sufficiency criterion. The quality of the test case directly determines the effectiveness of the software test due to the core problem in the software test process during the design of the test case. As the number of interaction points between the external device and the device and between each internal sub-device increases, the security, stability and exception handling capability of the device become more and more important, and the interface test also becomes an essential link in the test process.
The interface test aims at testing the correctness and stability of an interface, and the principle is that a simulation client sends a request message to a server, the server processes the corresponding message after receiving the request message and returns a response to the client, and the logic verification of the server is focused on. The interface test is based on software design documents such as a requirement specification and the like, and the test means is to regard program logic in the interface as a black box. At present, the design of a test case of an interface test is similar to that of a test case of a unit test, and a boundary value method or an equivalent method and other basic methods are adopted, but the method has the problems of subjectivity and non-universality.
In order to solve the above problem, an embodiment of the present application provides a method for generating a test case, where a plurality of interface parameters and at least one value corresponding to the interface parameters are extracted from an interface document of a target interface; constructing a test case network graph based on the interface parameters and the values, wherein the test case network graph comprises a plurality of nodes, the nodes are used for representing the values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows; and generating a plurality of test cases according to the test case network diagram, wherein each test case comprises at least two values corresponding to the interface parameters, and any two test cases comprise different node paths, so that a plurality of test cases with universality and wider coverage can be generated.
Fig. 1 is a schematic view of an application scenario of the test case generation method provided in the present application. As shown in fig. 1, the interface 10 including the automated generation system of test cases includes that a tester can click an "import interface document" on the interface 10 to import an interface document of a target interface, and the interface document is imported into the automated generation system, the automated generation system extracts interface parameters and parameter values in the interface document, displays the interface document on the interface 10, supports modification of the parameter values, and then automatically generates test cases, and the tester can click and export the test cases to obtain the test cases generated by the automated generation system, which is simple and convenient in process.
Hereinafter, the technical means of the present application will be described in detail by specific examples. It should be noted that the following several specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
Referring to fig. 2, a flowchart of steps of a method for generating a test case provided in an embodiment of the present application specifically includes the following steps:
s201, extracting a plurality of interface parameters and at least one value corresponding to the interface parameters from the interface document of the target interface.
The interface refers to a communication rule between different functional layers of the same computer and is called an interface, wherein the target interface is an interface which needs to generate a test case. An interface document is a document used to scofflaw the interface information provided by the system, which can tell the developer what data the interface can return, and what data the developer needs to enter in order to get that data, which interface to request. The interface document comprises a plurality of interface parameters, and each interface parameter corresponds to a plurality of values.
Illustratively, the interface parameter 1 is "this other line", a corresponding value of 0 indicates "this line", and a value of 1 indicates "other line". The interface parameter 2 is "account type", the corresponding value 1 indicates "current date", the value 2 indicates "regular", and the value 3 indicates "unit settlement card". The interface parameter 3 is a currency code, the corresponding value is CNY which represents RMB, the value is USD which represents USD, the value is EUR which represents Euro, and the value is JPY which represents Japanese. The interface parameter 4 is "fried sink", the value of 0 indicates "fried", and the value of 1 indicates "sink".
S202, constructing a test case network graph based on the interface parameters and the values.
The network diagram of the test case comprises a plurality of nodes, the nodes are used for representing values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows. Specifically, each node in the same row of the test case network diagram represents different values of the same interface parameter. Different rows of the test case network graph represent different node parameters. Wherein one node represents one value.
Illustratively, referring to fig. 3, the test case network diagram includes 4 rows of nodes, a first row of nodes represents an interface parameter 1 "this other row", a first column of nodes "1-1" of the first row of nodes represents a value 0, and a second column of nodes "1-2" represents a value 2. The second row of nodes represents the interface parameter 2 "account type", the first column of "2-1" nodes of the second row of nodes represents the value 1, the second column of nodes "2-2" represents the value 2, and the third column of nodes "2-3" represents the value 3. The third row of nodes represents that the interface parameter 3 is 'currency code', the first column of nodes '3-1' represents the value 'CNY', the second column of nodes '3-2' represents the value 'USD', the third column of nodes '3-2' represents the value 'EUR', and the fourth column of nodes '3-4' represents the value 'JPY'. The fourth row of nodes represents the interface parameter 4 'Stir-Rou', the first column of nodes '4-1' represents the value 0, and the second column of nodes '4-2' represents the value 1.
S203, generating a plurality of test cases according to the test case network diagram.
Each test case comprises values corresponding to at least two interface parameters, and any two test cases comprise different node paths. Specifically, each test case includes at most one node in each row of nodes in the test case network diagram, for example, in a process of generating any one test case in a plurality of test cases, at most one node can be selected from any one row of nodes in fig. 3. Further, any two test cases in the plurality of test cases do not contain the same node path, that is, each node path in each test case network graph is traversed only once.
Optionally, the multiple test cases cover a path between any two nodes in the adjacent rows.
In one embodiment, generating a plurality of test cases according to the test case network diagram includes: circularly executing the following steps: in the process of generating the current test case, determining a node in the Nth row of the test case network graph as a target node of the test case, wherein a node path between the first target node determined in the Nth row and the target node determined in the N-1 th row does not exist in the generated test case; and generating a current test case according to the plurality of target nodes. Wherein N is less than or equal to the number of the interface parameters.
Illustratively, in fig. 3, a first test case "(1-1) - (2-1) - (3-1) - (4-1)" is determined, the first test case includes node paths "(1-1) - (2-1)", "(2-1) - (3-1)" and "(3-1) - (4-1)", then a second test case is determined, such as "(1-1) - (2-2) - (3-1) - (4-2)", the second test case includes node paths "(1-1) - (2-2)", "(2-2) - (3-1) - (4-2)", the second test case includes node paths different from the node paths included in the first test case, and so on, the third test case includes node paths different from the node paths included in the first test case and the second test case, the fourth test case includes nodes different from the first test case, the fourth test case includes nodes, and the fourth test case includes a test case, and the second test case includes a test case, and the fourth test case includes a node path different from the first test case, and the second test case, and the fourth test case includes a node path.
Further, in the embodiment of the present application, a plurality of test cases may be generated according to a preset sequence, or a plurality of test cases may be generated randomly, which is not limited herein.
In the embodiment of the application, the plurality of test cases are generated by adopting the mode, so that the plurality of test cases can cover all node paths, the same node paths can not appear, the generation of the plurality of test cases which is more universal, more extensive and redundant can not exist, and the test efficiency can be improved when the plurality of test cases are used for testing the target interface.
On the basis of the foregoing embodiment, an embodiment of the present application provides another test case generation method, specifically referring to fig. 4, which specifically includes the following steps:
s401, extracting a plurality of interface parameters and at least one value corresponding to the interface parameters from the interface document of the target interface.
The specific implementation process of this step refers to S201, and is not described herein again.
S402, displaying the interface parameters and the corresponding values.
Referring to fig. 1, the interface parameters and corresponding values, such as interface parameter 1 and corresponding values 11 and 12, are displayed on the interface. Interface parameter 2 and corresponding values 21, 22, etc. Interface parameter 3 and corresponding values 31, 32, etc. And the interface parameter m and the corresponding value m1, m2 and the like.
And S403, receiving modification operation aiming at the values, and constructing a test case network diagram based on the interface parameters and the modified values.
The interface supports modification of values of interface parameters, testers can modify the values as required, and then a test case network diagram is constructed based on the interface parameters and the corresponding modified values.
It can be understood that the test case network diagram is constructed based on the interface parameters, the modified values and the unmodified values.
S404, generating a plurality of test cases according to the test case network diagram and the node numbers of the nodes.
The nodes have node numbers, and the node numbers represent row positions and column positions of the nodes in the test case network diagram. Illustratively, referring to FIG. 3, each node has a node number, which is represented by "i-j", where i represents the row position of the node in the testcase network diagram and j represents the column position of the node in the testcase network diagram.
Illustratively, assume that the target interface has m interface parameters, i.e., interface parameter C1 to interface parameter Cm. Each interface parameter has a corresponding value set, for example, the value set of the interface parameter C1 is D1, the value set Dm of the interface parameter Cm has a plurality of values, if a test case is generated, an exhaustive mode is adopted, the calculation amount is huge and unnecessary, for example, referring to fig. 3, m is 4, the value set D1 includes 2 values, the value set D2 includes 3 values, the value set D3 includes 4 values, and the value set D4 includes 2 values, and a 2 × 3 × 4 × 2 test cases (48) having a plurality of repeated node paths can be obtained in an exhaustive mode, which is unnecessary for interface testing and can result in the efficiency reduction of interface testing. If a boundary value is selected to form a test case by adopting a boundary method, the error of an interface can be exposed, then some values are supplemented according to an equivalence class division method, some discrete values are selected from each value set to form the test case, but the problem that the test case is large in data and not universal is also solved.
In addition, if a certain test case can realize the combined coverage of k values, the coverage of k-1, k-2, \ 8230and 2,1 value combinations is also realized. Therefore, the test cases generated by the method can generate the minimum number of test cases on the premise of realizing the full coverage of all value taking conditions so as to improve the testing efficiency. Illustratively, if the test case is "(1-1) - (2-1) - (3-1) - (4-1)", the test case may cover "(1-1) - (2-1) - (3-1) - (4-1)", "(1-1) - (2-1) - (3-1)", "(1-1) - (2-1) - (4-1)", "(1-1) - (3-1) - (4-1)", "(2-1) - (3-1) - (4-1)", and ″ (2-1) - (3-1) - (4-1) ", as well as" (1-1) - (2-1) "," (1-1) - (4-1) "," (1-1) - (3-1) "," (1-1) - (2-1) "," (2-1) - (3-1) "," (3-1) - (4-1) "," (1-1) "," (2-1) "," (3-1) "," (4-1) ", and so on. The method can generate the least number of test cases on the premise of realizing full coverage by adopting the traversal method.
Specifically, generating a plurality of test cases according to the test case network diagram and the node numbers of the nodes includes: circularly executing the following steps: in the process of generating the current test case, key nodes are selected line by line in a test case network diagram according to the sequence of increasing line numbers; generating a current test case according to the plurality of key nodes; when the key node of the current test case is selected, the node number of the determined key node is serially transmitted to the key node of the next row and is serially connected with the node number of the key node of the next row, a node path between the key node determined by the current row and the key node determined by the next row does not appear in the determined test case, and the serial node number output by the finally determined key node is the current test case.
Illustratively, the plurality of test cases shown in table 1 is generated based on the test case network diagram shown in fig. 3 in the manner described above:
TABLE 1
Referring to table 1, when generating test case 1, one key node is selected in each row line by line according to the ascending order of the row numbers. Obtaining a test case 1' (1-1) — (2-1) — (3-1) — (4-1) ", specifically, selecting a key node (1-1) in a first row of a test case network diagram, transmitting a node number (1-1) of the key node (1-1) to a key node (2-1) selected in a second row, connecting the node numbers (1-1) and (2-1) in series to obtain the key node (2-1)", then, "(1-1) — (2-1)" is transmitted to the key node (3-1) determined in the third row, and after concatenation, "(1-1) — (2-1) — (3-1)" is obtained, and then, "(1-1) — (2-1) — (3-1)" is transmitted to the key node (4-1) determined in the fourth row, and after concatenation, "(1-1) — (2-1) — (3-1) — (4-1)" is obtained, and the key node (4-1) outputs "(1-1) — (2-1) — (3-1) — (4-1)".
Further, the subsequent key nodes 2 to 10 are determined by the above method, wherein when the determined key node transmits the serial node number to the node in the next row, the node which is transmitted before is selected as the key node to transmit the serial node number. For example, in test case 6 in table 1, when the key node (2-3) transmits the node number (1-2) — (2-3) after the concatenation to the node (3-2), it needs to be determined that the node number has not been transmitted to the node (3-2) before transmitting the node number to the node (3-2). Therefore, the same node path can be ensured to be traversed only once when a plurality of test cases are generated.
Referring to table 1, the test case does not need to select one node in each row, but only one node in a row at most. Moreover, by adopting the mode of the application, only 10 test cases need to be generated for the test case network diagram shown in fig. 3, full coverage can be realized for each node and the combination of the nodes, and compared with the exhaustion quantity, the quantity is greatly reduced, so that the efficiency of interface testing can be improved by adopting the method.
Compared with the traditional interface test case generation mode, the mode for generating the test case by using the test case network diagram method is more scientific and universal, and the coverage scene is wider. Moreover, the interface test case can be directly generated after the interface document is imported, export is supported, efficiency is higher, and operability is stronger.
Referring to fig. 5, a schematic diagram of a device for generating a test case according to an embodiment of the present application is shown, where the device 50 for generating a test case includes:
an extracting module 501, configured to extract a plurality of interface parameters and at least one value corresponding to the interface parameter from an interface document of a target interface;
a building module 502, configured to build a test case network graph based on the interface parameters and the values, where the test case network graph includes a plurality of nodes, each node is used for representing a value, nodes in a same row represent values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows;
the generating module 503 is configured to generate a plurality of test cases according to the test case network diagram, where each test case includes values corresponding to at least two interface parameters, and any two test cases include different node paths.
In an embodiment of the present application, the generating module 503 is specifically configured to: circularly executing the following steps: in the process of generating the current test case, determining a node in the Nth row of the test case network diagram as a target node of the test case, wherein a node path between the first target node determined in the Nth row and the target node determined in the N-1 th row does not exist in the generated test case; and generating a current test case according to the plurality of target nodes.
In an embodiment of the present application, the generating module 503 is specifically configured to: and generating a plurality of test cases according to the test case network diagram and the node numbers of the nodes.
In an embodiment of the present application, when the generating module 503 generates a plurality of test cases according to the test case network diagram and the node numbers of the nodes, the generating module is specifically configured to: circularly executing the following steps: in the process of generating the current test case, key nodes are selected line by line in a test case network diagram according to the sequence of increasing line numbers; generating a current test case according to the plurality of key nodes; when the key node of the current test case is selected, the node number of the determined key node is serially transmitted to the key node of the next row and is serially connected with the node number of the key node of the next row, a node path between the key node determined by the current row and the key node determined by the next row does not appear in the determined test case, and the serial node number output by the finally determined key node is the current test case.
In one embodiment of the application, multiple test cases cover a path between any two nodes in adjacent rows.
In an embodiment of the present application, the building module 502 is specifically configured to: displaying the interface parameters and corresponding values; and receiving modification operation aiming at the value, and constructing a test case network diagram based on the interface parameter and the modified value.
Specifically, please refer to the contents of the embodiment of the test case generation method for the specific working contents of each module of the test case generation apparatus, which is not described herein again.
It should be noted that the division of the modules of the above apparatus is only a logical division, and the actual implementation may be wholly or partially integrated into one physical entity, or may be physically separated. And these modules can be realized in the form of software called by processing element; or may be implemented entirely in hardware; and part of the modules can be realized in the form of calling software by the processing element, and part of the modules can be realized in the form of hardware. For example, the processing module may be a processing element separately set up, or may be implemented by being integrated in a chip of the apparatus, or may be stored in a memory of the apparatus in the form of program code, and a function of the processing module may be called and executed by a processing element of the apparatus. Other modules are implemented similarly. In addition, all or part of the modules can be integrated together or can be independently realized. The processing element here may be an integrated circuit with signal processing capabilities. In implementation, each step of the above method or each module above may be implemented by an integrated logic circuit of hardware in a processor element or an instruction in the form of software.
For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when some of the above modules are implemented in the form of a processing element scheduler code, the processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. As another example, these modules may be integrated together, implemented in the form of a system-on-a-chip (SOC).
In the above embodiments, all or part of the implementation may be realized by software, hardware, firmware, or any combination thereof. When implemented in software, 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. The procedures or functions according to the embodiments of the present application are all or partially generated when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), among others.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device may be specifically a bank server or a block chain platform. As shown in fig. 6, the electronic device may include: a processor 61, a memory 62, a communication interface 63, and a system bus 64. The memory 62 and the communication interface 63 are connected to the processor 61 through a system bus 64 to complete communication therebetween, the memory 62 is used for storing computer-executable instructions, the communication interface 63 is used for communicating with other devices, and the processor 61 implements the solution of the above embodiment when executing the computer-executable instructions.
The system bus mentioned in fig. 6 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The system bus may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown, but this is not intended to represent only one bus or type of bus. The communication interface is used for realizing communication between the database access device and other equipment (such as a client, a read-write library and a read-only library). The memory may comprise Random Access Memory (RAM) and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The processor may be a general-purpose processor, including a central processing unit CPU, a Network Processor (NP), and the like; but also a digital signal processor DSP, an application specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic device, discrete gate or transistor logic, discrete hardware components.
Optionally, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the electronic device is caused to execute the method according to the embodiment shown in fig. 2 to fig. 3.
Optionally, an embodiment of the present application further provides a computer program product, where the computer program product includes: a computer program, stored in a readable storage medium, from which at least one processor of the electronic device can read the computer program, the at least one processor executing the computer program causing the electronic device to perform the method of the embodiment shown in fig. 2 to 3 described above.
In the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" describes the association relationship of the associated object, indicating that there may be three relationships, for example, a and/or B, which may indicate: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship; in the formula, the character "/" indicates that the preceding and following related objects are in a relationship of "division". "at least one of the following" or similar expressions refer to any combination of these items, including any combination of the singular or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c may be single or multiple.
It is to be understood that the various numerical references referred to in the embodiments of the present application are merely for convenience of description and distinction and are not intended to limit the scope of the embodiments of the present application. In the embodiment of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiment of the present application.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.
Claims (10)
1. A method for generating a test case is characterized by comprising the following steps:
extracting a plurality of interface parameters and at least one value corresponding to the interface parameters from an interface document of a target interface;
constructing a test case network graph based on the interface parameters and the values, wherein the test case network graph comprises a plurality of nodes, the nodes are used for representing the values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows;
and generating a plurality of test cases according to the test case network diagram, wherein each test case comprises values corresponding to the at least two interface parameters, and any two test cases comprise different node paths.
2. The method according to claim 1, wherein the generating a plurality of test cases according to the test case network diagram comprises: circularly executing the following steps:
in the process of generating a current test case, determining a node in the Nth row of the test case network diagram as a target node of the test case, wherein a node path between a first target node determined in the Nth row and a target node determined in the N-1 th row does not exist in the generated test case;
and generating the current test case according to the plurality of target nodes.
3. The method according to claim 1, wherein the node has a node number, and the node number indicates a row position and a column position of the node in the test case network diagram, and then the generating a plurality of test cases according to the test case network diagram includes:
and generating the plurality of test cases according to the test case network diagram and the node numbers of the nodes.
4. The method for generating test cases according to claim 1, wherein the generating the plurality of test cases according to the test case network diagram and the node number of the node comprises: circularly executing the following steps:
in the process of generating the current test case, key nodes are selected line by line in the test case network diagram according to the sequence of increasing line numbers;
generating the current test case according to the plurality of key nodes;
when the key nodes of the current test case are selected, the node numbers of the determined key nodes are serially transmitted to the key nodes of the next row and serially connected with the node numbers of the key nodes of the next row, the node paths between the key nodes determined by the current row and the key nodes determined by the next row do not appear in the determined test case, and the serially connected node numbers output by the finally determined key nodes are the current test case.
5. The method for generating the test case according to any one of claims 1 to 4, wherein the plurality of test cases cover a path between any two nodes in adjacent rows.
6. The method for generating the test case according to any one of claims 1 to 4, wherein the constructing a test case network diagram based on the interface parameters and the values includes:
displaying the interface parameters and the corresponding values;
and receiving modification operation aiming at the value, and constructing the test case network diagram based on the interface parameter and the modified value.
7. An apparatus for generating a test case, comprising:
the extraction module is used for extracting a plurality of interface parameters and at least one value corresponding to the interface parameters from an interface document of a target interface;
the building module is used for building a test case network graph based on the interface parameters and the values, the test case network graph comprises a plurality of nodes, the nodes are used for representing the values, the nodes in the same row represent the values of the same interface parameters, and a node path is formed between any two nodes in adjacent rows;
and the generating module is used for generating a plurality of test cases according to the test case network diagram, wherein each test case comprises values corresponding to the at least two interface parameters, and any two test cases comprise different node paths.
8. An electronic device comprising a memory and a processor; wherein,
the memory is used for storing program codes;
the processor is used for calling the program code to realize the test case generation method of any one of claims 1 to 6.
9. A computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, causes an electronic device to perform the method for generating test cases according to any one of claims 1 to 6.
10. A computer program product, the computer program product comprising: computer program stored in a readable storage medium, from which at least one processor of an electronic device can read the computer program, execution of the computer program by the at least one processor causing the electronic device to perform the method of generating a test case according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211148207.4A CN115422079A (en) | 2022-09-20 | 2022-09-20 | Test case generation method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211148207.4A CN115422079A (en) | 2022-09-20 | 2022-09-20 | Test case generation method and device and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115422079A true CN115422079A (en) | 2022-12-02 |
Family
ID=84205181
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211148207.4A Pending CN115422079A (en) | 2022-09-20 | 2022-09-20 | Test case generation method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115422079A (en) |
-
2022
- 2022-09-20 CN CN202211148207.4A patent/CN115422079A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11138163B2 (en) | Automatic root cause diagnosis in networks based on hypothesis testing | |
CN110474900B (en) | Game protocol testing method and device | |
US20240126817A1 (en) | Graph data query | |
CN106487603A (en) | A kind of response test method and device | |
EP4033440A1 (en) | Consensus method, apparatus and device of block chain | |
CN114372006A (en) | Method and system for automatically generating test case, computer equipment and storage medium | |
CN111475402B (en) | Program function testing method and related device | |
JP6419667B2 (en) | Test DB data generation method and apparatus | |
CN115858487A (en) | Data migration method and device | |
CN116561607A (en) | Method and device for detecting abnormality of resource interaction data and computer equipment | |
CN109003181B (en) | Suspicious user determination method, device, equipment and computer readable storage medium | |
Wang et al. | EtherFuzz: mutation fuzzing smart contracts for TOD vulnerability detection | |
CN114297037A (en) | Alarm clustering method and device | |
CN113342647A (en) | Test data generation method and device | |
CN112561690A (en) | Method, system, equipment and storage medium for testing credit card staging service interface | |
CN115422079A (en) | Test case generation method and device and electronic equipment | |
CN109324963A (en) | The method and terminal device of automatic test profitable result | |
CN114490415A (en) | Service testing method, computer device, storage medium, and computer program product | |
CN112559331A (en) | Test method and device | |
CN111427571A (en) | Data verification method and device | |
CN112380798B (en) | Parameter checking method, device, equipment and storage medium | |
CN110096555B (en) | Table matching processing method and device for distributed system | |
CN117708151A (en) | Data processing method and device and computer equipment | |
He et al. | Measuring Component Importance for Network System Using Cellular Automata | |
CN117349184A (en) | Test case generation method, device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |