Traversal test path generation method, device, electronic device and readable storage medium

By creating directed graphs and optimizing path lengths using the Bellman-Ford algorithm, traversal test paths are generated, and the problem of inefficient testing in automated traversal tests is solved, and more efficient software defect discovery and testing coverage is achieved.

CN114721925BActive Publication Date: 2024-11-12CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110001482.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-04
Publication Date
2024-11-12
Estimated Expiration
2041-01-04

AI Technical Summary

Technical Problem

The testing efficiency in automated traversal testing technology is low, mainly due to the efficiency bottleneck caused by manual configuration traversal testing paths.

Method used

By obtaining the historical test result data of the software page to be tested, a directed graph is created, and the traversal test path is determined based on the preamble controls of the page control and the number of target defects. The Bellman-Ford algorithm is used to optimize the path length to generate the longest path.

Benefits of technology

It improves the testing efficiency of automated traversal testing, can detect software defects more quickly, and reduces the complexity and cost of manual configuration paths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721925B_ABST
    Figure CN114721925B_ABST
Patent Text Reader

Abstract

The present invention provides a traversal test path generation method, device, electronic device and readable storage medium. It includes: obtaining historical test result data of a software page to be tested, the historical test result data includes the preorder control and target defect number of each page control in the M page controls of the software page to be tested, the preorder control is the previous page control relative to the currently accessed page control in the historical traversal test process, and the target defect number is the number of defects triggered by accessing the page control from the preorder control; based on the preorder control and target defect number of each page control in the M page controls, creating a first control directed graph of the software page to be tested, the first control directed graph includes M nodes of the M page controls; determining the access path with the longest path length among the N access paths composed of the M nodes in the first control directed graph to obtain the traversal test path. The embodiment of the present invention can improve the test efficiency of automated traversal testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of data service technology, and in particular to a traversal test path generation method, device, electronic device, and readable storage medium. Background Art

[0002] In the context of agile software development, version iterations are fast and test cycles are shortened, requiring testers to quickly deliver test results with the help of automated testing methods. In order to cover as much of the test scope as possible and to be able to replace testers in checking each module of the software, the concept of automated traversal testing came into being.

[0003] Automated traversal testing refers to traversing and clicking on the controls on the software interface through program control to find as many defects as possible in the tested controls or applications. In order to achieve more possible test coverage and find more software defects, it is very important to reasonably select the traversal test path.

[0004] Currently, traversal testing tools usually require manual configuration of traversal test paths, resulting in relatively low testing efficiency. Summary of the invention

[0005] The embodiments of the present invention provide a traversal test path generation method, device, electronic device and readable storage medium to solve the problem of relatively low test efficiency existing in the automated traversal test technology.

[0006] To solve the above problems, the present invention is achieved as follows:

[0007] In a first aspect, an embodiment of the present invention provides a method for generating a traversal test path, the method comprising:

[0008] Acquire historical test result data of a software page to be tested, wherein the software page to be tested includes M page controls, and the historical test result data includes a predecessor control and a target defect number of each page control in the M page controls, wherein the predecessor control is a page control previous to a currently accessed page control in a historical traversal test process, and the target defect number is the number of defects triggered by accessing the page control from the predecessor control, and M is a positive integer greater than 1;

[0009] Based on the preceding control and the target defect quantity of each page control in the M page controls, creating a first control directed graph of the software page to be tested, wherein the first control directed graph includes M nodes of the M page controls;

[0010] Determine the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control to obtain a traversal test path, where N is a positive integer.

[0011] In the above scheme, the step of creating a first control directed graph of the software page to be tested based on the preceding control and the target defect quantity of each page control in the M page controls includes:

[0012] Create M nodes of the M page controls;

[0013] Based on the predecessor control and the target defect number of each page control in the M page controls, a directed edge between nodes in the M nodes is created, wherein the path direction of the directed edge represents the access path from the predecessor control to the page control, and the path length of the directed edge is determined by the target defect number of the page control;

[0014] Among them, the first control directed graph of the software page to be tested also includes directed edges between nodes in the M nodes.

[0015] In the above scheme, the step of determining the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control to obtain the traversal test path includes:

[0016] Determine a source node among the M nodes, the source node representing a starting node of the access path;

[0017] Determine the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control to obtain a traversal test path.

[0018] In the above scheme, the step of determining the access path with the longest path length among the N access paths from the source node to other nodes in the M nodes except the source node in the directed graph of the first control to obtain a traversal test path includes:

[0019] Performing a reverse operation on the path length of the directed edge in the first control directed graph to obtain a second control directed graph;

[0020] Obtaining the initial path length from the source node to the other nodes in the directed graph of the second control;

[0021] Performing an iterative relaxation operation on each directed edge in the directed graph of the second control to update the initial path length;

[0022] When it is determined that the second control directed graph does not include a negative weight loop, the target access path is determined to be the access path with the longest path length among the N access paths in the first control directed graph to obtain a traversal test path, and the target access path is the access path corresponding to the initial path length updated in the second control directed graph.

