Program testing method, device and electronic equipment based on test case

By generating the program interface dependency graph and dividing the full-coverage test chain, the problems of high duplication and low accuracy of test cases in the existing technology are solved, chain testing of the program interface dependency level is realized, and the reusability of test cases is improved. and accuracy of program testing.

CN118069501BActive Publication Date: 2024-09-06JIANGSU SHURUI DATA TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410091631.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-22
Publication Date
2024-09-06
Estimated Expiration
2044-01-22

AI Technical Summary

Technical Problem

Existing program testing methods ignore the dependencies between program interfaces, resulting in high duplication of test cases and low accuracy.

Method used

By generating a program interface dependency graph, full-coverage test chain division is performed, test case groups are automatically generated, and chain testing of program interface dependency levels is realized.

Benefits of technology

It improves the reusability of test cases and the accuracy of program testing, ensuring comprehensive coverage of program interface dependencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118069501B
    Figure CN118069501B
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose a program testing method, device and electronic device based on test cases. A specific implementation of the method includes: determining the program information to be tested; generating a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information; performing the following processing steps on the program interface dependency subgraph: dividing the program interface dependency subgraph into full coverage test chains; generating a set of test case groups for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain; performing program testing on the program interface test chain through the test case group corresponding to the program interface test chain to generate program test results. This implementation improves the reuse of test cases, realizes program testing at the program interface dependency level, and improves the accuracy of program testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a program testing method, device, and electronic device based on test cases. Background Art

[0002] Program testing refers to a technology that performs functional testing on programs to be released to ensure the functional integrity of the programs to be tested. It is one of the main means of discovering program errors and program defects in the programs to be tested. At present, when performing program testing, the commonly used method is: using pre-written automatic test programs, taking program interfaces as test units, and performing automatic program testing through pre-written test cases.

[0003] However, the inventors have found that when the above method is adopted, the following technical problems often occur:

[0004] There are often program interface dependencies in the test program. The testing method that uses the program interface as the test unit ignores the dependencies between the program interfaces, resulting in a high degree of test case duplication and affecting the accuracy of program testing.

[0005] The above information disclosed in this Background section is only for enhancement of understanding of the background of the inventive concept and therefore it may contain information that does not form the prior art that is already known in this country to a person of ordinary skill in the art. Summary of the invention

[0006] The content of this disclosure is used to introduce concepts in a brief form, which will be described in detail in the detailed implementation section below. The content of this disclosure is not intended to identify the key features or essential features of the technical solution claimed for protection, nor is it intended to limit the scope of the technical solution claimed for protection.

[0007] Some embodiments of the present disclosure propose a program testing method, apparatus, and electronic device based on test cases to solve one or more of the technical problems mentioned in the above background technology section.

[0008] In a first aspect, some embodiments of the present disclosure provide a program testing method based on test cases, the method comprising: determining program information to be tested, wherein the program information to be tested comprises: a set of program interface information to be tested, the program interface information to be tested in the set of program interface information to be tested comprises: program interface dependency information and program interface parameter description information; generating a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information, wherein the program interface dependency graph comprises: at least one program interface dependency subgraph; for each The program interface dependency subgraph executes the following processing steps: divide the above program interface dependency subgraph into full coverage test chains to generate a program interface test chain group; generate a test case group set for the above program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, wherein there is a one-to-one correspondence between the test case group and the program interface test chain; for each program interface test chain in the above program interface test chain group, perform program testing on the above program interface test chain through the test case group corresponding to the above program interface test chain in the above test case group set to generate a program test result.

[0009] In a second aspect, some embodiments of the present disclosure provide a program testing device based on test cases, the device comprising: a first generating unit, configured to determine program information to be tested, wherein the program information to be tested comprises: a set of program interface information to be tested, the program interface information to be tested in the set of program interface information to be tested comprises: program interface dependency information and program interface parameter description information; a second generating unit, configured to generate a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information, wherein the program interface dependency graph comprises: at least one program interface dependency subgraph; an executing unit, configured to execute the program information to be tested for the program interface information to be tested. For each program interface dependency subgraph in at least one program interface dependency subgraph, perform the following processing steps: divide the above program interface dependency subgraph into full coverage test chains to generate a program interface test chain group; generate a test case group set for the above program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, wherein there is a one-to-one correspondence between the test case group and the program interface test chain; for each program interface test chain in the above program interface test chain group, perform program testing on the above program interface test chain through the test case group corresponding to the above program interface test chain in the above test case group set to generate a program test result.

[0010] In a third aspect, some embodiments of the present disclosure provide an electronic device comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner of the above-mentioned first aspect.

[0011] In a fourth aspect, some embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method described in any implementation manner of the above-mentioned first aspect is implemented.

