A computer software automatic test analysis method and test platform

By statically analyzing the software source code and building a knowledge graph, identifying code changes and prioritizing test cases, the problem of difficult to identify code changes and generating test cases in the existing technology is solved, and efficient test coverage and risk assessment are achieved.

CN119046167BActive Publication Date: 2025-02-11HANGZHOU JIEJING SCI & TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411484151.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-11
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

It is difficult for the existing technology to effectively identify key changes in the code during the frequent updates and iterations of software, generate new test cases and conduct risk analysis, resulting in the impact of test coverage and accuracy.

Method used

By statically analyzing the source code of computer software, building a knowledge graph, detecting the addition, deleting and changing of source code, iteratively compute the influencing factors of the knowledge graph node, identifying test cases that need to be re-execution, and prioritizing test cases.

Benefits of technology

It realizes intelligent identification of key changing areas in the code, improves test coverage and accuracy, optimizes the allocation of test resources, and reduces the risk of omission errors during software updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046167B_ABST
    Figure CN119046167B_ABST
Patent Text Reader

Abstract

The present invention discloses a computer software automatic test analysis method and a test platform, which relate to the technical field of software test analysis. The method comprises: statically analyzing the source code of the computer software, mapping the key elements of the source code into entities, and constructing a knowledge graph based on the entities and relationships. When the software version is iterated, the code changes are detected and mapped to the knowledge graph nodes, and the changed areas are marked. According to the preset dependency depth parameters, the affected node set is iteratively calculated, the test cases are associated with the knowledge graph nodes, the test cases that need to be re-executed are identified, the priorities are sorted, and the test case sets and execution sequences are generated; according to the test case sets, the test case execution sequences are generated, the test results are obtained, the failed cases are analyzed, and the sources of defects are located. By intelligently identifying the key change points of the code and introducing the risk assessment and priority sorting mechanism, the efficiency and coverage of the test are improved, the test cost is reduced, and the quality and stability of the software are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing and analysis, and in particular to a computer software automatic testing and analysis method and a testing platform. Background Art

[0002] As the scale and complexity of software systems continue to increase, the reliability and stability of software have become particularly important. Traditional software testing methods usually rely on manually writing test cases and manually analyzing software errors. This method is inefficient and it is difficult to ensure the coverage and depth of testing when facing complex large-scale systems.

[0003] In the prior art, although automated testing tools have been used, these tools can usually only automatically execute based on known test cases, and cannot dynamically analyze and generate new test cases based on the structure and changes of the code and changes in system requirements. This leads to a huge testing workload during the frequent software updates and iterations, and it is easy to miss new vulnerabilities or risk points. Especially when the software undergoes major changes, the testing tools of the prior art cannot effectively identify the key change points of the code, and thus cannot generate new test cases and perform risk analysis for these change points, which affects the test coverage and accuracy. In addition, it is difficult for existing tools to perform intelligent risk assessment and test case priority sorting based on test results, which poses new challenges to improving test efficiency and reducing test costs. Summary of the invention

[0004] Based on the above-mentioned shortcomings of the prior art, the purpose of the present invention is to provide a computer software automatic testing and analysis method and a testing platform to solve the above-mentioned technical problems.

[0005] To achieve the above object, the present invention provides the following technical solution: a computer software automatic testing and analysis method, comprising:

[0006] Perform static analysis on the source code of computer software, set key elements in the source code as entities, and construct a knowledge graph based on the entities and the relationships between them;

[0007] When the computer software version is iterated, the addition, deletion and change of the source code are detected, the detected source code changes are mapped to the nodes of the knowledge graph, and the changed areas are marked;

[0008] Iteratively calculate the impact factor of the knowledge graph node according to the changed area and the preset dependency depth parameter, and obtain the affected node set according to the impact factor;

[0009] Associating the test cases with the nodes of the knowledge graph, identifying the test cases that need to be re-executed according to the knowledge graph node set and the affected node set covered by the test cases, prioritizing the test cases, and generating a test case set;

[0010] Based on the test case set, a test case execution sequence is generated, test results are obtained, failed cases are analyzed, and the source of defects is located.