[0023] In the above scheme, each of the M page controls includes at least one target defect number, the page control corresponding to the source node is the page control with the largest number of comprehensive defects among the M page controls, and the comprehensive defect number is the sum of the at least one target defect number.

[0024] In a second aspect, an embodiment of the present invention further provides a traversal test path generation device, comprising:

[0025] An acquisition module is used to acquire historical test result data of a software page to be tested, wherein the software page to be tested includes M page controls, and the historical test result data includes a predecessor control and a target defect number of each page control in the M page controls, wherein the predecessor control is a page control previous to a currently accessed page control during a historical traversal test, and the target defect number is the number of defects triggered by accessing the page control from the predecessor control, and M is a positive integer greater than 1;

[0026] A creation module, configured to create a first control directed graph of the software page to be tested based on a preceding control and a target defect quantity of each page control in the M page controls, wherein the first control directed graph includes M nodes of the M page controls;

[0027] A determination module is used to determine the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control, so as to obtain a traversal test path, where N is a positive integer.

[0028] In the above scheme, the creation module includes:

[0029] A first creation unit, used to create M nodes of the M page controls;

[0030] A second creation unit is used to create a directed edge between nodes in the M nodes based on a predecessor control and a target defect number of each page control in the M page controls, wherein a path direction of the directed edge represents an access path from the predecessor control to the page control, and a path length of the directed edge is determined by the target defect number of the page control;

[0031] Among them, the first control directed graph of the software page to be tested also includes directed edges between nodes in the M nodes.

[0032] In the above solution, the determination module includes:

[0033] A first determining unit, configured to determine a source node among the M nodes, wherein the source node represents a starting node of an access path;

[0034] The second determination unit is used to determine the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control, so as to obtain a traversal test path.

[0035] In the above scheme, the second determination unit is specifically used to perform a reverse operation on the path length of the directed edge in the first control directed graph to obtain the second control directed graph; obtain the initial path length from the source node to the other nodes in the second control directed graph; perform an iterative relaxation operation on each directed edge in the second control directed graph to update the initial path length; when it is determined that the second control directed graph does not include a negative weight loop, determine the target access path as the access path with the longest path length among the N access paths in the first control directed graph to obtain a traversal test path, and the target access path is the access path corresponding to the initial path length updated in the second control directed graph.

[0036] In the above scheme, each of the M page controls includes at least one target defect number, the page control corresponding to the source node is the page control with the largest number of comprehensive defects among the M page controls, and the comprehensive defect number is the sum of the at least one target defect number.

[0037] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps in the method described in the first aspect.

[0038] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium for storing a program, wherein the program, when executed by a processor, implements the steps in the method described in the first aspect.

[0039] In an embodiment of the present invention, by obtaining the preceding control and target defect quantity of each page control in the M page controls in the software page to be tested, and based on the preceding control and target defect quantity of each page control in the M page controls, a first control directed graph of the software page to be tested is created, wherein the first control directed graph includes M nodes of the M page controls; thus, the traversal test path can be obtained by determining the access path with the longest path length among the N access paths composed of the M nodes in the first control directed graph. In this way, the test efficiency of the automated traversal test can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0041] Figure 1 It is a flowchart of a traversal test path generation method provided by an embodiment of the present invention;

[0042] Figure 2 is a schematic diagram of the topological structure of the directed graph of the first control in an embodiment of the present invention;

[0043] Figure 3 It is a schematic diagram of a flow chart of generating a traversal test path of a software page to be tested in an embodiment of the present invention;

[0044] Figure 4 is a structural schematic diagram of a traversal test path generating device provided by an embodiment of the present invention;

[0045] Figure 5 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] The terms "first", "second" etc. in the embodiments of the present invention are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. In addition, the terms "include" and "have" and any variation thereof are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or units need not be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment. In addition, "and / or" is used in the present application to represent at least one of the connected objects, such as A and / or B and / or C, which represents 7 situations including single A, single B, single C, and A and B all exist, B and C all exist, A and C all exist, and A, B and C all exist.

[0048] The following first describes the traversal test path generation method provided by an embodiment of the present invention.

[0049] It should be noted that the traversal test path generation method provided in the embodiment of the present invention can be executed by the traversal test path generation device of the embodiment of the present invention. The traversal test path generation device of the embodiment of the present invention can be configured in any electronic device to execute the traversal test path generation method of the embodiment of the present invention. The electronic device can be a server or a terminal, which is not specifically limited here.

[0050] See also Figure 1 , the figure shows a schematic diagram of the process of the traversal test path generation method provided by an embodiment of the present invention. Figure 1 As shown, the method may include the following steps:

[0051] Step 101, obtaining historical test result data of the software page to be tested, wherein the software page to be tested includes M page controls, and the historical test result data includes a predecessor control and a target defect number of each page control in the M page controls, wherein the predecessor control is the page control previous to the currently accessed page control during the historical traversal test process, and the target defect number is the number of defects triggered by accessing the page control from the predecessor control, and M is a positive integer greater than 1.