[0012] The above-mentioned various embodiments of the present disclosure have the following beneficial effects: through the program testing method based on test cases of some embodiments of the present disclosure, the reusability of test cases is improved and the accuracy of program testing is guaranteed. Specifically, the reason for the high repetition of test cases and the low accuracy of program testing is that there is often program interface dependency in the test program, and the test method with program interface as the test unit ignores the dependency relationship between program interfaces. Based on this, the program testing method based on test cases of some embodiments of the present disclosure, first, determines the program information to be tested, wherein the above-mentioned program information to be tested includes: a set of program interface information to be tested, and the program interface information to be tested in the above-mentioned program interface information set to be tested includes: program interface dependency information and program interface parameter description information, so as to describe the program to be tested from the perspective of program interface parameters and program interface dependency. Secondly, according to the program interface dependency information included in the program interface information, a program interface dependency graph for the above-mentioned program interface information set to be tested is generated, wherein the above-mentioned program interface dependency graph includes: at least one program interface dependency subgraph. In this way, the dependency relationship between the program interfaces corresponding to the program to be tested is portrayed in the form of a graph. Then, for each program interface dependency subgraph in the at least one program interface dependency subgraph, the following processing steps are performed: the first step is to divide the program interface dependency subgraph into full coverage test chains to generate a program interface test chain group. In practice, the program interface dependency relationship is relatively complex, that is, it is often impossible to determine a test chain that covers all test interfaces. Therefore, it is necessary to divide the program interface dependency subgraph from the perspective of full coverage to ensure the comprehensiveness of subsequent program testing. The second step is to generate a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, wherein there is a one-to-one correspondence between the test case group and the program interface test chain, thereby automatically generating a test case group for the program interface test chain. The third step is to perform program testing on the program interface test chain for each program interface test chain in the program interface test chain group through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result. In this way, chained program interface testing is implemented from the perspective of program interface dependency, which improves the reuse of test cases, and program testing at the program interface dependency level is implemented, which improves the accuracy of program testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.

[0014] Figure 1is a flow chart of some embodiments of a program testing method based on a test case according to the present disclosure;

[0015] Figure 2 It is a schematic diagram of the program interface dependency graph;

[0016] Figure 3 is a schematic diagram of the structure of some embodiments of a program testing device based on a test case according to the present disclosure;

[0017] Figure 4 It is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION

[0018] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0019] It should also be noted that, for ease of description, only the parts related to the invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other.

[0020] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0021] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0022] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0023] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0024] refer to Figure 1 , shows a process 100 of some embodiments of a program testing method based on a test case according to the present disclosure. The program testing method based on a test case includes the following steps:

[0025] Step 101, determine the program information to be tested.

[0026] In some embodiments, the execution subject (for example, a computing device) of the program testing method based on the test case can determine the program information to be tested. The program information to be tested represents the program to be tested. The above-mentioned program information to be tested includes: a set of program interface information to be tested. The program interface information to be tested represents the program interface in the program to be tested. The program interface information to be tested in the above-mentioned program interface information set to be tested includes: program interface dependency information and program interface parameter description information. The program interface dependency information represents other program interfaces that the program interface corresponding to the program interface information to be tested needs to rely on when executing. The program interface parameter description information represents the parameter description of the input and output parameters of the program interface corresponding to the program interface information to be tested.

[0027] As an example, the program interface dependency information can be represented in the form of a program interface table. For example, the program interface information A to be tested corresponds to program interface A, and the program interface dependency information included in the program interface information A to be tested can be [program interface B, program interface C, program interface D], indicating that program interface A needs to rely on program interface B, program interface C and program interface D when executing. The program interface parameter description information can be represented by an input parameter description table and an output parameter description table. For example, the program interface parameter description information can be: {input parameter description table: {[parameter A, parameter type: int], [parameter B, parameter type: double]}, output parameter description table: {[parameter C, parameter type: double]}}. In practice, the above-mentioned execution subject can scan the program to be executed to generate the above-mentioned program information to be tested.

[0028] It should be noted that the above-mentioned computing device can be hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or it can be implemented as a single server or a single terminal device. When the computing device is embodied as software, it can be installed in the hardware devices listed above. It can be implemented as multiple software or software modules for providing distributed services, for example, or it can be implemented as a single software or software module. No specific limitation is made here. It should be understood that the number of computing devices is only schematic. It can have any number according to the implementation needs.

[0029] In some optional implementations of some embodiments, the execution subject determines the program information to be tested, which may include the following steps:

[0030] The first step is to obtain the program file package to be tested.

[0031] The program file package to be tested adopts a tree structure to store at least one program file to be tested. In practice, the execution subject can obtain the program file package to be tested through a wired connection or a wireless connection.

[0032] In the second step, for each of the at least one program file to be tested, the following program interface information generation step is performed:

[0033] The first sub-step is to scan the above-mentioned program files to be tested to generate a program interface list.

[0034] The program interfaces in the program interface list may be program interfaces defined in the program file to be tested.