[0011] The present invention is further configured such that the key elements in the source code include basic entities and member entities, the basic entities include classes, interfaces, enumerations and structures, and the member entities include functions, variables, attributes and constants; the relationships between the entities include structural relationships and calling relationships, the structural relationships include inheritance, implementation, dependency, association, aggregation and combination, and the calling relationships include function calls and variable calls.

[0012] The present invention is further configured to construct a knowledge graph according to the entities and the relationships between the entities, including:

[0013] Convert the source code into an abstract syntax tree through a parser, traverse the nodes of the abstract syntax tree, and identify the entity type of the node;

[0014] Setting the entity as a node and adding it to the knowledge graph, setting the properties of the node, where the properties of the node include entity name, entity type and entity location;

[0015] The relationship between the entities is set as the edge of the knowledge graph node, and the attributes of the edge are set. The attributes of the edge include the relationship type and direction.

[0016] The present invention is further configured to iteratively calculate the influence factor of the knowledge graph node according to the changed area and the preset dependency depth parameter, and obtain the affected node set according to the influence factor, including:

[0017] Extracting all the changed nodes in the changed area, and setting all the changed nodes as a changed node set;

[0018] Allocating an initial impact factor to all nodes in the knowledge graph, wherein when a node in the knowledge graph belongs to a changed node set, the initial impact factor is one, and when a node in the knowledge graph does not belong to a changed node set, the initial impact factor is zero;

[0019] The influence factors of knowledge graph nodes are iteratively calculated according to the preset influence propagation algorithm, and the number of iterations depends on the depth parameter;

[0020] A node set whose influence factor is greater than or equal to a preset influence factor threshold is defined as an affected node set.

[0021] The present invention is further configured such that the calculation logic of the preset influence propagation algorithm is: ,in, For the The node at the iteration The impact factor, Representation Node The set of predecessor nodes, For the The node at the iteration The impact factor, To affect the transfer function, , is the edge weight, which is used to indicate the strength of the dependency relationship and has a value range of (0,1). is the attenuation factor.

[0022] The present invention is further configured to associate the test case with the node of the knowledge graph, and identify the test case that needs to be re-executed according to the knowledge graph node set and the affected node set covered by the test case, including:

[0023] Determine the set of knowledge graph nodes covered by test cases through code coverage analysis;

[0024] According to the knowledge graph node set and the affected node set covered by the test case, the affected node set of the test case is calculated, wherein the affected node set of the test case is the union of the knowledge graph node set and the affected node set covered by the test case.

[0025] The present invention is further configured to prioritize test cases and generate a test case set, including:

[0026] Calculate the test case influence based on the node's influence factor;

[0027] Calculate the historical defect detection capability based on the historical execution times of the test case and the number of detected defects;

[0028] Calculate the execution cost index based on the average computation time of the test cases;

[0029] Calculate a priority score based on test case impact, historical defect detection capability, and execution cost index.

[0030] The present invention is further configured such that the calculation logic of the test case influence is: ,in, For the The impact of test cases, For the The set of test case affected nodes for a test case, For Node The impact factor, is the influence adjustment parameter, which is used to control the nonlinear enhancement of the node influence factor;

[0031] The calculation logic of the historical defect detection capability is: ,in, For the Historical defect detection capabilities for test cases, For the The number of defects detected by the test cases, For the The historical execution times of each test case;

[0032] The calculation logic of the execution cost index is: ,in, For the The execution cost index of the test cases, For the Average test case computation time for test cases;

[0033] The calculation logic of the priority score is: ,in, For the The priority score of each test case. , and It is an adjustment parameter used to control the weight of the test case influence, historical defect detection capability and execution cost index on the priority.

[0034] The present invention is further configured to generate a test case execution sequence according to the test case set, obtain test results, analyze failed cases, and locate defect sources, including:

[0035] Generate a test case execution sequence according to the descending order of priority of the test cases in the test case set;

[0036] Automatically execute the test cases according to the test case execution sequence and obtain the test results;