[0052] In this embodiment, the software page to be tested may be a software page of a software module to be tested, wherein the software module to be tested may correspond to at least one software page, and the software page to be tested may be any software page of the software module to be tested.

[0053] In the actual engineering implementation of automated traversal testing, in order to avoid frequent loop jumps between software pages in the software module and reduce the test efficiency, the traversal of the next-level software page is usually considered after all page controls of the current software page are traversed. Therefore, the traversal test path generation problem of the software module can be decomposed into the traversal test path generation problem of each software page, and for each software page, the traversal test path is generated for the software page, wherein the software page currently performing the traversal test path generation can be referred to as the software page to be tested. For example, the software module corresponds to software page 1, software page 2 and software page 3, and its test logic order is software page 1->software page 2->software page 3, that is, first complete the traversal test of software page 1, then jump to the traversal test of the next-level software page, namely software page 2, and finally complete the traversal test of the last-level software page, namely software page 3.

[0054] Among them, generating a traversal test path for the software page to be tested refers to solving the optimal traversal test path for the software page to be tested, so that when the software page to be tested is tested using the traversal test path, the defect problems of the software page to be tested in the software module can be tested to the maximum extent.

[0055] Since the page controls that triggered defects during the historical traversal test process are very likely to trigger defects again under the traversal test path, the historical test result data can be collected as sample data for generating the current traversal test path.

[0056] Among them, the historical traversal test of the software module refers to the process relative to the current traversal test, which can be called the previous round of traversal test. The historical traversal test of the software module can include traversal testing of the software module by manually configuring the traversal test path, traversal testing of the software module by using automated traversal testing tools, traversal testing of the software module by using breadth-first traversal or depth-first traversal algorithms, or traversal testing of the software module by using other methods.

[0057] Accordingly, the historical test result data of the software module may include the historical test result data of each software page. The historical test result data of the historical traversal test of the software module may be stored, and accordingly, during the current round of traversal testing, the stored historical test result data may be obtained as the generation of the traversal test path of the current round of traversal testing. Specifically, the historical test result data of each software page within the current test range of the software module may be obtained, and the historical test result data of the software page to be tested may be obtained from the historical test result data of each software page within the current test range of the software module.

[0058] The software page to be tested may include multiple page controls, and the defects that may be triggered by a page control are not only related to the page control, but also to the page controls traversed before clicking the page control, that is, the generation of software module defects is related to the front-end interaction logic. Therefore, different traversal test paths, that is, the order of traversal of page controls, will test different numbers of defects in the software module.

[0059] Since whether a page control triggers a defect is not only related to the page control itself, but also to the access path of the page control, that is, the page interaction logic, the data to be concerned about when generating the traversal test path may be the number of defects triggered by the page control and the access path of the page control. In the historical traversal test process, the number of defects and access paths triggered by the page control in each software page of the software module can be stored. Accordingly, the historical test result data of the software page to be tested may include the preceding control of each page control in the M page controls in the software page to be tested and the target number of defects of each page control.

[0060] The target defect number of the page control refers to the defect number triggered by accessing the current page control from the previous control, and the previous control refers to the previous page control relative to the currently accessed page control during the historical traversal test.

[0061] The target number of defects triggered by page controls can be easily obtained through the results of the previous round of traversal testing, and the access path of page controls involves all controls before accessing the page control. Considering the simplicity of storage, all page controls in the software page can be abstracted as nodes, and the access path of page controls is the directed vector diagram between the nodes of each page control. The parent access page control of the page control can be recorded, and the source can be traced upward to obtain the predecessor control of each page control, that is, the traversal test path.

[0062] Specifically, for the page control w n , 1≤n≤N, N represents the total number of page controls of software page k in the software module, then page control w n The historical test result data can be expressed as [w q ,Q nq ], where the page control w q Represents the page control w n The preceding control, Q nq Indicates that from the page control w q Access to page control w n The number of defects triggered.

[0063] It should be noted that when the software module is traversed for the first time, since there is no historical traversal test result data, in this application scenario, a traditional traversal test scheme can be adopted. The traversal test path is not defined, and only the depth-first traversal or breadth-first traversal of the software page is completed, and the test result data is stored so that the historical test result data can be used in the next round of traversal testing to complete the generation of the traversal test path of the software page to be tested in the software module.

[0064] Step 102: Create a first control directed graph of the software page to be tested based on the preceding control and the target defect quantity of each page control in the M page controls, wherein the first control directed graph includes M nodes of the M page controls.

[0065] A first control directed graph of the software page to be tested may be created based on a preceding control and a target defect quantity of each page control in the M page controls, wherein the first control directed graph includes M nodes of the M page controls.

[0066] The first control directed graph is composed of two important information, namely, nodes and directed edges. The nodes correspond to page controls, and each node corresponds to a page control. In practical applications, the nodes can be represented by a specific data structure or data object, and the traversal test path generation device can create a node corresponding to the page control for each page by creating a data object, and the attribute characteristics of the node include the attribute information of the page control.

