CN116225886A - Test case generation method, device, equipment, storage medium and program product - Google Patents

Test case generation method, device, equipment, storage medium and program product Download PDF

Info

Publication number
CN116225886A
CN116225886A CN202111511718.3A CN202111511718A CN116225886A CN 116225886 A CN116225886 A CN 116225886A CN 202111511718 A CN202111511718 A CN 202111511718A CN 116225886 A CN116225886 A CN 116225886A
Authority
CN
China
Prior art keywords
interface
parameters
relation
determining
mapping relation
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
Application number
CN202111511718.3A
Other languages
Chinese (zh)
Inventor
邹意林
高玉军
刘璐辰
卢凯旋
林晓升
何埜
张天泽
曹紫光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202111511718.3A priority Critical patent/CN116225886A/en
Publication of CN116225886A publication Critical patent/CN116225886A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

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)
  • Test And Diagnosis Of Digital Computers (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the disclosure provides a test case generation method, a device, equipment, a storage medium and a program product, which relate to a test technology and comprise the steps of obtaining a data transmission relation among interfaces, wherein the data transmission relation comprises a plurality of initial mapping relations; determining the probability of each initial mapping relation according to each initial mapping relation in the data transmission relation, wherein the probability is used for representing the probability of a parameter from one interface when the parameter is used as the parameter of another interface; and determining the real mapping relation among the interfaces according to the probability of each initial mapping relation, and generating a scene use case according to each real mapping relation. In the scheme provided by the embodiment, the real mapping relation with higher occurrence probability in the parameter transfer process can be determined, so that the mapping relation which is more in line with the actual scene and used for representing the parameter transfer can be obtained, and further the scene use case which is in line with the actual application scene can be generated based on the real mapping relation.

Description

Test case generation method, device, equipment, storage medium and program product
Technical Field
The embodiment of the disclosure relates to the field of testing, in particular to a test case generation method, a device, equipment, a storage medium and a program product.
Background
For a network application or system, the code needs to be tested, for example, after part of the code is developed or after all of the code is developed. When testing the code of an application or system, the interface of the application or system needs to be tested.
In order to improve the interface test efficiency, an automatic test platform exists in the prior art. The automatic platform can be utilized to generate test cases, execute the test cases, carry out test case assertion based on the execution result, generate test case reports and the like.
However, some interfaces in the prior art cannot automatically generate test cases. For example, when a parameter of one interface is used as an input parameter of another interface, a test case for testing the parameter transfer relationship between the interfaces cannot be automatically generated, and only the test case can be written manually.
Disclosure of Invention
The embodiment of the disclosure provides a test case generation method, a device, equipment, a storage medium and a program product, so as to realize automatic generation of cases for logical relations between test interfaces.
In a first aspect, an embodiment of the present disclosure provides a test case generating method, including:
Acquiring recording flow of a system to be tested, wherein the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service externally, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and dependency relations among the series of interfaces;
determining a target mapping relation in the interface call chain according to the recorded flow, wherein the target mapping relation is used for representing parameters of a first interface as parameters of a second interface;
generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed.
In a second aspect, an embodiment of the present disclosure provides a test case generating apparatus, including:
the system comprises an acquisition unit, a control unit and a control unit, wherein the acquisition unit is used for acquiring recording flow of a system to be tested, the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service to the outside, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and the dependency relationship among the series of interfaces;
The mapping unit is used for determining a target mapping relation in the interface call chain according to the recorded flow, wherein the target mapping relation is used for representing parameters of a first interface as input parameters of a second interface;
the case generation unit is used for generating a target test case according to the target mapping relation; wherein, when the target test case is executed, taking the parameter of the first interface as the parameter of the second interface, the embodiment of the disclosure provides an electronic device, which includes: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executes the computer-executable instructions stored by the memory, such that the at least one processor performs the test case generation method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer readable storage medium having stored therein computer executable instructions that when executed by a processor implement the test case generating method according to the first aspect and the various possible designs of the first aspect.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program which, when executed by a processor, implements the test case generation method of the first aspect and the various possible designs of the first aspect above.
The test case generation method, the device, the equipment, the storage medium and the program product provided by the embodiment comprise the steps of obtaining the recording flow of the system to be tested, wherein the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service externally, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and the dependency relationship among the series of interfaces; determining a target mapping relation in an interface call chain according to the recording flow, wherein the target mapping relation is used for representing parameters of a first interface as parameters of a second interface; generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed. In the scheme provided by the embodiment, the mapping relation of parameter transmission between interfaces can be determined according to the recorded flow, so that the scene use case which accords with the actual application scene can be generated based on the mapping relation.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, a brief description will be given below of the drawings that are needed in the embodiments or the description of the prior art, it being obvious that the drawings in the following description are some embodiments of the present disclosure, and that other drawings may be obtained from these drawings without inventive effort to a person of ordinary skill in the art.
FIG. 1 is a flow chart of a test case generation method according to an exemplary embodiment of the present disclosure;
FIG. 2 is a graph of dependencies between interfaces shown in an exemplary embodiment of the present disclosure;
FIG. 3 is a flow chart diagram of a test case generation method shown in another exemplary embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a portion of an initial mapping relationship shown in an exemplary embodiment of the present disclosure;
FIG. 5 is a schematic diagram of an interface link sub-graph shown in an exemplary embodiment of the present disclosure;
FIG. 6 is a schematic diagram of an interface topology shown in an exemplary embodiment of the present disclosure;
FIG. 7 is a schematic diagram of generating key-value pairs, as shown in an exemplary embodiment of the present disclosure;
FIG. 8 is a schematic diagram of a test case generating device according to an exemplary embodiment of the present disclosure;
FIG. 9 is a schematic diagram of a test case generating device according to another exemplary embodiment of the present disclosure;
fig. 10 is a schematic structural view of an electronic device shown in another exemplary embodiment of the present disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without inventive effort, based on the embodiments in this disclosure are intended to be within the scope of this disclosure.
In the development process of software codes, the interface is an important link, and whether the interface has a logic problem can be checked through the interface test, so that the codes for realizing the interface can be corrected before the software is online.
To verify that the interface functions properly, the interface may be tested using a test case. The test case can be executed, the interface is called in the process of executing the case, the case is further processed through the logic of the interface, and an execution result is obtained. By executing the execution result obtained by the test case, whether the logic of the interface is correct or not can be verified, and whether the expected function can be realized or not can be verified.
The research and development personnel can write the test cases by themselves, and can also generate the test cases by using the existing automation platform. However, when the interface to be tested is implemented in function, depending on the functions of other interfaces, since there is a dependency relationship between the interface and other interfaces, for example, when the output of one interface is used as the input of another interface, the automation platform cannot automatically generate the test cases for testing the scenerised interface.
In order to solve the technical problems, in the scheme provided by the disclosure, the recording flow of the system to be tested can be obtained, the target mapping relation for representing the parameter transfer relation between interfaces is extracted according to the recording flow, and then the target test case can be generated according to the target mapping relation, so that the parameter transfer relation between interfaces can be tested by using the scene case.
FIG. 1 is a flow chart of a test case generation method according to an exemplary embodiment of the present disclosure.
As shown in fig. 1, the test case generating method provided by the present disclosure includes:
step 101, obtaining a recording flow of a system to be tested, wherein the recording flow comprises an interface call chain executed by the system to be tested in the process of providing services externally, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and a dependency relationship between the series of interfaces.
The test case generation method provided by the embodiment can be used for generating the test case. The test case can test the parameter transfer relation between interfaces. The method provided by the disclosure can be applied to a server side or a user terminal side.
FIG. 2 is a graph of dependencies between interfaces, as shown in an exemplary embodiment of the present disclosure.
As shown in fig. 2, the output parameter a of the interface 21 is input to the interface 22, after the interface 22 receives the parameter a, the parameter a may be processed to obtain the parameter B, and after that, the interface 22 also inputs the parameter a and the parameter B to the interface 23, and the interface 23 processes the parameters a and B.
In the application scenario, because of the mapping relation of the contexts between the interfaces and the strong dependency relation between the interfaces, the test cases for testing the dependency relation between the interfaces cannot be generated based on the existing automatic test platform.
Specifically, in the test case generating method provided by the present disclosure, the recording flow of the system to be tested may be obtained, where the recording flow includes an interface call chain executed by the system to be tested in a process of providing services to the outside, and the interface call chain is used to represent a series of interfaces called by the system to be tested in response to an external trigger operation and a dependency relationship between the series of interfaces.
When the system to be tested runs, each interface called by the system to be tested during running and the dependency relationship among the interfaces can be obtained, and an interface calling chain is obtained. Multiple interface call chains can be obtained when the system to be tested runs, so that the recording flow is obtained. For example, the system to be tested can execute the first service, and then a first interface call chain of the system to be tested is obtained; the second service may be executed using the system to be tested, and further a second interface call chain of the system to be tested may be obtained. And combining the plurality of interface call chains to obtain the recorded flow.
In an alternative embodiment, if the scheme provided in the present disclosure is applied to the user terminal side, the user terminal responds to the operation of the user to execute the code logic, and records the interfaces substituted in the execution process and the dependency relationship between the interfaces. In another optional implementation manner, if the scheme provided in the present disclosure is applied to the server side, the user terminal may respond to the operation of the user to execute the code logic, and send the data transmission relationship between the interfaces in the execution process to the server, and if the interfaces in the server are called, the server may further record the data transmission relationship between the interfaces.
Specifically, the user may operate the electronic device, for example, the user may click a recording key displayed in an interface of the user terminal, and further send a recording operation for recording the traffic to the user terminal. If the scheme provided by the disclosure is executed by the user terminal, the user terminal can respond to the operation to acquire the recording flow. If the server executes the scheme provided by the disclosure, the user terminal can send a recording operation for recording the traffic to the server, so that the server can respond to the operation and acquire the recording traffic.
Further, after clicking the recording key, the user can operate the system to be tested, so that the electronic equipment calls the interfaces based on the operation, and the calling relationship and the parameter transmission relationship between the interfaces are obtained to acquire the recording flow. If the method provided by the present disclosure is executed by the server, the user terminal may also send the collected recording traffic to the server.
After the recording is finished, the user can click a key for stopping recording in the electronic equipment, and based on the current user operation, the recording flow generated by the operation flow can be obtained. After that, the user can click the recording key on the user terminal again, and further can acquire the recording data again.
Specifically, in the scheme provided by the disclosure, a batch of recording flow can be obtained based on each recording operation of a user, and then a test case can be generated according to a plurality of batches of recording flow, so that the test case can be used for comprehensively testing the functions of each interface of the system to be tested.
In an optional implementation manner, if the scheme provided by the disclosure is executed by the server, the server may further perform screening among the received recording flows according to the identifier of the user terminal, so as to obtain each recording flow. For example, the recording flow obtained by recording through the first terminal may be obtained, and for example, the recording flow obtained by recording through the second terminal may be obtained.
In the scheme provided by the disclosure, a user can operate a system to be tested for many times, and then the electronic equipment can call each interface for many times based on the dependency relationship among the interfaces, so that a richer interface call chain for representing the parameter transmission relationship among the interfaces can be obtained. For example, during a first operation, a user may log in to an account, browse goods, purchase goods. In the second operation, the user can view the purchased commodity order and contact the customer service to apply for after-sales service.
Because different operation flows can relate to different interfaces and possibly different functions of the same interface, the interface call chains which are richer and accord with the actual use situation of users can be collected through the method.
Step 102, determining a target mapping relation in an interface call chain according to the recorded flow, wherein the target mapping relation is used for representing parameters of a first interface as an input parameter of a second interface.
The recording flow comprises a plurality of interface call chains, and each interface call chain comprises a dependency relationship among interfaces, so that the target mapping relationship can be determined according to the dependency relationship.
Specifically, the dependency relationship between interfaces refers to a data transmission relationship between interfaces, for example, in an operation process, an output parameter a of the interface 21 is input to the interface 22, and then there is a dependency relationship between the interface 21 and the interface 22, specifically, the parameter a of the interface 21 is used as an input parameter of the interface 22.
And processing a plurality of call chains in the recorded flow to determine the target mapping relation. The target mapping relationship is used for representing a parameter of the first interface as an input parameter of the second interface, and the parameter can be the input parameter of the first interface or the output parameter of the first interface.
Further, the call chain includes a dependency relationship among a plurality of interfaces, and an initial mapping relationship among the interfaces can be determined according to the dependency relationship, for example, the parameter a of the interface 21 is used as an input parameter of the interface 22, and then the interface 21 and the interface 22 have an initial mapping relationship.
In practical application, when the number of the initial mapping relations is large, the target mapping relation can be determined in the number of the initial mapping relations, so that the target mapping relation with the highest occurrence frequency is obtained. For example, when the parameter a of the plurality of interfaces is used as the parameter of the interface 22, a plurality of initial mapping relationships may be generated, and the initial mapping relationship with the highest occurrence frequency may be determined as the target mapping relationship.
For example, when the parameter a is taken as the parameter of the interface 33, the parameter a may be from the interface 31 or from the interface 32, the probability for representing the initial mapping relationship of the parameter a from the interface 31 is 4/5, and the probability for representing the initial mapping relationship of the parameter a from the interface 32 is 1/5, so the parameter a of the interface 31 can be taken as the parameter of the interface 33 to be taken as the target mapping relationship.
If it is determined that the parameters in the plurality of initial mapping relationships are the same and the second interfaces receiving the parameters are the same, the occurrence probability of each initial mapping relationship can be determined, so that the target mapping relationship is determined.
The target mapping relation with higher occurrence frequency accords with the actual scene better, so that the target mapping relation which accords with the actual scene better can be determined by the method.
Step 103, generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed.
Further, a target test case can be generated according to each target mapping relation, the first interface and the second interface can be executed when the target test case is executed, and parameters of the first interface are used as parameters of the second interface, so that the parameters can be transferred in each interface according to the target mapping relation.
In actual application, the target test cases which accord with the actual scene can be generated based on the target mapping relation which accords with the actual scene, and then the dependency relation among interfaces of the system to be tested can be tested through the target test cases.
By the method, the real mapping relation which is more in line with the actual scene can be determined.
Furthermore, a scenario case can be generated according to each real mapping relation, specifically, a test case can be generated, each interface can be executed when the test case is executed, and parameters are transferred in each interface based on the determined real mapping relation.
In actual application, scene use cases conforming to the actual scene can be generated based on the actual mapping relation conforming to the actual scene, and in the scheme provided by the disclosure, the scene use cases are generated according to the data transmission relation among the interfaces, so that the generated scene use cases can cover more data transmission conditions among the interfaces, more interface functions are tested, and the test coverage rate is higher.
The test case generation method provided by the disclosure comprises the following steps: acquiring recording flow of a system to be tested, wherein the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service to the outside, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and a dependency relationship between the series of interfaces; determining a target mapping relation in an interface call chain according to the recording flow, wherein the target mapping relation is used for representing parameters of a first interface as parameters of a second interface; generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed. In the test case generation method provided by the disclosure, the target mapping relation for representing the dependency relation between the interfaces can be determined through the recording flow, so that the target test case can be generated based on the relation, and the dependency relation between the interfaces can be tested through the target test case.
FIG. 3 is a flow chart of a test case generation method according to another exemplary embodiment of the present disclosure.
As shown in fig. 3, the test case generating method provided by the present disclosure includes:
step 301, obtaining a recording flow of a system to be tested, where the recording flow includes an interface call chain executed by the system to be tested in a process of providing services to the outside, and the interface call chain is used to represent a series of interfaces and a dependency relationship between a series of interfaces that are called by the system to be tested in response to an external trigger operation.
Step 301 is similar to the implementation of step 101 and will not be described again.
The test case generation method provided by the embodiment can be used for generating the test case. The test cases can test cases of dependency relationships existing between interfaces.
Step 302, determining an initial mapping relation and the probability of the initial mapping relation in each interface call chain of the recorded flow; the initial mapping relation is used for representing parameters of the first interface as a parameter entering relation of the second interface; the probability is the probability of each initial mapping relation in a plurality of mapping relations taking the same parameter as the input parameter of the same interface.
Specifically, each interface call chain of the obtained recording flow includes a series of interfaces called by the system to be tested in response to external trigger operation and a dependency relationship between the series of interfaces. Therefore, the parameter transmission relation among the interfaces can be determined according to the call chains of the interfaces, so that the initial mapping relation is obtained.
The initial mapping relationship is used for representing the parameter of the first interface as the parameter entering relationship of the second interface, for example, the parameter exiting K of the first interface is used as the parameter entering relationship of the second interface.
Specifically, part of parameters of the first interface are used as all of the parameters of the second interface, all of parameters of the first interface are used as all of the parameters of the second interface, and all of parameters of the first interface are used as part of the parameters of the second interface.
Further, in each determined initial mapping relationship, there may be a case where the same reference of the second interface may originate from a different first interface, for example, there is an interface 1, an interface 2, and an interface 3, in which in the first operation flow, the parameter a in the interface 1 is input into the interface 3, and in the second operation flow, the parameter a in the interface 2 is input into the interface 3.
When testing the function of the interface 3, the function of the interface 3 can be tested based on the parameter a, whether the parameter a is acquired from the interface 1 or the parameter a is acquired from the interface 2.
In order to enable the generated test case to test the interface function more in line with the actual application scene, in the scheme provided by the disclosure, the probability of each initial mapping relation is also determined, and then the target mapping relation is determined based on the probability in a plurality of initial mapping relations when the same parameter is used as the parameter of the second interface, so that the target mapping relation with higher occurrence probability can be determined when the same parameter is input to the same second interface through a plurality of paths, and further more accurate test cases can be generated.
The target mapping relationship can represent an actual parameter transfer relationship, so that the target mapping relationship is more in line with an actual scene, and a test case more in line with the actual scene can be obtained through the scheme of the present disclosure.
Fig. 4 is a schematic diagram of a portion of an initial mapping relationship shown in an exemplary embodiment of the present disclosure.
As shown in fig. 4, a part of the initial mapping relationship included in the acquired data transmission relationship between the interfaces may be as shown in fig. 4.
Wherein, the initial mapping relationship 44 is used for characterizing the response parameter 1-resq-1 in the interface 41 as the parameter of the request parameter 3-rep-2 in the interface 43; the initial mapping relationship 45 is used for characterizing the request parameters 1-rep-2 in the interface 41 as the parameters of the request parameters 2-rep-3 in the interface 42; the initial mapping relationship 46 is used to characterize the response parameters 1-resq-4 in the interface 41 as the parameters of the request parameters 2-rep-4 in the interface 42; the initial mapping 47 is used to characterize the response parameter 2-resq-5 in the interface 42 as an entry for the request parameter 3-rep-2 in the interface 43.
Specifically, since the parameters in both the interface 41 and the interface 42 are likely to be input into the interface 43 as the entry of 3-rep-2, the probability of the parameter of the interface 41 as the entry of 3-rep-2 in the interface 43 and the probability of the parameter of the interface 42 as the entry of 3-rep-2 in the interface 43 can be calculated.
Further, for example, in the initial mapping, there are 8 parameters 1-resq-1 of the relationship characterization interface 41 as the entries for 3-rep-2 in the interface 43, and 2 parameters 2-resq-5 of the relationship characterization interface 42 as the entries for 3-rep-2 in the interface 43. The probability of parameter 1-resq-1 of interface 41 as an entry to 3-rep-2 in interface 43 is 4/5 and the probability of parameter 2-resq-5 of interface 42 as an entry to 3-rep-2 in interface 43 is 1/5. The initial mapping relationship with the highest probability can be used as the target mapping relationship.
When determining the initial mapping relation, determining an interface relation topological graph according to each interface call chain in the recorded flow; the interface relation topological graph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces.
The recording flow includes call relations among interfaces, so that an interface relation topological graph can be constructed based on the call relations.
Specifically, if the recorded data includes multiple interface call chains obtained based on multiple operations of the user, an interface link sub-graph of each interface call chain may be generated according to each interface call chain in the recorded traffic; the interface link subgraph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces.
Fig. 5 is a schematic diagram of an interface link sub-graph shown in an exemplary embodiment of the present disclosure.
As shown in fig. 5, for example, the recording traffic includes 3 interface call chains, and an interface link sub-graph 51 may be generated for a first interface call chain, an interface link sub-graph 52 may be generated for a second interface call chain, and an interface link sub-graph 53 may be generated for a third interface call chain.
The scheme provided by the disclosure can generate a corresponding interface link sub-graph based on each interface call chain, and call relations among interfaces can be recorded through the interface link sub-graph, and specifically can include directions of parameter transmission among the interfaces. For example, if one parameter of the interface 1 is input into the interface 2 and another parameter of the interface 1 is input into the interface 3, the interface link sub-graph includes an edge of the interface 1 pointing to the interface 2 and an edge of the interface 1 pointing to the interface 3.
Specifically, the sub-graphs of each interface link can be combined to generate an interface relation topological graph. For the same batch of interface call chains in the recorded flow, a plurality of interface link subgraphs can be generated, and for generating a test case for more comprehensively testing the parameter transmission relation among interfaces, the interface link subgraphs can be combined to obtain an interface relation topological graph.
Further, a main link graph may be determined in the interface link subgraph; and merging each other interface link subgraphs into the main link diagram according to the nodes included in the other interface link subgraphs and the nodes included in the main link diagram to obtain an interface relation topological diagram.
In practical application, each interface link sub-graph comprises a plurality of nodes, and each interface link sub-graph can be combined according to the same nodes in each interface link sub-graph to obtain an interface relation topological graph. The interface relation topological graph also comprises nodes used for representing interfaces and edges used for representing data transmission directions among the interfaces.
And if the other interface link subgraphs comprise the same nodes as those in the main link graph, the repeated nodes in the other interface link subgraphs can be combined with the repeated nodes in the main link graph, so that the other interface link subgraphs are combined into the main link graph.
Specifically, if no duplicate node exists between one interface link sub-graph and any other interface link sub-graph, it is indicated that the interface link sub-graph does not belong to the application scenario of the current test case, and the interface link sub-graph may not be combined into the main link graph.
Fig. 6 is a schematic diagram of an interface topology shown in an exemplary embodiment of the present disclosure.
As shown in fig. 6, combining the three interface link subgraphs shown in fig. 5 can result in an interface topology shown at 61.
After determining the interface relation topological graph, the initial mapping relation can be determined according to the interface relation topological graph.
Further, according to the determined interface relationship topology diagram, the parameter transmission direction between the interfaces can be determined, for example, in the interface relationship topology diagram, when an edge of the interface 1 pointing to the interface 2 exists, it can be determined that the parameter in the interface 1 is transmitted to the interface 2.
In practical application, the parameter transmission relation between the interfaces can be determined according to the pointing relation between the interfaces in the interface relation topological graph.
Specifically, according to parameters included in each interface, a key value pair corresponding to each interface can be determined; the keys in the key-value pair are used to characterize the parameter identification and the values in the key-value pair are used to characterize the parameter. Each interface includes a request parameter and a response parameter, and for each parameter, a key value pair thereof can be constructed.
FIG. 7 is a schematic diagram of generating key-value pairs, as shown in an exemplary embodiment of the present disclosure.
As shown in fig. 7, the left side is a code block of a request parameter in an interface, and the right side is a key value pair constructed based on the request parameter.
Further, the codes in the code block can be parsed into character strings, and key value pairs can be obtained. For example, one request parameter in the interface is "p.s.m", the code used to obtain the request parameter may be used as the key for the request parameter, for example "source_node.psm", and the key and value in each key-value pair are separated by a colon.
In practical application, the key in the key value pair is used for representing the parameter identification, and the value in the key value pair is used for representing the parameter, for example, in the key value pair 'source_node. Psm: p.s.m', source_node. Psm is the key, and p.s.m is the value.
And determining an initial mapping relation according to the parameter transmission direction among interfaces and key value pairs of each interface included in the interface relation topological graph.
Specifically, in the interface topology, there is a parameter transfer relationship between two interfaces connected by an edge, so that the parameter transfer relationship between the interfaces connected by an edge can be determined according to the key value pair of the interfaces connected by an edge.
Further, the first interface and the second interface may be determined according to the inter-interface parameter transmission direction included in the interface relationship topology chart, for example, two interfaces having the inter-interface parameter transmission direction may be determined as the first interface and the second interface, respectively. For example, in the relational topology, if there is an edge where the interface 1 points to the interface 2, the interface 1 may be determined as a first interface, and the interface 2 may be determined as a second interface.
After that, the same parameters can be determined according to the key value pair of the first interface and the key value pair of the second interface, and the initial mapping relation between the first interface and the second interface can be determined according to the same parameters.
For example, if the key value pair of the first interface and the key value pair of the second interface have the same parameter a, the parameter a in the first interface may be determined to be used as the parameter of the second interface, so as to determine the initial mapping relationship existing between the two interfaces.
Further, the initial mapping relation constructed includes any one of the following relations:
the part of parameters of one interface is used as the whole of the other interface, the whole of parameters of one interface is used as the whole of the other interface, and the whole of parameters of one interface is used as the part of the other interface.
By the implementation mode, various initial mapping relations among the interfaces can be determined, and further test cases for comprehensively covering functions among the interfaces are generated.
After determining each initial mapping relationship, the probability of each initial mapping relationship can also be determined. The same kind of mapping relation can be determined according to the initial mapping relation, parameters in the initial mapping relation in the same kind of mapping relation are the same, and the second interfaces for receiving the parameters are the same.
The method comprises the steps of generating a plurality of initial mapping relations according to recording flow, and classifying the initial mapping relations to obtain a plurality of similar mapping relations. Each similar mapping relation comprises a plurality of initial mapping relations.
Specifically, the parameters are the same among the initial mapping relations included in the similar mapping relations, and the second interfaces for receiving the parameters are the same. When a parameter is taken as a reference of the second interface, the source of the parameter may include a plurality of interfaces, so that the initial mapping relationships may be divided into a similar mapping relationship.
For example, one similar mapping relationship includes two initial mapping relationships, one of which is used for characterizing the parameter a of the interface 1 as the parameter of the interface 3, and the other is used for characterizing the parameter a of the interface 2 as the parameter of the interface 3, and the two initial mapping relationships are identical in parameters and the interfaces receiving the parameters are also identical, so that the two initial mapping relationships can be divided into similar mapping relationships.
After the similar mapping relations are determined, the probability of occurrence of each initial mapping relation is determined in the similar mapping relations.
Further, the probability of occurrence of each initial mapping relationship in each similar mapping relationship can be determined according to each initial mapping relationship included in each similar mapping relationship.
In practical application, the occurrence times of each initial mapping relation in the similar mapping relation can be determined, and then the occurrence probability of each initial mapping relation can be determined according to the occurrence times of each initial mapping relation and the number of the initial mapping relations included in the similar mapping relation.
The similar mapping relationship may include a plurality of initial mapping relationships, and may include repeated initial mapping relationships. For example, in the recording flow collected based on the user operation, the parameter a including the two interfaces 1 is input to the interface 3, and then two parameters a used for characterizing the interfaces 1 may be included in the same kind of mapping relationship as initial mapping parameters of the input parameters of the interface 3, and the number of occurrences of the initial mapping parameters is 2.
Specifically, the ratio of the number of occurrences of each initial mapping relationship to the number of initial mapping relationships included in the similar mapping relationship may be determined as the probability of occurrence of each initial mapping relationship. The probability can be used for representing the occurrence frequency of each initial mapping relation in the similar mapping relation, and further, the parameter transmission relation which accords with the actual application scene can be determined in the similar mapping relation.
Step 303, determining the target mapping relation in the interface call chain according to the probability of each initial mapping relation.
Further, for each of the similar mapping relationships, a target mapping relationship may be determined therein. For example, the initial mapping relationship with the highest probability in the similar mapping relationships can be determined as the target mapping relationship.
For example, in the similar mapping relationship, the probability that the parameter 1-resq-1 of the interface 41 is taken as the parameter of 3-rep-2 in the interface 43 is 4/5, and the probability that the parameter 2-resq-5 of the interface 42 is taken as the parameter of 3-rep-2 in the interface 43 is 1/5, then the parameter 1-resq-1 of the interface 41 can be taken as the initial mapping relationship of the parameter of 3-rep-2 in the interface 43, and can be taken as the target mapping relationship of the similar mapping relationship.
Step 304, generating a target test case according to the target mapping relation; the step 304 of taking the parameter of the first interface as the parameter of the second interface when the target test case is executed is similar to the execution mode of the step 103, and will not be described again.
In an alternative embodiment, the interfaces may also be tested using the generated test cases. For example, the test case may be executed, and then the interface is used to process the test case, so as to obtain an execution result.
The test report may also be generated according to the execution result, for example, the test report may include the execution result and may further include a preset expected result.
In the test case generation method provided by the disclosure, the target mapping relation with higher occurrence probability in the parameter transmission process can be determined in a plurality of initial mapping relations, so that the target mapping relation which is more in line with the actual scene and used for representing the parameter transmission can be obtained, and the test scene case in line with the actual application scene can be generated based on the target mapping relation.
Fig. 8 is a schematic structural diagram of a test case generating device according to an exemplary embodiment of the present disclosure.
As shown in fig. 8, the test case generating device 800 provided in the present disclosure includes:
the obtaining unit 810 is configured to obtain a recording flow of a system to be tested, where the recording flow includes an interface call chain executed by the system to be tested in a process of providing services to the outside, where the interface call chain is used to represent a series of interfaces called by the system to be tested in response to an external trigger operation and a dependency relationship between the series of interfaces;
a mapping unit 820, configured to determine, according to the recording flow, a target mapping relationship in the interface call chain, where the target mapping relationship is used to represent a parameter of a first interface as an input parameter of a second interface;
A case generating unit 830, configured to generate a target test case according to the target mapping relationship; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed.
According to the test case generating device, the target mapping relation used for representing the dependency relation between the interfaces can be determined through the recorded flow, so that the target test case can be generated based on the relation, and the dependency relation between the interfaces can be tested through the target test case.
Fig. 9 is a schematic structural view of a test case generating device according to another exemplary embodiment of the present disclosure.
As shown in fig. 9, in an alternative implementation manner of the test case generating device 900 provided in the present disclosure, based on the foregoing embodiment, the mapping unit 820 includes:
an initial mapping module 821, configured to determine an initial mapping relationship and a probability of the initial mapping relationship in each of the interface call chains of the recording traffic; the initial mapping relation is used for representing parameters of the first interface as a parameter entering relation of the second interface; the probability is the probability of each initial mapping relation in a plurality of mapping relations taking the same parameter as the input parameter of the same interface;
And the target mapping module 822 is configured to determine a target mapping relationship in the interface call chain according to the probability of each initial mapping relationship.
In an alternative embodiment, the initial mapping module 821 is specifically configured to:
determining similar mapping relations according to the initial mapping relations, wherein parameters in the initial mapping relations in the similar mapping relations are the same, and second interfaces for receiving the parameters are the same;
and determining the occurrence probability of each initial mapping relation in the similar mapping relation.
In an alternative embodiment, the initial mapping module 821 is specifically configured to:
determining the occurrence times of each initial mapping relation in the similar mapping relation;
and determining the occurrence probability of each initial mapping relation according to the occurrence times of each initial mapping relation and the number of the initial mapping relations included in the similar mapping relations.
In an alternative embodiment, the initial mapping relationship includes any one of the following relationships:
the partial parameters of the first interface are used as all the parameters of the second interface, all the parameters of the first interface are used as all the parameters of the second interface, and all the parameters of the first interface are used as part of the parameters of the second interface.
In an alternative embodiment, the initial mapping module 821 is specifically configured to:
determining an interface relation topological graph according to each interface call chain in the recorded flow; the interface relation topological graph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and determining the initial mapping relation according to the interface relation topological graph.
In an alternative embodiment, the initial mapping module 821 is specifically configured to:
generating an interface link sub-graph of each interface call chain according to each interface call chain in the recorded flow; the interface link subgraph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and merging all the interface link subgraphs to generate the interface relation topological graph.
In an alternative embodiment, the initial mapping module 821 is specifically configured to:
determining a main link diagram in the interface link subgraph;
and merging all other interface link subgraphs into the main link diagram according to the nodes included in other interface link subgraphs and the nodes included in the main link diagram to obtain the interface relation topological diagram.
In an optional implementation manner, the initial mapping module 821 is specifically configured to determine, according to parameters included in each interface, a key value pair corresponding to each interface; the keys in the key value pair are used for representing parameter identification, and the values in the key value pair are used for representing parameters;
and determining the initial mapping relation according to the parameter transmission direction among interfaces and key value pairs of each interface included in the interface relation topological graph.
The initial mapping module 821 is specifically configured to:
determining the first interface and the second interface according to the parameter transmission direction between interfaces included in the interface relation topological graph;
and determining the same parameters according to the key value pairs of the first interface and the key value pairs of the second interface, and determining the initial mapping relation between the first interface and the second interface according to the same parameters.
The device provided in this embodiment may be used to execute the technical solution of the foregoing method embodiment, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
Referring to fig. 10, there is shown a schematic structural diagram of an electronic device 1000 suitable for use in implementing embodiments of the present disclosure, which electronic device 1000 may be a terminal device or a server. The terminal device may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a personal digital assistant (Personal Digital Assistant, PDA for short), a tablet (Portable Android Device, PAD for short), a portable multimedia player (Portable Media Player, PMP for short), an in-vehicle terminal (e.g., an in-vehicle navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 10 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 10, the electronic apparatus 1000 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 1001 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage device 1008 into a random access Memory (Random Access Memory, RAM) 1003. In the RAM 1003, various programs and data necessary for the operation of the electronic apparatus 1000 are also stored. The processing device 1001, the ROM 1002, and the RAM 1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
In general, the following devices may be connected to the I/O interface 1005: input devices 1006 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 1007 including, for example, a liquid crystal display (Liquid Crystal Display, LCD for short), a speaker, a vibrator, and the like; storage 1008 including, for example, magnetic tape, hard disk, etc.; and communication means 1009. The communication means 1009 may allow the electronic device 1000 to communicate wirelessly or by wire with other devices to exchange data. While fig. 10 shows an electronic device 1000 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to 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 shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 1009, or installed from the storage device 1008, or installed from the ROM 1002. The above-described functions defined in the method of the embodiment of the present disclosure are performed when the computer program is executed by the processing device 1001.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any 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 the context of this 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 the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated 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 perform the methods shown in the above-described embodiments.
Computer program code for carrying out operations of the present disclosure may be written in 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 kind of network, including a local area network (Local Area Network, LAN for short) or a wide area network (Wide Area Network, WAN for short), or it may be connected to an external computer (e.g., connected via the internet using an internet service provider).
The flowcharts 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 involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The name of the unit does not in any way constitute a limitation of the unit itself, for example the first acquisition unit may also be described as "unit acquiring at least two internet protocol addresses".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on 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 a first aspect, according to one or more embodiments of the present disclosure, there is provided a test case generating method, including:
acquiring recording flow of a system to be tested, wherein the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service externally, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and dependency relations among the series of interfaces;
determining a target mapping relation in the interface call chain according to the recorded flow, wherein the target mapping relation is used for representing parameters of a first interface as parameters of a second interface;
generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed. According to one or more embodiments of the present disclosure, the determining, according to the recording flow, a target mapping relationship in the interface call chain includes: determining an initial mapping relation and the probability of the initial mapping relation in each interface call chain of the recorded flow; the initial mapping relation is used for representing parameters of the first interface as a parameter entering relation of the second interface; the probability is the probability of each initial mapping relation in a plurality of mapping relations taking the same parameter as the input parameter of the same interface;
And determining the target mapping relation in the interface call chain according to the probability of each initial mapping relation. According to one or more embodiments of the present disclosure, determining a probability of an initial mapping relationship includes:
determining similar mapping relations according to the initial mapping relations, wherein parameters in the initial mapping relations in the similar mapping relations are the same, and second interfaces for receiving the parameters are the same;
and determining the occurrence probability of each initial mapping relation in the similar mapping relation.
According to one or more embodiments of the present disclosure, the determining, in the homogeneous mapping relationships, a probability of occurrence of each initial mapping relationship includes:
determining the occurrence times of each initial mapping relation in the similar mapping relation;
and determining the occurrence probability of each initial mapping relation according to the occurrence times of each initial mapping relation and the number of the initial mapping relations included in the similar mapping relations.
The initial mapping relation comprises any one of the following relations:
the partial parameters of the first interface are used as all the parameters of the second interface, all the parameters of the first interface are used as all the parameters of the second interface, and all the parameters of the first interface are used as part of the parameters of the second interface.
According to one or more embodiments of the present disclosure, the determining an initial mapping relationship in each of the interface call chains of the recording traffic includes:
determining an interface relation topological graph according to each interface call chain in the recorded flow; the interface relation topological graph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and determining the initial mapping relation according to the interface relation topological graph.
According to one or more embodiments of the present disclosure, the determining an interface relationship topology map according to each of the interface call chains in the recording traffic includes:
generating an interface link sub-graph of each interface call chain according to each interface call chain in the recorded flow; the interface link subgraph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and merging all the interface link subgraphs to generate the interface relation topological graph.
According to one or more embodiments of the present disclosure, the merging the respective interface link subgraphs to generate the interface relationship topology graph includes:
determining a main link diagram in the interface link subgraph;
And merging all other interface link subgraphs into the main link diagram according to the nodes included in other interface link subgraphs and the nodes included in the main link diagram to obtain the interface relation topological diagram. According to one or more embodiments of the present disclosure, the determining the initial mapping relationship according to the interface relationship topology map includes:
determining a key value pair corresponding to each interface according to parameters included in each interface; the keys in the key value pair are used for representing parameter identification, and the values in the key value pair are used for representing parameters;
and determining the initial mapping relation according to the parameter transmission direction among interfaces and key value pairs of each interface included in the interface relation topological graph.
According to one or more embodiments of the present disclosure, determining the initial mapping relationship according to a parameter transmission direction between interfaces and a key value pair of each interface included in the interface relationship topology graph includes:
determining the first interface and the second interface according to the parameter transmission direction between interfaces included in the interface relation topological graph;
and determining the same parameters according to the key value pairs of the first interface and the key value pairs of the second interface, and determining the initial mapping relation between the first interface and the second interface according to the same parameters.
In a second aspect, according to one or more embodiments of the present disclosure, there is provided a test case generating apparatus including:
the system comprises an acquisition unit, a control unit and a control unit, wherein the acquisition unit is used for acquiring recording flow of a system to be tested, the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service to the outside, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and the dependency relationship among the series of interfaces;
the mapping unit is used for determining a target mapping relation in the interface call chain according to the recorded flow, wherein the target mapping relation is used for representing parameters of a first interface as input parameters of a second interface;
the case generation unit is used for generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed.
According to one or more embodiments of the present disclosure, the mapping unit includes:
the initial mapping module is used for determining an initial mapping relation and the probability of the initial mapping relation in each interface call chain of the recording flow; the initial mapping relation is used for representing parameters of the first interface as a parameter entering relation of the second interface; the probability is the probability of each initial mapping relation in a plurality of mapping relations taking the same parameter as the input parameter of the same interface;
And the target mapping module is used for determining the target mapping relation in the interface call chain according to the probability of each initial mapping relation.
According to one or more embodiments of the present disclosure, the initial mapping module is specifically configured to:
determining similar mapping relations according to the initial mapping relations, wherein parameters in the initial mapping relations in the similar mapping relations are the same, and second interfaces for receiving the parameters are the same;
and determining the occurrence probability of each initial mapping relation in the similar mapping relation.
According to one or more embodiments of the present disclosure, the initial mapping module is specifically configured to:
determining the occurrence times of each initial mapping relation in the similar mapping relation;
and determining the occurrence probability of each initial mapping relation according to the occurrence times of each initial mapping relation and the number of the initial mapping relations included in the similar mapping relations.
According to one or more embodiments of the present disclosure, the initial mapping relationship includes any one of the following relationships:
the partial parameters of the first interface are used as all the parameters of the second interface, all the parameters of the first interface are used as all the parameters of the second interface, and all the parameters of the first interface are used as part of the parameters of the second interface.
According to one or more embodiments of the present disclosure, the initial mapping module is specifically configured to:
determining an interface relation topological graph according to each interface call chain in the recorded flow; the interface relation topological graph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and determining the initial mapping relation according to the interface relation topological graph.
According to one or more embodiments of the present disclosure, the initial mapping module is specifically configured to:
generating an interface link sub-graph of each interface call chain according to each interface call chain in the recorded flow; the interface link subgraph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and merging all the interface link subgraphs to generate the interface relation topological graph.
According to one or more embodiments of the present disclosure, the initial mapping module is specifically configured to:
determining a main link diagram in the interface link subgraph;
and merging all other interface link subgraphs into the main link diagram according to the nodes included in other interface link subgraphs and the nodes included in the main link diagram to obtain the interface relation topological diagram.
According to one or more embodiments of the present disclosure, the initial mapping module is specifically configured to determine, according to parameters included in each interface, a key value pair corresponding to each interface; the keys in the key value pair are used for representing parameter identification, and the values in the key value pair are used for representing parameters;
and determining the initial mapping relation according to the parameter transmission direction among interfaces and key value pairs of each interface included in the interface relation topological graph.
According to one or more embodiments of the present disclosure, the initial mapping module 821 is specifically configured to:
determining the first interface and the second interface according to the parameter transmission direction between interfaces included in the interface relation topological graph;
and determining the same parameters according to the key value pairs of the first interface and the key value pairs of the second interface, and determining the initial mapping relation between the first interface and the second interface according to the same parameters.
In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executes the computer-executable instructions stored by the memory, such that the at least one processor performs the test case generation method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium having stored therein computer-executable instructions which, when executed by a processor, implement the test case generating method according to the above first aspect and the various possible designs of the first aspect.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program which, when executed by a processor, implements the test case generation method of the first aspect and the various possible designs of the first aspect as described above.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (14)

1. A test case generation method, comprising:
acquiring recording flow of a system to be tested, wherein the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service externally, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and dependency relations among the series of interfaces;
Determining a target mapping relation in the interface call chain according to the recorded flow, wherein the target mapping relation is used for representing parameters of a first interface as parameters of a second interface;
generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed.
2. The method of claim 1, wherein determining the target mapping relationship in the interface call chain according to the recording traffic comprises: determining an initial mapping relation and the probability of the initial mapping relation in each interface call chain of the recorded flow; the initial mapping relation is used for representing parameters of the first interface as a parameter entering relation of the second interface; the probability is the probability of each initial mapping relation in a plurality of mapping relations taking the same parameter as the input parameter of the same interface;
and determining the target mapping relation in the interface call chain according to the probability of each initial mapping relation.
3. The method of claim 2, wherein determining the probability of the initial mapping relationship comprises:
Determining similar mapping relations according to the initial mapping relations, wherein parameters in the initial mapping relations in the similar mapping relations are the same, and second interfaces for receiving the parameters are the same;
and determining the occurrence probability of each initial mapping relation in the similar mapping relation.
4. A method according to claim 3, wherein said determining the probability of occurrence of each initial mapping in said homogeneous mapping comprises:
determining the occurrence times of each initial mapping relation in the similar mapping relation;
and determining the occurrence probability of each initial mapping relation according to the occurrence times of each initial mapping relation and the number of the initial mapping relations included in the similar mapping relations.
5. The method according to any one of claims 2-4, wherein the initial mapping relationship includes any one of the following relationships:
the partial parameters of the first interface are used as all the parameters of the second interface, all the parameters of the first interface are used as all the parameters of the second interface, and all the parameters of the first interface are used as part of the parameters of the second interface.
6. The method of claim 2, wherein said determining an initial mapping in each of said interface call chains of said recorded traffic comprises:
Determining an interface relation topological graph according to each interface call chain in the recorded flow; the interface relation topological graph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and determining the initial mapping relation according to the interface relation topological graph.
7. The method of claim 6, wherein said determining an interface relationship topology from each of said interface call chains in said recorded traffic comprises:
generating an interface link sub-graph of each interface call chain according to each interface call chain in the recorded flow; the interface link subgraph comprises nodes used for representing interfaces and edges used for representing parameter transmission directions among the interfaces;
and merging all the interface link subgraphs to generate the interface relation topological graph.
8. The method of claim 7, wherein the merging the interface link subgraphs to generate the interface relationship topology graph comprises:
determining a main link diagram in the interface link subgraph;
and merging all other interface link subgraphs into the main link diagram according to the nodes included in other interface link subgraphs and the nodes included in the main link diagram to obtain the interface relation topological diagram.
9. The method of claim 6, wherein said determining said initial mapping from said interface relationship topology map comprises:
determining a key value pair corresponding to each interface according to parameters included in each interface; the keys in the key value pair are used for representing parameter identification, and the values in the key value pair are used for representing parameters;
and determining the initial mapping relation according to the parameter transmission direction among interfaces and key value pairs of each interface included in the interface relation topological graph.
10. The method of claim 9, wherein determining the initial mapping relationship according to the inter-interface parameter transmission direction and the key value pair of each interface included in the interface relation topology map comprises:
determining the first interface and the second interface according to the parameter transmission direction between interfaces included in the interface relation topological graph;
and determining the same parameters according to the key value pairs of the first interface and the key value pairs of the second interface, and determining the initial mapping relation between the first interface and the second interface according to the same parameters.
11. A test case generating apparatus, comprising:
The system comprises an acquisition unit, a control unit and a control unit, wherein the acquisition unit is used for acquiring recording flow of a system to be tested, the recording flow comprises an interface call chain executed by the system to be tested in the process of providing service to the outside, and the interface call chain is used for representing a series of interfaces called by the system to be tested in response to external triggering operation and the dependency relationship among the series of interfaces;
the mapping unit is used for determining a target mapping relation in the interface call chain according to the recorded flow, wherein the target mapping relation is used for representing parameters of a first interface as input parameters of a second interface;
the case generation unit is used for generating a target test case according to the target mapping relation; and taking the parameters of the first interface as the parameters of the second interface when the target test case is executed.
12. An electronic device, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing computer-executable instructions stored in the memory causes the at least one processor to perform the test case generation method of any one of claims 1 to 10.
13. A computer-readable storage medium having stored therein computer-executable instructions that, when executed by a processor, implement the test case generation method of any of claims 1 to 10.
14. A computer program product comprising a computer program which, when executed by a processor, implements the test case generation method according to any one of claims 1-10.
CN202111511718.3A 2021-12-06 2021-12-06 Test case generation method, device, equipment, storage medium and program product Pending CN116225886A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111511718.3A CN116225886A (en) 2021-12-06 2021-12-06 Test case generation method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111511718.3A CN116225886A (en) 2021-12-06 2021-12-06 Test case generation method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN116225886A true CN116225886A (en) 2023-06-06

Family

ID=86587930

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111511718.3A Pending CN116225886A (en) 2021-12-06 2021-12-06 Test case generation method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN116225886A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117349185A (en) * 2023-12-04 2024-01-05 杭银消费金融股份有限公司 System testing method based on interface strength dependence grading
CN117389908A (en) * 2023-12-12 2024-01-12 深圳市铱云云计算有限公司 Dependency analysis method, system and medium for interface automation test case

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117349185A (en) * 2023-12-04 2024-01-05 杭银消费金融股份有限公司 System testing method based on interface strength dependence grading
CN117349185B (en) * 2023-12-04 2024-02-23 杭银消费金融股份有限公司 System testing method based on interface strength dependence grading
CN117389908A (en) * 2023-12-12 2024-01-12 深圳市铱云云计算有限公司 Dependency analysis method, system and medium for interface automation test case
CN117389908B (en) * 2023-12-12 2024-03-26 深圳市铱云云计算有限公司 Dependency analysis method, system and medium for interface automation test case

Similar Documents

Publication Publication Date Title
CN112328419B (en) Test case generation method and device of remote procedure call interface, storage medium and electronic equipment
CN111679990B (en) Test data generation method and device, readable medium and electronic equipment
CN111897740B (en) User interface testing method and device, electronic equipment and computer readable medium
CN110390493B (en) Task management method and device, storage medium and electronic equipment
CN116225886A (en) Test case generation method, device, equipment, storage medium and program product
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN111190657B (en) Activity configuration method and device, readable medium and electronic equipment
CN113392018B (en) Traffic distribution method and device, storage medium and electronic equipment
CN112954056B (en) Method and device for processing monitoring data, electronic equipment and storage medium
CN117493150A (en) Code quality detection method, apparatus, device, storage medium, and program
CN112379967B (en) Simulator detection method, device, equipment and medium
CN117251355A (en) Performance test method, device, equipment, computer readable storage medium and product
CN116149978A (en) Service interface testing method and device, electronic equipment and storage medium
CN115981987A (en) Test case processing method and device
CN114116480A (en) Method, device, medium and equipment for determining application program test coverage rate
CN114116517B (en) Front-end item analysis method and device, medium and electronic equipment
CN117687923A (en) Test case management method and device, readable medium and electronic equipment
CN117312126A (en) Stability testing method, device, equipment, readable storage medium and product
CN115481007A (en) Test method, test device, storage medium and electronic equipment
CN114036053A (en) Test method, test device, readable medium and electronic equipment
CN118093352A (en) Test case generation method, device, equipment, medium and product
CN118377693A (en) Service testing method, device, medium and electronic equipment
CN118193349A (en) Interface test platform and system
CN116545729A (en) Multi-application security test method, device, electronic equipment and computer readable medium
CN115640204A (en) Page compatibility testing method and device, electronic 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