Test case generation method, apparatus, device, medium, and computer program product
Patent Information
- Application Number
- CN202210516695.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-12
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2042-05-12
AI Technical Summary
[0002]在软件开发的相关场景中,通常需要对开发或者修改的软件进行测试,当测试结果符合预期时,才对该软件进行上线发布;在对软件进行测试时,通常需要编写测试用例来对该软件进行测试;现有的方法中,测试用例的编写通常由相关技术人员进行手动编写,效率低下,并且手动编写测试用例可能会存在遗漏,导致该软件的测试用例覆盖不全面,即可能未编写该软件在某些特定场景下所需的测试用例,导致软件在某些特定场景下无法进行测试
[0019]In this embodiment, after obtaining multiple interface tag groups and multiple parameter tag groups, the multiple interface tag groups and multiple parameter tag groups can be traversed to determine the target tag group currently being traversed. Each interface tag group includes at least one interface tag, each parameter tag group includes at least one parameter tag, and the target tag group includes: target interface tags determined from each interface tag group of the multiple interface tag groups, and target parameter tags determined from each parameter tag group of the multiple parameter tag groups. Then, test parameters corresponding to each target parameter tag in the target tag group can be obtained, and target tags can be generated based on the invocation of the interface call methods corresponding to each target interface tag in the target tag group to the test parameters corresponding to the target parameter tags in the target tag group. The target test cases correspond to the groups; where an interface tag corresponds to a functional module in the code to be tested, the interface call method corresponding to a target interface tag is used to generate interface test cases to test the functional module corresponding to that target interface tag, and the target test cases corresponding to the target tag group are used to test the code to be tested based on the test parameters corresponding to each target parameter tag in the target tag group; based on this, multiple target tag groups can be generated that fully cover each interface tag in multiple interface tag groups and each parameter tag in multiple parameter tag groups, and further, target test cases corresponding to each target tag group can be generated as test cases for testing the code to be tested, that is, test cases that fully cover the code to be tested can be generated, which can further improve the accuracy of testing, and there is no need to manually write test cases, which is more efficient.
Smart Images