[0067] A directed edge corresponds to an access path from node to node, that is, an access path from the previous control of a page control to the page control. A directed edge can be in vector form, which can include two attributes, one is a direction attribute and the other is a length attribute.

[0068] The direction attribute of the directed edge can be determined by the previous control of the page control and the page control, that is, the path direction from the previous control to the page control can be determined as the direction of the directed edge. The length attribute of the directed edge can be determined by the target defect number of the page control, that is, the target defect number of the page control can be determined as the path length of the directed edge.

[0069] Since more than one traversal test path may be used to test the software page during multiple tests of historical traversal, a page control may include multiple predecessor controls, that is, the nodes of the page control and the nodes of its predecessor controls can form multiple directed edges, and accordingly, the M nodes and the directed edges of the M nodes can form one or more access paths of the M page controls, that is, multiple traversal test paths can be constructed.

[0070] See also Figure 2 , Figure 2 is a schematic diagram of the topological structure of the directed graph of the first control in an embodiment of the present invention, such as Figure 2 As shown, the software page to be tested includes 5 page controls, which can be represented by node w1, node w2, node w3, node w4 and node w5 respectively. Since for node w4, its page control can include multiple pre-order controls, that is, its access path can include multiple access paths, such as accessing from node w5 to node w4, accessing from node w2 to node w4, and accessing from node w1 to node w4, therefore, in the first control directed graph, the M nodes and the directed edges of the M nodes can constitute multiple traversal test paths of the M page controls.

[0071] The data form of the first control directed graph can be expressed by the following formula (1):

[0072] G k =(W k ,B k );k=1,2,...,K (1)

[0073] Where K represents the total number of software pages of the software module under test, and k represents the sequence number of the software page to be tested. k Represents the first control directed graph of the software page k to be tested, W k represents the node set of the page control of the software page k to be tested, and B k Represents the set of directed edges of the software page k to be tested.

[0074] The node set of the page control of the software page k to be tested can be expressed by the following formula (2):

[0075] W k ={w1,w2,...,w n}; 1≤n≤N (2)

[0076] Among them, w i (1≤i≤N) represents the page control of the node with sequence number i.

[0077] The set of directed edges of the software page k to be tested can be expressed by the following formula (3):

[0078] B k = {b ij},|b ij |=Q ij , 1≤i,j≤N,|Q ij |>0 (3)

[0079] Among them, b ij (1≤i,j≤N) represents the slave node w i Page control to node w j The directed path of the page control, also represents the node w i The page control is node w j The preceding control of the page control if and only if |Q ij |>0, b ij Only exists, and Q ij Represents the slave node w i Page control to node w j The number of defects triggered by the page controls. Obviously, |b ij |=Q ij It indicates that the weight of the directed edge between nodes, that is, between page controls, is the number of target defects carried on the edge of the page control.

[0080] Step 103, determining the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control to obtain a traversal test path, where N is a positive integer.

[0081] The purpose of the embodiment of the present invention is to find an optimal traversal test path from the multiple traversal test paths so that the traversal test path can trigger as many defects as possible.

[0082] Since the weight of the directed edge between the nodes in the directed graph of the first control, that is, the page controls, is the target number of defects carried on the edge of the page control, the problem of solving the optimal traversal test path of the software page to be tested can be converted into the problem of solving the longest path among the N access paths of the directed graph of the first control. In other words, the access path of the longest path among the N access paths of the directed graph of the first control can represent the optimal traversal test path of the software page to be tested.

[0083] In this embodiment, by obtaining the preceding control and target defect number of each page control in the M page controls in the software page to be tested, and based on the preceding control and target defect number of each page control in the M page controls, a first control directed graph of the software page to be tested is created, and the first control directed graph includes M nodes of the M page controls; in this way, the traversal test path can be obtained by determining the access path with the longest path length among the N access paths composed of the M nodes in the first control directed graph. In this way, compared with the solution of manually configuring the traversal test path, automatically determining the traversal test path through historical test result data can improve the test efficiency of the traversal test.

[0084] Moreover, when determining the traversal test path, this embodiment takes into account that the defects that may be triggered by the page control are not only related to the page control itself, but also to the predecessor controls of clicking the page control, that is, taking into account the correlation between whether the triggering of the page control will cause a defect and the predecessor controls triggered by the page control, and no longer adopts the idea of ​​taking the best in a single step, but solves the problem of solving the optimal traversal test path for each software page in the software module, and abstracts it into a global optimal traversal test path problem, thereby improving the traversal test effect of the software module and reducing the algorithm complexity of the traversal test path generation.

[0085] Moreover, considering the trade-off of algorithm complexity in actual engineering implementation, the historical test result data of the software module can be obtained as the sample data of the current traversal test, and the traversal test path of the current traversal test of the software module can be solved based on the historical test result data. Under the premise of a certain algorithm complexity, the global optimal traversal test path of the software page can be automatically generated, which is easier to implement in engineering, has low complexity, and can reduce labor costs.