[0035] In the second sub-step, for each program interface in the above-mentioned program interface list, the program interface code corresponding to the above-mentioned program interface is filtered to determine at least one dependent program interface corresponding to the above-mentioned program interface, as the program interface dependency information included in the program interface information to be tested corresponding to the above-mentioned program interface in the above-mentioned program interface information set to be tested, and the program interface parameters of the above-mentioned program interface are determined, as the program interface parameter description information included in the program interface information to be tested corresponding to the above-mentioned program interface in the above-mentioned program interface information set to be tested.

[0036] The dependent program interface may be a program interface that the program interface needs to rely on when executing.

[0037] Step 102: Generate a program interface dependency graph for the program interface information set to be tested according to the program interface dependency information included in the program interface information.

[0038] In some embodiments, the above-mentioned execution subject can generate a program interface dependency graph for the set of program interface information to be tested based on the program interface dependency information included in the program interface information. The above-mentioned program interface dependency graph includes: at least one program interface dependency subgraph. Among them, the program interface dependency graph is used to describe the dependency relationship between program interfaces in the form of a graph. Specifically, since the program interfaces corresponding to the program interface information to be tested in the set of program interface information to be tested often do not have complete dependency relationships, that is, there are partial interface dependencies between program interfaces, the program interface dependency graph includes at least one program interface dependency subgraph. The program interface dependency subgraph is a directed graph. Among them, the graph nodes in the program interface dependency subgraph represent the program interfaces. The directed dependency edges in the program interface dependency subgraph represent the dependency relationship between program interfaces. In practice, the above-mentioned execution subject can generate a program interface dependency graph for the set of program interface information to be tested based on the program interface dependency information included in the program interface information by updating the graph nodes.

[0039] As an example, the program interface corresponding to the program interface information set to be tested may be [program interface A, program interface B, program interface C, program interface D, program interface E, program interface F, program interface G, program interface H, program interface I]. Among them, the program interface dependency information corresponding to program interface A may be [program interface B, program interface C, program interface D]. The program interface dependency information corresponding to program interface B may be [program interface D]. The program interface dependency information corresponding to program interface C may be [program interface D, program interface E]. The program interface dependency information corresponding to program interface F may be [program interface F]. In practice, when a program interface is recursive, there is a dependency relationship pointing to itself. The program interface dependency information corresponding to program interface G may be [program interface H]. The program interface dependency information corresponding to program interface H may be [program interface I]. For details, see Figure 2 The program interface dependency graph shown in Figure 1 is as follows: Figure 2 The program interface dependency graph shown includes: program interface dependency subgraph 201, program interface dependency subgraph 202 and program interface dependency subgraph 203. Among them, program interface dependency subgraph 201 includes graph nodes corresponding to program interface A, graph nodes corresponding to program interface B, graph nodes corresponding to program interface C, graph nodes corresponding to program interface D, and graph nodes corresponding to program interface E. Program interface dependency subgraph 201 includes graph nodes corresponding to program interface F. Program interface dependency subgraph 203 includes graph nodes corresponding to program interface G, graph nodes corresponding to program interface H, and graph nodes corresponding to program interface I. Specifically, in the program interface dependency subgraph 201, there is a directed dependency edge from the graph node corresponding to program interface A to the graph node corresponding to program interface B, there is a directed dependency edge from the graph node corresponding to program interface A to the graph node corresponding to program interface C, there is a directed dependency edge from the graph node corresponding to program interface A to the graph node corresponding to program interface D, there is a directed dependency edge from the graph node corresponding to program interface C to the graph node corresponding to program interface B, there is a directed dependency edge from the graph node corresponding to program interface C to the graph node corresponding to program interface D, and there is a directed dependency edge from the graph node corresponding to program interface C to the graph node corresponding to program interface E. In the program interface dependency subgraph 202, there is a directed dependency edge from the graph node corresponding to program interface F to the graph node corresponding to program interface F. In the program interface dependency subgraph 203, there is a directed dependency edge from the graph node corresponding to program interface G to the graph node corresponding to program interface H, and there is a directed dependency edge from the graph node corresponding to program interface H to the graph node corresponding to program interface I.

[0040] In some optional implementations of some embodiments, the execution subject generates a program interface dependency graph for the program interface information set to be tested according to the program interface dependency information included in the program interface information, which may include the following steps:

[0041] The first step is to generate the initial program interface dependency graph.

[0042] The number of nodes in the graph nodes included in the above-mentioned initial program interface dependency graph is consistent with the number of program interface information to be tested in the above-mentioned program interface information set to be tested, and there is a one-to-one correspondence between the graph nodes included in the initial program interface dependency graph and the program interface information to be tested. In practice, the above-mentioned initial program interface dependency graph may only include graph nodes corresponding to program interfaces, and does not include directed dependency edges between graph nodes.

[0043] In the second step, according to the program interface information set to be tested and the initial program interface dependency graph, the following graph update steps are performed:

