Test case generation method, device, equipment, storage medium and program product
By acquiring recorded traffic to determine the target mapping relationship of the interface call chain and generating target test cases, the problem of the inability to automatically generate parameter passing relationships between interfaces is solved, realizing automated testing of dependencies between interfaces and improving test coverage and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- DOUYIN VISION CO LTD
- Filing Date
- 2021-12-06
- Publication Date
- 2026-05-22
AI Technical Summary
In existing technologies, the parameter passing relationships between interfaces cannot be automatically generated into test cases, making it impossible to automate the testing of dependencies between interfaces.
By acquiring the recorded traffic of the system under test, the target mapping relationship in the interface call chain is determined, target test cases are generated, and the target mapping relationship is used to realize automated testing of parameter passing between interfaces.
It has enabled automated testing of parameter passing relationships between interfaces, generated test cases that conform to actual application scenarios, and improved test coverage and efficiency.
Smart Images

Figure CN116225886B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of testing, and more particularly to a test case generation method, apparatus, device, storage medium, and program product. Background Technology
[0002] For web applications or systems, it is necessary to test their code. This can be done, for example, after some code has been developed or after all code has been developed. When testing the code of an application or system, it is also necessary to test its interfaces.
[0003] To improve the efficiency of interface testing, automated testing platforms exist in existing technologies. These platforms can be used to generate test cases, execute test cases, perform test case assertions based on the execution results, and generate test case reports.
[0004] However, existing technologies cannot automatically generate test cases for some interfaces. For example, when a parameter of one interface is used as an input parameter of another interface, test cases for testing this parameter passing relationship between the interfaces cannot be automatically generated, and test cases must be written manually. Summary of the Invention
[0005] This disclosure provides a test case generation method, apparatus, device, storage medium, and program product to automate the generation of test cases for testing the logical relationships between interfaces.
[0006] In a first aspect, embodiments of this disclosure provide a test case generation method, including:
[0007] Obtain the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external trigger operations and the dependencies between the series of interfaces.
[0008] Based on the recorded traffic, the target mapping relationship in the interface call chain is determined, and the target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface;
[0009] Based on the target mapping relationship, target test cases are generated; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface.
[0010] Secondly, embodiments of this disclosure provide a test case generation apparatus, comprising:
[0011] The acquisition unit is used to acquire the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external triggering operations and the dependencies between the series of interfaces.
[0012] A mapping unit is used to determine the target mapping relationship in the interface call chain based on the recorded traffic, wherein the target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface;
[0013] A test case generation unit is used to generate target test cases according to the target mapping relationship; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface. Thirdly, this disclosure provides an electronic device, including: at least one processor and a memory;
[0014] The memory stores computer-executed instructions;
[0015] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the test case generation method as described in the first aspect and various possible designs of the first aspect.
[0016] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the test case generation method described in the first aspect and various possible designs of the first aspect.
[0017] Fifthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the test case generation method described in the first aspect and various possible designs of the first aspect.
[0018] The test case generation method, apparatus, device, storage medium, and program product provided in this embodiment include acquiring recorded traffic of the system under test. The recorded traffic includes an interface call chain executed by the system under test during the provision of services to the outside world. The interface call chain represents a series of interfaces called by the system under test in response to external trigger operations and the dependencies between these interfaces. Based on the recorded traffic, a target mapping relationship is determined in the interface call chain. This target mapping relationship represents the parameter of the first interface as the input parameter of the second interface. Based on the target mapping relationship, target test cases are generated. When the target test cases are executed, the parameter of the first interface is used as the input parameter of the second interface. In the solution provided in this embodiment, the parameter transmission mapping relationship between interfaces can be determined based on the recorded traffic, thereby enabling the generation of scenario test cases that conform to actual application scenarios based on this mapping relationship. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating a test case generation method as an exemplary embodiment of the present disclosure;
[0021] Figure 2 A dependency graph between interfaces illustrated in an exemplary embodiment of this disclosure;
[0022] Figure 3 A flowchart illustrating a test case generation method as shown in another exemplary embodiment of this disclosure;
[0023] Figure 4 This is a schematic diagram illustrating a portion of the initial mapping relationships in an exemplary embodiment of this disclosure;
[0024] Figure 5 This is a schematic diagram of an interface link sub-diagram illustrating an exemplary embodiment of the present disclosure;
[0025] Figure 6 This is a schematic diagram of an interface topology shown in an exemplary embodiment of the present disclosure;
[0026] Figure 7 This is a schematic diagram illustrating the generation of key-value pairs as an exemplary embodiment of the present disclosure;
[0027] Figure 8 A schematic diagram of the structure of a test case generation apparatus shown in an exemplary embodiment of this disclosure;
[0028] Figure 9 A schematic diagram of the structure of a test case generation apparatus shown in another exemplary embodiment of this disclosure;
[0029] Figure 10 This is a schematic diagram of the structure of an electronic device shown as another exemplary embodiment of the present disclosure. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0031] In the software code development process, testing interfaces is a crucial step. Interface testing can check for logical problems in the interface, and thus allow the code used to implement the interface to be corrected before the software goes live.
[0032] To verify whether an interface functions correctly, test cases can be used to test it. Specifically, test cases are executed, during which the interface is called, and the interface's logic processes the test cases, yielding the execution results. The execution results from these test cases verify whether the interface's logic is correct and whether it achieves the expected functionality.
[0033] Developers can write test cases themselves or use existing automation platforms to generate them. However, when the interface to be tested depends on the functionality of other interfaces, the automation platform cannot automatically generate test cases for testing specific scenarios because of these dependencies—for example, when the output parameter of one interface is used as the input parameter of another.
[0034] To address the aforementioned technical issues, the solution provided in this disclosure can acquire the recorded traffic of the system under test, extract a target mapping relationship to characterize the parameter transmission relationship between interfaces based on the recorded traffic, and then generate target test cases based on this target mapping relationship. Thus, the parameter transmission relationship between interfaces can be tested using these scenario test cases.
[0035] Figure 1 This is a flowchart illustrating a test case generation method as an exemplary embodiment of the present disclosure.
[0036] like Figure 1 As shown, the test case generation method provided in this disclosure includes:
[0037] Step 101: Obtain the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external trigger operations and the dependencies between a series of interfaces.
[0038] The test case generation method provided in this embodiment can be used to generate test cases. These test cases can test the parameter passing relationships between interfaces. The method provided in this disclosure can be applied to the server side or the user terminal side.
[0039] Figure 2 This is a dependency graph between interfaces illustrated in an exemplary embodiment of the present disclosure.
[0040] like Figure 2 As shown, the output parameter A of interface 21 will be input into interface 22. After receiving parameter A, interface 22 can process parameter A to obtain parameter B. After that, interface 22 will also input parameter A and parameter B into interface 23, which will process parameter A and parameter B.
[0041] In this application scenario, due to the context mapping relationship between interfaces and the strong dependency relationship between them, it is impossible to generate test cases for testing the dependency relationship between interfaces based on the existing automated testing platform.
[0042] Specifically, the test case generation method provided in this disclosure can obtain the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external trigger operations and the dependencies between the series of interfaces.
[0043] By observing the runtime interfaces called by the system under test and the dependencies between them, a call chain can be obtained. Multiple call chains can be obtained during system runtime to capture recorded traffic. For example, the system under test can execute a first service to capture the first call chain; a second service can be executed to capture the second call chain. Multiple call chains can be combined to capture recorded traffic.
[0044] In one optional implementation, if the solution provided in this disclosure is applied to the user terminal side, the user terminal responds to the user's operation and executes the code logic, and records the interfaces used during execution, as well as the dependencies between the interfaces. In another optional implementation, if the solution provided in this disclosure is applied to the server side, the user terminal can respond to the user's operation and execute the code logic, and send the data transmission relationships between the interfaces during execution to the server. If an interface in the server is called, the server can further record the data transmission relationships between the interfaces.
[0045] Specifically, a user can operate an electronic device. For example, a user can click the record button displayed on the user terminal's interface to send a record operation to the user terminal for recording data traffic. If the solution provided in this disclosure is executed by the user terminal, the user terminal can respond to the operation and obtain the recorded data traffic. If the solution provided in this disclosure is executed by the server, the user terminal can send a record operation to the server for recording data traffic, enabling the server to respond to the operation and obtain the recorded data traffic.
[0046] Furthermore, after the user clicks the record button, they can operate the system under test, thereby enabling the electronic device to call interfaces based on this operation and obtain the call relationships and parameter transmission relationships between interfaces to collect recording traffic. If the method provided in this disclosure is executed by the server, the user terminal can also send the collected recording traffic to the server.
[0047] After recording is complete, the user can click the stop recording button on the electronic device. Based on the current user action, the recording data generated during this process can be obtained. The user can then click the record button on the user's device again to retrieve the recorded data.
[0048] Specifically, the solution provided in this disclosure can obtain a batch of recording traffic based on each recording operation of the user, and then generate test cases based on multiple batches of recording traffic. These test cases can then be used to conduct comprehensive testing of the functions of each interface of the system under test.
[0049] In one optional implementation, if the solution provided in this disclosure is executed by a server, the server can also filter the received recording traffic according to the identifier of the user terminal to obtain each type of recording traffic. For example, the server can obtain the recording traffic recorded through a first terminal, or the server can obtain the recording traffic recorded through a second terminal.
[0050] In practical applications, the parameter transmission relationships between interfaces will differ in different application scenarios. To enable test cases to test more interfaces and more inter-interface dependencies, the solution provided in this disclosure allows users to operate the system under test multiple times. This causes the electronic device to call each interface multiple times based on the inter-interface dependencies, resulting in a richer interface call chain that characterizes the parameter transmission relationships between interfaces. For example, during the first operation, the user can log in to their account, browse products, and purchase products. During the second operation, the user can view their purchased product orders and contact customer service to apply for after-sales service.
[0051] Since different operation processes involve different interfaces, and may also involve different functions of the same interface, this method can collect a richer interface call chain that is more in line with the actual usage of users.
[0052] Step 102: Based on the recorded traffic, determine the target mapping relationship in the interface call chain. The target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface.
[0053] The recorded traffic includes multiple API call chains, and each API call chain contains dependencies between APIs. Therefore, the target mapping relationship can be determined based on these dependencies.
[0054] Specifically, the dependency relationship between interfaces refers to the data transmission relationship between interfaces. For example, during an operation, the output parameter A of interface 21 is input to interface 22. Therefore, there is a dependency relationship between interface 21 and interface 22, specifically, the parameter A of interface 21 is used as the input parameter of interface 22.
[0055] Multiple call chains in the recorded traffic can be processed to determine the target mapping relationship. The target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface. These parameters can be either input parameters or output parameters of the first interface.
[0056] Furthermore, the call chain includes dependencies between multiple interfaces. The initial mapping relationship between interfaces can be determined based on this dependency relationship. For example, if parameter A of interface 21 is used as the input parameter of interface 22, then there is an initial mapping relationship between interface 21 and interface 22.
[0057] In practical applications, when there are many initial mapping relationships, a target mapping relationship can be determined from among them to obtain the target mapping relationship that appears most frequently. For example, if multiple interfaces have parameter A as input parameters of interface 22, multiple initial mapping relationships can be generated, and the initial mapping relationship that appears most frequently can be determined as the target mapping relationship.
[0058] For example, when parameter A is used as the input parameter of interface 33, parameter A may come from interface 31 or interface 32. The probability of using parameter A to represent the initial mapping relationship from interface 31 is 4 / 5, and the probability of using parameter A to represent the initial mapping relationship from interface 32 is 1 / 5. Therefore, parameter A of interface 31 can be used as the input parameter of interface 33 as the target mapping relationship.
[0059] If it is determined that among multiple initial mapping relationships, there are multiple initial mapping relationships with the same parameters and the same second interface for receiving the parameters, then the probability of occurrence of each initial mapping relationship can be determined, thereby identifying the target mapping relationship.
[0060] Target mapping relationships that occur more frequently are more consistent with real-world scenarios. Therefore, this method can help determine target mapping relationships that are more consistent with real-world scenarios.
[0061] Step 103: Generate target test cases based on the target mapping relationship; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface.
[0062] Furthermore, target test cases can be generated based on the target mapping relationships. When executing a target test case, the first interface and the second interface can be executed, and the parameters of the first interface can be used as the input parameters of the second interface, thereby enabling the transmission of parameters in each interface according to the target mapping relationships.
[0063] In practical applications, target test cases that are more in line with the actual scenario can be generated based on the target mapping relationship that is more in line with the actual scenario. In turn, the dependency relationship between the interfaces of the system to be tested can be tested through the target test cases.
[0064] In this way, a more realistic mapping relationship that conforms to the actual scenario can be determined.
[0065] Furthermore, scenario use cases can be generated based on each real mapping relationship. Specifically, a test case can be generated, which can execute each interface and pass parameters in each interface based on the determined real mapping relationship.
[0066] In practical applications, scenario test cases can be generated based on real mapping relationships that are more in line with actual scenarios. Moreover, the scenario test cases generated in this disclosure based on the data transmission relationship between multiple interfaces can also cover more data transmission situations between interfaces, thereby testing more interface functions and achieving higher test coverage.
[0067] The test case generation method disclosed herein includes: acquiring recorded traffic of the system under test, the recorded traffic including an interface call chain executed by the system under test during the provision of services to the outside world, the interface call chain representing a series of interfaces called by the system under test in response to external trigger operations and the dependencies between these interfaces; determining a target mapping relationship in the interface call chain based on the recorded traffic, the target mapping relationship representing that the parameters of the first interface are used as input parameters of the second interface; and generating target test cases based on the target mapping relationship; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface. In the test case generation method disclosed herein, a target mapping relationship representing the dependencies between interfaces can be determined through recorded traffic, and then target test cases can be generated based on this relationship, through which the dependencies between interfaces can be tested.
[0068] Figure 3 This is a flowchart illustrating a test case generation method as shown in another exemplary embodiment of this disclosure.
[0069] like Figure 3 As shown, the test case generation method provided in this disclosure includes:
[0070] Step 301: Obtain the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external trigger operations and the dependencies between a series of interfaces.
[0071] Step 301 is implemented in a similar way to step 101, and will not be described again.
[0072] The test case generation method provided in this embodiment can be used to generate test cases. Test cases are test cases that test the dependencies between interfaces.
[0073] Step 302: Determine the initial mapping relationship and the probability of the initial mapping relationship in each interface call chain of the recorded traffic; wherein, the initial mapping relationship is used to characterize the relationship between the parameters of the first interface and the input parameters of the second interface; the probability is the probability of each initial mapping relationship occurring in multiple mapping relationships where the same parameter is the input parameter of the same interface.
[0074] Specifically, the interface call chains in the acquired recorded traffic include a series of interfaces called by the system under test in response to external trigger operations, as well as the dependencies between these interfaces. Therefore, the parameter transmission relationships between interfaces can be determined based on each interface call chain, thereby obtaining the initial mapping relationship.
[0075] The initial mapping relationship is used to characterize the relationship between the parameters of the first interface and the input parameters of the second interface. For example, the output parameter K of the first interface is used as the input parameter of the second interface.
[0076] Specifically, some parameters of the first interface are used as all input parameters of the second interface, all parameters of the first interface are used as all input parameters of the second interface, and all parameters of the first interface are used as some input parameters of the second interface.
[0077] Furthermore, in the determined initial mapping relationships, there may be cases where the same input parameter of the second interface may come from different first interfaces. For example, there are interfaces 1, 2 and 3. In the first operation process, parameter A in interface 1 is input into interface 3, and in the second operation process, parameter A in interface 2 is input into interface 3.
[0078] When testing the functionality of interface 3, whether parameter A is obtained from interface 1 or interface 2, the functionality of interface 3 can be tested based on parameter A.
[0079] In order to enable the generated test cases to test interface functions that are more in line with actual application scenarios, the solution provided in this disclosure also determines the probability of each initial mapping relationship. Then, based on the probability, the target mapping relationship is determined among multiple initial mapping relationships when the same parameter is used as the input parameter of the second interface. This allows us to determine the target mapping relationship with a higher probability when the same parameter is input to the same second interface through multiple channels, thereby generating more accurate test cases.
[0080] The target mapping relationship can represent the actual parameter transfer relationship. Therefore, the target mapping relationship is more in line with the actual scenario, and thus the solution disclosed in this paper can obtain test cases that are more in line with the actual scenario.
[0081] Figure 4 This is a schematic diagram illustrating a portion of the initial mapping relationship as an exemplary embodiment of this disclosure.
[0082] like Figure 4 As shown, the initial mapping relationships included in the data transmission relationships between the obtained interfaces can be as follows: Figure 4 As shown.
[0083] Wherein, initial mapping relationship 44 is used to represent the response parameter 1-resq-1 in interface 41 as the input parameter of request parameter 3-rep-2 in interface 43; initial mapping relationship 45 is used to represent the request parameter 1-rep-2 in interface 41 as the input parameter of request parameter 2-rep-3 in interface 42; initial mapping relationship 46 is used to represent the response parameter 1-resq-4 in interface 41 as the input parameter of request parameter 2-rep-4 in interface 42; initial mapping relationship 47 is used to represent the response parameter 2-resq-5 in interface 42 as the input parameter of request parameter 3-rep-2 in interface 43.
[0084] Specifically, since the parameters in interfaces 41 and 42 may be input into interface 43 as input parameters of 3-rep-2, the probability of the parameter of interface 41 being used as input parameter of 3-rep-2 in interface 43, and the probability of the parameter of interface 42 being used as input parameter of 3-rep-2 in interface 43 can be calculated.
[0085] Furthermore, for example, in the initial mapping relationship, there are 8 parameters 1-resq-1 of relation representation interface 41 that serve as input parameters 3-rep-2 in interface 43, and 2 parameters 2-resq-5 of relation representation interface 42 that serve as input parameters 3-rep-2 in interface 43. The probability that parameter 1-resq-1 of interface 41 serves as an input parameter of 3-rep-2 in interface 43 is 4 / 5, and the probability that parameter 2-resq-5 of interface 42 serves as an input parameter of 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.
[0086] When determining the initial mapping relationship, the interface relationship topology can be determined first based on the interface call chain in the recorded traffic; the interface relationship topology includes nodes that represent interfaces and edges that represent the direction of parameter transmission between interfaces.
[0087] The recorded traffic includes the call relationships between various interfaces, so an interface relationship topology graph can be constructed based on these call relationships.
[0088] Specifically, if the recorded data includes multiple interface call chains obtained based on multiple user operations, an interface link subgraph can be generated for each interface call chain in the recorded traffic; the interface link subgraph includes nodes to represent interfaces and edges to represent the direction of parameter transmission between interfaces.
[0089] Figure 5 This is a schematic diagram of an interface link sub-diagram illustrating an exemplary embodiment of the present disclosure.
[0090] like Figure 5As shown, for example, the recorded traffic includes 3 interface call chains. For the first interface call chain, an interface link subgraph 51 can be generated; for the second interface call chain, an interface link subgraph 52 can be generated; and for the third interface call chain, an interface link subgraph 53 can be generated.
[0091] The solution provided in this disclosure can generate a corresponding interface link subgraph based on each interface call chain. The interface link subgraph can record the call relationships between interfaces, specifically including the direction of parameter transmission between interfaces. For example, if a parameter from interface 1 is input to interface 2, and another parameter from interface 1 is input to interface 3, then the interface link subgraph includes the edge from interface 1 to interface 2, and the edge from interface 1 to interface 3.
[0092] Specifically, the various interface link subgraphs can be merged to generate an interface relationship topology diagram. For the same batch of interface call chains in the recorded traffic, multiple interface link subgraphs can be generated. In order to generate test cases for more comprehensive testing of the parameter transmission relationship between interfaces, the various interface link subgraphs can be merged to obtain the interface relationship topology diagram.
[0093] Furthermore, a main link diagram can be determined from the interface link sub-diagrams; then, based on the nodes included in the other interface link sub-diagrams and the nodes included in the main link diagram, the various other interface link sub-diagrams are merged into the main link diagram to obtain the interface relationship topology diagram.
[0094] In practical applications, each interface link subgraph includes several nodes. By merging the various interface link subgraphs based on the common nodes present in each subgraph, an interface relationship topology graph can be obtained. This topology graph also includes nodes representing interfaces and edges representing the data transmission direction between interfaces.
[0095] In this process, a main link graph can be determined from multiple interface link subgraphs. If other interface link subgraphs include the same node as the main link graph, the duplicate node in the other interface link subgraphs can be merged with the duplicate node in the main link graph, thereby merging the other interface link subgraphs into the main link graph.
[0096] Specifically, if an interface link subgraph has no duplicate nodes with any other interface link subgraph, it means that the interface link subgraph does not belong to the application scenario of the current test case, and the interface link subgraph does not need to be merged into the main link graph.
[0097] Figure 6 This is a schematic diagram of an interface topology shown as an exemplary embodiment of the present disclosure.
[0098] like Figure 6 As shown, for Figure 5By merging the three interface link sub-diagrams shown in Figure 61, an interface topology diagram as shown in Figure 61 can be obtained.
[0099] After determining the interface relationship topology, the initial mapping relationship can also be determined based on the interface relationship topology.
[0100] Furthermore, based on the determined interface relationship topology, the parameter transmission direction between each interface can be determined. For example, if there is an edge in the interface relationship topology that points from interface 1 to interface 2, then it can be determined that the parameters in interface 1 are transmitted to interface 2.
[0101] In practical applications, the parameter transmission relationship between interfaces can be determined based on the pointing relationship between each interface in the interface relationship topology diagram.
[0102] Specifically, based on the parameters included in each interface, the corresponding key-value pairs can be determined for each interface; the key in the key-value pair is used to represent the parameter identifier, and the value in the key-value pair is used to represent the parameter. Each interface includes request parameters and response parameters, and key-value pairs can be constructed for each type of parameter.
[0103] Figure 7 This is a schematic diagram illustrating the generation of key-value pairs as an exemplary embodiment of the present disclosure.
[0104] like Figure 7 As shown, the left side is a code block for request parameters in an interface, and the right side is a key-value pair built based on those request parameters.
[0105] Furthermore, the code within the code block can be parsed into strings, thus obtaining key-value pairs. For example, if a request parameter in the interface is "psm", the code used to retrieve this request parameter can be used as the key of the request parameter, such as "source_node.psm", with the key and value in each key-value pair separated by a colon ":".
[0106] In practical applications, the key in a key-value pair is used to represent the parameter identifier, and the value in the key-value pair is used to represent the parameter. For example, in the key-value pair "source_node.psm:psm", source_node.psm is the key and psm is the value.
[0107] The initial mapping relationship is determined based on the parameter transmission direction between interfaces and the key-value pairs of each interface included in the interface relationship topology diagram.
[0108] Specifically, in the interface topology diagram, there is a parameter transmission relationship between two interfaces connected by an edge. Therefore, the parameter transmission relationship between interfaces connected by an edge can be determined based on the key-value pairs of the interfaces connected by the edge.
[0109] Furthermore, the first and second interfaces can be determined based on the parameter transmission direction between interfaces included in the interface relationship topology graph. For example, two interfaces with a parameter transmission direction between them can be designated as the first and second interfaces, respectively. For instance, if there is an edge in the relationship topology graph pointing from interface 1 to interface 2, then interface 1 can be designated as the first interface, and interface 2 as the second interface.
[0110] Subsequently, the same parameters can be determined based on the key-value pairs of the first interface and the key-value pairs of the second interface, and the initial mapping relationship between the first interface and the second interface can be determined based on the same parameters.
[0111] For example, if the key-value pairs of the first interface and the key-value pairs of the second interface have the same parameter A, then the parameter A in the first interface can be determined as the input parameter of the second interface, and thus the initial mapping relationship between the two interfaces can be determined.
[0112] Furthermore, the initial mapping relationship constructed includes any of the following relationships:
[0113] Some parameters of one interface are used as all parameters of another interface; all parameters of one interface are used as all parameters of another interface; all parameters of one interface are used as some parameters of another interface.
[0114] This implementation method allows for the determination of various initial mapping relationships between interfaces, thereby generating test cases that more comprehensively cover the functions between interfaces.
[0115] After determining the initial mapping relationships, the probability of each initial mapping relationship can also be determined. Specifically, based on the initial mapping relationships, similar mapping relationships can be determined, where the parameters of each initial mapping relationship in the same category are the same, and the second interface for receiving the parameters is the same.
[0116] Based on the recorded traffic, multiple initial mapping relationships can be generated. These initial mapping relationships can be categorized to obtain multiple similar mapping relationships. Each similar mapping relationship includes several initial mapping relationships.
[0117] Specifically, among the initial mapping relationships included in the same category, the parameters are the same, and the second interface receiving the parameters is the same. When a parameter is used as an input parameter of the second interface, the source of the parameter may include multiple interfaces. Therefore, these initial mapping relationships can be grouped into a single mapping relationship of the same category.
[0118] For example, a mapping relationship of the same type includes two initial mapping relationships. One initial mapping relationship is used to represent that parameter A of interface 1 is used as the input parameter of interface 3, and the other initial mapping relationship is used to represent that parameter A of interface 2 is used as the input parameter of interface 3. The parameters of these two initial mapping relationships are the same, and the interfaces that receive the parameters are also the same. Therefore, these two initial mapping relationships can be classified into the same type of mapping relationship.
[0119] Among them, after determining the mapping relationship of the same type, the probability of each initial mapping relationship appearing is determined in the mapping relationship of the same type.
[0120] Furthermore, the probability of each initial mapping relationship appearing in each class of mapping relationships can be determined based on the initial mapping relationships included in each class of mapping relationships.
[0121] In practical applications, the number of times each initial mapping relationship appears in the same type of mapping relationship can be determined. Then, based on the number of times each initial mapping relationship appears and the number of initial mapping relationships included in the same type of mapping relationship, the probability of each initial mapping relationship appearing can be determined.
[0122] Among them, a class of mapping relationships can include multiple initial mapping relationships, and can include repeated initial mapping relationships. For example, in the recorded traffic collected based on user operations, if parameter A from interface 1 is input to interface 3 twice, then a class of mapping relationships can include two initial mapping parameters that represent parameter A from interface 1 as input parameters of interface 3, and the number of occurrences of this initial mapping parameter is 2.
[0123] Specifically, the probability of each initial mapping relationship occurring can be determined by the ratio of the number of occurrences of each initial mapping relationship to the number of initial mapping relationships included in the same category. This probability characterizes the frequency of occurrence of each initial mapping relationship within the same category, thus allowing the determination of parameter transmission relationships that conform to the actual application scenario within that category of mapping relationships.
[0124] Step 303: Determine the target mapping relationship in the interface call chain based on the probability of each initial mapping relationship.
[0125] Furthermore, for each type of mapping relationship, a target mapping relationship can be identified. For example, the initial mapping relationship with the highest probability among the types of mapping relationships can be identified as the target mapping relationship.
[0126] For example, in the same type of mapping relationship, the probability that parameter 1-resq-1 of interface 41 is used as the input parameter of 3-rep-2 in interface 43 is 4 / 5, and the probability that parameter 2-resq-5 of interface 42 is used as the input parameter of 3-rep-2 in interface 43 is 1 / 5. Therefore, the initial mapping relationship that parameter 1-resq-1 of interface 41 is used as the input parameter of 3-rep-2 in interface 43 can be used as the target mapping relationship of the same type of mapping relationship.
[0127] Step 304: Generate target test cases based on the target mapping relationship; wherein, when the target test cases are executed, the parameters of the first interface are used as the input parameters of the second interface. Step 304 is similar to the execution method of step 103, and will not be described again.
[0128] In one alternative implementation, the generated test cases can also be used to test each interface. For example, the test case can be executed, and then the interface can be used to process the test case to obtain the execution result.
[0129] It can also generate test reports based on the execution results. For example, the test report can include the execution results as well as the preset expected results.
[0130] The test case generation method provided in this disclosure can identify the target mapping relationship with a higher probability of occurrence during parameter transmission from multiple initial mapping relationships. This allows for obtaining a target mapping relationship that better reflects the actual scenario and represents parameter transmission. Furthermore, test scenario test cases that conform to the actual application scenario can be generated based on this target mapping relationship.
[0131] Figure 8 This is a schematic diagram of the structure of a test case generation apparatus shown in an exemplary embodiment of the present disclosure.
[0132] like Figure 8 As shown, the test case generation apparatus 800 provided in this disclosure includes:
[0133] The acquisition unit 810 is used to acquire the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external triggering operations and the dependencies between the series of interfaces.
[0134] The mapping unit 820 is used to determine the target mapping relationship in the interface call chain based on the recorded traffic, wherein the target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface;
[0135] The test case generation unit 830 is used to generate target test cases according to the target mapping relationship; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface.
[0136] The test case generation apparatus provided in this disclosure can determine the target mapping relationship for representing the dependency relationship between interfaces by recording traffic, and then generate target test cases based on this relationship. The dependency relationship between interfaces can be tested through the target test cases.
[0137] Figure 9 This is a schematic diagram of the structure of a test case generation apparatus, which is another exemplary embodiment of the present disclosure.
[0138] like Figure 9 As shown, in an optional embodiment of the test case generation apparatus 900 provided in this disclosure, based on the above embodiments, the mapping unit 820 includes:
[0139] An initial mapping module 821 is used to determine an initial mapping relationship and the probability of the initial mapping relationship in each of the interface call chains of the recorded traffic; wherein, the initial mapping relationship is used to characterize the relationship of the parameters of the first interface as input parameters of the second interface; the probability is the probability of each initial mapping relationship occurring in multiple mapping relationships where the same parameters are input parameters of the same interface.
[0140] The target mapping module 822 is used to determine the target mapping relationship in the interface call chain based on the probability of each initial mapping relationship.
[0141] In one optional implementation, the initial mapping module 821 is specifically used for:
[0142] Based on each initial mapping relationship, a similar mapping relationship is determined, wherein the parameters in each initial mapping relationship of the similar mapping relationship are the same, and the second interface for receiving the parameters is the same;
[0143] In the aforementioned mapping relationships, determine the probability of each initial mapping relationship occurring.
[0144] In one optional implementation, the initial mapping module 821 is specifically used for:
[0145] Determine the number of occurrences of each initial mapping relationship in the aforementioned similar mapping relationships;
[0146] The probability of each initial mapping relationship is determined based on the number of times each initial mapping relationship occurs and the number of initial mapping relationships included in the same type of mapping relationship.
[0147] In one optional implementation, the initial mapping relationship includes any of the following relationships:
[0148] Some parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as some input parameters of the second interface.
[0149] In one optional implementation, the initial mapping module 821 is specifically used for:
[0150] An interface relationship topology is determined based on each interface call chain in the recorded traffic; wherein, the interface relationship topology includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces;
[0151] The initial mapping relationship is determined based on the interface relationship topology diagram.
[0152] In one optional implementation, the initial mapping module 821 is specifically used for:
[0153] Based on each interface call chain in the recorded traffic, an interface link subgraph is generated for each interface call chain; the interface link subgraph includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces.
[0154] The various interface link subgraphs are merged to generate the interface relationship topology graph.
[0155] In one optional implementation, the initial mapping module 821 is specifically used for:
[0156] A main link diagram is determined in the interface link sub-diagram;
[0157] Based on the nodes included in other interface link subgraphs and the nodes included in the main link graph, the various other interface link subgraphs are merged into the main link graph to obtain the interface relationship topology graph.
[0158] In an optional implementation, the initial mapping module 821 is specifically used to determine the key-value pair corresponding to each interface based on the parameters included in each interface; the key in the key-value pair is used to represent the parameter identifier, and the value in the key-value pair is used to represent the parameter.
[0159] The initial mapping relationship is determined based on the parameter transmission direction between interfaces and the key-value pairs of each interface included in the interface relationship topology diagram.
[0160] The initial mapping module 821 is specifically used for:
[0161] Based on the parameter transmission direction between interfaces included in the interface relationship topology diagram, determine the first interface and the second interface;
[0162] Based on the key-value pairs of the first interface and the key-value pairs of the second interface, the same parameters are determined, and the initial mapping relationship between the first interface and the second interface is determined based on the same parameters.
[0163] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0164] refer to Figure 10 The diagram illustrates a structural schematic of an electronic device 1000 suitable for implementing embodiments of the present disclosure. The electronic device 1000 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), portable Android devices (PADs), portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 10 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0165] like Figure 10 As shown, the electronic device 1000 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 1001, which can 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 (RAM) 1003. The RAM 1003 also stores various programs and data required for the operation of the electronic device 1000. The processing unit 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0166] Typically, the following devices can be connected to the I / O interface 1005: input devices 1006 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 1007 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1008 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows electronic device 1000 to exchange data via wireless or wired communication with other devices. Although Figure 10 An electronic device 1000 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0167] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 1009, or installed from storage device 1008, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of embodiments of this disclosure.
[0168] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0169] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0170] The aforementioned 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 embodiments.
[0171] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0172] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0173] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0174] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0175] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0176] In a first aspect, according to one or more embodiments of this disclosure, a test case generation method is provided, comprising:
[0177] Obtain the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external trigger operations and the dependencies between the series of interfaces.
[0178] Based on the recorded traffic, the target mapping relationship in the interface call chain is determined, and the target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface;
[0179] Based on the target mapping relationship, target test cases are generated; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface. According to one or more embodiments of this disclosure, determining the target mapping relationship in the interface call chain based on the recorded traffic includes: determining an initial mapping relationship and a probability of the initial mapping relationship in each interface call chain of the recorded traffic; wherein, the initial mapping relationship is used to characterize the relationship where the parameters of the first interface are used as input parameters of the second interface; the probability is the probability of each initial mapping relationship occurring among multiple mapping relationships where the same parameter is used as an input parameter of the same interface.
[0180] Based on the probabilities of each initial mapping relationship, the target mapping relationship in the interface call chain is determined. According to one or more embodiments of this disclosure, determining the probability of the initial mapping relationship includes:
[0181] Based on each initial mapping relationship, a similar mapping relationship is determined, wherein the parameters in each initial mapping relationship of the similar mapping relationship are the same, and the second interface for receiving the parameters is the same;
[0182] In the aforementioned mapping relationships, determine the probability of each initial mapping relationship occurring.
[0183] According to one or more embodiments of this disclosure, determining the probability of each initial mapping relationship occurring in the same type of mapping relationship includes:
[0184] Determine the number of occurrences of each initial mapping relationship within the aforementioned similar mapping relationships;
[0185] The probability of each initial mapping relationship is determined based on the number of times each initial mapping relationship occurs and the number of initial mapping relationships included in the same type of mapping relationship.
[0186] The initial mapping relationship includes any of the following relationships:
[0187] Some parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as some input parameters of the second interface.
[0188] According to one or more embodiments of this disclosure, determining the initial mapping relationship in each of the interface call chains of the recorded traffic includes:
[0189] An interface relationship topology is determined based on each interface call chain in the recorded traffic; wherein, the interface relationship topology includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces;
[0190] The initial mapping relationship is determined based on the interface relationship topology diagram.
[0191] According to one or more embodiments of this disclosure, determining the interface relationship topology based on each of the interface call chains in the recorded traffic includes:
[0192] Based on each interface call chain in the recorded traffic, an interface link subgraph is generated for each interface call chain; the interface link subgraph includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces.
[0193] The various interface link subgraphs are merged to generate the interface relationship topology graph.
[0194] According to one or more embodiments of this disclosure, merging the various interface link subgraphs to generate the interface relationship topology graph includes:
[0195] A main link diagram is determined in the interface link sub-diagram;
[0196] Based on the nodes included in other interface link subgraphs and the nodes included in the main link graph, the various other interface link subgraphs are merged into the main link graph to obtain the interface relationship topology graph. According to one or more embodiments of this disclosure, determining the initial mapping relationship based on the interface relationship topology graph includes:
[0197] Based on the parameters included in each interface, determine the key-value pair corresponding to each interface; the key in the key-value pair is used to represent the parameter identifier, and the value in the key-value pair is used to represent the parameter.
[0198] The initial mapping relationship is determined based on the parameter transmission direction between interfaces and the key-value pairs of each interface included in the interface relationship topology diagram.
[0199] According to one or more embodiments of this disclosure, determining the initial mapping relationship based on the parameter transmission direction between interfaces and the key-value pairs of each interface included in the interface relationship topology diagram includes:
[0200] Based on the parameter transmission direction between interfaces included in the interface relationship topology diagram, determine the first interface and the second interface;
[0201] Based on the key-value pairs of the first interface and the key-value pairs of the second interface, the same parameters are determined, and the initial mapping relationship between the first interface and the second interface is determined based on the same parameters.
[0202] Secondly, according to one or more embodiments of this disclosure, a test case generation apparatus is provided, comprising:
[0203] The acquisition unit is used to acquire the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external triggering operations and the dependencies between the series of interfaces.
[0204] A mapping unit is used to determine the target mapping relationship in the interface call chain based on the recorded traffic, wherein the target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface;
[0205] The test case generation unit is used to generate target test cases based on the target mapping relationship; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface.
[0206] According to one or more embodiments of this disclosure, the mapping unit includes:
[0207] An initial mapping module is used to determine an initial mapping relationship and the probability of the initial mapping relationship in each of the interface call chains of the recorded traffic; wherein, the initial mapping relationship is used to characterize the relationship of the parameters of the first interface as input parameters of the second interface; the probability is the probability of each initial mapping relationship occurring in multiple mapping relationships where the same parameter is the input parameter of the same interface.
[0208] The target mapping module is used to determine the target mapping relationship in the interface call chain based on the probability of each initial mapping relationship.
[0209] According to one or more embodiments of this disclosure, the initial mapping module is specifically used for:
[0210] Based on each initial mapping relationship, a similar mapping relationship is determined, wherein the parameters in each initial mapping relationship of the similar mapping relationship are the same, and the second interface for receiving the parameters is the same;
[0211] In the aforementioned mapping relationships, determine the probability of each initial mapping relationship occurring.
[0212] According to one or more embodiments of this disclosure, the initial mapping module is specifically used for:
[0213] Determine the number of occurrences of each initial mapping relationship in the aforementioned similar mapping relationships;
[0214] The probability of each initial mapping relationship is determined based on the number of times each initial mapping relationship occurs and the number of initial mapping relationships included in the same type of mapping relationship.
[0215] According to one or more embodiments of this disclosure, the initial mapping relationship includes any of the following relationships:
[0216] Some parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as some input parameters of the second interface.
[0217] According to one or more embodiments of this disclosure, the initial mapping module is specifically used for:
[0218] An interface relationship topology is determined based on each interface call chain in the recorded traffic; wherein, the interface relationship topology includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces;
[0219] The initial mapping relationship is determined based on the interface relationship topology diagram.
[0220] According to one or more embodiments of this disclosure, the initial mapping module is specifically used for:
[0221] Based on each interface call chain in the recorded traffic, an interface link subgraph is generated for each interface call chain; the interface link subgraph includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces.
[0222] The various interface link subgraphs are merged to generate the interface relationship topology graph.
[0223] According to one or more embodiments of this disclosure, the initial mapping module is specifically used for:
[0224] A main link diagram is determined in the interface link sub-diagram;
[0225] Based on the nodes included in other interface link subgraphs and the nodes included in the main link graph, the various other interface link subgraphs are merged into the main link graph to obtain the interface relationship topology graph.
[0226] According to one or more embodiments of this disclosure, the initial mapping module is specifically used to determine a key-value pair corresponding to each interface based on the parameters included in each interface; the key in the key-value pair is used to represent the parameter identifier, and the value in the key-value pair is used to represent the parameter.
[0227] The initial mapping relationship is determined based on the parameter transmission direction between interfaces and the key-value pairs of each interface included in the interface relationship topology diagram.
[0228] According to one or more embodiments of this disclosure, the initial mapping module 821 is specifically used for:
[0229] Based on the parameter transmission direction between interfaces included in the interface relationship topology diagram, determine the first interface and the second interface;
[0230] Based on the key-value pairs of the first interface and the key-value pairs of the second interface, the same parameters are determined, and the initial mapping relationship between the first interface and the second interface is determined based on the same parameters.
[0231] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory;
[0232] The memory stores computer-executed instructions;
[0233] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the test case generation method as described in the first aspect and various possible designs of the first aspect.
[0234] Fourthly, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, and when a processor executes the computer-executable instructions, the test case generation method described in the first aspect and various possible designs of the first aspect is implemented.
[0235] Fifthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the test case generation method described in the first aspect and various possible designs of the first aspect.
[0236] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0237] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0238] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A test case generation method, characterized in that, include: Obtain the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external trigger operations and the dependencies between the series of interfaces. Based on the recorded traffic, the target mapping relationship in the interface call chain is determined, and the target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface; Based on the target mapping relationship, target test cases are generated; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface; The step of determining the target mapping relationship in the interface call chain based on the recorded traffic includes: determining the initial mapping relationship and the probability of the initial mapping relationship in each of the interface call chains of the recorded traffic; wherein, the initial mapping relationship is used to characterize the relationship of the parameters of the first interface as input parameters of the second interface; the probability is the probability of each initial mapping relationship occurring in multiple mapping relationships where the same parameters are input parameters of the same interface. Based on the probability of each initial mapping relationship, the target mapping relationship in the interface call chain is determined; The probability of determining the initial mapping relationship includes: Based on each initial mapping relationship, a similar mapping relationship is determined. The parameters in each initial mapping relationship of the same type are the same, and the second interface for receiving the parameters is the same, but the interfaces from which the parameters originate are different. In the aforementioned mapping relationships, determine the probability of each initial mapping relationship occurring.
2. The method according to claim 1, characterized in that, Determining the probability of each initial mapping relationship occurring within the same type of mapping relationship includes: Determine the number of occurrences of each initial mapping relationship in the aforementioned similar mapping relationships; The probability of each initial mapping relationship is determined based on the number of times each initial mapping relationship occurs and the number of initial mapping relationships included in the same type of mapping relationship.
3. The method according to claim 2, characterized in that, The initial mapping relationship includes any of the following relationships: Some parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as all input parameters of the second interface; all parameters of the first interface are used as some input parameters of the second interface.
4. The method according to claim 1, characterized in that, Determining the initial mapping relationship in each of the interface call chains of the recorded traffic includes: An interface relationship topology is determined based on each interface call chain in the recorded traffic; wherein, the interface relationship topology includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces; The initial mapping relationship is determined based on the interface relationship topology diagram.
5. The method according to claim 4, characterized in that, The step of determining the interface relationship topology based on each interface call chain in the recorded traffic includes: Based on each interface call chain in the recorded traffic, an interface link subgraph is generated for each interface call chain; the interface link subgraph includes nodes for representing interfaces and edges for representing the parameter transmission direction between interfaces. The various interface link subgraphs are merged to generate the interface relationship topology graph.
6. The method according to claim 5, characterized in that, The step of merging the various interface link subgraphs to generate the interface relationship topology graph includes: A main link diagram is determined in the interface link sub-diagram; Based on the nodes included in other interface link subgraphs and the nodes included in the main link graph, the various other interface link subgraphs are merged into the main link graph to obtain the interface relationship topology graph.
7. The method according to claim 4, characterized in that, The step of determining the initial mapping relationship based on the interface relationship topology diagram includes: Based on the parameters included in each interface, determine the key-value pair corresponding to each interface; the key in the key-value pair is used to represent the parameter identifier, and the value in the key-value pair is used to represent the parameter. The initial mapping relationship is determined based on the parameter transmission direction between interfaces and the key-value pairs of each interface included in the interface relationship topology diagram.
8. The method according to claim 7, characterized in that, Based on the parameter transmission directions between interfaces and the key-value pairs of each interface included in the interface relationship topology diagram, the initial mapping relationship is determined, including: Based on the parameter transmission direction between interfaces included in the interface relationship topology diagram, determine the first interface and the second interface; Based on the key-value pairs of the first interface and the key-value pairs of the second interface, the same parameters are determined, and the initial mapping relationship between the first interface and the second interface is determined based on the same parameters.
9. A test case generation device, characterized in that, include: The acquisition unit is used to acquire the recorded traffic of the system under test. The recorded traffic includes the interface call chain executed by the system under test in the process of providing services to the outside world. The interface call chain is used to represent a series of interfaces called by the system under test in response to external triggering operations and the dependencies between the series of interfaces. A mapping unit is used to determine the target mapping relationship in the interface call chain based on the recorded traffic, wherein the target mapping relationship is used to represent the parameters of the first interface as input parameters of the second interface; The test case generation unit is used to generate target test cases according to the target mapping relationship; wherein, when the target test cases are executed, the parameters of the first interface are used as input parameters of the second interface; The mapping unit is specifically used to determine the initial mapping relationship and the probability of the initial mapping relationship in each of the interface call chains of the recorded traffic; wherein, the initial mapping relationship is used to characterize the relationship between the parameters of the first interface and the input parameters of the second interface; the probability is the probability of each initial mapping relationship occurring in multiple mapping relationships where the same parameter is the input parameter of the same interface; and the target mapping relationship in the interface call chain is determined according to the probability of each initial mapping relationship. The mapping unit is further specifically used to determine similar mapping relationships based on each initial mapping relationship, wherein the parameters in each initial mapping relationship in the similar mapping relationship are the same and the second interface for receiving the parameters is the same, while the interface from which the parameters originate is different; and to determine the probability of each initial mapping relationship occurring in the similar mapping relationship.
10. An electronic device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the test case generation method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by the processor, implement the test case generation method as described in any one of claims 1 to 8.
12. A computer program product comprising a computer program that, when executed by a processor, implements the test case generation method according to any one of claims 1-8.