[0086] Optionally, step 102 specifically includes:

[0087] Create M nodes of the M page controls;

[0088] Based on the predecessor control and the target defect number of each page control in the M page controls, a directed edge between nodes in the M nodes is created, wherein the path direction of the directed edge represents the access path from the predecessor control to the page control, and the path length of the directed edge is determined by the target defect number of the page control;

[0089] Among them, the first control directed graph of the software page to be tested also includes directed edges between nodes in the M nodes.

[0090] In this implementation manner, specifically described is a process of creating a first control directed graph of the software page to be tested based on the preceding control and the target defect quantity of each page control in the M page controls.

[0091] Specifically, M nodes of M page controls can be created based on a specific data structure or data object, and the created node set can be used k ={w1,w2,...,w n}; 1≤n≤N represents.

[0092] For the created node, you can traverse the node w i ∈W k ,i=1,2,...,N page controls, for w j ∈W k ,j=1,2,...,N,j≠i, if |Q ij |>0, then w i The preceding control is w j , draw the node w of the page control j To the node w of the page control i The directed vector b ji , and there is also a ji The weight is Q ij , that is, node w i The target number of defects for the page control.

[0093] In this embodiment, by creating nodes of page controls of the software page to be tested and creating directed edges between nodes based on the predecessor controls of the page controls and the target number of defects, a first control directed graph of the software page to be tested can be constructed, and then the optimal traversal test path of the software page to be tested can be solved based on the first control directed graph.

[0094] Optionally, step 103 specifically includes:

[0095] Determine a source node among the M nodes, the source node representing a starting node of the access path;

[0096] Determine the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control to obtain a traversal test path.

[0097] In this embodiment, if Figure 2 The nodes in the first control directed graph shown represent page controls, the vectors between the nodes represent the access paths between the nodes, and the vector values ​​represent the number of target defects triggered by the access paths. Therefore, solving the traversal test path problem that triggers the largest number of defects can be transformed into solving the longest path problem of the first control directed graph.

[0098] Furthermore, for the first control directed graph, a source node can be specified to transform the optimal traversal test path problem into the problem of solving the longest path from the source node to other nodes of the software page to be tested. Figure 2 , specifying the source node as node w1, and the purpose of this implementation is to solve the longest path from node w1 to other nodes, including node w2, node w3, node w4 and node w5. The longest path represents the optimal traversal test path of the software page to be tested.

[0099] Among them, the source node can be any one of the M nodes, or it can be a node of the page control that can follow the maximum number of triggered defects as the source node, or a node of the page control that does not include the preceding control as the source node. This implementation does not make specific limitations.

[0100] Existing or new algorithms such as the Floyd algorithm or the Bellman-Ford algorithm can be used to determine the access path with the longest path length among the N access paths from the source node to other nodes in the M nodes except the source node in the directed graph of the first control.

[0101] Optionally, the step of determining the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control to obtain a traversal test path includes:

[0102] Performing a reverse operation on the path length of the directed edge in the first control directed graph to obtain a second control directed graph;

[0103] Obtaining the initial path length from the source node to the other nodes in the directed graph of the second control;

[0104] Performing an iterative relaxation operation on each directed edge in the directed graph of the second control to update the initial path length;

[0105] When it is determined that the second control directed graph does not include a negative weight loop, the target access path is determined to be the access path with the longest path length among the N access paths in the first control directed graph to obtain a traversal test path, and the target access path is the access path corresponding to the initial path length updated in the second control directed graph.

[0106] In this implementation, the Bellman-Ford algorithm may be used to determine the longest access path among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control.

[0107] The Bellman-Ford algorithm is an algorithm for solving the single-source shortest path of a directed graph. Its basic principle is to gradually obtain the shortest path by performing a cyclic edge relaxation operation on the directed graph. The algorithm allows the edge weights in the directed graph to be negative. Therefore, the weights of the directed edges in the first control directed graph, i.e., the path length, can be inverted to obtain the second control directed graph. Then, solving the single-source maximum path problem in the first control directed graph can be transformed into solving the single-source shortest path problem in the second control directed graph. Therefore, the Bellman-Ford algorithm can be applied to complete the generation of the traversal test path of the software page to be tested.

[0108] See also Figure 3 , Figure 3 FIG. 1 is a schematic diagram of a flow chart of a traversal test path of a software page to be tested in an embodiment of the present invention. Figure 3 As shown, the generation of the traversal test path of the software page to be tested using the Bellman-Ford algorithm includes the following steps:

[0109] Step 301, invert the weights of all directed edges in the first control directed graph to update the first control directed graph to obtain a second control directed graph.

[0110] The main goal of this step is to transform the longest path problem of the directed graph of the first control into the shortest path problem of the directed graph of the second control by inverting the weights of all directed edges in the directed graph of the first control.

[0111] The set of directed edges of the second control directed graph can be expressed by formula (4).