[0044] In the first sub-step, the program interface information to be tested corresponding to the target position value is selected from the program interface information set to be tested as the target program interface information to be tested.

[0045] The initial value of the target position value is 1, that is, when the graph updating step is executed for the first time, the program interface information to be tested corresponding to the first position is selected from the program interface information set to be tested as the target program interface information to be tested.

[0046] The second sub-step is to update the directed dependency edge of at least one graph node in the initial program interface dependency graph that corresponds to the program interface dependency information included in the target program interface information to be tested, so as to generate an initial program interface dependency graph after the dependency edge is updated.

[0047] As an example, see further Figure 2 , the target program interface information to be tested can correspond to program interface A. Therefore, the above-mentioned execution entity can update the directed dependency edge between the graph node corresponding to program interface A and the graph node corresponding to program interface B, update the directed dependency edge between the graph node corresponding to program interface A and the graph node corresponding to program interface C, and update the directed dependency edge between the graph node corresponding to program interface A and the graph node corresponding to program interface D.

[0048] In the third sub-step, in response to the target position value being greater than or equal to the quantity of the program interface information to be tested in the program interface information set to be tested, the initial program interface dependency graph after the dependency edges are updated is determined as the above-mentioned program interface dependency graph.

[0049] In the third step, in response to the target position value being less than the number of program interface information to be tested in the program interface information set to be tested, the target position value is incremented, the target position value after the position value increment is used as the target position value, and the initial program interface dependency graph after the dependency edge is updated is used as the initial program interface dependency graph, and the above graph updating step is performed again.

[0050] In practice, the above execution subject can add 1 to the target position value to achieve self-increment of the position value.

[0051] Step 103: for each program interface dependency subgraph in at least one program interface dependency subgraph, perform the following processing steps:

[0052] Step 1031, divide the program interface dependency subgraph into full coverage test chains to generate a program interface test chain group.

[0053] In some embodiments, the execution entity may divide the program interface dependency subgraph into full coverage test chains to generate a program interface test chain group.

[0054] The program interface test chain can be a test chain that represents the test order. In practice, the execution subject can use an ant colony algorithm to perform full coverage test chain division on the program interface dependency subgraph to generate a program interface test chain group. For example, see further Figure 2 The program interface dependency subgraph 201 shown, the program interface test chain group corresponding to the program interface dependency subgraph 201 may include: program interface test chain A, program interface test chain B, program interface test chain C and program interface test chain D. Among them, program interface test chain A is: program interface A->program interface B->program interface D. Program interface test chain B is: program interface A->program interface D. Program interface test chain C is: program interface A->program interface C->program interface D. Program interface test chain D is: program interface A->program interface C->program interface E.

[0055] In some optional implementations of some embodiments, the execution subject divides the program interface dependency subgraph into full coverage test chains to generate a program interface test chain group, which may include the following steps:

[0056] In the first step, the node out-degree value and the node in-degree value corresponding to each graph node in at least one target graph node are determined.

[0057] Wherein, at least one target graph node is at least one graph node included in the above-mentioned program interface dependency subgraph. Figure 2 In the program interface dependency subgraph 201 shown, the out-degree value of the graph node corresponding to program interface A is 3. The out-degree value of the graph node corresponding to program interface A is 0.

[0058] In the second step, a target graph node whose corresponding node out-degree value meets the screening condition is selected from the at least one target graph node as the path source node, wherein the node out-degree value corresponding to the target graph node is greater than 0 and the corresponding node in-degree value is equal to 0.

[0059] The third step is to use the path source node as the root node and perform graph-tree conversion on the program interface dependency subgraph to generate a program interface dependency subtree.

[0060] The fourth step is to use the path source node as the traversal start node and perform a deep traversal on the program interface dependency subtree to generate a program interface test chain group corresponding to the program interface dependency subgraph.

[0061] Step 1032: Generate a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain.

[0062] In some embodiments, the execution subject may generate a set of test case groups for the program interface test chain group based on the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain. In practice, for each program interface test chain in the program interface test chain group, the execution subject may generate a test case group based on the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain as a constraint.

[0063] In some optional implementations of some embodiments, the execution subject generates a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, which may include the following steps:

[0064] For each program interface test chain in the above program interface test chain group, perform the following test case generation steps:

[0065] The first step is to determine the program interface information to be tested corresponding to the path source node included in the program interface test chain as the target program interface information to be tested.

[0066] The second step is to extract interface parameter features from the program interface parameter description information included in the target program interface information to be tested, so as to generate interface parameter features.

[0067] Among them, the above-mentioned interface parameter features include: interface parameter semantic features and interface parameter value features. In practice, the above-mentioned execution subject can extract parameter semantic features from the program interface parameter description information included in the above-mentioned target program interface information to be tested through the TextRNN model to generate interface parameter semantic features. The interface parameter value features can be obtained by mapping the parameter range of the parameter type of the interface parameter.