[0037] Filter the test cases with failed execution results from the test results, use the knowledge graph node set covered by the test cases to determine the code entities involved in the test cases, and locate the source of the defects.

[0038] The present invention also provides a computer software automatic testing platform, the system comprising:

[0039] Graph construction module: static analysis of the source code of the computer software is performed, key elements in the source code are set as entities, and a knowledge graph is constructed based on the relationships between the entities;

[0040] Change marking module: when the computer software version is iterated, the addition, deletion and change of the source code are detected, the detected source code changes are mapped to the nodes of the knowledge graph, and the changed areas are marked;

[0041] Setting parameter module: iteratively calculating the impact factor of the knowledge graph node according to the changed area and the preset dependency depth parameter, and obtaining the affected node set according to the impact factor;

[0042] Prioritization module: associates test cases with nodes of the knowledge graph, identifies test cases that need to be re-executed based on the knowledge graph node set and the affected node set covered by the test cases, prioritizes the test cases, and generates a test case set;

[0043] Execution analysis module: Generates test case execution sequence according to the test case set, obtains test results, analyzes failed cases, and locates the source of defects.

[0044] The present invention provides a computer software automatic test analysis method and a test platform. The method performs static analysis on the source code of the computer software, sets the key elements in the source code as entities, and constructs a knowledge graph according to the relationship between the entities; when the computer software version is iterated, the addition, deletion and change of the source code are detected, the detected source code changes are mapped to the nodes of the knowledge graph, and the change area is marked; the influence factor of the knowledge graph node is iteratively calculated according to the change area and the preset dependency depth parameter, and the affected node set is obtained according to the influence factor; the test case is associated with the node of the knowledge graph, and the test case that needs to be re-executed is identified according to the knowledge graph node set and the affected node set covered by the test case, and the test case is prioritized to generate a test case set; according to the test case set, a test case execution sequence is generated, the test result is obtained, the failed case is analyzed, and the defect source is located, and the beneficial effects produced include:

[0045] 1. Intelligent identification of key change points: The present invention can intelligently identify key change areas in the code, especially key nodes and structural changes in the code, and focus on testing these high-risk areas. In this way, test cases can more accurately cover potential error points, improve test coverage, and reduce the risk of missing errors during software updates;

[0046] 2. Risk assessment and test priority sorting: This invention introduces a risk assessment model based on code changes and historical test results, which can dynamically calculate the risk value of each test case and prioritize the test cases according to the risk level. This mechanism ensures that high-risk areas are verified first in the test, optimizes the allocation of test resources, and improves the accuracy and efficiency of the test;

[0047] 3. Improve test efficiency and reduce test costs: By automatically generating test cases, dynamically adjusting test strategies, and intelligently sorting, the present invention effectively reduces the workload of testers and greatly improves the efficiency of test execution. Compared with traditional manual testing, the present invention can cover more code paths and change areas in the same time, thereby significantly reducing test costs, especially in a software development environment with frequent iterations;

[0048] 4. Adapt to agile development and continuous integration environment: This invention is particularly suitable for the rapid iteration requirements in agile development and continuous integration (CI / CD) processes. It can automatically adapt to frequent changes in code and ensure that efficient and accurate testing support can still be provided in a rapid release environment. This flexible testing method helps to improve the speed of software delivery and ensure software quality.

[0049] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0051] Figure 1 A flowchart of a computer software automatic testing and analysis method is shown as an exemplary embodiment of the present invention;

[0052] Figure 2 The present invention is a schematic diagram of the structure of a computer software automatic testing platform according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0053] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.

[0054] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0055] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.

[0056] Embodiment 1

[0057] A computer software automatic test analysis method, such as Figure 1 As shown, including:

[0058] Perform static analysis on the source code of computer software, set key elements in the source code as entities, and construct a knowledge graph based on the entities and the relationships between them;

[0059] When the computer software version is iterated, the addition, deletion and change of the source code are detected, the detected source code changes are mapped to the nodes of the knowledge graph, and the changed areas are marked;