[0112] B k = {b ij},|b ij |=-Q ij , 1≤i,j≤N,|Q ij |>0 (4)

[0113] Among them, compared with the first control directed graph, the second control directed graph is the same as the first control directed graph except that the weights of the directed edges are different.

[0114] Step 302: Select a source node.

[0115] The source node may be selected after step 301 or before step 301 .

[0116] Since the source node of the software page to be tested has many access times, the selection of the source node can follow the goal of maximizing the number of triggered defects. That is, each of the M page controls includes at least one target defect number, and the page control corresponding to the source node is the page control with the largest number of comprehensive defects among the M page controls, and the comprehensive defect number is the sum of the at least one target defect number. Among them, each target defect number is the number of defects triggered from a preceding control of the page control to the page control, and different target defect numbers are the number of defects triggered from different preceding controls of the page control to the page control.

[0117] Specifically, for the first control directed graph G k Middle node w i The page control, the collection of its predecessor controls S i It can be expressed as S i ={w j},1≤j≤N,i≠j and |Q ji |≠0, then the source node formula of the directed graph of the first control can be defined as shown in the following formula (5):

[0118]

[0119] Step 303: Initialize the shortest path from the source node to other nodes.

[0120] According to the Bellman-Ford algorithm, the node w of the page control in the second control directed graph i The shortest path is d i Description, then d i It can be expressed by the following formula (6):

[0121]

[0122] Step 304: perform an iterative relaxation operation on each directed edge in the directed graph of the second control.

[0123] In this step, the relaxation operation is repeatedly performed on each edge in the set of directed edges of the second control directed graph to update the initialized shortest distance, so that the shortest distance estimate of the page control of each node in the node set in the second control directed graph gradually approaches its shortest distance.

[0124] For b ij ∈B k , let the source node of the second control directed graph be w k' , the shortest distance d i Represents the source node w k' To node w i The shortest distance, let the shortest distance vector be l i , indicating the shortest distance from the source node w k' To node w i In addition, let node w j Yes i The preceding node of |b ji | represents the slave node w j To node w i The weight of the directed edge of . The relaxation operation is described as follows:

[0125] If there is a directed edge b ji Satisfies the following formula (7):

[0126] d i >d j +|b ji | (7)

[0127] Then use the following equations (8) and (9) to update d i Values:

[0128] d i =d j +|b ji | (8)