[0068] The third step is to batch generate test cases for the above-mentioned program interface test chain through the pre-trained test case generation model and interface parameter features, and obtain the test case group corresponding to the above-mentioned program interface test chain in the above-mentioned test case group set.

[0069] In practice, the test case generation model can adopt the BERT model.

[0070] Step 1033, for each program interface test chain in the program interface test chain group, program testing is performed on the program interface test chain through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result.

[0071] In some embodiments, for each program interface test chain in the program interface test chain group, the execution subject may perform program testing on the program interface test chain through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result. The program test result indicates whether an exception occurs in the program interface when executing the test case, and the type of exception when the exception occurs.

[0072] In some optional implementations of some embodiments, the execution subject performs program testing on the program interface test chain through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result, which may include the following steps:

[0073] The first step is to determine the test case distribution of the test case group corresponding to the above program interface test chain.

[0074] In practice, the execution subject may generate a histogram of the test case group corresponding to the program interface test chain to determine the test case distribution. For example, the test case distribution may be a normal distribution.

[0075] The second step is to determine at least one test case segmentation boundary based on the above test case distribution.

[0076] In practice, the execution entity may calculate the confidence level to determine the confidence interval, so as to obtain at least one test case segmentation boundary.

[0077] The third step is to segment the test case group corresponding to the program interface test chain through the at least one test case segmentation boundary to obtain at least one test case block.

[0078] In practice, first, the execution subject may segment the histogram of the test case group corresponding to the program interface test chain by at least one test case segmentation boundary to obtain multiple segmentation intervals. Then, the execution subject may determine the test cases within the segmentation intervals as test case blocks.

[0079] The fourth step is to generate, for at least one of the test case blocks, a test case coverage probability for the test case block based on the ratio of the number of test cases included in the test case block to the number of test cases included in the test case group corresponding to the program interface test chain.

[0080] Among them, the test case coverage probability = the number of test cases included in the above test case block / the number of test cases included in the test case group corresponding to the program interface test chain.

[0081] In the fifth step, according to the test case coverage probability corresponding to the test case block and the program testing requirement, test cases are extracted from the at least one test case block as the test cases to be used, so as to obtain a set of test cases to be used.

[0082] Among them, the program test requirement represents the demand for test cases used to test the program interface. In practice, the above-mentioned execution subject can control the number of times the test cases are extracted by the program test requirement, and randomly extract test cases from the above-mentioned at least one test case block as the test cases to be used according to the test case coverage probability corresponding to the test case block, and obtain a set of test cases to be used. Specifically, the higher the test case coverage probability, the higher the probability of being drawn. In practice, the more test cases there are, the more the completeness of the program interface can be tested, but due to constraints such as the program launch time, it is often impossible to comprehensively test the program interface. Therefore, the present application controls the extraction of test cases and subsequent testing based on the test case coverage probability and the program test requirement to ensure that the completeness of the program interface is at a high confidence level.

[0083] The sixth step is to perform program testing on the program interface test chain using the test case set to be used to generate the program test results.

[0084] In practice, the execution subject can perform program testing on the program interface corresponding to the path source node in the program interface test chain through the set of test cases to be used to generate the above program test results. Since the execution of the program interface corresponding to the path source node depends on the program interface corresponding to the child node, that is, the program interface corresponding to the path source node is tested, the program interface corresponding to all graph nodes in the program interface test chain can be tested synchronously, and the test speed and coverage are greatly improved.

[0085] Optionally, the above method further includes:

[0086] The first step is to generate an abnormal code warning information set for the above-mentioned program information to be tested based on the above-mentioned program test results.

[0087] Among them, the abnormal code warning information in the above abnormal code warning information set includes: abnormal code point location, abnormal code type and abnormal test case.

[0088] The second step is to send, for each abnormal code warning information in the abnormal code warning information set, the abnormal code warning information to the warning information receiving node corresponding to the abnormal code warning information.

[0089] The alarm information receiving node may be a data processing node bound to a program interface corresponding to the abnormal code alarm information.