[0060] Iteratively calculate the impact factor of the knowledge graph node according to the changed area and the preset dependency depth parameter, and obtain the affected node set according to the impact factor;

[0061] Associating the test cases with the nodes of the knowledge graph, identifying the test cases that need to be re-executed according to the knowledge graph node set and the affected node set covered by the test cases, prioritizing the test cases, and generating a test case set;

[0062] Based on the test case set, a test case execution sequence is generated, test results are obtained, failed cases are analyzed, and the source of defects is located.

[0063] Specifically, static analysis refers to analyzing the structure and semantic information of source code without executing the code, extracting key elements and dependencies. Static analysis is performed at the source code level without compiling or executing the code, avoiding the impact of the runtime environment. Static analysis converts the source code into an abstract syntax tree using a corresponding parser according to the grammatical rules of the programming language. The present invention is further configured such that the key elements in the source code include basic entities and member entities, the basic entities include classes, interfaces, enumerations and structures, and the member entities include functions, variables, attributes and constants; the relationships between the entities include structural relationships and calling relationships, the structural relationships include inheritance, implementation, dependency, association, aggregation and combination, and the calling relationships include function calls and variable calls.

[0064] Knowledge Graph is a semantic network used to describe entities (objects, concepts) and their relationships in the real world. In the form of a graph, the knowledge graph uses various types of entities as nodes and the relationships between entities as edges to construct a structured and semantic knowledge representation system; the present invention is further configured to construct a knowledge graph based on the relationships between the entities, including:

[0065] The source code is converted into an abstract syntax tree through a parser, and the nodes of the abstract syntax tree are traversed to identify the entity type of the node. Specifically, an abstract syntax tree (AST) is a tree data structure whose nodes represent syntax elements (such as expressions, statements, declarations, etc.) in the source code. A parser is a program that performs lexical analysis and syntactic analysis on the source code according to the syntax rules of the programming language and converts it into an abstract syntax tree (AST). Lexical analysis: splits the source code text into a series of lexical units (Tokens), such as keywords, identifiers, operators, etc. Syntactic analysis: organizes lexical units into grammatical structures according to the grammatical rules of the language and constructs an AST. Recursively or iteratively, traverse the AST in a depth-first or breadth-first manner, visit each node, and determine the corresponding entity type according to the type of the AST node (Node Type).

[0066] The entity is set as a node and added to the knowledge graph, and the properties of the node are set. The properties of the node include entity name, entity type and entity position. Specifically, each identified entity is added to the knowledge graph as a node. The entity name refers to the name of the entity in the source code, such as class name, function name and variable name; the entity type refers to the type to which the entity belongs, such as class, function and variable; the entity position refers to the position of the entity in the source code, including the file name, starting line number and ending line number;

[0067] The relationship between the entities is set as the edge of the knowledge graph node, and the attributes of the edge are set, wherein the attributes of the edge include the relationship type and direction. Specifically, the grammatical relationship between the entities is identified through the connection between the AST nodes. In the knowledge graph, an edge is added between each pair of entity nodes with a relationship. The directionality of the relationship is indicated, such as from a subclass to a parent class (inheritance), and from a caller to a callee (call).

[0068] Detecting additions, deletions, and changes to source code. The detection method includes using a version control system or a difference comparison tool to compare the new and old versions of the source code, identifying newly added, deleted, and modified code elements, and mapping the detected source code changes to the nodes of the knowledge graph. The mapping process is specifically as follows: adding new elements: adding new nodes and corresponding edges to the knowledge graph; deleting elements: deleting corresponding nodes and edges in the knowledge graph, or marking them as deleted; modifying elements: updating the properties of the corresponding nodes in the knowledge graph to reflect the modification of the code; marking the affected nodes and edges to form a change area;

[0069] The present invention is further configured to iteratively calculate the influence factor of the knowledge graph node according to the changed area and the preset dependency depth parameter, and obtain the affected node set according to the influence factor, including:

[0070] Extracting all the changed nodes in the changed area, and setting all the changed nodes as a changed node set;