[0129] l i =(w k' ,w j ,w i ) (9)

[0130] Step 305 , determine whether there is a negative weight loop in the directed graph of the second control, if yes, execute step 306 , if not, execute step 307 .

[0131] According to the Bellman-Ford algorithm, determine the directed edge b ij ∈B k The two nodes w i and w j Convergence: If all the nodes associated with the directed edges in the second control directed graph converge, it means that the second control directed graph does not have a negative weight loop and there is a shortest path reachable from the source node; otherwise, it means that the second control directed graph has a negative weight loop and there is no shortest path reachable from the source node, and jump to step 306.

[0132] Step 306: If there is a negative-weight loop in the directed graph of the second control, a traditional traversal test path is adopted.

[0133] If there is a negative-weight loop in the directed graph of the second control, there is no global shortest path, so a traditional traversal test path can be adopted, for example, a traversal test path obtained by a depth-first traversal algorithm or a breadth-first traversal algorithm.

[0134] Step 307: When there is no negative weight loop in the second control directed graph, for each node in the second control directed graph, there is a shortest path reachable from the source node. Let the source node be w k' , it can be described as shown in the following formula (10):

[0135]

[0136] l i ,1≤i≤N,i≠k' is the traversal test path of traversing the page controls of other nodes starting from the page control of the source node in the topology of the second control directed graph.

[0137] After that, the above steps can be used to obtain the traversal test paths of each software page in the software module, and obtain a set of test traversal paths of the software module. Simply configure the set of traversal test paths into the automated traversal test code library to perform the current round of traversal testing and store the test results for the next round of traversal testing.

[0138] The test results may include the number of defects triggered by the page control and the predecessor controls of the page control. The predecessor controls of the page control may be obtained according to the set of traversal test paths. The number of defects triggered by the page control may be captured by program code during the traversal test and saved in a database.

[0139] The various optional implementation modes introduced in the embodiments of the present invention may be implemented in combination with each other or may be implemented separately if they do not conflict with each other, and the embodiments of the present invention are not limited to this.

[0140] The following is a description of a traversal test path generating device provided by an embodiment of the present invention.

[0141] See also Figure 4 , the figure shows a schematic diagram of the structure of the traversal test path generation device provided by an embodiment of the present invention. Figure 4 As shown, the traversal test path generating device 400 includes:

[0142] The acquisition module 401 is used to acquire historical test result data of the software page to be tested, wherein the software page to be tested includes M page controls, and the historical test result data includes a predecessor control and a target defect number of each page control in the M page controls, wherein the predecessor control is a page control previous to the currently accessed page control in the historical traversal test process, and the target defect number is the number of defects triggered by accessing the page control from the predecessor control, and M is a positive integer greater than 1;

[0143] A creation module 402 is used to create a first control directed graph of the software page to be tested based on the preceding control and the target defect quantity of each page control in the M page controls, wherein the first control directed graph includes M nodes of the M page controls;

[0144] The determination module 403 is used to determine the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control, so as to obtain a traversal test path, where N is a positive integer.

[0145] Optionally, the creation module 402 includes:

[0146] A first creation unit, used to create M nodes of the M page controls;

[0147] A second creation unit is used to create a directed edge between nodes in the M nodes based on a predecessor control and a target defect number of each page control in the M page controls, wherein a path direction of the directed edge represents an access path from the predecessor control to the page control, and a path length of the directed edge is determined by the target defect number of the page control;

[0148] Among them, the first control directed graph of the software page to be tested also includes directed edges between nodes in the M nodes.

[0149] Optionally, the determining module 403 includes:

[0150] A first determining unit, configured to determine a source node among the M nodes, wherein the source node represents a starting node of an access path;

[0151] The second determination unit is used to determine the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control, so as to obtain a traversal test path.

[0152] Optionally, the second determination unit is specifically used to perform a reverse operation on the path length of the directed edges in the first control directed graph to obtain the second control directed graph; obtain the initial path length from the source node to the other nodes in the second control directed graph; perform an iterative relaxation operation on each directed edge in the second control directed graph to update the initial path length; when it is determined that the second control directed graph does not include a negative weight loop, determine the target access path as the access path with the longest path length among the N access paths in the first control directed graph to obtain a traversal test path, wherein the target access path is the access path corresponding to the initial path length updated in the second control directed graph.

[0153] Optionally, each of the M page controls includes at least one target defect number, the page control corresponding to the source node is the page control with the largest number of comprehensive defects among the M page controls, and the comprehensive defect number is the sum of the at least one target defect number.

[0154] The traversal test path generating device 400 can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.

[0155] The electronic device provided by the embodiment of the present invention is described below.

[0156] See also Figure 5 , the figure shows a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 5 As shown, the electronic device 500 includes: a processor 501 , a memory 502 , a user interface 503 and a bus interface 504 .

[0157] The processor 501 is used to read the program in the memory 502 and execute the following process:

[0158] Acquire historical test result data of a software page to be tested, wherein the software page to be tested includes M page controls, and the historical test result data includes a predecessor control and a target defect number of each page control in the M page controls, wherein the predecessor control is a page control previous to a currently accessed page control in a historical traversal test process, and the target defect number is the number of defects triggered by accessing the page control from the predecessor control, and M is a positive integer greater than 1;

[0159] Based on the preceding control and the target defect quantity of each page control in the M page controls, creating a first control directed graph of the software page to be tested, wherein the first control directed graph includes M nodes of the M page controls;

[0160] Determine the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control to obtain a traversal test path, where N is a positive integer.

[0161] exist Figure 5 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically one or more processors represented by processor 501 and various circuits of memory represented by memory 502 are linked together. The bus architecture may also link together various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface 504 provides an interface. For different user devices, the user interface 503 may also be an interface that can be connected to external or internal devices, and the connected devices include but are not limited to keypads, displays, speakers, microphones, joysticks, etc.

[0162] The processor 501 is responsible for managing the bus architecture and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. Optionally, the processor 501 can be a CPU, ASIC, FPGA or CPLD. The memory 502 can store data used by the processor 501 when performing operations.

[0163] Optionally, the processor 501 is further configured to:

[0164] Create M nodes of the M page controls;

[0165] Based on the predecessor control and the target defect number of each page control in the M page controls, a directed edge between nodes in the M nodes is created, wherein the path direction of the directed edge represents the access path from the predecessor control to the page control, and the path length of the directed edge is determined by the target defect number of the page control;

[0166] Among them, the first control directed graph of the software page to be tested also includes directed edges between nodes in the M nodes.

[0167] Optionally, the processor 501 is further configured to:

[0168] Determine a source node among the M nodes, the source node representing a starting node of the access path;

[0169] Determine the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control to obtain a traversal test path.

[0170] Optionally, the processor 501 is further configured to:

[0171] Performing a reverse operation on the path length of the directed edge in the first control directed graph to obtain a second control directed graph;

[0172] Obtaining the initial path length from the source node to the other nodes in the directed graph of the second control;

[0173] Performing an iterative relaxation operation on each directed edge in the directed graph of the second control to update the initial path length;

[0174] When it is determined that the second control directed graph does not include a negative weight loop, the target access path is determined to be the access path with the longest path length among the N access paths in the first control directed graph to obtain a traversal test path, and the target access path is the access path corresponding to the initial path length updated in the second control directed graph.

[0175] Optionally, each of the M page controls includes at least one target defect number, the page control corresponding to the source node is the page control with the largest number of comprehensive defects among the M page controls, and the comprehensive defect number is the sum of the at least one target defect number.

[0176] Preferably, an embodiment of the present invention also provides an electronic device, including a processor 501, a memory 502, and a computer program stored in the memory 502 and executable on the processor 501. When the computer program is executed by the processor 501, the various processes of the above-mentioned traversal test path generation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0177] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned traversal test path generation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0178] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0179] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0180] In the embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0181] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0182] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0183] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.