[0090] The above-mentioned various embodiments of the present disclosure have the following beneficial effects: through the program testing method based on test cases of some embodiments of the present disclosure, the reusability of test cases is improved and the accuracy of program testing is guaranteed. Specifically, the reason for the high repetition of test cases and the low accuracy of program testing is that there is often program interface dependency in the test program, and the test method with program interface as the test unit ignores the dependency relationship between program interfaces. Based on this, the program testing method based on test cases of some embodiments of the present disclosure, first, determines the program information to be tested, wherein the above-mentioned program information to be tested includes: a set of program interface information to be tested, and the program interface information to be tested in the above-mentioned program interface information set to be tested includes: program interface dependency information and program interface parameter description information, so as to describe the program to be tested from the perspective of program interface parameters and program interface dependency. Secondly, according to the program interface dependency information included in the program interface information, a program interface dependency graph for the above-mentioned program interface information set to be tested is generated, wherein the above-mentioned program interface dependency graph includes: at least one program interface dependency subgraph. In this way, the dependency relationship between the program interfaces corresponding to the program to be tested is portrayed in the form of a graph. Then, for each program interface dependency subgraph in the at least one program interface dependency subgraph, the following processing steps are performed: the first step is to divide the program interface dependency subgraph into full coverage test chains to generate a program interface test chain group. In practice, the program interface dependency relationship is relatively complex, that is, it is often impossible to determine a test chain that covers all test interfaces. Therefore, it is necessary to divide the program interface dependency subgraph from the perspective of full coverage to ensure the comprehensiveness of subsequent program testing. The second step is to generate a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, wherein there is a one-to-one correspondence between the test case group and the program interface test chain, thereby automatically generating a test case group for the program interface test chain. The third step is to perform program testing on the program interface test chain for each program interface test chain in the program interface test chain group through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result. In this way, chained program interface testing is implemented from the perspective of program interface dependency, which improves the reuse of test cases, and program testing at the program interface dependency level is implemented, which improves the accuracy of program testing.

[0091] Further references Figure 3 As an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of a program testing device based on a test case, and these device embodiments are similar to Figure 1 Corresponding to the method embodiments shown, the program testing device based on test cases can be specifically applied to various electronic devices.

[0092] like Figure 3 As shown, some embodiments of the program testing device 300 based on test cases include: a determination unit, a generation unit and an execution unit. The determination unit 301 is configured to determine the program information to be tested, wherein the program information to be tested includes: a set of program interface information to be tested, and the program interface information to be tested in the set of program interface information to be tested includes: program interface dependency information and program interface parameter description information; the generation unit 302 is configured to generate a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information, wherein the program interface dependency graph includes: at least one program interface dependency subgraph; the execution unit 303 is configured to generate a program interface dependency graph for each of the at least one program interface dependency subgraph. The program interface dependency subgraph executes the following processing steps: divide the above program interface dependency subgraph into full coverage test chains to generate a program interface test chain group; generate a test case group set for the above program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, wherein there is a one-to-one correspondence between the test case group and the program interface test chain; for each program interface test chain in the above program interface test chain group, perform program testing on the above program interface test chain through the test case group corresponding to the above program interface test chain in the above test case group set to generate a program test result.

[0093] It can be understood that the units recorded in the test case-based program testing device 300 are similar to the reference Figure 1 Therefore, the operations, features and beneficial effects described above for the method are also applicable to the program testing device 300 based on the test case and the units contained therein, and will not be described in detail here.

[0094] Reference below Figure 4 , which shows a structural schematic diagram of an electronic device (eg, a computing device) 400 suitable for implementing some embodiments of the present disclosure. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0095] like Figure 4As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory 402 or a program loaded from a storage device 408 into a random access memory 403. Various programs and data required for the operation of the electronic device 400 are also stored in the random access memory 403. The processing device 401, the read-only memory 402, and the random access memory 403 are connected to each other via a bus 404. An input / output interface 405 is also connected to the bus 404.

[0096] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 4 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0097] In particular, according to some embodiments of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the read-only memory 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of some embodiments of the present disclosure are executed.

[0098] It should be noted that the computer-readable medium recorded in some embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In some embodiments of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0099] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0100] The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist independently without being installed in the electronic device. The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: determines the program information to be tested, wherein the above-mentioned program information to be tested includes: a set of program interface information to be tested, and the program interface information to be tested in the above-mentioned program interface information set to be tested includes: program interface dependency information and program interface parameter description information; generates a program interface dependency graph for the above-mentioned program interface information set to be tested according to the program interface dependency information included in the program interface information, wherein the above-mentioned program interface dependency graph includes: at least one program interface dependency subgraph; for the above-mentioned at least one program interface dependency For each program interface dependency subgraph in the subgraph, the following processing steps are executed: the above program interface dependency subgraph is divided into full coverage test chains to generate a program interface test chain group; according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, a test case group set for the above program interface test chain group is generated, wherein there is a one-to-one correspondence between the test case group and the program interface test chain; for each program interface test chain in the above program interface test chain group, program testing is performed on the above program interface test chain through the test case group corresponding to the above program interface test chain in the above test case group set to generate a program test result.

[0101] Computer program code for performing the operations of some embodiments of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0102] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0103] The units described in some embodiments of the present disclosure may be implemented by software or by hardware. The described units may also be set in a processor, for example, may be described as: a processor includes a determination unit, a generation unit and an execution unit. Wherein, the names of these units do not constitute a limitation on the unit itself in some cases, for example, the execution unit may also be described as "for each program interface dependency subgraph in the at least one program interface dependency subgraph mentioned above, the following processing steps are performed: the above program interface dependency subgraph is divided into full coverage test chains to generate a program interface test chain group; according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, a test case group set for the above program interface test chain group is generated, wherein there is a one-to-one correspondence between the test case group and the program interface test chain; for each program interface test chain in the above program interface test chain group, the above program interface test chain is subjected to program testing through the test case group corresponding to the above program interface test chain in the above test case group set, so as to generate a unit of program test results".