[0071] An initial impact factor is assigned to all nodes in the knowledge graph, wherein when a node in the knowledge graph belongs to a change node set, the initial impact factor is one, and when a node in the knowledge graph does not belong to a change node set, the initial impact factor is zero; the present invention is further configured such that the calculation logic of the preset influence propagation algorithm is: ,in, For the The node at the iteration The impact factor, Representation Node The set of predecessor nodes, For the The node at the iteration The impact factor, To affect the transfer function, , is the edge weight, which is used to indicate the strength of the dependency relationship and has a value range of (0,1). is the impact attenuation factor. Specifically, the impact propagation algorithm is used to simulate the algorithm of the change impact propagation in the knowledge graph, considering the dependency relationship between nodes and the attenuation of the impact. The predecessor node refers to the set of nodes pointing to the current node in the directed graph, indicating that the current node depends on these predecessor nodes; the edge weight It is used to quantify the strength of the dependency between nodes. The larger the weight, the stronger the dependency and the more obvious the effect of the impact propagation. The above calculation logic uses the structural information in the knowledge graph to accurately simulate the propagation process of the change impact in the system. Through multiple iterations, the impact factor gradually accumulates, reflecting the depth and breadth of the change impact, helping to identify the code areas that need to be tested, and optimizing the selection and execution order of test cases; by setting the dependency depth and threshold, the test resources are reasonably allocated to avoid unnecessary testing.

[0072] The influence factor of the knowledge graph node is iteratively calculated according to the preset influence propagation algorithm, and the number of iterations is the dependency depth parameter; specifically, the dependency depth parameter is used to control the maximum number of iterations of influence propagation and determine the depth of influence analysis;

[0073] A node set whose influence factor is greater than or equal to a preset influence factor threshold is defined as an affected node set.

[0074] The present invention is further configured to associate the test case with the node of the knowledge graph, and identify the test case that needs to be re-executed according to the knowledge graph node set and the affected node set covered by the test case, including:

[0075] Determine the set of knowledge graph nodes covered by the test case through code coverage analysis; specifically, code coverage analysis is a test analysis technology used to determine which code lines or code entities are executed during the test case execution process. When executing the test case, use code coverage tools (including JaCoCo, Cobertura, and GCov) to record the code path actually executed by the test case; map the executed code entities obtained by code coverage analysis to the corresponding nodes in the knowledge graph;

[0076] According to the knowledge graph node set covered by the test case and the affected node set, the test case affected node set is calculated, wherein the test case affected node set is the union of the knowledge graph node set covered by the test case and the affected node set; specifically, by merging the node set covered by the test case with the affected node set, all nodes related to the test case are obtained, including the nodes covered by itself and the affected nodes in the system.

[0077] The present invention is further configured to prioritize test cases and generate a test case set, including:

[0078] The influence of the test case is calculated according to the influence factor of the node; the calculation logic of the influence of the test case is: ,in, For the The impact of test cases, For the The set of test case affected nodes for a test case, For Node The impact factor, is the influence adjustment parameter, which is used to control the nonlinear enhancement of the node influence factor. Specifically, the test case influence is used to evaluate the coverage of the test case for the code area affected by the change, reflecting its importance in discovering potential defects. The above calculation logic calculates the probability that the test case covers at least one affected node, comprehensively considers the influence factors of all covered nodes, and uses the exponential parameter , emphasizing the contribution of high-impact factor nodes to the influence of test cases, making the impact of key nodes on influence more significant; influence adjustment parameters The value range is [1,3].

[0079] The historical defect detection capability is calculated based on the historical execution times of the test case and the number of detected defects. The calculation logic of the historical defect detection capability is: ,in, For the Historical defect detection capabilities for test cases, For the The number of defects detected by the test cases, For the The historical execution times of a test case; the historical defect detection capability is used to measure the effectiveness of the test case in detecting defects in the past, reflecting its contribution to quality assurance; the above calculation logic calculates the average ability to find defects in each execution, taking into account the impact of the number of executions to prevent the dilution of effectiveness due to frequent executions through parameters;