[0184] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A traversal test path generation method, characterized in that: The method comprises: Acquire historical test result data of a software page to be tested, wherein the software page to be tested includes M page controls, and the historical test result data includes a predecessor control and a target defect number of each page control in the M page controls, wherein the predecessor control is a page control previous to a currently accessed page control in a historical traversal test process, and the target defect number is the number of defects triggered by accessing the page control from the predecessor control, and M is a positive integer greater than 1; Creating M nodes of the M page controls; the first control directed graph of the software page to be tested includes the M nodes of the M page controls; Based on the predecessor control and the target defect number of each page control in the M page controls, creating directed edges between nodes in the M nodes, the path direction of the directed edges representing the access path from the predecessor control to the page control, and the path length of the directed edges being determined by the target defect number of the page control; the first control directed graph also includes directed edges between nodes in the M nodes; Determine the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control to obtain a traversal test path, where N is a positive integer.

2. The method according to claim 1, characterized in that The step of determining the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control to obtain a traversal test path includes: Determine a source node among the M nodes, the source node representing a starting node of the access path; Determine the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control to obtain a traversal test path.

3. The method according to claim 2, characterized in that The step of determining the access path with the longest path length among the N access paths from the source node to other nodes in the M nodes except the source node in the first control directed graph to obtain a traversal test path includes: Performing a reverse operation on the path length of the directed edge in the first control directed graph to obtain a second control directed graph; Obtaining the initial path length from the source node to the other nodes in the directed graph of the second control; Performing an iterative relaxation operation on each directed edge in the directed graph of the second control to update the initial path length; When it is determined that the second control directed graph does not include a negative weight loop, the target access path is determined to be the access path with the longest path length among the N access paths in the first control directed graph to obtain a traversal test path, and the target access path is the access path corresponding to the initial path length updated in the second control directed graph.

4. The method according to claim 2, characterized in that: Each of the M page controls includes at least one target defect number, the page control corresponding to the source node is the page control with the largest number of comprehensive defects among the M page controls, and the comprehensive defect number is the sum of the at least one target defect number.

5. A traversal test path generation device, characterized in that: include: An acquisition module is used to acquire historical test result data of a software page to be tested, wherein the software page to be tested includes M page controls, and the historical test result data includes a predecessor control and a target defect number of each page control in the M page controls, wherein the predecessor control is a page control previous to a currently accessed page control during a historical traversal test, and the target defect number is the number of defects triggered by accessing the page control from the predecessor control, and M is a positive integer greater than 1; A creation module, configured to create a first control directed graph of the software page to be tested based on a preceding control and a target defect quantity of each page control in the M page controls, wherein the first control directed graph includes M nodes of the M page controls; A determination module, used to determine the access path with the longest path length among the N access paths composed of the M nodes in the directed graph of the first control, so as to obtain a traversal test path, where N is a positive integer; The creation module includes: A first creation unit, used to create M nodes of the M page controls; A second creation unit is used to create a directed edge between nodes in the M nodes based on a predecessor control and a target defect number of each page control in the M page controls, wherein a path direction of the directed edge represents an access path from the predecessor control to the page control, and a path length of the directed edge is determined by the target defect number of the page control; Among them, the first control directed graph of the software page to be tested also includes directed edges between nodes in the M nodes.

6. The device according to claim 5, characterized in that The determination module comprises: A first determining unit, configured to determine a source node among the M nodes, wherein the source node represents a starting node of an access path; The second determination unit is used to determine the access path with the longest path length among the N access paths from the source node to other nodes among the M nodes except the source node in the directed graph of the first control, so as to obtain a traversal test path.

7. The device according to claim 6, characterized in that The second determination unit is specifically used to perform a reverse operation on the path length of the directed edge in the first control directed graph to obtain the second control directed graph; obtain the initial path length from the source node to the other nodes in the second control directed graph; perform an iterative relaxation operation on each directed edge in the second control directed graph to update the initial path length; when it is determined that the second control directed graph does not include a negative weight loop, determine the target access path as the access path with the longest path length among the N access paths in the first control directed graph to obtain a traversal test path, and the target access path is the access path corresponding to the initial path length updated in the second control directed graph.

8. The device according to claim 6, characterized in that Each of the M page controls includes at least one target defect number, the page control corresponding to the source node is the page control with the largest number of comprehensive defects among the M page controls, and the comprehensive defect number is the sum of the at least one target defect number.

9. An electronic device, characterized in that: The electronic device comprises: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the traversal test path generation method as claimed in any one of claims 1 to 4 when executed by the processor.

10. A readable storage medium for storing a program, characterized in that: When the program is executed by a processor, the steps in the traversal test path generation method according to any one of claims 1 to 4 are implemented.