[0104] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0105] The above descriptions are only some preferred embodiments of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) and the technical solutions formed.

Claims

1. A program testing method based on test cases, comprising: Determine the program information to be tested, wherein the program information to be tested includes: a program interface information set to be tested, and the program interface information to be tested in the program interface information set to be tested includes: program interface dependency information and program interface parameter description information; Generate a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information, wherein the program interface dependency graph includes: at least one program interface dependency subgraph; For each program interface dependency subgraph in the at least one program interface dependency subgraph, the following processing steps are performed: Performing full coverage test chain division on the program interface dependency subgraph to generate a program interface test chain group; Generate a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, wherein there is a one-to-one correspondence between the test case group and the program interface test chain; For each program interface test chain in the program interface test chain group, program testing is performed on the program interface test chain through a test case group corresponding to the program interface test chain in the test case group set to generate a program test result, wherein: The step of generating a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information comprises: Generate an initial program interface dependency graph, wherein the node quantity value of the graph nodes included in the initial program interface dependency graph is consistent with the quantity value of the program interface information to be tested in the program interface information set to be tested, and there is a one-to-one correspondence between the graph nodes included in the initial program interface dependency graph and the program interface information to be tested; According to the program interface information set to be tested and the initial program interface dependency graph, perform the following graph update steps: Selecting the program interface information to be tested corresponding to the target position value from the program interface information set to be tested as the target program interface information to be tested; Performing a directed dependency edge update on at least one graph node in the initial program interface dependency graph corresponding to the program interface dependency information included in the target program interface information to be tested, so as to generate an initial program interface dependency graph after dependency edge update; In response to the target position value being greater than or equal to the quantity value of the program interface information to be tested in the program interface information set to be tested, determining the initial program interface dependency graph after the dependency edges are updated as the program interface dependency graph; In response to the target position value being less than the number of program interface information to be tested in the program interface information set to be tested, the target position value is incremented, the target position value after the position value is incremented is used as the target position value, and the initial program interface dependency graph after the dependency edge is updated is used as the initial program interface dependency graph, and the graph updating step is performed again, wherein the program interface dependency subgraph is divided into full coverage test chains to generate a program interface test chain group, including: Determine a node out-degree value and a node in-degree value corresponding to each graph node in at least one target graph node, wherein the at least one target graph node is at least one graph node included in the program interface dependency subgraph; Filter out a target graph node whose corresponding node out-degree value satisfies the filtering condition from the at least one target graph node as a path source node, wherein the node out-degree value corresponding to the target graph node is greater than 0 and the corresponding node in-degree value is equal to 0; Taking the path source node as the root node, performing graph-tree conversion on the program interface dependency subgraph to generate a program interface dependency subtree; Taking the path source node as the traversal start node, the program interface dependency subtree is deeply traversed to generate a program interface test chain group corresponding to the program interface dependency subgraph, wherein: The step of generating a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain includes: For each program interface test chain in the program interface test chain group, the following test case generation steps are performed: Determine the program interface information to be tested corresponding to the path source node included in the program interface test chain as the target program interface information to be tested; Extracting interface parameter features from the program interface parameter description information included in the target program interface information to be tested, so as to generate interface parameter features, wherein the interface parameter features include: interface parameter semantic features and interface parameter value features; By using the pre-trained test case generation model and interface parameter features, test cases for the program interface test chain are generated in batches, and a test case group corresponding to the program interface test chain in the test case group set is obtained, wherein: The performing program testing on the program interface test chain through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result includes: Determine the test case distribution of the test case group corresponding to the program interface test chain; Determining at least one test case segmentation boundary according to the test case distribution; Splitting the test case group corresponding to the program interface test chain through the at least one test case segmentation boundary to obtain at least one test case block; For the at least one test case block, generating a test case coverage probability for the test case block according to a ratio of the number of test cases included in the test case block and the number of test cases included in the test case group corresponding to the program interface test chain; Extracting test cases from the at least one test case block as test cases to be used, according to the test case coverage probability corresponding to the test case block and the program test requirement, to obtain a set of test cases to be used; The program interface test chain is subjected to program testing through the set of test cases to be used to generate the program test result.

2. The method according to claim 1, wherein: The method further comprises: Generate an abnormal code warning information set for the program information to be tested according to the program test result, wherein the abnormal code warning information in the abnormal code warning information set includes: abnormal code point position, abnormal code type and abnormal test case; For each abnormal code warning information in the abnormal code warning information set, the abnormal code warning information is sent to the warning information receiving node corresponding to the abnormal code warning information.