[0080] The execution cost index is calculated according to the average calculation time of the test cases; the calculation logic of the execution cost index is: ,in, For the The execution cost index of the test cases, For the The average calculation time of the test cases for each test case; specifically, the execution cost index is used to evaluate the execution cost of the test case, reflecting its occupation of resources and time; the above calculation logic uses an exponential function to amplify the impact of execution time on cost, so that the cost index of long-term test cases increases significantly;

[0081] The priority score is calculated based on the test case impact, historical defect detection capability, and execution cost index. The calculation logic of the priority score is: ,in, For the The priority score of each test case. , and The adjustment parameters are used to control the weight of the influence of test case influence, historical defect detection capability and execution cost index on priority; the priority score comprehensively considers the influence, historical performance and execution cost of the test case to calculate its priority for sorting and selection; the above calculation logic realizes the nonlinear weighted combination of test case influence, historical defect detection capability and execution cost index through exponential and logarithmic functions, avoiding simple linear weighted summation, and using logarithmic functions to smooth the results to prevent the priority scores from being too different and maintain the stability of sorting; the adjustment parameters are used to control the weight of the influence, historical defect detection capability and execution cost index of the test case to calculate the priority score of the test case for sorting and selection; the above calculation logic realizes the nonlinear weighted combination of test case influence, historical defect detection capability and execution cost index through exponential and logarithmic functions, avoiding simple linear weighted summation, and using logarithmic functions to smooth the results to prevent the priority scores from being too different and maintain the stability of sorting; the adjustment parameters are used to control the weight of the test case influence, historical defect detection capability and execution cost index, and to adjust the parameters to prevent the priority scores from being too different and maintain the stability of sorting ..., avoiding simple linear weighted summation, and using logarithmic functions to smooth the results, avoiding simple linear weighted summation, and maintaining the stability of sorting; the above calculation logic realizes the nonlinear weighted combination of test case influence, historical defect detection capability and execution cost index, avoiding simple linear weighted summation, and using logarith , and The values ​​of are all greater than 0. By considering the influence, historical performance and execution cost, a comprehensive evaluation of the value of test cases is achieved, the rationality of priority sorting is ensured, high-value test cases are executed first, the defect discovery rate is increased, the waste of test resources is reduced, and the software quality is improved.

[0082] The present invention is further configured to generate a test case execution sequence according to the test case set, obtain test results, analyze failed cases, and locate defect sources, including:

[0083] Generate a test case execution sequence according to the descending order of priority of the test cases in the test case set;

[0084] Automatically execute the test cases according to the test case execution sequence and obtain the test results;

[0085] Filter the test cases with failed execution results from the test results, use the knowledge graph node set covered by the test cases to determine the code entities involved in the test cases and locate the source of the defects. Specifically, by using the knowledge graph node set covered by the test cases, directly locate the code entities involved in the failed test cases, shorten the defect location time, generate the execution sequence according to the test case priority, ensure that the key test cases are executed first, and improve the utilization efficiency of test resources.

[0086] Embodiment 2

[0087] See also Figure 2 , the exemplary computer software automatic testing platform includes:

[0088] Graph construction module: static analysis of the source code of the computer software is performed, key elements in the source code are set as entities, and a knowledge graph is constructed based on the relationships between the entities;

[0089] Change marking module: when the computer software version is iterated, the addition, deletion and change of the source code are detected, the detected source code changes are mapped to the nodes of the knowledge graph, and the changed areas are marked;

[0090] Setting parameter module: iteratively calculating the impact factor of the knowledge graph node according to the changed area and the preset dependency depth parameter, and obtaining the affected node set according to the impact factor;

[0091] Prioritization module: associates test cases with nodes of the knowledge graph, identifies test cases that need to be re-executed based on the knowledge graph node set and the affected node set covered by the test cases, prioritizes the test cases, and generates a test case set;

[0092] Execution analysis module: Generates test case execution sequence according to the test case set, obtains test results, analyzes failed cases, and locates the source of defects.

[0093] It should be noted that the computer software automatic testing platform provided in the above embodiment and the computer software automatic testing analysis method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In actual application, the computer software automatic testing platform provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the system into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0094] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.