Figure CN117093468B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a test case generation method, apparatus, device, medium, and computer program product. Background Technology
[0002] In software development scenarios, it is usually necessary to test the developed or modified software. Only when the test results meet expectations will the software be released online. When testing software, test cases are usually written. In existing methods, test cases are usually written manually by relevant technical personnel, which is inefficient and may result in omissions, leading to incomplete test case coverage. That is, test cases required for certain specific scenarios may not be written, making the software untestable in certain scenarios. Summary of the Invention
[0003] This application provides a test case generation method, apparatus, device, medium, and computer program product that can efficiently generate comprehensive test cases.
[0004] On the one hand, embodiments of this application provide a test case generation method, including:
[0005] Obtain multiple interface tag groups and multiple parameter tag groups; each of the multiple interface tag groups includes at least one interface tag, and each of the multiple parameter tag groups includes at least one parameter tag;
[0006] The system iterates through the plurality of interface tag groups and the plurality of parameter tag groups, and determines the target tag group to be traversed from the plurality of interface tag groups and the plurality of parameter tag groups; the target tag group includes: the target interface tag determined from each interface tag group of the plurality of interface tag groups, and the target parameter tag determined from each parameter tag group of the plurality of parameter tag groups;
[0007] Obtain the test parameters corresponding to each target parameter label in the target label group;
[0008] Based on the API call methods corresponding to each target API tag in the target tag group, the test parameters corresponding to the target parameter tags in the target tag group are called, and target test cases corresponding to the target tag group are generated.
[0009] On one hand, embodiments of this application provide a test case generation apparatus, including:
[0010] The acquisition unit is used to acquire multiple interface tag groups and multiple parameter tag groups; each of the multiple interface tag groups includes at least one interface tag, and each of the multiple parameter tag groups includes at least one parameter tag.
[0011] The processing unit is configured to traverse the plurality of interface tag groups and the plurality of parameter tag groups, and determine the target tag group to be traversed from the plurality of interface tag groups and the plurality of parameter tag groups; the target tag group includes: a target interface tag determined from each interface tag group of the plurality of interface tag groups, and a target parameter tag determined from each parameter tag group of the plurality of parameter tag groups;
[0012] The processing unit is also used to obtain the test parameters corresponding to each target parameter label in the target label group;
[0013] The processing unit is further configured to generate target test cases corresponding to the target tag group by calling the test parameters corresponding to the target parameter tags in the target tag group based on the interface calling methods corresponding to each target interface tag in the target tag group.
[0014] On one hand, embodiments of this application provide a test case generation device, characterized in that the test case generation device includes an input interface and an output interface, and further includes:
[0015] A processor, adapted to implement one or more instructions; and,
[0016] A computer storage medium storing one or more instructions adapted to be loaded by the processor and executed by the above-described test case generation method.
[0017] On one hand, this application provides a computer storage medium, characterized in that the computer storage medium stores computer program instructions, which, when executed by a processor, are used to execute the above-mentioned test case generation method.
[0018] On one hand, embodiments of this application provide a computer program product or a computer program, the computer program product including a computer program stored in a computer storage medium; the processor of the test case generation device reads the computer program from the computer storage medium, the processor executes the computer program, causing the test case generation device to execute the above-described test case generation method.
[0019] In this embodiment, after obtaining multiple interface tag groups and multiple parameter tag groups, the multiple interface tag groups and multiple parameter tag groups can be traversed to determine the target tag group currently being traversed. Each interface tag group includes at least one interface tag, each parameter tag group includes at least one parameter tag, and the target tag group includes: target interface tags determined from each interface tag group of the multiple interface tag groups, and target parameter tags determined from each parameter tag group of the multiple parameter tag groups. Then, test parameters corresponding to each target parameter tag in the target tag group can be obtained, and target tags can be generated based on the invocation of the interface call methods corresponding to each target interface tag in the target tag group to the test parameters corresponding to the target parameter tags in the target tag group. The target test cases correspond to the groups; where an interface tag corresponds to a functional module in the code to be tested, the interface call method corresponding to a target interface tag is used to generate interface test cases to test the functional module corresponding to that target interface tag, and the target test cases corresponding to the target tag group are used to test the code to be tested based on the test parameters corresponding to each target parameter tag in the target tag group; based on this, multiple target tag groups can be generated that fully cover each interface tag in multiple interface tag groups and each parameter tag in multiple parameter tag groups, and further, target test cases corresponding to each target tag group can be generated as test cases for testing the code to be tested, that is, test cases that fully cover the code to be tested can be generated, which can further improve the accuracy of testing, and there is no need to manually write test cases, which is more efficient. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application 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 only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram of the structure of a test case generation model provided in an embodiment of this application;
[0022] Figure 2 This is a flowchart illustrating a test case generation method provided in an embodiment of this application;
[0023] Figure 3 This is a schematic diagram illustrating the generation of target test cases corresponding to target tag groups, provided in an embodiment of this application.
[0024] Figure 4This is a flowchart illustrating another test case generation method provided in an embodiment of this application;
[0025] Figure 5 This is a flowchart illustrating another test case generation method provided in an embodiment of this application;
[0026] Figure 6 This is a schematic diagram of another test case generation model provided in an embodiment of this application;
[0027] Figure 7 This is a flowchart illustrating another test case generation method provided in an embodiment of this application;
[0028] Figure 8a This is a flowchart illustrating another test case generation method provided in an embodiment of this application;
[0029] Figure 8b This is a schematic diagram illustrating the generation of test cases in an existing test case generation method provided in an embodiment of this application;
[0030] Figure 9 This is a schematic diagram of the test case generation device provided in the embodiments of this application;
[0031] Figure 10 This is a schematic diagram of the test case generation device provided in the embodiments of this application. Detailed Implementation
[0032] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0033] This application provides a test case generation scheme. After obtaining multiple interface tag groups and multiple parameter tag groups, it iterates through the multiple interface tag groups and multiple parameter tag groups to determine the target tag group to be traversed. Each interface tag group includes at least one interface tag, each parameter tag group includes at least one parameter tag, and the target tag group includes: target interface tags determined from each interface tag group of the multiple interface tag groups, and target parameter tags determined from each parameter tag group of the multiple parameter tag groups. This allows for the acquisition of test cases from the target tag group. The test parameters corresponding to each target parameter tag are generated based on the call methods of the interface call methods corresponding to each target interface tag in the target tag group to the test parameters corresponding to the target parameter tags in the target tag group. This generates target test cases for the target tag group. Furthermore, it can generate multiple target tag groups that fully cover each interface tag in multiple interface tag groups and each parameter tag in multiple parameter tag groups. In other words, it can generate test cases that fully cover each interface tag in multiple interface tag groups and each parameter tag in multiple parameter tag groups.
[0034] For example, if we obtain two interface tag groups, interface tag group 1 and interface tag group 2, and interface tag group 1 contains 3 interface tags (A1, A2, A3), and interface tag group 2 contains 3 interface tags (B1, B2, B3); and if we obtain 3 parameter tag groups, parameter tag group 1, parameter tag group 2, and parameter tag group 3, and parameter tag group 1 contains 2 parameter tags (a1, a2), parameter tag group 2 contains 3 parameter tags (b1, b2, b3), and parameter tag group 3 contains 4 parameter tags (c1, c2, c3, c4); then by traversing these two interface tag groups and these three parameter tag groups, we can obtain a complete coverage of each interface tag in the two interface tag groups and each parameter tag in the three parameter tag groups. Each target label group can be used to generate target test cases corresponding to each target label group.
[0035] In its specific implementation, the test case generation scheme proposed in this application can be executed by a test case generation device, which can be a terminal device or a server. The terminal device here can include, but is not limited to, computers, smartphones, tablets, laptops, smart voice interaction devices, smart home appliances, vehicle terminals, smart wearable devices, etc. The server here can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0036] In one embodiment, the test case generation scheme proposed in this application can be used to generate test cases for testing code to be tested. The code to be tested can be code used to implement any legal function, such as code used to implement resource transfer function (i.e., electronic payment function) in a resource transfer scenario (i.e., electronic payment scenario), or code used to implement facial recognition function in a facial recognition scenario. For ease of explanation, the embodiments of this application will subsequently describe the code to be tested as code used to implement resource transfer function in a resource transfer scenario. Furthermore, the multiple interface tag groups and multiple parameter tag groups obtained by the test case generation device can be multiple interface tag groups and multiple parameter tag groups obtained by the test case generation device in advance through analysis of each functional module of the code to be tested. That is, multiple interface tag groups and multiple parameter tag groups corresponding to the code to be tested can be obtained through analysis of each functional module of the code to be tested, and then test cases for full coverage testing of the code to be tested can be generated based on the multiple interface tag groups and multiple parameter tag groups corresponding to the code to be tested. Optionally, the acquired multiple interface tag groups and multiple parameter tag groups can be input by the target object. That is, after the test case generation device obtains the multiple interface tag groups and multiple parameter tag groups corresponding to the code under test based on the analysis of each functional module of the code under test, it can output the multiple interface tag groups and multiple parameter tag groups corresponding to the code under test so that the target object can understand each interface tag in the multiple interface tag groups and each parameter tag in the multiple parameter tag groups corresponding to the code under test, and input the test parameters corresponding to each parameter tag in the multiple parameter tag groups so that the test case generation device can generate test cases to test the code under test based on the test parameters corresponding to each parameter tag in the acquired multiple parameter tag groups; wherein, the target object can be any legitimate user.
[0037] In one embodiment, among the functional modules of the code to be tested, one functional module corresponds to one interface tag and one functional module corresponds to one interface call method. The interface call method corresponding to the functional module can be used to indicate the generation logic of the interface test case corresponding to the functional module, and can be used to generate interface test cases for testing the functional module. Optionally, the interface call method corresponding to the functional module can be written by a technician. The interface tag corresponding to the functional module can be set by a technician or created by a test case generation device. The code modules corresponding to each interface tag in any interface tag group within multiple interface tag groups are used to implement the same function. For example, if the code to be tested is used to implement the resource transfer function, and the code to be tested includes 6 functional modules, namely functional module 1, functional module 2, functional module 3, functional module 4, functional module 5, and functional module 6, if functional modules 1, 2, and 3 are used to implement the function of transferring resources from different ways, and functional modules 4, 5, and 6 are used to implement the function of generating orders from different ways, then functional modules 1, 2, and 3 can be considered to implement the same function, only with different implementation methods, and functional modules 4, 5, and 6 can be considered to implement the same function, namely the order generation function, only with different order generation methods.
[0038] In one embodiment, parameter tags corresponding to the same interface tag group can be obtained based on parameter analysis of the functional modules corresponding to each interface tag in the same interface tag group. In a feasible implementation, the common input parameters of the functional modules corresponding to each interface tag in the same interface tag group can be used as common input parameters of the functional modules corresponding to each interface tag in the same interface tag group, and the parameter tags of the common input parameters can be determined to identify each common input parameter. Further, the parameter tags corresponding to the same interface tag group can be classified according to parameter type to obtain one or more parameter tag groups corresponding to the same interface tag group, wherein the parameter types of the parameter tags included in different parameter tag groups are different. That is to say, in the process of generating test cases for the code to be tested based on test parameters, the required test parameters are the same for the functional modules corresponding to different interface tags in a certain interface tag group.
[0039] In one embodiment, this application proposes a test case generation model to implement the test case generation scheme proposed in this application. The test case generation model proposed in this application may include a call layer, a scenario concatenation layer, and a business logic layer. The call layer is used to traverse multiple interface tag groups and multiple parameter tag groups, and determine the target tag group currently being traversed from these groups. The business logic layer is used to obtain the test parameters corresponding to each target parameter tag in the target tag group and send these test parameters to the scenario concatenation layer. The scenario concatenation layer may include interface call methods corresponding to each interface tag in the multiple interface tag groups. This layer receives the target tag group sent by the call layer and, through the interface call methods corresponding to each target interface tag in the target tag group included in the scenario concatenation layer, calls the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer to generate target test cases corresponding to the target tag group. In other words, after receiving multiple interface tag groups and multiple parameter tag groups, the test case generation device can iterate through these groups via the call layer in the test case generation model to obtain the currently iterated target tag group, and then send the target tag group to the scenario concatenation layer. Upon receiving the target tag group from the call layer, the scenario concatenation layer can use the interface call methods corresponding to each target interface tag in the target tag group to call the test parameters corresponding to the target parameter tags obtained from the business logic layer, thereby generating the target test cases corresponding to the target tag group. In this case, the test parameters corresponding to the target parameter tags in the target tag group can be input from the target object; the business logic layer plays the role of parameter passing.
[0040] Furthermore, when the test case generation scheme proposed in this application is applied in complex scenarios such as resource transfer scenarios, the parameters processed by each functional module in the code to be tested may be parameters obtained after parameter conversion of user input parameters, such as parameters obtained after encrypting user input parameters. Therefore, based on the characteristics of the code to be tested in the resource transfer scenario, during the process of generating test cases for the code to be tested, the test parameters corresponding to each target parameter tag in the target tag group should be parameters obtained after encrypting the original parameters input by the target object. At this time, the parameter encryption operation can be implemented by the business logic layer. In this case, the business logic layer can include parameter encryption methods corresponding to each parameter tag in multiple parameter tag groups. The parameter encryption method corresponding to a parameter tag is used to encrypt the original parameters corresponding to that parameter tag input by the target object. Optionally, the parameter encryption methods corresponding to each parameter tag can be written by technical personnel.
[0041] See Figure 1 This is a schematic diagram of a test case generation model provided in this application embodiment. After receiving the original parameters corresponding to each parameter tag in multiple parameter tag groups input by the target object, the business logic layer can further encrypt the original parameters corresponding to each parameter tag in multiple parameter tag groups using the parameter encryption methods included in the business logic layer, to obtain the test parameters corresponding to each parameter tag in multiple parameter tag groups. After receiving multiple interface tag groups and multiple parameter tag groups, the interface layer can traverse the multiple interface tag groups and multiple parameter tag groups through the calling layer to obtain the target tag group currently being traversed, and send the target tag group to the scenario concatenation layer. After receiving the target tag group sent by the calling layer, the scenario concatenation layer can call the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer using the interface calling methods corresponding to each target interface tag in the target tag group included in the scenario concatenation layer, to generate the target test cases corresponding to the target tag group.
[0042] In another feasible implementation, after the interface layer receives multiple interface tag groups and multiple parameter tag groups, the calling layer can traverse these groups to obtain the current target tag group and send it to the scenario concatenation layer. Upon receiving the target tag group from the calling layer, the scenario concatenation layer can send a test parameter retrieval request to the business logic layer using the interface call methods corresponding to each target interface tag in the target tag group. This request requests the return of the test parameters corresponding to each target parameter tag in the target tag group. Upon receiving the test parameter retrieval request, the business logic layer can encrypt the original parameters corresponding to each target parameter tag in the target tag group using the parameter encryption methods corresponding to each target parameter tag in the target tag group. This encrypts the test parameters corresponding to each target parameter tag in the target tag group and returns them to the interface call methods corresponding to each target interface tag in the target tag group within the scenario concatenation layer. This allows for the invocation of the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer, thereby generating target test cases corresponding to the target tag group. By using a layered design to generate test cases, the model achieves high cohesion and low coupling. Business logic is maintained in one place and called in multiple places, meaning test parameters are maintained in one place and called in multiple places, reducing maintenance costs.
[0043] It is worth noting that the test case generation model proposed above is only one implementation of the test case generation method proposed in this application. Figure 1The various layers in the test case generation model shown can be individually or completely merged into one or more other layers, or some of the layers can be further divided into multiple functionally smaller layers. This can achieve the same operation without affecting the technical effect of the embodiments of this application. For example, the test case generation method proposed in this application can be implemented through only one scenario concatenation layer.
[0044] It should be noted that in the specific implementation of this application, user-related data (such as test parameters input by the target object) are involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with local laws, regulations and standards.
[0045] Based on the above test case generation scheme, this application provides a test case generation method. See also... Figure 2 This is a flowchart illustrating a test case generation method provided in an embodiment of this application. Figure 2 The test case generation method shown can be executed by the test case generation device. Figure 2 The test case generation method shown may include the following steps:
[0046] S201, obtain multiple interface tag groups and multiple parameter tag groups.
[0047] In one embodiment, any interface tag group among multiple interface tag groups includes at least one interface tag, and any parameter tag group among multiple parameter tag groups includes at least one parameter tag. The multiple interface tag groups and multiple parameter tag groups are used to generate test cases for testing the code to be tested. The multiple interface tag groups and multiple parameter tag groups correspond to the code to be tested, and the multiple interface tag groups and multiple parameter tag groups corresponding to different codes to be tested may be different. In each functional module of the code to be tested, one functional module corresponds to one interface tag, and one functional module corresponds to one interface call method. The interface call method corresponding to a functional module can be used to indicate the generation logic of the interface test cases corresponding to that functional module, i.e., the generation logic of the interface test cases used to test that functional module. The interface call method corresponding to a functional module can also be maintained through the interface tag corresponding to that functional module. The code modules corresponding to the various interface tags included in any interface tag group among the multiple interface tag groups are used to implement the same function. One interface tag group among the multiple interface tag groups corresponds to one or more parameter tag groups. That is, in the process of generating test cases for the code to be tested based on test parameters, the required test parameters are the same for functional modules corresponding to different interface tags in a certain interface tag group. Optionally, multiple interface tag groups and multiple parameter tag groups can be input from a target object, which can be any legitimate user.
[0048] S202, traverse multiple interface tag groups and multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and multiple parameter tag groups.
[0049] The target tag group includes: target interface tags determined from each of the multiple interface tag groups, and target parameter tags determined from each of the multiple parameter tag groups. For example, if two interface tag groups are obtained, namely interface tag group 1 and interface tag group 2, and interface tag group 1 includes 3 interface tags, namely A1, A2, and A3, and interface tag group 2 includes 3 interface tags, namely B1, B2, and B3; and three parameter tag groups are obtained, namely parameter tag group 1, parameter tag group 2, and parameter tag group 3, and parameter tag group 1 includes 2 parameter tags, namely a1 and a2, parameter tag group 2 includes 3 parameter tags, namely b1, b2, and b3, and parameter tag group 3 includes 4 parameter tags, namely c1, c2, c3, and c4; then by traversing the two interface tag groups and the three parameter tag groups, a complete coverage of each interface tag in the two interface tag groups and each parameter tag in the three parameter tag groups can be obtained. There are several target label groups. The target label group being traversed can be "A1, B1, a1, b1, c1", "A2, B1, a1, b1, c1", "A3, B1, a1, b1, c1", "A1, B2, a1, b1, c1", and so on.
[0050] S203, obtain the test parameters corresponding to each target parameter label in the target label group.
[0051] In one embodiment, the test parameters corresponding to each target parameter label in the target label group can be input by the target object; specifically, the test case generation device can filter the test parameters corresponding to each target parameter label in the target label group from the test parameters corresponding to each parameter label in the multiple parameter label groups input by the target object.
[0052] In one embodiment, when the test case generation method proposed in this application is applied in complex scenarios such as resource transfer scenarios, the parameters processed by each functional module in the code to be tested may be parameters obtained after parameter conversion of user input parameters, such as parameters obtained after encrypting user input parameters. Therefore, based on the characteristics of the code to be tested in the resource transfer scenario, during the process of generating test cases for the code to be tested, the test parameters corresponding to each target parameter label in the target label group should be parameters obtained after encrypting the original parameters input by the target object. Based on this, in one feasible implementation, before obtaining the test parameters corresponding to each target parameter label in the target label group, the test case generation device can obtain the original parameters corresponding to each parameter label in multiple parameter label groups; based on the parameter encryption method corresponding to each parameter label in multiple parameter label groups, the original parameters corresponding to each parameter label in multiple parameter label groups are encrypted respectively to obtain the test parameters corresponding to each parameter label in multiple parameter label groups; thus enabling the test case generation device to filter out the test parameters corresponding to each target parameter label in the target label group from the obtained test parameters corresponding to each parameter label in multiple parameter label groups when obtaining the test parameters corresponding to each target parameter label in the target label group.
[0053] In another feasible implementation, the test case generation device obtains the test parameters corresponding to each target parameter label in the target label group, which may include: obtaining the original parameters corresponding to each target parameter label in the target label group; and encrypting the original parameters corresponding to each target parameter label in the target label group based on the parameter encryption method of each target parameter label in the target label group to obtain the test parameters corresponding to each target parameter label in the target label group. In other words, after obtaining the original parameters corresponding to each parameter label in multiple parameter label groups input by the target object, the test case generation device can determine the original parameters corresponding to each target parameter label in the target label group from the original parameters corresponding to each parameter label in the multiple parameter label groups, and encrypt the original parameters corresponding to each target parameter label in the target label group based on the corresponding parameter encryption method to obtain the test parameters corresponding to each target parameter label in the target label group.
[0054] S204, Based on the API call methods corresponding to each target API tag in the target tag group, the test parameters corresponding to the target parameter tags in the target tag group are called, and target test cases corresponding to the target tag group are generated.
[0055] In one embodiment, the interface invocation method corresponding to a target interface tag can be used to indicate the logic for generating interface test cases for the functional module corresponding to the target interface tag. This logic can be used to generate interface test cases for testing the functional module corresponding to the target interface tag. Specifically, the test case generation device generates target test cases for the target tag group by invoking the test parameters corresponding to the target parameter tags in the target tag group based on the interface invocation methods corresponding to each target interface tag in the target tag group. This can include: for any target interface tag in the target tag group, determining the parameter tag group corresponding to any target interface tag based on the correspondence between multiple interface tag groups and multiple parameter tag groups; obtaining the target parameter tag determined from the parameter tag group corresponding to any target interface tag from each target parameter tag in the target tag group; generating interface test cases corresponding to any target interface tag based on the invocation method corresponding to the obtained target parameter tag; and combining the interface test cases corresponding to each target interface tag in the target tag group to obtain the target test cases corresponding to the target tag group. In other words, since one of the multiple interface tag groups corresponds to one or more parameter tag groups, the test parameters required for the functional modules corresponding to different interface tags in a certain interface tag group are the same when generating test cases for the code to be tested based on test parameters. Therefore, in the process of generating target test cases for the target tag group based on the target tag group, it is necessary to obtain the test parameters required by the interface call methods corresponding to different target interface tags in the target tag group from the test parameters corresponding to each target parameter tag in the target tag group. Then, based on the interface call methods corresponding to each target interface tag in the target tag group, the test parameters corresponding to the obtained target parameter tags are called to generate interface test cases for each target interface tag.
[0056] For example, see Figure 3 This is a schematic diagram illustrating the generation of target test cases corresponding to target tag groups provided in an embodiment of this application. If two interface tag groups are obtained, namely interface tag group 1 and interface tag group 2, if interface tag group 1 includes 3 interface tags, namely A1, A2, and A3, and interface tag group 2 includes 3 interface tags, namely B1, B2, and B3; if three parameter tag groups are obtained, namely parameter tag group 1, parameter tag group 2, and parameter tag group 3, if parameter tag group 1 includes 2 parameter tags, namely a1 and a2, and parameter tag group 2 includes 3 parameter tags, namely b1, b2, and b3, and parameter tag group 3 includes 4 parameter tags, namely c1, c2, c3, and c4, the obtained multiple interface tag groups and multiple parameter tag groups are... Figure 3The representation is as {[A1, A2, A3], [B1, B2, B3], [a1, a2], [b1, b2, b3], [c1, c2, c3, c4]}; if the correspondence between multiple interface tag groups and multiple parameter tag groups indicates that: interface tag group 1 corresponds to parameter tag group 1, interface tag group 2 corresponds to parameter tag group 2 and parameter tag group 3, and if the target tag group being traversed is "A1, B1, a1, b1, c1", then... Figure 3 If the target interface label is represented as [A1+B1+a1+b1+c1], then for the target interface label A1, the target parameter label determined from the parameter label group corresponding to the target interface label A1 is obtained from the target parameter labels of the target label group. For the target interface label A2, the target parameter labels determined from the parameter label group corresponding to the target interface label A2 are obtained from the target parameter labels of the target label group. Furthermore, the test case generation device can generate interface test cases corresponding to each target interface label by calling the test parameters corresponding to the obtained target parameter labels based on the interface calling method corresponding to each target interface label. Specifically, the test case generation device can call the test parameters corresponding to the obtained target parameter labels based on the interface calling method corresponding to the target interface label A1, that is, call the test parameters corresponding to a1 to generate interface test cases corresponding to the target interface label A1. It can also call the test parameters corresponding to the obtained target parameter labels based on the interface calling method corresponding to the target interface label B1, that is, call the test parameters corresponding to b1 and c1 to generate interface test cases corresponding to the target interface label B1. Since the target test cases corresponding to the target tag group are generated by calling the test parameters corresponding to the target parameter tags in the target tag group through the interface call methods corresponding to each target interface tag in the target tag group, the code of the target test cases corresponding to the target interface tags in different target tag groups is similar and the code style is consistent when the target interface tags included in different target tag groups are the same but the target parameter tags are different. The differences only occur in the part involving test parameters.
[0057] In this embodiment, after obtaining multiple interface tag groups and multiple parameter tag groups, the multiple interface tag groups and multiple parameter tag groups can be traversed to determine the target tag group currently being traversed. Each interface tag group includes at least one interface tag, each parameter tag group includes at least one parameter tag, and the target tag group includes: target interface tags determined from each interface tag group of the multiple interface tag groups, and target parameter tags determined from each parameter tag group of the multiple parameter tag groups. Then, test parameters corresponding to each target parameter tag in the target tag group can be obtained, and target tags can be generated based on the invocation of the interface call methods corresponding to each target interface tag in the target tag group to the test parameters corresponding to the target parameter tags in the target tag group. The target test cases correspond to the groups; where an interface tag corresponds to a functional module in the code to be tested, the interface call method corresponding to a target interface tag is used to generate interface test cases to test the functional module corresponding to that target interface tag, and the target test cases corresponding to the target tag group are used to test the code to be tested based on the test parameters corresponding to each target parameter tag in the target tag group; based on this, multiple target tag groups can be generated that fully cover each interface tag in multiple interface tag groups and each parameter tag in multiple parameter tag groups, and further, target test cases corresponding to each target tag group can be generated as test cases for testing the code to be tested, that is, test cases that fully cover the code to be tested can be generated, which can further improve the accuracy of testing, and there is no need to manually write test cases, which is more efficient.
[0058] Based on the above embodiments, this application provides another method for generating test cases. See also Figure 4 This is a flowchart illustrating another test case generation method provided in an embodiment of this application. Figure 4 The test case generation method shown can be executed by the test case generation device. Figure 4 The test case generation method shown may include the following steps:
[0059] S401, obtain multiple interface tag groups and multiple parameter tag groups.
[0060] Among them, any interface tag group in the multiple interface tag groups includes at least one interface tag, and any parameter tag group in the multiple parameter tag groups includes at least one parameter tag.
[0061] In one embodiment, the multiple interface tag groups and the multiple parameter tag groups can be input by the target object. The tag format of each interface tag in the multiple interface tag groups and each parameter tag in the multiple parameter tag groups can be a first format. That is, the target object can input multiple interface tag groups and multiple parameter tag groups in the first format. In one feasible implementation, to accommodate users with different language habits, the user-inputted multiple initial interface tag groups and multiple initial parameter tag groups in a second format can be converted to obtain multiple interface tag groups and multiple parameter tag groups in a first format. In this case, the test case generation device obtains the multiple interface tag groups and multiple parameter tag groups, which may include: obtaining multiple initial interface tag groups and multiple initial parameter tag groups; each initial interface tag group in the multiple initial interface tag groups includes at least one initial interface tag, each initial parameter tag group in the multiple initial parameter tag groups includes at least one initial parameter tag, and the tag format of each initial interface tag in the multiple initial interface tag groups and each initial parameter tag in the multiple initial parameter tag groups is in the second format; based on a preset mapping relationship, each initial interface tag in the multiple initial interface tag groups in the second format is mapped to an interface tag in the first format, and each initial parameter tag in the multiple initial parameter tag groups in the second format is mapped to a parameter tag in the first format, thereby obtaining the interface tag groups corresponding to each initial interface tag group in the multiple initial interface tag groups and the parameter tag groups corresponding to each initial parameter tag group in the multiple initial parameter tag groups. The first format and the second format can be different language formats. The first and second formats can be set according to specific needs, and the mapping relationship between each initial interface tag in the multiple initial interface tag groups of the second format and each interface tag in the multiple interface tag groups of the first format, as well as the mapping relationship between each initial parameter tag in the multiple initial parameter tag groups of the second format and each parameter tag in the multiple parameter tag groups of the first format, can be defined. For example, if a functional module of the code to be tested is used to implement cash payment, and the interface tag of the first format corresponding to this functional module is set to "banpay", and the initial interface tag of the second format corresponding to this functional module is set to "cash payment", then after receiving the initial interface tag "cash payment" input by the user, the test case generation device will map the initial interface tag "cash payment" to "banpay", and then generate test cases based on the interface tag of the second format. By setting the initial interface tags of the second format corresponding to each interface tag in the multiple interface tag groups of the first format, and setting the initial parameter tags corresponding to each parameter tag in the multiple parameter tag groups of the first format, it is convenient for users with different language habits to use.
[0062] S402, traverse multiple interface tag groups and multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and multiple parameter tag groups.
[0063] The target tag group includes: target interface tags determined from each of the multiple interface tag groups, and target parameter tags determined from each of the multiple parameter tag groups; the relevant process of step S402 is similar to the relevant process of step S202 above, and will not be repeated here.
[0064] S403, detect the running logic indicated by each target interface label and each target parameter label in the target label group.
[0065] S404 If the running logic indicated by each target interface label and each target parameter label in the target label group is normal, then trigger the execution to obtain the test parameters corresponding to each target parameter label in the target label group.
[0066] In steps S403 to S404, the running logic indicated by each target interface label and each target parameter label in the target label group is normally represented, and the functional modules corresponding to each target interface label in the target label group will not have logical conflicts when processing the test parameters corresponding to each target parameter label in the target label group. For example, if two interface tag groups are obtained, namely interface tag group 1 and interface tag group 2, and interface tag group 1 includes 3 interface tags, namely A1, A2, and A3, and interface tag group 2 includes 3 interface tags, namely B1, B2, and B3; if three parameter tag groups are obtained, namely parameter tag group 1, parameter tag group 2, and parameter tag group 3, and parameter tag group 1 includes 2 parameter tags, namely a1 and a2, parameter tag group 2 includes 3 parameter tags, namely b1, b2, and b3, and parameter tag group 3 includes 4 parameter tags, namely c1, c2, c3, and c4, the obtained multiple interface tag groups and multiple parameter tag groups are represented as {[A1, A2, A3], [B1, B2, B3], [a1, a2], [b1, b2, b3], [c1, c2, c3, c4]}; if multiple interface tag groups and multiple parameter tag groups are obtained... The correspondence between the number tag groups indicates that interface tag group 1 corresponds to parameter tag group 1, and interface tag group 2 corresponds to parameter tag group 2 and parameter tag group 3. If the execution logic of the code to be tested indicates that a logical conflict will occur when the code to be tested processes the test parameter corresponding to parameter tag b3 and the test parameter corresponding to parameter tag c4 at the same time, then if the combination of target parameter tags in the currently traversed target tag group includes the combination of b3 and c4 (e.g., target tag groups "A1, B1, a1, b3, c4", "A2, B1, a1, b3, c4", "A3, B1, a1, b3, c4", "A1, B2, a1, b3, c4", etc.), the execution logic indicated by the target tag group will be considered abnormal. Optionally, the test case generation device can output a prompt message at this time to indicate that no target test case has been generated for the target tag group. In practice, the test case generation device can determine whether the running logic indicated by each target interface tag and each target parameter tag in the target tag group is normal according to the preset judgment rules. The preset judgment rules can be set according to the running logic of the code to be tested.
[0067] S405, Based on the API call methods corresponding to each target API tag in the target tag group, the test parameters corresponding to the target parameter tags in the target tag group are called, and target test cases corresponding to the target tag group are generated.
[0068] The process of step S405 is similar to that of step S204 above, and will not be described again here.
[0069] In one embodiment, after the test case generation device generates target test cases corresponding to the target tag group, it can output the target test cases corresponding to the target tag group so that the target object can understand the target test cases corresponding to the target tag group. Furthermore, the test case generation device can use the target test cases corresponding to the target tag group to test the code to be tested and obtain the test results of the code to be tested based on the target tag group. Even further, it can output the test results of the code to be tested based on the target tag group so that the target object can understand the test results of the code to be tested based on the target tag group.
[0070] In one embodiment, the target object may also partially input multiple interface tag groups and multiple parameter tag groups, so that the test case generation device can generate test cases based on the specific input of the target object. For example, if two interface tag groups are obtained based on the analysis of each functional module in the code to be tested, namely interface tag group 1 and interface tag group 2, interface tag group 1 includes 3 interface tags, namely A1, A2, and A3, and interface tag group 2 includes 3 interface tags, namely B1, B2, and B3; if three parameter tag groups are obtained based on the analysis of each functional module in the code to be tested, namely parameter tag group 1, parameter tag group 2, and parameter tag group 3, and if parameter tag group 1 includes 2 parameter tags, namely a1 and a2, and parameter tag group 2 includes 3 parameter tags... The tags are b1, b2, and b3. If parameter tag group 3 includes 4 parameter tags, c1, c2, c3, and c4, then the target object can input partial interface tag groups and partial parameter tag groups such as {[A1, A2], [B1, B3], [a1, a2], [b1, b2], [c1, c2, c3]} and {[A1, A2, A3], [B1], [a1, a2], [b1, b2, b3], [c1, c2]}. The test case generation device can generate test cases based on the specific input of the target object.
[0071] In one embodiment, the test case generation device can generate target test cases corresponding to a specified tag group based on a specified tag group input by the target object. Specifically, the test case generation device can receive a test request input by the target object; the test request carries a specified tag group, which includes: a specified interface tag determined from each of multiple interface tag groups, and a specified parameter tag determined from each of multiple parameter tag groups; obtain the target test case corresponding to the specified tag group; and use the target test case corresponding to the specified tag group to test the code to be tested, obtaining the test result of the code to be tested based on the specified tag group. The process of the test case generation device obtaining the target test case corresponding to the specified tag group is similar to the process of the test case generation device generating the target test case corresponding to the currently traversed target tag group, and will not be repeated here. Optionally, if the test case generation device receives a test request input by the target object after traversing multiple interface tag groups and multiple parameter tag groups and obtaining target test cases corresponding to multiple target tag groups, the test case generation device can obtain the target test case corresponding to the specified tag group from the target test cases corresponding to the multiple target tag groups.
[0072] In this embodiment, after obtaining multiple interface tag groups and multiple parameter tag groups, the multiple interface tag groups and multiple parameter tag groups can be traversed to determine the target tag group to be traversed. Each interface tag group in the multiple interface tag groups includes at least one interface tag, each parameter tag group in the multiple parameter tag groups includes at least one parameter tag, and the target tag group includes: target interface tags determined from each interface tag group in the multiple interface tag groups, and target parameter tags determined from each parameter tag group in the multiple parameter tag groups. Furthermore, the execution logic indicated by each target interface tag and each target parameter tag in the target tag group can be detected. Under the condition that the running logic indicated by each target interface label and each target parameter label in the target label group is normal, the test parameters corresponding to each target parameter label in the target label group are obtained. Furthermore, based on the interface call methods corresponding to each target interface label in the target label group, the test parameters corresponding to the test parameters in the target parameter label group are called, and target test cases corresponding to the target label group are generated. This can avoid the process of generating target test cases for the target label group even when the running logic indicated by each target interface label and each target parameter label in the target label group is abnormal. It can save computing resources and improve the efficiency and speed of test case generation.
[0073] Based on the above embodiments, this application provides another method for generating test cases. See also Figure 5This is a flowchart illustrating another test case generation method provided in an embodiment of this application. Figure 5 The test case generation method shown can be executed by the test case generation device. Figure 5 The test case generation method shown may include the following steps:
[0074] S501, construct the interface tags for each functional module in the code to be tested, and build multiple interface tag groups based on the interface tags of each functional module in the code to be tested.
[0075] Among them, the code modules corresponding to each interface tag in any interface tag group in the multiple interface tag groups are used to implement the same function.
[0076] In one embodiment, if the code to be tested is code used to implement resource transfer functionality, by analyzing the code, the functional modules used to implement resource transfer functionality from different sources can be grouped together, and then the interface tags corresponding to the functional modules used to implement resource transfer functionality from different sources can be grouped together as an interface tag group; similarly, the functional modules used to implement order generation functionality from different sources can be grouped together, and then the interface tags corresponding to the functional modules used to implement order generation functionality from different sources can be grouped together as an interface tag group; for example, if the functional modules used to implement resource transfer functionality from different sources are: a balance payment module, a quick payment module, and a balance transfer payment module... The functional modules are labeled as follows: banpay, fpay, lqtpay. The functional modules used to generate orders from different sources are: large order module, public order module, and combined order module, with corresponding interface tags: plat_public_api, public_api, plat_preorder. Therefore, in the two resulting interface tag groups, interface tag group 1 includes: banpay, fpay, lqtpay, and interface tag group 2 includes: plat_public_api, public_api, plat_preorder. Furthermore, to accommodate users with different language habits, a mapping relationship can be established between the first format interface tags and the second format initial interface tags. If the second format is set to Chinese, then the corresponding initial interface tags in the second format for each interface tag in interface tag group 1, such as banpay, fpay, and lqtpay, can be: Lingqian Payment, Quick Payment, and Lingqiantong Payment. Similarly, the corresponding initial interface tags in the second format for each interface tag in interface tag group 2, such as plat_public_api, public_api, and plat_preorder, can be: Dadan Shidan, Gongfu Shidan, and Hedan Shidan.
[0077] S502, for any interface tag group among multiple interface tag groups, based on the parameter analysis of the functional modules corresponding to each interface tag in any interface tag group, obtain the parameter tag corresponding to any interface tag group.
[0078] In one embodiment, when the test case generation device analyzes the parameters of the functional modules corresponding to each interface tag in a given interface tag group, it can determine the parameter tags for that interface tag group based on parameter analysis of the functional modules corresponding to each interface tag in that interface tag group. The common input parameters of the functional modules corresponding to each interface tag in that interface tag group can be used as the common input parameters of the functional modules corresponding to each interface tag in that interface tag group, thus identifying the parameter tags of these common input parameters. Furthermore, to accommodate users with different language habits, a mapping relationship between parameter tags in a first format and initial parameter tags in a second format can be constructed. If the second format is set to Chinese, and if the code to be tested is code used to implement resource transfer functionality, taking interface tag group 1 (i.e., the functional module used to implement resource transfer from different methods) as an example, if the common input parameters of the balance payment module, quick payment module, and balance transfer module are respectively: parameters of verification type: parameters for password verification, parameters for fingerprint verification in iOS system, and parameters for fingerprint verification in Android system... Parameters for verifying facial information, parameters for password-free payment; parameters of SMS verification type: parameters for SMS verification, parameters for SMS-free payment verification; parameters of Intimate Payment type: parameters for Intimate Payment, parameters for Non-Intimate Payment; parameters of user type: parameters indicating that the user is an unregistered user, parameters indicating that the user has not bound a card, parameters indicating that the user has bound a card, parameters indicating that the user is an unregistered user abroad, parameters indicating that the user is an unbound user abroad, parameters indicating that the user is an unbound user abroad, parameters indicating that the user is a bound user abroad; the parameter tags of the first format corresponding to the obtained interface tag group, and the initial parameter tags of the corresponding second format can be shown in Table 1 below.
[0079] Table 1
[0080]
[0081] S503, classify the parameter tags corresponding to any interface tag group according to the parameter type to obtain one or more parameter tag groups corresponding to any interface tag group.
[0082] In steps S502 to S503, the parameter types of the parameter tags included in different parameter tag groups are different. For each interface tag shown in Table 1 above, each parameter tag can be classified according to the parameter type as verification type, verification SMS type, intimate payment type and user type, to obtain the four parameter tag groups corresponding to the interface tag group.
[0083] In one embodiment, after obtaining the interface call methods corresponding to each functional module in the code to be tested, the test case generation device can encapsulate the interface call methods of each functional module and store the encapsulated interface call methods in the scenario concatenation layer of the test case generation model. The encapsulated interface call methods of each functional module can be maintained based on the interface tags corresponding to each functional module. After obtaining the parameter encryption methods corresponding to each parameter tag, the test case generation device can encapsulate the parameter encryption methods corresponding to each parameter tag and store the encapsulated parameter encryption methods corresponding to each parameter tag in the business logic layer of the test case generation model. The encapsulated parameter encryption methods corresponding to each parameter tag can be maintained based on each parameter tag. The parameter encryption methods corresponding to each parameter tag can be used to encrypt the original parameters corresponding to each input parameter tag to obtain the test parameters corresponding to each parameter tag that can be invoked by the interface call methods. Optionally, the scenario concatenation layer can be divided into a service layer and a client layer. The interface call methods corresponding to each functional module can be stored in the client layer of the scenario concatenation layer and called by the service layer. Specifically, the interface call methods corresponding to each target interface tag in the target tag group included in the scenario concatenation layer are called to invoke the test parameters obtained from the business logic layer. The generated interface test cases corresponding to each target interface tag are combined to obtain the target test cases corresponding to the target tag group. Further, optionally, the parameter encryption method corresponding to each parameter tag, in addition to encrypting the original parameters corresponding to each parameter tag, can also encapsulate other functional methods. For example, it can encapsulate a parameter validation method for verifying the original parameters corresponding to each input parameter tag, and a packet sending method for sending the test parameters corresponding to each parameter tag obtained by encrypting the original parameters to the scene concatenation layer. Optionally, the common methods in the parameter encryption method, parameter validation method, and packet sending method can be automatically generated by the test case generation device. By separating the business logic layer, which includes parameter encryption methods for encrypting raw user input parameters, and dividing the parameter encryption methods corresponding to each parameter label according to parameter type, rapid parameter expansion can be achieved. For example, if a new test parameter needs to be added, only a corresponding parameter encryption method needs to be added to the business logic layer, and a parameter label needs to be added for maintenance, reducing the cost of modification.
[0084] See Figure 6This is a schematic diagram of another test case generation model provided in this application embodiment. This test case generation model is adaptably applicable to resource transfer scenarios. The test case generation model may include a call layer, a scenario concatenation layer, and a business logic layer. The scenario concatenation layer is specifically divided into a service layer and a terminal layer. The call layer is used to traverse multiple interface tag groups and multiple parameter tag groups, and determine the target tag group to be traversed from these groups. The business logic layer includes parameter encryption methods corresponding to each parameter tag in the multiple parameter tag groups. The original parameters corresponding to each target parameter tag in the target tag group can be encrypted using the parameter encryption methods corresponding to each target parameter tag in the target tag group to obtain the parameters in the target tag group. The test parameters corresponding to each target parameter label are sent to the scenario concatenation layer. The terminal layer of the scenario concatenation layer can include the interface call methods corresponding to each interface label in multiple interface label groups. The scenario concatenation layer is used to receive the target label group sent by the call layer, and through the interface call methods corresponding to each target interface label in the target label group included in the terminal layer of the scenario concatenation layer, it calls the test parameters corresponding to the target parameter labels in the target label group obtained from the business logic layer, generates interface test cases corresponding to each target interface label, and then combines the interface test cases corresponding to each target interface label generated in the terminal layer through the service layer of the scenario concatenation layer to obtain the target test cases corresponding to the target label group.
[0085] Furthermore, the test case generation model can also include a data persistence layer, a public method layer, a request sending layer, a protocol layer (also known as an external link layer), and a business domain layer. The protocol layer can include an interface protocol for reading the original parameters corresponding to each parameter tag in the multiple parameter tag groups input by the target object. The request sending layer includes initialization methods for request classes, response classes, etc., for initializing the original parameters corresponding to each parameter tag in the multiple parameter tag groups to the request class or response class, so that the original parameters corresponding to each parameter tag in the multiple parameter tag groups can be invoked by the business logic layer through the request class or response class. The common method layer includes common methods applicable to specific business scenarios. For example, in the resource transfer scenario, it includes common business methods in the resource transfer domain (i.e., the electronic payment domain), including common result verification methods and business parameter processing methods. The data persistence layer carries the ability to store and access data. It can exchange with the underlying data, obtain business information data, and interact with other dependent components (such as the business logic layer). The business domain layer defines global variables needed throughout the entire processing flow. It is used throughout the entire process and is the place where business changes occur most frequently. It is the core layer of the business system.
[0086] pass Figure 6 The test case generation model shown describes a process where, during the generation of test cases for the code to be tested based on multiple interface tag groups and multiple parameter tag groups, the test case generation device can read the interface protocol through the protocol layer, and based on the interface protocol, read the original parameters corresponding to each parameter tag in the multiple parameter tag groups input by the target user. The original parameters corresponding to each parameter tag in the multiple parameter tag groups are then initialized into a request class or response class through the request sending layer, so that the business logic layer can call the original parameters corresponding to each parameter tag in the multiple parameter tag groups by calling the request class or response class.
[0087] Furthermore, the original parameters corresponding to each parameter tag in the multiple parameter tag groups included in the business logic layer can be encrypted using the parameter encryption methods corresponding to each parameter tag in the multiple parameter tag groups to obtain the test parameters corresponding to each parameter tag in the multiple parameter tag groups. After receiving the multiple interface tag groups and multiple parameter tag groups at the interface layer, the call layer can traverse the multiple interface tag groups and multiple parameter tag groups to obtain the target tag group currently being traversed, and send the target tag group to the scenario concatenation layer. After receiving the target tag group sent by the call layer, the scenario concatenation layer can call the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer using the interface call methods corresponding to each target interface tag in the target tag group included in the terminal layer of the scenario concatenation layer, generate interface test cases corresponding to each target interface tag, and combine the interface test cases corresponding to each target interface tag based on the service layer in the scenario concatenation layer to obtain the target test cases corresponding to the target tag group.
[0088] In another feasible implementation, after the interface layer receives multiple interface tag groups and multiple parameter tag groups, it can traverse these groups through the call layer to obtain the target tag group currently being traversed, and then send the target tag group to the scene concatenation layer. Upon receiving the target tag group from the call layer, the scene concatenation layer can send a test parameter retrieval request to the business logic layer through the interface call methods corresponding to each target interface tag in the target tag group included in the terminal layer of the scene concatenation layer, requesting the return of the test parameters corresponding to each target parameter tag in the target tag group. Upon receiving the test parameter retrieval request, the business logic layer can retrieve the test parameters corresponding to each target parameter tag in the target tag group included in the business logic layer. The parameter encryption method corresponding to the parameter tags encrypts the original parameters corresponding to each target parameter tag in the target tag group to obtain the test parameters corresponding to each target parameter tag in the target tag group. The test parameters corresponding to each target parameter tag in the target tag group are then returned to the interface call methods corresponding to each target interface tag in the target tag group, which are included in the terminal layer of the scenario concatenation layer. This enables the invocation of the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer, thereby generating interface test cases corresponding to each target interface tag. Finally, the interface test cases corresponding to each target interface tag are combined based on the service layer in the scenario concatenation layer to obtain the target test cases corresponding to the target tag group.
[0089] S504, obtain multiple interface tag groups and multiple parameter tag groups.
[0090] Among them, any interface tag group in the multiple interface tag groups includes at least one interface tag, and any parameter tag group in the multiple parameter tag groups includes at least one parameter tag; the relevant process of step S504 is similar to the relevant process of step S201 above, and will not be repeated here.
[0091] S505: Traverse multiple interface tag groups and multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and multiple parameter tag groups.
[0092] The target tag group includes: target interface tags determined from each of the multiple interface tag groups, and target parameter tags determined from each of the multiple parameter tag groups.
[0093] In one embodiment, if the common input parameters of the functional modules used to implement the function of generating orders from different sources—the large order placement module, the public order placement module, and the combined order placement module—are: parameters of order method type: parameters representing entrusted deduction and parameters representing non-entrusted deduction (i.e., parameters for table collection bank payment), then traversing multiple interface tag groups and multiple parameter tag groups can yield the following results. A target tag group; a target tag group can be used to indicate the running logic of the code under test in a specific scenario. By traversing multiple interface tag groups and multiple parameter tag groups, a target tag group that fully covers the code under test can be generated, and test cases for testing the code under test in a fully covered scenario can be generated.
[0094] S506, obtain the test parameters corresponding to each target parameter label in the target label group.
[0095] S507, based on the API call methods corresponding to each target API tag in the target tag group, the test parameters corresponding to the target parameter tags in the target tag group are called, and target test cases corresponding to the target tag group are generated.
[0096] The processes of steps S506 to S507 are similar to those of steps S203 to S204 described above, and will not be repeated here.
[0097] See Figure 7 This is a flowchart illustrating another test case generation method provided in this application embodiment. If the test case generation device obtains multiple initial interface tag groups and multiple initial parameter tag groups as follows: {[Pocket Payment, Quick Payment, Pocket Payment], [Large Order, Public Order, Combined Order], [Password Verification, iOS Fingerprint Verification, Android Verification, Face Verification, Password-Free], [Short Message Verification, Short Message-Free], [Intimate Payment, Non-Intimate Payment], [Unregistered, Unbound Card, Bound Card, Unregistered Abroad, Unbound Card Abroad, Bound Card Abroad], [Direct Deduction, Non-Direct Deduction]}, where Direct Deduction is the original second format corresponding to the interface tag group [Large Order, Public Order, Combined Order]. Parameter tags; furthermore, the test case generation device can, based on a preset mapping relationship, map each initial interface tag in the multiple initial interface tag groups of the second format to an interface tag in the first format, and map each initial parameter tag in the multiple initial parameter tag groups of the second format to a parameter tag in the first format, thereby obtaining the interface tag groups corresponding to each initial interface tag group in the multiple initial interface tag groups and the parameter tag groups corresponding to each initial parameter tag group in the multiple initial parameter tag groups; then the test case generation device can traverse the multiple interface tag groups and the multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and the multiple parameter tag groups.
[0098] In another feasible implementation, the test case generation device can traverse multiple initial interface tag groups and multiple initial parameter tag groups, determine the currently traversed initial target tag group from the multiple initial interface tag groups and multiple initial parameter tag groups, and map the second format initial target tag group to the first format target tag group based on a preset mapping relationship. If the currently traversed initial target tag group is [Payment in Small Balance + Order Placement + Password Verification + SMS Free Payment + Non-Intimate Payment + Bound Card + Non-Authorized Deduction], then the test case generation device can call the test parameters corresponding to "Non-Authorized Deduction" based on the interface call method corresponding to "Order Placement" to generate the interface test case corresponding to "Order Placement", and can call the test parameters corresponding to "Password Verification, SMS Free Payment, Non-Intimate Payment, Bound Card" respectively based on the interface call method corresponding to "Payment in Small Balance" to generate the interface test case corresponding to "Payment in Small Balance"; then the interface test case corresponding to "Order Placement" and the interface test case corresponding to "Payment in Small Balance" are combined to obtain a target test case.
[0099] In one embodiment, the parameter encryption methods corresponding to different parameter tags can be encapsulated as different plugins, and the test parameters can be extracted in a plug-in manner. The test parameters only need to be set once and can be invoked in multiple API call methods; see also Figure 8a This is a flowchart illustrating another test case generation method provided in this application embodiment. If two interface tag groups are obtained, namely interface tag group 1 and interface tag group 2, if interface tag group 1 includes 3 interface tags, namely A1, A2, and A3, and interface tag group 2 includes 3 interface tags, namely B1, B2, and B3; if three parameter tag groups are obtained, namely parameter tag group 1, parameter tag group 2, and parameter tag group 3, if parameter tag group 1 includes 2 parameter tags, namely a1 and a2, and parameter tag group 2 includes 3 parameter tags, namely b1, b2, and b3, and parameter tag group 3 includes 4 parameter tags, namely c1, c2, c3, and c4, the obtained multiple interface tag groups and multiple parameter tag groups are... Figure 3The expression is represented as {[A1, A2, A3], [B1, B2, B3], [a1, a2], [b1, b2, b3], [c1, c2, c3, c4]}. The interface layer can traverse multiple interface tag groups and multiple parameter tag groups to obtain multiple target tag groups. These target tag groups can include: [A1+B1+a1+b1+c1], [A2+B1+a1+b1+c1], [A3+B1+a1+b1+c1], [A1+B2+a1+b1+c1], [A1+B3+a1+b1+c1], etc., totaling 216 target tag groups. If the correspondence between multiple interface tag groups and multiple parameter tag groups indicates that interface tag group 1 corresponds to parameter tag group 1, and interface tag group 2 corresponds to... Parameter tag group 2 and parameter tag group 3 correspond to each other. When generating target test cases for different target tag groups, it is not necessary to repeatedly input the test parameters required for different target tag groups. It is only necessary to use the parameter plugins corresponding to parameter tags a1 and a2, parameter plugins corresponding to parameter tags b1, b2 and b3, and parameter plugins corresponding to parameter tags c1, c2 and c3 in the business logic layer to realize the calling of the corresponding test parameters in the interface calling methods corresponding to different interface tags in multiple interface tag groups. Furthermore, in the scenario concatenation layer, the interface test cases corresponding to each target interface tag in any target tag group are combined to obtain the test cases corresponding to that target tag group, and thus obtain the test cases corresponding to all target tag groups.
[0100] See Figure 8bThis is a schematic diagram illustrating the generation of test cases in a conventional test case generation method provided in this application embodiment. In the conventional test case generation method, the target object needs to sequentially input each target tag group and the test parameters corresponding to each target tag group. Taking the generation of a target test case for a target tag group input by the target object as an example, in the conventional test case generation method, after receiving each target tag group and the test parameters corresponding to each target tag group, the test case generation device can call different target interface tags in the target tag group, and the interface calling method under the specific parameter tag combination indicated by the target tag group, call the test parameters corresponding to the specific parameter tag combination indicated by the target tag group, and generate the target test case corresponding to the target tag group; that is, for the target tag group [A1+B1+a1+b1... For the target tag group [A1+B1+a2+b2+c1], target interface tag A1 has one interface call method when the corresponding target parameter tag is a1, and target interface tag B1 has one interface call method when the corresponding target parameter tag is b1+c1. For the target tag group [A1+B1+a2+b2+c1], target interface tag A1 has one interface call method when the corresponding target parameter tag is a2, and target interface tag B1 has one interface call method when the corresponding target parameter tag is b2+c1. This necessitates writing multiple interface call methods for the same interface tag, i.e., multiple interface call methods for the same functional module, resulting in a large workload. Furthermore, inconsistent writing styles among these multiple interface call methods can increase the difficulty of modifying and maintaining them. In contrast, the test case generation method proposed in this application only requires writing one interface call method for the same interface tag, i.e., only one interface call method for the same functional module. This reduces the workload, decreases the code size of the interface call method, and facilitates maintenance.
[0101] In one embodiment, by comparing the test case generation method proposed in this application with existing test case generation methods, it is found that the test case generation method proposed in this application outperforms existing test case generation methods in multiple dimensions. The specific comparison results are shown in Table 2 below:
[0102] Table 2
[0103]
[0104]
[0105] As shown in Table 2, the test case generation method proposed in this application improves upon existing test case generation methods in terms of code duplication rate, code volume, and modification cost, while also reducing writing time (where writing time (new scenario) refers to the time consumed by modifying the code of the corresponding test case generation method when adding new functions to the code to be tested, and writing time (old scenario) refers to the time consumed by modifying the code of the corresponding test case generation method when modifying existing functions of the code to be tested). For example, when adding a new functional module to implement the same functionality as the functional module indicated by the interface tag group—for instance, adding a module to generate orders from other sources based on the existing module—only the interface call method corresponding to the new functional module needs to be added to the interface call method of the interface tag group, and the parameter encryption method corresponding to the new functional module needs to be added to the parameter tag group of the interface tag group. No other parts need to be changed. Similarly, when adding test parameters, only a corresponding parameter encryption method needs to be added to the business logic layer, and a parameter tag needs to be added for maintenance, reducing the cost of modification.
[0106] In this embodiment, interface tags for each functional module in the code to be tested can be constructed by analyzing the various functional modules in the code to be tested. Multiple interface tag groups are then formed based on these interface tags. The code modules corresponding to the interface tags in any interface tag group within these multiple interface tag groups are used to implement the same function. For any interface tag group within these multiple interface tag groups, parameter tags corresponding to the functional modules corresponding to each interface tag in that interface tag group are obtained based on parameter analysis. These parameter tags are then categorized according to parameter type to obtain one or more parameter tag groups corresponding to that interface tag group. Different parameter tag groups contain parameter tags with different parameter types. After obtaining the interface call methods corresponding to each functional module in the code to be tested, the code modules of each functional module can be... The API call methods are encapsulated and stored in the scenario concatenation layer of the test case generation model. After obtaining the parameter encryption methods corresponding to each parameter tag, these methods are encapsulated and stored in the business logic layer of the test case generation model. Then, after obtaining multiple API tag groups, multiple parameter tag groups, and the test parameters corresponding to each parameter tag in each parameter tag group, test cases are generated based on the API call methods corresponding to each API tag in the multiple API tag groups and their corresponding test parameters. Through analysis of each functional module in the code to be tested, API tags and parameter tags corresponding to each functional module can be generated. Finally, based on the API tags in the multiple API tag groups and the parameter tags in the multiple parameter tag groups, test cases covering all aspects of the code to be tested can be generated.
[0107] Based on the aforementioned embodiments of the test case generation method, this application provides a test case generation apparatus. See also... Figure 9 This is a schematic diagram of a test case generation device provided in an embodiment of this application. The test case generation device may include an acquisition unit 901 and a processing unit 902. Figure 9 The test case generation device shown can operate the following units:
[0108] The acquisition unit 901 is used to acquire multiple interface tag groups and multiple parameter tag groups; any interface tag group in the multiple interface tag groups includes at least one interface tag, and any parameter tag group in the multiple parameter tag groups includes at least one parameter tag.
[0109] Processing unit 902 is configured to traverse the plurality of interface tag groups and the plurality of parameter tag groups, and determine the target tag group to be traversed from the plurality of interface tag groups and the plurality of parameter tag groups; the target tag group includes: a target interface tag determined from each interface tag group of the plurality of interface tag groups, and a target parameter tag determined from each parameter tag group of the plurality of parameter tag groups;
[0110] The processing unit 902 is also used to obtain the test parameters corresponding to each target parameter label in the target label group;
[0111] The processing unit 902 is further configured to generate target test cases corresponding to the target tag group by calling the test parameters corresponding to the target parameter tags in the target tag group based on the interface calling methods corresponding to each target interface tag in the target tag group.
[0112] In one embodiment, the processing unit 902 is further configured to:
[0113] Obtain the original parameters corresponding to each parameter label in the multiple parameter label groups;
[0114] Based on the parameter encryption method corresponding to each parameter tag in the multiple parameter tag groups, the original parameters corresponding to each parameter tag in the multiple parameter tag groups are encrypted respectively to obtain the test parameters corresponding to each parameter tag in the multiple parameter tag groups.
[0115] In one embodiment, when the processing unit 902 obtains the test parameters corresponding to each target parameter label in the target label group, it specifically performs the following operations:
[0116] Obtain the original parameters corresponding to each target parameter label in the target label group;
[0117] Based on the parameter encryption method corresponding to each target parameter tag in the target tag group, the original parameters corresponding to each target parameter tag in the target tag group are encrypted respectively to obtain the test parameters corresponding to each target parameter tag in the target tag group.
[0118] In one embodiment, when the processing unit 902 generates target test cases corresponding to the target tag group based on the interface call methods corresponding to each target interface tag in the target tag group and the call to the test parameters corresponding to the target parameter tags in the target tag group, it specifically performs the following operations:
[0119] For any target interface tag in the target tag group, the parameter tag group corresponding to the target interface tag is determined based on the correspondence between the multiple interface tag groups and the multiple parameter tag groups;
[0120] From each target parameter tag in the target tag group, obtain the target parameter tag determined from the parameter tag group corresponding to any target interface tag;
[0121] Based on the API call method corresponding to any target API tag, the API call method calls the test parameters corresponding to the obtained target parameter tag, and generates API test cases corresponding to any target API tag.
[0122] The interface test cases corresponding to each target interface tag in the target tag group are combined to obtain the target test cases corresponding to the target tag group.
[0123] In one embodiment, the tag format of each interface tag in the plurality of interface tag groups and each parameter tag in the plurality of parameter tag groups is a first format;
[0124] When the acquisition unit 901 acquires multiple interface tag groups and multiple parameter tag groups, it specifically performs the following operations:
[0125] Obtain multiple initial interface tag groups and multiple initial parameter tag groups; each initial interface tag group in the multiple initial interface tag groups includes at least one initial interface tag, each initial parameter tag group in the multiple initial parameter tag groups includes at least one initial parameter tag, and the tag format of each initial interface tag in the multiple initial interface tag groups and each initial parameter tag in the multiple initial parameter tag groups is a second format;
[0126] Based on a preset mapping relationship, each initial interface tag in the multiple initial interface tag groups of the second format is mapped to an interface tag in the first format, and each initial parameter tag in the multiple initial parameter tag groups of the second format is mapped to a parameter tag in the first format, thereby obtaining the interface tag group corresponding to each initial interface tag group in the multiple initial interface tag groups and the parameter tag group corresponding to each initial parameter tag group in the multiple initial parameter tag groups.
[0127] In one embodiment, the processing unit 902 is further configured to:
[0128] Detect the execution logic indicated by each target interface tag and each target parameter tag in the target tag group;
[0129] If the running logic indicated by each target interface label and each target parameter label in the target label group is normal, then the execution is triggered to obtain the test parameters corresponding to each target parameter label in the target label group.
[0130] In one embodiment, the processing unit 902 is further configured to:
[0131] Construct interface tags for each functional module in the code to be tested, and form multiple interface tag groups based on the interface tags of each functional module in the code to be tested; the code modules corresponding to each interface tag in any interface tag group are used to implement the same function.
[0132] For any interface tag group among the plurality of interface tag groups, based on parameter analysis of the functional modules corresponding to each interface tag in the interface tag group, the parameter tag corresponding to the interface tag group is obtained.
[0133] The parameter tags corresponding to any interface tag group are classified according to their parameter types to obtain one or more parameter tag groups corresponding to any interface tag group; different parameter tag groups include parameter tags with different parameter types.
[0134] In one embodiment, the acquisition unit 901 is further configured to: receive a test request input by a target object; the test request carries a specified tag group, the specified tag group including: a specified interface tag determined from each of the plurality of interface tag groups, and a specified parameter tag determined from each of the plurality of parameter tag groups;
[0135] The processing unit 902 is also used to obtain the target test cases corresponding to the specified tag group;
[0136] The processing unit 902 is further configured to test the code to be tested using the target test cases corresponding to the specified tag group, and obtain the test results of the code to be tested based on the specified tag group; the code to be tested is used to implement the resource transfer function.
[0137] In one embodiment, the test case generation method is implemented through a test case generation model, which includes a call layer, a scenario concatenation layer, and a business logic layer. The call layer is used to traverse the multiple interface tag groups and the multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and the multiple parameter tag groups. The business logic layer is used to obtain the test parameters corresponding to each target parameter tag in the target tag group, and send the test parameters corresponding to each target parameter tag in the target tag group to the scenario concatenation layer. The scenario concatenation layer is used to receive the target tag group sent by the call layer, and through the interface call methods corresponding to each target interface tag in the target tag group included in the scenario concatenation layer, call the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer to generate the target test cases corresponding to the target tag group.
[0138] According to one embodiment of this application, Figure 2 , Figure 4 as well as Figure 5 The test case generation method shown can involve various steps that can be generated by... Figure 9 The test case generation device shown is executed by each unit within it. For example, Figure 2 The step S201 shown can be performed by Figure 9 The test case generation device shown uses the acquisition unit 901 to execute the test case generation. Figure 2 Steps S202 to S204 shown can be derived from Figure 9 The test case generation device shown is executed by the processing unit 902. For example, Figure 4 The step S401 shown can be performed by Figure 9 The test case generation device shown uses the acquisition unit 901 to execute the test case generation. Figure 4 Steps S402 to S405 shown can be derived from... Figure 9 The test case generation device shown is executed by the processing unit 902. For example, Figure 5 The step S504 shown can be performed by Figure 9 The test case generation device shown uses the acquisition unit 901 to execute the test case generation. Figure 5 Steps S501 to S503 and steps S505 to S507 shown can be derived from... Figure 9 The test case generation device shown is executed by the processing unit 902.
[0139] According to another embodiment of this application, Figure 9 The test case generation device shown can be composed of individual or combined units into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effect of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the test case generation device based on logical function division may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0140] According to another embodiment of this application, the following can be achieved by running on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), a device capable of performing operations such as... Figure 2 , Figure 4 as well as Figure 5The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 9 The test case generation apparatus shown herein, and the test case generation method for implementing the embodiments of this application, are described. The computer program may be recorded on, for example, a computer-readable storage medium, loaded onto the aforementioned computing device via the computer-readable storage medium, and run therein.
[0141] Based on the aforementioned embodiments of the test case generation method and the test case generation device, this application also provides a test case generation apparatus. See also... Figure 10 This is a schematic diagram of the structure of a test case generation device provided in an embodiment of this application. Figure 10 The test case generation device shown may include at least a processor 1001, an input interface 1002, an output interface 1003, and a computer storage medium 1004. The processor 1001, input interface 1002, output interface 1003, and computer storage medium 1004 may be connected via a bus or other means.
[0142] The computer storage medium 1004 can be stored in the memory of the test case generation device. The computer storage medium 1004 is used to store computer programs, which include program instructions. The processor 1001 is used to execute the program instructions stored in the computer storage medium 1004. The processor 1001 (or CPU (Central Processing Unit)) is the computing and control core of the test case generation device. It is suitable for implementing one or more instructions, specifically for loading and executing one or more instructions to realize the above-mentioned test case generation method flow or corresponding functions.
[0143] This application embodiment also provides a computer storage medium (Memory), which is a memory device in the test case generation device for storing programs and data. It is understood that the computer storage medium here can include the built-in storage medium in the terminal, or it can include extended storage media supported by the terminal. The computer storage medium provides storage space, which stores the terminal's operating system. Furthermore, the storage space also stores one or more instructions suitable for loading and execution by the processor 1001. These instructions can be one or more computer programs (including program code). It should be noted that the computer storage medium here can be a high-speed random access memory (RAM), or it can be non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer storage medium located remotely from the aforementioned processor.
[0144] In one embodiment, the processor 1001 and the input interface 1002 may load and execute one or more instructions stored in the computer storage medium to achieve the aforementioned related... Figure 2 , Figure 4 as well as Figure 5 In the test case generation method embodiment, the corresponding steps of the method are as follows: In a specific implementation, one or more instructions in the computer storage medium are loaded and executed by the processor 1001 and the input interface 1002:
[0145] Input interface 1002 is used to obtain multiple interface tag groups and multiple parameter tag groups; any interface tag group in the multiple interface tag groups includes at least one interface tag, and any parameter tag group in the multiple parameter tag groups includes at least one parameter tag;
[0146] The processor 1001 is configured to traverse the plurality of interface tag groups and the plurality of parameter tag groups, and determine the target tag group to be traversed from the plurality of interface tag groups and the plurality of parameter tag groups; the target tag group includes: a target interface tag determined from each interface tag group of the plurality of interface tag groups, and a target parameter tag determined from each parameter tag group of the plurality of parameter tag groups;
[0147] The processor 1001 is also used to acquire test parameters corresponding to each target parameter label in the target label group;
[0148] The processor 1001 is further configured to generate target test cases corresponding to the target tag group by calling the test parameters corresponding to the target parameter tags in the target tag group based on the interface calling methods corresponding to each target interface tag in the target tag group.
[0149] In one embodiment, the processor 1001 is further configured to:
[0150] Obtain the original parameters corresponding to each parameter label in the multiple parameter label groups;
[0151] Based on the parameter encryption method corresponding to each parameter tag in the multiple parameter tag groups, the original parameters corresponding to each parameter tag in the multiple parameter tag groups are encrypted respectively to obtain the test parameters corresponding to each parameter tag in the multiple parameter tag groups.
[0152] In one embodiment, when the processor 1001 obtains the test parameters corresponding to each target parameter label in the target label group, it specifically performs the following operations:
[0153] Obtain the original parameters corresponding to each target parameter label in the target label group;
[0154] Based on the parameter encryption method corresponding to each target parameter tag in the target tag group, the original parameters corresponding to each target parameter tag in the target tag group are encrypted respectively to obtain the test parameters corresponding to each target parameter tag in the target tag group.
[0155] In one embodiment, when the processor 1001 generates target test cases corresponding to the target tag group based on the interface call methods corresponding to each target interface tag in the target tag group and the call to the test parameters corresponding to the target parameter tags in the target tag group, it specifically performs the following operations:
[0156] For any target interface tag in the target tag group, the parameter tag group corresponding to the target interface tag is determined based on the correspondence between the multiple interface tag groups and the multiple parameter tag groups;
[0157] From each target parameter tag in the target tag group, obtain the target parameter tag determined from the parameter tag group corresponding to any target interface tag;
[0158] Based on the API call method corresponding to any target API tag, the API call method calls the test parameters corresponding to the obtained target parameter tag, and generates API test cases corresponding to any target API tag.
[0159] The interface test cases corresponding to each target interface tag in the target tag group are combined to obtain the target test cases corresponding to the target tag group.
[0160] In one embodiment, the tag format of each interface tag in the plurality of interface tag groups and each parameter tag in the plurality of parameter tag groups is a first format;
[0161] When the input interface 1002 acquires multiple interface label groups and multiple parameter label groups, it performs the following operations:
[0162] Obtain multiple initial interface tag groups and multiple initial parameter tag groups; each initial interface tag group in the multiple initial interface tag groups includes at least one initial interface tag, each initial parameter tag group in the multiple initial parameter tag groups includes at least one initial parameter tag, and the tag format of each initial interface tag in the multiple initial interface tag groups and each initial parameter tag in the multiple initial parameter tag groups is a second format;
[0163] Based on a preset mapping relationship, each initial interface tag in the multiple initial interface tag groups of the second format is mapped to an interface tag in the first format, and each initial parameter tag in the multiple initial parameter tag groups of the second format is mapped to a parameter tag in the first format, thereby obtaining the interface tag group corresponding to each initial interface tag group in the multiple initial interface tag groups and the parameter tag group corresponding to each initial parameter tag group in the multiple initial parameter tag groups.
[0164] In one embodiment, the processor 1001 is further configured to:
[0165] Detect the execution logic indicated by each target interface tag and each target parameter tag in the target tag group;
[0166] If the running logic indicated by each target interface label and each target parameter label in the target label group is normal, then the execution is triggered to obtain the test parameters corresponding to each target parameter label in the target label group.
[0167] In one embodiment, the processor 1001 is further configured to:
[0168] Construct interface tags for each functional module in the code to be tested, and form multiple interface tag groups based on the interface tags of each functional module in the code to be tested; the code modules corresponding to each interface tag in any interface tag group are used to implement the same function.
[0169] For any interface tag group among the plurality of interface tag groups, based on parameter analysis of the functional modules corresponding to each interface tag in the interface tag group, the parameter tag corresponding to the interface tag group is obtained.
[0170] The parameter tags corresponding to any interface tag group are classified according to their parameter types to obtain one or more parameter tag groups corresponding to any interface tag group; different parameter tag groups include parameter tags with different parameter types.
[0171] In one embodiment, the input interface 1002 is further configured to receive a test request input by a target object; the test request carries a specified tag group, the specified tag group including: a specified interface tag determined from each of the plurality of interface tag groups, and a specified parameter tag determined from each of the plurality of parameter tag groups;
[0172] The processor 1001 is also used to obtain the target test cases corresponding to the specified tag group;
[0173] The processor 1001 is further configured to test the code to be tested using the target test cases corresponding to the specified tag group, and obtain the test results of the code to be tested based on the specified tag group; the code to be tested is used to implement the resource transfer function.
[0174] In one embodiment, the test case generation method is implemented through a test case generation model, which includes a call layer, a scenario concatenation layer, and a business logic layer. The call layer is used to traverse the multiple interface tag groups and the multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and the multiple parameter tag groups. The business logic layer is used to obtain the test parameters corresponding to each target parameter tag in the target tag group, and send the test parameters corresponding to each target parameter tag in the target tag group to the scenario concatenation layer. The scenario concatenation layer is used to receive the target tag group sent by the call layer, and through the interface call methods corresponding to each target interface tag in the target tag group included in the scenario concatenation layer, call the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer to generate the target test cases corresponding to the target tag group.
[0175] This application provides a computer program product, which includes a computer program stored in a computer storage medium. A processor of a test case generation device reads the computer program from the computer storage medium and executes the computer program, causing the test case generation device to perform the aforementioned actions. Figure 2 , Figure 4 as well as Figure 5 The method embodiment shown. The computer-readable storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0176] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A test case generation method, characterized in that, include: Construct interface tags for each functional module in the code to be tested, and build multiple interface tag groups based on the interface tags of each functional module in the code to be tested; The code modules corresponding to each interface tag in any of the multiple interface tag groups are used to implement the same function. For any interface tag group among the plurality of interface tag groups, based on parameter analysis of the functional modules corresponding to each interface tag in the interface tag group, the parameter tag corresponding to the interface tag group is obtained. The parameter tags corresponding to any interface tag group are classified according to their parameter types to obtain one or more parameter tag groups corresponding to any interface tag group; different parameter tag groups include parameter tags with different parameter types; Obtain multiple interface tag groups and multiple parameter tag groups; each of the multiple interface tag groups includes at least one interface tag, and each of the multiple parameter tag groups includes at least one parameter tag; Traverse the multiple interface tag groups and the multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and the multiple parameter tag groups; The target tag group includes: target interface tags determined from each of the plurality of interface tag groups, and target parameter tags determined from each of the plurality of parameter tag groups; Obtain the test parameters corresponding to each target parameter label in the target label group; Based on the API call methods corresponding to each target API tag in the target tag group, the test parameters corresponding to the target parameter tags in the target tag group are called, and target test cases corresponding to the target tag group are generated.
2. The method as described in claim 1, characterized in that, The method further includes: Obtain the original parameters corresponding to each parameter label in the multiple parameter label groups; Based on the parameter encryption method corresponding to each parameter tag in the multiple parameter tag groups, the original parameters corresponding to each parameter tag in the multiple parameter tag groups are encrypted respectively to obtain the test parameters corresponding to each parameter tag in the multiple parameter tag groups.
3. The method as described in claim 1, characterized in that, The step of obtaining the test parameters corresponding to each target parameter label in the target label group includes: Obtain the original parameters corresponding to each target parameter label in the target label group; Based on the parameter encryption method corresponding to each target parameter tag in the target tag group, the original parameters corresponding to each target parameter tag in the target tag group are encrypted respectively to obtain the test parameters corresponding to each target parameter tag in the target tag group.
4. The method as described in claim 1, characterized in that, The step of calling the test parameters corresponding to the target parameter tags in the target tag group based on the interface call methods corresponding to each target interface tag in the target tag group, and generating target test cases corresponding to the target tag group, includes: For any target interface tag in the target tag group, the parameter tag group corresponding to the target interface tag is determined based on the correspondence between the multiple interface tag groups and the multiple parameter tag groups; From each target parameter tag in the target tag group, obtain the target parameter tag determined from the parameter tag group corresponding to any target interface tag; Based on the API call method corresponding to any target API tag, the API call method calls the test parameters corresponding to the obtained target parameter tag, and generates API test cases corresponding to any target API tag. The interface test cases corresponding to each target interface tag in the target tag group are combined to obtain the target test cases corresponding to the target tag group.
5. The method as described in claim 1, characterized in that, The tag format of each interface tag in the plurality of interface tag groups and each parameter tag in the plurality of parameter tag groups is the first format; The process of obtaining multiple interface tag groups and multiple parameter tag groups includes: Obtain multiple initial interface tag groups and multiple initial parameter tag groups; each initial interface tag group in the multiple initial interface tag groups includes at least one initial interface tag, each initial parameter tag group in the multiple initial parameter tag groups includes at least one initial parameter tag, and the tag format of each initial interface tag in the multiple initial interface tag groups and each initial parameter tag in the multiple initial parameter tag groups is a second format; Based on a preset mapping relationship, each initial interface tag in the multiple initial interface tag groups of the second format is mapped to an interface tag in the first format, and each initial parameter tag in the multiple initial parameter tag groups of the second format is mapped to a parameter tag in the first format, thereby obtaining the interface tag group corresponding to each initial interface tag group in the multiple initial interface tag groups and the parameter tag group corresponding to each initial parameter tag group in the multiple initial parameter tag groups.
6. The method as described in claim 1, characterized in that, The method further includes: Detect the execution logic indicated by each target interface tag and each target parameter tag in the target tag group; If the running logic indicated by each target interface label and each target parameter label in the target label group is normal, then the execution is triggered to obtain the test parameters corresponding to each target parameter label in the target label group.
7. The method as described in claim 1, characterized in that, The method further includes: Receive a test request input from the target object; the test request carries a specified tag group, the specified tag group including: a specified interface tag determined from each of the plurality of interface tag groups, and a specified parameter tag determined from each of the plurality of parameter tag groups; Obtain the target test cases corresponding to the specified tag group; The code to be tested is tested using the target test cases corresponding to the specified tag group, and the test results of the code to be tested based on the specified tag group are obtained; the code to be tested is used to implement the resource transfer function.
8. The method as described in claim 1, characterized in that, The test case generation method is implemented through a test case generation model, which includes a call layer, a scenario concatenation layer, and a business logic layer. The call layer is used to traverse the multiple interface tag groups and the multiple parameter tag groups, and determine the target tag group to be traversed from the multiple interface tag groups and the multiple parameter tag groups. The business logic layer is used to obtain the test parameters corresponding to each target parameter tag in the target tag group, and send the test parameters corresponding to each target parameter tag in the target tag group to the scenario concatenation layer. The scenario concatenation layer is used to receive the target tag group sent by the call layer, and through the interface call methods corresponding to each target interface tag in the target tag group included in the scenario concatenation layer, call the test parameters corresponding to the target parameter tags in the target tag group obtained from the business logic layer, and generate the target test cases corresponding to the target tag group.
9. A test case generation device, characterized in that, include: The processing unit is used to construct interface tags for each functional module in the code to be tested, and to form multiple interface tag groups based on the interface tags of each functional module in the code to be tested; the code modules corresponding to each interface tag in any interface tag group are used to implement the same function. The processing unit is further configured to, for any interface tag group among the plurality of interface tag groups, obtain the parameter tag corresponding to the interface tag group based on the parameter analysis of the functional modules corresponding to each interface tag in the interface tag group. The processing unit is further configured to classify the parameter tags corresponding to any interface tag group according to the parameter type, thereby obtaining one or more parameter tag groups corresponding to any interface tag group; different parameter tag groups include parameter tags with different parameter types; The acquisition unit is used to acquire multiple interface tag groups and multiple parameter tag groups; each of the multiple interface tag groups includes at least one interface tag, and each of the multiple parameter tag groups includes at least one parameter tag. The processing unit is further configured to traverse the plurality of interface tag groups and the plurality of parameter tag groups, and determine the target tag group currently being traversed from the plurality of interface tag groups and the plurality of parameter tag groups; The target tag group includes: target interface tags determined from each of the plurality of interface tag groups, and target parameter tags determined from each of the plurality of parameter tag groups; The processing unit is also used to obtain the test parameters corresponding to each target parameter label in the target label group; The processing unit is further configured to generate target test cases corresponding to the target tag group by calling the test parameters corresponding to the target parameter tags in the target tag group based on the interface calling methods corresponding to each target interface tag in the target tag group.
10. A test case generation device, characterized in that, The test case generation device includes an input interface and an output interface, and also includes: A processor, adapted to implement one or more instructions; and, A computer storage medium storing one or more instructions adapted to be loaded by the processor and executed by the test case generation method as described in any one of claims 1-8.
11. A computer storage medium, characterized in that, The computer storage medium stores computer program instructions, which, when executed by a processor, are used to perform the test case generation method as described in any one of claims 1-8.
12. A computer program product or computer program, characterized in that, The computer program product includes a computer program that, when executed by a processor, is used to load and execute the test case generation method as described in any one of claims 1-8.
Citation Information
Patent Citations
Interface testing method and device
CN106354634A