3. The method according to claim 2, wherein: The step of determining the program information to be tested includes: Obtaining a program file package to be tested, wherein the program file package to be tested adopts a tree structure to store at least one program file to be tested; For each of the at least one program file to be tested, the following step of generating program interface information to be tested is performed: Scan the program file to be tested to generate a program interface list; For each program interface in the program interface list, filter the program interface code corresponding to the program interface to determine at least one dependent program interface corresponding to the program interface, as program interface dependency information included in the program interface information to be tested corresponding to the program interface in the program interface information set to be tested, and determine program interface parameters of the program interface, as program interface parameter description information included in the program interface information to be tested corresponding to the program interface in the program interface information set to be tested.

4. A program testing device based on a test case, comprising: The determination unit is configured to determine the program information to be tested, wherein the program information to be tested includes: a program interface information set to be tested, and the program interface information to be tested in the program interface information set to be tested includes: program interface dependency information and program interface parameter description information; A generating unit is configured to generate a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information, wherein the program interface dependency graph includes: at least one program interface dependency subgraph; The execution unit is configured to perform the following processing steps for each program interface dependency subgraph in the at least one program interface dependency subgraph: divide the program interface dependency subgraph into full coverage test chains to generate a program interface test chain group; generate a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain, wherein there is a one-to-one correspondence between the test case group and the program interface test chain; for each program interface test chain in the program interface test chain group, perform program testing on the program interface test chain through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result, wherein, The step of generating a program interface dependency graph for the set of program interface information to be tested according to the program interface dependency information included in the program interface information comprises: Generate an initial program interface dependency graph, wherein the node quantity value of the graph nodes included in the initial program interface dependency graph is consistent with the quantity value of the program interface information to be tested in the program interface information set to be tested, and there is a one-to-one correspondence between the graph nodes included in the initial program interface dependency graph and the program interface information to be tested; According to the program interface information set to be tested and the initial program interface dependency graph, perform the following graph update steps: Selecting the program interface information to be tested corresponding to the target position value from the program interface information set to be tested as the target program interface information to be tested; Performing a directed dependency edge update on at least one graph node in the initial program interface dependency graph corresponding to the program interface dependency information included in the target program interface information to be tested, so as to generate an initial program interface dependency graph after dependency edge update; In response to the target position value being greater than or equal to the quantity value of the program interface information to be tested in the program interface information set to be tested, determining the initial program interface dependency graph after the dependency edges are updated as the program interface dependency graph; In response to the target position value being less than the number of program interface information to be tested in the program interface information set to be tested, the target position value is incremented, the target position value after the position value is incremented is used as the target position value, and the initial program interface dependency graph after the dependency edge is updated is used as the initial program interface dependency graph, and the graph updating step is performed again, wherein the program interface dependency subgraph is divided into full coverage test chains to generate a program interface test chain group, including: Determine a node out-degree value and a node in-degree value corresponding to each graph node in at least one target graph node, wherein the at least one target graph node is at least one graph node included in the program interface dependency subgraph; Filter out a target graph node whose corresponding node out-degree value satisfies the filtering condition from the at least one target graph node as a path source node, wherein the node out-degree value corresponding to the target graph node is greater than 0 and the corresponding node in-degree value is equal to 0; Taking the path source node as the root node, performing graph-tree conversion on the program interface dependency subgraph to generate a program interface dependency subtree; Taking the path source node as the traversal start node, the program interface dependency subtree is deeply traversed to generate a program interface test chain group corresponding to the program interface dependency subgraph, wherein: The step of generating a test case group set for the program interface test chain group according to the program interface parameter description information included in the program interface information to be tested corresponding to the program interface test chain includes: For each program interface test chain in the program interface test chain group, the following test case generation steps are performed: Determine the program interface information to be tested corresponding to the path source node included in the program interface test chain as the target program interface information to be tested; Extracting interface parameter features from the program interface parameter description information included in the target program interface information to be tested, so as to generate interface parameter features, wherein the interface parameter features include: interface parameter semantic features and interface parameter value features; By using the pre-trained test case generation model and interface parameter features, test cases for the program interface test chain are generated in batches, and a test case group corresponding to the program interface test chain in the test case group set is obtained, wherein: The performing program testing on the program interface test chain through the test case group corresponding to the program interface test chain in the test case group set to generate a program test result includes: Determine the test case distribution of the test case group corresponding to the program interface test chain; Determining at least one test case segmentation boundary according to the test case distribution; Splitting the test case group corresponding to the program interface test chain through the at least one test case segmentation boundary to obtain at least one test case block; For the at least one test case block, generating a test case coverage probability for the test case block according to a ratio of the number of test cases included in the test case block and the number of test cases included in the test case group corresponding to the program interface test chain; Extracting test cases from the at least one test case block as test cases to be used, according to the test case coverage probability corresponding to the test case block and the program test requirement, to obtain a set of test cases to be used; The program interface test chain is subjected to program testing through the set of test cases to be used to generate the program test result.

5. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.

6. A computer readable medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.