[0095] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.

[0096] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0097] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0098] Those of ordinary skill 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 this application.

[0099] 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.

[0100] In the several embodiments provided in the present application, it should be understood that the disclosed system can be implemented in other ways. For example, the device embodiments described above are only 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0101] 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 solution of this embodiment.

[0102] In addition, each functional unit in each embodiment of the present application 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.

[0103] 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 application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.

[0104] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A computer software automatic testing and analysis method, characterized in that: include: Perform static analysis on the source code of computer software, set key elements in the source code as entities, and construct a knowledge graph based on the entities and the relationships between them; When the computer software version is iterated, the addition, deletion and change of the source code are detected, the detected source code changes are mapped to the nodes of the knowledge graph, and the changed areas are marked; Iteratively calculating the influence factor of the knowledge graph node according to the change area and the preset dependency depth parameter, and obtaining the affected node set according to the influence factor, including: extracting all the change nodes in the change area, and setting all the change nodes as the change node set; assigning initial influence factors to all nodes in the knowledge graph, wherein when the node in the knowledge graph belongs to the change node set, the initial influence factor is one, and when the node in the knowledge graph does not belong to the change node set, the initial influence factor is zero; iteratively calculating the influence factor of the knowledge graph node according to the preset influence propagation algorithm, and the number of iterations is the dependency depth parameter; defining the node set whose influence factor is greater than or equal to the preset influence factor threshold as the affected node set; the calculation logic of the preset influence propagation algorithm is: in, is the node n at the tth iteration k The impact factor of Pre(n k ) represents node n k The set of predecessor nodes, is the node n at the t-1th iteration i The impact factor, T ik To affect the transfer function, ω ik is the edge weight, which is used to indicate the strength of the dependency relationship. Its value range is (0,1], and γ is the influence attenuation factor; The test cases are associated with nodes of the knowledge graph, and according to the knowledge graph node set and the affected node set covered by the test cases, the test cases that need to be re-executed are identified, the test cases are prioritized, and a test case set is generated, including: determining the knowledge graph node set covered by the test cases through code coverage analysis; calculating the affected node set of the test cases according to the knowledge graph node set and the affected node set covered by the test cases, wherein the affected node set of the test cases is the union of the knowledge graph node set and the affected node set covered by the test cases; calculating the influence of the test cases according to the influence factors of the nodes; calculating the historical defect detection capability according to the historical execution times and the number of detected defects of the test cases; calculating the execution cost index according to the average calculation time of the test cases; calculating the priority score according to the test case influence, the historical defect detection capability and the execution cost index; the calculation logic of the influence of the test cases is: Among them, I j is the influence of the jth test case, M j is the set of test case affected nodes of the jth test case, I k For node n k The influence factor of α is the influence adjustment parameter, which is used to control the nonlinear enhancement of the node influence factor; the calculation logic of the historical defect detection capability is: Among them, H j is the historical defect detection capability of the jth test case, D j is the number of defects detected by the jth test case, E j is the historical execution times of the jth test case; the calculation logic of the execution cost index is: Among them, C j is the execution cost index of the jth test case, t j is the average test case calculation time of the jth test case; the calculation logic of the priority score is: Among them, P j is the priority score of the jth test case, δ, β and It is a parameter adjustment used to control the weight of the test case influence, historical defect detection capability and execution cost index on the priority; Based on the test case set, a test case execution sequence is generated, test results are obtained, failed cases are analyzed, and the source of defects is located.

2. A computer software automatic testing and analysis method according to claim 1, characterized in that: The key elements in the source code include basic entities and member entities. The basic entities include classes, interfaces, enumerations and structures, and the member entities include functions, variables, attributes and constants. The relationships between the entities include structural relationships and calling relationships. The structural relationships include inheritance, implementation, dependency, association, aggregation and combination, and the calling relationships include function calls and variable calls.

3. A computer software automatic testing and analysis method according to claim 2, characterized in that: Constructing a knowledge graph according to the entities and the relationships between the entities, including: Convert the source code into an abstract syntax tree through a parser, traverse the nodes of the abstract syntax tree, and identify the entity type of the node; Setting the entity as a node and adding it to the knowledge graph, setting the properties of the node, where the properties of the node include entity name, entity type and entity location; The relationship between the entities is set as the edge of the knowledge graph node, and the attributes of the edge are set. The attributes of the edge include the relationship type and direction.

4. A computer software automatic testing and analysis method according to claim 1, characterized in that: Generate a test case execution sequence based on the test case set, obtain test results, analyze failed cases, and locate the source of defects, including: Generate a test case execution sequence according to the descending order of priority of the test cases in the test case set; Automatically execute the test cases according to the test case execution sequence and obtain the test results; Filter the test cases with failed execution results from the test results, use the knowledge graph node set covered by the test cases to determine the code entities involved in the test cases, and locate the source of the defects.

5. A computer software automatic testing platform, characterized in that: include: Graph construction module: static analysis of the source code of the computer software is performed, key elements in the source code are set as entities, and a knowledge graph is constructed based on the relationships between the entities; Change marking module: when the computer software version is iterated, the addition, deletion and change of the source code are detected, the detected source code changes are mapped to the nodes of the knowledge graph, and the changed areas are marked; Setting parameter module: iteratively calculating the influence factor of the knowledge graph node according to the change area and the preset dependency depth parameter, and obtaining the affected node set according to the influence factor, including: extracting all the change nodes in the change area, and setting all the change nodes as the change node set; assigning initial influence factors to all nodes in the knowledge graph, wherein when the node in the knowledge graph belongs to the change node set, the initial influence factor is one, and when the node in the knowledge graph does not belong to the change node set, the initial influence factor is zero; iteratively calculating the influence factor of the knowledge graph node according to the preset influence propagation algorithm, and the number of iterations is the dependency depth parameter; defining the node set whose influence factor is greater than or equal to the preset influence factor threshold as the affected node set; the calculation logic of the preset influence propagation algorithm is: in, is the node n at the tth iteration k The impact factor of Pre(n k ) represents node n k The set of predecessor nodes, is the node n at the t-1th iteration i The impact factor, T ik To affect the transfer function, ω ik is the edge weight, which is used to indicate the strength of the dependency relationship. Its value range is (0,1], and γ is the influence attenuation factor; Prioritization module: associate test cases with nodes of the knowledge graph, identify test cases that need to be re-executed according to the knowledge graph node set and affected node set covered by the test cases, prioritize the test cases, and generate a test case set, including: determining the knowledge graph node set covered by the test cases through code coverage analysis; calculating the affected node set of the test cases according to the knowledge graph node set and affected node set covered by the test cases, wherein the affected node set of the test cases is the union of the knowledge graph node set and the affected node set covered by the test cases; calculating the influence of the test cases according to the influence factors of the nodes; calculating the historical defect detection capability according to the historical execution times and the number of detected defects of the test cases; calculating the execution cost index according to the average calculation time of the test cases; calculating the priority score according to the test case influence, the historical defect detection capability and the execution cost index; the calculation logic of the test case influence is: Among them, I j is the influence of the jth test case, M j is the set of test case affected nodes of the jth test case, I k For node n k The influence factor of α is the influence adjustment parameter, which is used to control the nonlinear enhancement of the node influence factor; the calculation logic of the historical defect detection capability is: Among them, H j is the historical defect detection capability of the jth test case, D j is the number of defects detected by the jth test case, E j is the historical execution times of the jth test case; the calculation logic of the execution cost index is: Among them, C j is the execution cost index of the jth test case, t j is the average test case calculation time of the jth test case; the calculation logic of the priority score is: Among them, P j is the priority score of the jth test case, δ, β and It is a parameter adjustment used to control the weight of the test case influence, historical defect detection capability and execution cost index on the priority; Execution analysis module: Generates test case execution sequence according to the test case set, obtains test results, analyzes failed cases, and locates the source of defects.

Citation Information

Patent Citations

  • A risk-driven test method and apparatus and a computer-readable storage medium

    CN109101410A