Software testing method and device, electronic equipment and storage medium

By building a knowledge graph and testing recommendations based on it, the problem of low testing efficiency and accuracy of existing software testing methods is solved, and more efficient and accurate software testing is achieved.

CN119807069APending Publication Date: 2025-04-11CHINA TELECOM INTELLIGENT NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411996934.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The testing efficiency and accuracy of existing software testing methods are low, especially when facing large-scale and high-complex network management and control systems, traditional testing methods are difficult to ensure the comprehensiveness and accuracy of test coverage.

Method used

By obtaining the data to be tested, determining the call chain data, building a knowledge graph, and determining the test recommendation results based on the knowledge graph, guiding the software testing process. This method combines static and dynamic analysis to build a comprehensive call chain map to realize intelligent testing recommendations.

Benefits of technology

It improves the efficiency and accuracy of software testing, ensures the comprehensiveness and accuracy of test coverage, especially in the change testing of large and complex software systems, which significantly improves the targetedness and accuracy of tests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807069A_ABST
    Figure CN119807069A_ABST
Patent Text Reader

Abstract

The invention discloses a software testing method and device, electronic equipment and a storage medium. The software testing method comprises the steps that to-be-tested data are obtained, and the to-be-tested data comprise code data and test cases; determining call chain data according to the to-be-tested data; constructing a knowledge graph according to the call chain data; according to the knowledge graph, a test recommendation result is determined, and the test recommendation result is used for guiding the test process of the software. The technical problem that an existing software testing method is low in testing efficiency and accuracy is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a software testing method, device, electronic equipment and storage medium. Background Art

[0002] In the context of modern software development and maintenance, software testing faces unprecedented challenges, especially for large-scale, highly complex network management and control systems, such as box-type wavelength division management and control systems. With the rapid increase in the number of devices managed by the system, the complexity and interdependence of functional modules have become increasingly complex, and traditional software testing methods have gradually revealed their limitations. Traditional testing methods usually rely on manual design and execution of test cases, which is not only inefficient, but also often difficult to ensure the comprehensiveness and accuracy of test coverage when faced with frequent software changes and a large code base.

[0003] In order to overcome the defects of traditional software testing methods, the software testing field has begun to explore smarter and more efficient testing methods, using advanced technologies such as call chain analysis and automated testing, aiming to improve the intelligence level of testing, enhance test accuracy, and reduce test costs. However, although the current software testing method based on call chain graphs provides a new testing perspective, it still has some shortcomings in practical applications. For example, existing technologies often focus on static analysis and identify call chains through code scanning and other means, but this method is difficult to capture dynamic behaviors at runtime, and the test coverage is not comprehensive enough. In addition, when recommending test cases, existing technologies often require manual intervention and predefined scopes, which to a certain extent limits the intelligence and efficiency of the test.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a software testing method, device, electronic device and storage medium to at least solve the technical problems of low testing efficiency and accuracy of existing software testing methods.

[0006] According to one aspect of an embodiment of the present invention, a software testing method is provided, comprising: obtaining data to be tested, wherein the data to be tested includes code data and test cases; determining call chain data based on the data to be tested; constructing a knowledge graph based on the call chain data; and determining a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

[0007] Optionally, determining the call chain data according to the data to be tested includes: using a scanning algorithm to scan the code data to determine function nodes and function call relationships; determining the call chain data according to the function nodes and function call relationships.

[0008] Optionally, based on the data to be tested, call chain data is determined, including: code instrumentation of the code data, injecting a preset call tracking component into the code data, wherein the parameters of the preset call tracking component include test cases and business methods; executing the test cases using a preset proxy service, and collecting log data of the preset call tracking component; and determining the call chain data based on the log data.

[0009] Optionally, a knowledge graph is constructed based on the call chain data, including: based on the call chain data, obtaining detailed data corresponding to the call chain data, the detailed data including: the correspondence between the code package, code file and function corresponding to each call link, as well as the path, location, input and output parameters, comments, and code lines; based on the detailed data, a knowledge graph is constructed.

[0010] Optionally, a knowledge graph is constructed based on the call chain data, including: using a preset weighted algorithm to weight the call chain data to obtain a weighted call chain; and determining the knowledge graph based on the weighted call chain.

[0011] Optionally, the test recommendation results include a recommended test scope. The test recommendation results are determined based on the knowledge graph, including: using a preset code comparison strategy to determine the version difference data; determining the impact scope of the difference data based on the version difference data and the knowledge graph; and determining the recommended test scope based on the impact scope of the difference data.

[0012] Optionally, the test recommendation results include recommended test cases. According to the knowledge graph, the test recommendation results are determined, including: using a preset code comparison strategy to determine version difference data; and determining recommended test cases based on the version difference data and weight data in the knowledge graph.

[0013] Optionally, the test recommendation results include a recommended test scope and recommended test cases. The test recommendation results are determined based on the knowledge graph, including: determining the difference impact scope based on the knowledge graph and a preset code comparison strategy; determining the recommended test scope and recommended test cases based on the difference impact scope.

[0014] According to another aspect of an embodiment of the present invention, a software testing device is also provided, including: an acquisition module for acquiring data to be tested, wherein the data to be tested includes code data and test cases; a determination module for determining call chain data based on the data to be tested; a construction module for constructing a knowledge graph based on the call chain data; and an output module for determining a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

[0015] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the software testing method in any one of the above items is executed when the program is running.

[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein when the executable program runs, the device where the storage medium is located is controlled to execute any of the above-mentioned software testing methods.

[0017] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the computer program implements any of the above software testing methods.

[0018] In an embodiment of the present invention, data to be tested is obtained, wherein the data to be tested includes code data and test cases; based on the data to be tested, call chain data is determined; based on the call chain data, a knowledge graph is constructed; based on the knowledge graph, a test recommendation result is determined, wherein the test recommendation result is used to guide the software testing process. The present invention achieves the purpose of intelligently performing test recommendations by extracting call chain information and constructing a knowledge graph, thereby achieving the technical effect of improving the test efficiency and accuracy of software testing, thereby solving the technical problem of low test efficiency and accuracy of existing software testing methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0020] Figure 1 is a flowchart of a software testing method according to one embodiment of the present invention;

[0021] Figure 2 is an example flow chart of a weighted algorithm according to one embodiment of the present invention;

[0022] Figure 3 is a first flow chart of a software testing method according to one embodiment of the present invention;

[0023] Figure 4 is a second flow chart of a software testing method according to one embodiment of the present invention;

[0024] Figure 5 is a third flow chart of a software testing method according to one embodiment of the present invention;

[0025] Figure 6is a fourth flow chart of a software testing method according to one embodiment of the present invention;

[0026] Figure 7 is a structural block diagram of a software testing device according to one embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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 should fall within the scope of protection of the present invention.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] According to an embodiment of the present invention, an embodiment of a software testing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0030] The method embodiment may also be performed in an electronic device, a similar control device or an electronic device including a memory and a processor. Taking an electronic device as an example, the electronic device may include one or more processors and a memory for storing data. Optionally, the electronic device may also include a communication device and a display device for communication functions. It will be understood by those skilled in the art that the above structural description is only illustrative and does not limit the structure of the above electronic device. For example, the electronic device may also include more or fewer components than the above structural description, or have a configuration different from the above structural description.

[0031] The processor may include one or more processing units. For example, the processor may include a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a field-programmable gate array (FPGA), a neural-network processing unit (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, and the like. Among them, different processing units may be independent components or integrated into one or more processors. In some instances, the electronic device may also include one or more processors.

[0032] The memory can be used to store computer programs, such as storing the computer programs corresponding to the software testing methods in the embodiments of the present invention, and the processor implements the above-mentioned software testing methods by running the computer programs stored in the memory. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the electronic device via a grid. Examples of the above-mentioned grid include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0033] There are some professional terms in the present invention, which are explained here:

[0034] Knowledge graph: A method of structuring, organizing and representing knowledge, using graphical models to represent the relationships and attributes between things. It combines the theories and methods of applied mathematics, graphics, information visualization technology, information science and other disciplines with metrological citation analysis, co-occurrence analysis and other methods to vividly display the core structure, development history, frontier fields and overall knowledge architecture of the discipline.

[0035] Call chain: In software architecture and distributed systems, it refers to a sequence of calls between a series of functions, methods, or microservices. This sequence starts from an initial point (such as a user request, system event, or scheduled task), goes through a series of intermediate steps (which may include interactions between multiple services or components), and finally reaches one or more endpoints (such as database queries, file operations, response sending, etc.).

[0036] Figure 1 is a flowchart of a software testing method according to one embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0037] Step S101, obtaining data to be tested, wherein the data to be tested includes code data and test cases.

[0038] Specifically, in the early stages of software testing, it is first necessary to collect comprehensive test data. These data mainly include two categories: one is the source code data of the software, that is, the program code written by the developer, which is the basis for building the call chain graph; the other is the existing test case data, which contains the expected input and output of the software function, as well as the execution steps, which will be used to perform dynamic testing and evaluate the test results. In step S101, the system will automatically pull the latest code data and test cases from the code repository and test management platform to ensure that the test is based on the latest software status.

[0039] Step S102, determining the call chain data according to the data to be tested.

[0040] Specifically, after obtaining the data to be tested, the system will determine the call chain data in two ways: static and dynamic.

[0041] Optionally, static analysis techniques, such as code scanning and symbolic execution, are used to identify the function, method or service call relationships in the code and construct a static call chain.

[0042] Optionally, through dynamic tracing technology, such as bytecode injection, instrumentation, etc., the actual call sequence when the software is running is recorded to form a dynamic call chain.

[0043] The combination of the above two methods can not only capture the static structure of the code, but also reflect the dynamic behavior at runtime, so as to more comprehensively identify the call link information in the system and provide detailed data support for the subsequent construction of the knowledge graph.

[0044] Step S103, construct a knowledge graph based on the call chain data.

[0045] Specifically, the call chain data obtained from step S102 is used to construct a knowledge graph. In the graph, nodes represent entities in the software system, such as functions, methods, classes, files, modules, etc.; edges represent call relationships between entities, such as function calls, method calls, module references, etc.

[0046] Optionally, the system will also collect the weight relationship between the test case and the function call chain, and assign weights to the nodes in the call chain through weighted algorithms (such as weighted call count and business module weighted) to reflect the importance of each entity and the priority of the test. This weight information is integrated into the knowledge graph to form a graphical structure containing entities, relationships and their weights, providing an intelligent data foundation for test recommendations.

[0047] Step S104, determining a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

[0048] Specifically, based on the knowledge graph constructed in step S103, the graph query algorithm is used to analyze the impact of code changes on the call chain and identify the affected functions, methods or modules. Based on these analysis results, the test scope is accurately located, and a set of test cases that are highly relevant to the changes are recommended in combination with the test case data. These test cases not only cover the change points, but also consider the impact of the change points on the upstream and downstream of the call chain to ensure the comprehensiveness and depth of the test. The recommended test case set will be sorted according to its weight in the call chain, and test cases with higher weights will be executed first to achieve optimal configuration of test resources and improve test efficiency.

[0049] Optionally, the test recommendation results are displayed in a visual manner for the tester's reference, to guide the software testing process and ensure the quality and stability of the software after the change.

[0050] In summary, the present invention realizes the intelligent, automated and efficient software testing by constructing and utilizing call chains and knowledge graphs. In particular, it can significantly improve the pertinence and accuracy of the test, reduce the test cost, and provide strong technical support for software development and maintenance for change testing of large and complex software systems.

[0051] In an embodiment of the present invention, data to be tested is obtained, wherein the data to be tested includes code data and test cases; based on the data to be tested, call chain data is determined; based on the call chain data, a knowledge graph is constructed; based on the knowledge graph, a test recommendation result is determined, wherein the test recommendation result is used to guide the software testing process. The present invention achieves the purpose of intelligently performing test recommendations by extracting call chain information and constructing a knowledge graph, thereby achieving the technical effect of improving the test efficiency and accuracy of software testing, thereby solving the technical problem of low test efficiency and accuracy of existing software testing methods.

[0052] Optionally, in step S102, the call chain data is determined according to the data to be tested, including:

[0053] Step S201, using a scanning algorithm to scan code data to determine function nodes and function call relationships;

[0054] Specifically, code parsing tools, such as the Abstract Syntax Tree (AST) parser, are used to perform structured analysis on the source code to identify the definition and call point of each function. Functions can be understood as independent execution units in the code, which carry specific functions or business logic. The system treats each identified function as a node, records its location in the code, parameter types, return value types and other detailed information, and forms a function node set.

[0055] Specifically, we deeply analyze the control flow and data flow inside the function and extract the calling relationship between functions. This includes direct calls (one function directly calls another function) and indirect calls (indirectly calling a target function through a series of intermediate functions). Recording the context information of these calls, such as the conditions under which the calls occur and the parameter passing of the calls, is crucial for accurately constructing the call chain graph.

[0056] Step S202, determining the call chain data according to the function nodes and the function call relationship.

[0057] Specifically, after the function nodes and call relationships are extracted, all function nodes and call relationships are integrated to form a complete call chain data set. This data set contains the structural information of the call chain. In the call chain graph, function nodes are connected by call relationship edges, forming a graphical structure that can reflect the logical call path inside the software. The call chain graph not only includes the direct relationship of function calls, but also can reveal deeper call relationships through recursive analysis, providing an intuitive visualization basis for determining the call chain data.

[0058] Optionally, in step S102, determining the call chain data according to the data to be tested further includes:

[0059] Step S301, code instrumentation is performed on the code data, and a preset call tracking component is injected into the code data, wherein the parameters of the preset call tracking component include test cases and business methods;

[0060] Specifically, after static analysis determines the preliminary structure of the call chain, code instrumentation technology is used to obtain more accurate dynamic call chain data. Code instrumentation is a software development and testing technology that allows additional instructions or components to be inserted into the code to collect specific information at runtime.

[0061] Specifically, a preset call tracking component is designed and implemented, which can collect call information at key nodes of code execution, including caller, callee, call parameters, return value, etc. The parameter design of this component needs to include the identification of the test case and the business method related to it, so as to record the call association between the test case and the business method in dynamic operation.

[0062] Specifically, bytecode manipulation tools, such as Java's ASM framework or Python's Bytecode module, are used to automatically insert preset call tracking components for key function or method execution points during code compilation or runtime. These insertion points usually include the entry and exit of the function, as well as important logical branch points, to ensure that the call details of the software runtime can be captured.

[0063] Step S302, executing the test case using the preset proxy service, and collecting log data of the preset call tracking component;

[0064] Specifically, after the instrumented code is ready, the test cases are executed through the preset proxy service to simulate the real operating environment of the software and collect dynamic call chain data therefrom.

[0065] Specifically, the test cases are executed through the preset proxy server, which is responsible for coordinating and controlling the test environment to ensure that the test cases are executed under conditions as close to the production environment as possible. During the execution process, the preset call tracking component will be activated to record the dynamic information of each function call.

[0066] Specifically, the log data generated by the preset call tracking component will be collected and initially parsed by the proxy server to extract key information of the call chain, such as the caller, the callee, the call parameters, etc. The parsed log data will be formatted for subsequent analysis and storage.

[0067] Step S303, determining the call chain data according to the log data.

[0068] Specifically, we conduct in-depth analysis on the collected log data and identify the actual call chain when the software is running by comparing the call information before and after the instrumentation. These dynamic call chain data can supplement the results of static analysis and provide a more realistic and comprehensive call chain view.

[0069] Specifically, the dynamic call chain information will be integrated into the existing call chain data to form a complete call chain dataset containing static and dynamic analysis results.

[0070] Optionally, compare and verify the results of static analysis and dynamic tracing to ensure the accuracy and comprehensiveness of the call chain data, and provide a more precise data foundation for the subsequent construction of knowledge graphs and test case recommendations.

[0071] Optionally, in step S103, a knowledge graph is constructed according to the call chain data, including:

[0072] Step S401, according to the call chain data, obtaining detailed data corresponding to the call chain data, the detailed data including: the corresponding relationship between the code package, code file and function corresponding to each call link, as well as the path, location, input and output parameters, comments, and code lines;

[0073] Specifically, after determining the call chain data, the detailed information of the call chain is deeply mined and analyzed to provide richer and more specific data support for the construction of the knowledge graph.

[0074] Specifically, the call chain data is parsed to extract the correspondence between the code packages, code files, and specific functions involved in each call chain. For example, when FuncA (function A) calls FuncB (function B), the system will record the information of the code file and code package where FuncA is located, as well as the corresponding location information of FuncB.

[0075] Specifically, for each function node, the system records its complete path and specific location in the code base, such as file name, line number, etc., which helps to accurately locate each entity in the knowledge graph.

[0076] Specifically, the input parameters (input parameters) and return results (output parameters) of the function call are extracted from the call chain data, including the parameter type, parameter value, and return value type, which is crucial for understanding the logical behavior and calling context of the function.

[0077] Specifically, the annotation information and related code lines of the function nodes are collected. The annotation information can provide the functional description and business logic of the function, while the code line information helps in the subsequent code change analysis, ensuring that the knowledge graph can dynamically reflect the code changes.

[0078] Step S402, construct a knowledge graph based on the detailed data.

[0079] Specifically, based on the detailed information of the acquired call chain data, a knowledge graph is constructed. This is a process of structuring and graphing complex data, which aims to clearly represent the internal logic of the software system and the relationship between entities through a graphical structure.

[0080] Specifically, a knowledge graph is initialized in a graph database (such as Neo4j), node types are created, such as code package nodes, code file nodes, function nodes, etc., and relationship types between nodes are defined, such as "include", "call", etc.

[0081] Specifically, according to the detailed information of the acquired call chain data, a corresponding node is created, and the node attributes are filled, such as the function name, location, parameter type, comment information, etc. For example, a function node FuncA is created in the graph database, and attributes such as code file, code package, location, parameter type, etc. are added to it.

[0082] Specifically, the relationship between nodes is established, such as the relationship between FuncA calling FuncB, and finally a knowledge graph is formed.

[0083] It should be noted that with the iteration and change of software, the knowledge graph needs to be updated regularly to ensure that the nodes and relationships in the graph always reflect the latest code structure and call logic. This includes re-analyzing the call chain data, updating node attributes and relationship weights, and adding or deleting nodes and relationships after code changes to maintain the accuracy and timeliness of the knowledge graph.

[0084] Optionally, in step S103, constructing a knowledge graph according to the call chain data further includes:

[0085] Step S501, using a preset weighting algorithm, weighting the call chain data to obtain a weighted call chain;

[0086] Specifically, after obtaining detailed call chain data, a weighted algorithm is used to measure and evaluate the importance of each entity and relationship in the call chain, thereby providing a more accurate data basis for knowledge graph construction.

[0087] Exemplarily, the weighting algorithm includes call count weighting and business module weighting. Figure 2 is a flowchart of a weighted algorithm according to one embodiment of the present invention, such as Figure 2 As shown in the figure, the specific calculation process of call count weighting and business module weighting is shown. Call count weighting refers to calculating the number of calls of each function in the call chain. Generally, functions or methods with high call frequencies play a more critical role in software operation, so their weights in the weighted call chain should also be higher. Business module weighting refers to assigning additional weights in the call chain based on the business module to which the function belongs. For example, if a function belongs to a high-risk or core business module, it will be assigned a higher weight even if its call frequency is not high to ensure that these key modules are adequately covered by tests.

[0088] Specifically, through comprehensive calculation of preset weighted algorithms, such as comprehensive calculation of weighted call times and weighted business module, weighted processing is performed on each node and edge in the call chain to form a weighted call chain.

[0089] Optionally, the specific implementation of the weighting algorithm includes but is not limited to linear weighting, exponential weighting, or a dynamic weighting strategy based on machine learning, ensuring that the weight distribution can accurately reflect the actual importance of functions and call chains.

[0090] It should be noted that as the software is iterated and changed, the weighted call chain should also be updated regularly to reflect the latest code structure and call logic. This includes recalculating the number of calls and business module weights after code changes, and adjusting the weights of nodes and edges in the weighted call chain to maintain the accuracy and timeliness of the weighted call chain.

[0091] Step S502, determine the knowledge graph according to the weighted call chain.

[0092] Specifically, based on the function nodes in the weighted call chain, corresponding graph nodes are created, such as code package nodes, code file nodes, function nodes, etc., and the attributes of the nodes are filled in, including the function name, location, parameter type, annotation information, and the weight value associated therewith.

[0093] Specifically, according to the call relationship in the weighted call chain, the edges between nodes are established, and the weight value is set for each edge. These weight values ​​reflect the importance of the function call and are helpful for the subsequent test case selection and test scope determination.

[0094] Optionally, during the construction of the knowledge graph, the graph is optimized and adjusted according to the characteristics of the weighted call chain to ensure that the structure of the graph can effectively represent the complex relationship of the call chain in the software system. For example, the weight values ​​are normalized so that the weights between different function nodes and call relationships can be directly compared.

[0095] After the knowledge graph is built, it will allow the system to perform complex queries and analyses, such as finding all call paths for a specific function, determining key call links based on weight values, etc. These query results will be used to guide the optimization recommendations of test cases and the precise positioning of the test scope.

[0096] Optionally, in step S104, the test recommendation result includes a recommended test scope, and the test recommendation result is determined according to the knowledge graph, including:

[0097] Step S601, using a preset code comparison strategy to determine version difference data;

[0098] Specifically, a preset code comparison strategy is used to perform difference analysis on the new and old code versions to determine version difference data.

[0099] Specifically, we integrate version control tools (such as Git) and use the application programming interface (API) provided by them to obtain code differences between specific versions of software projects. This includes differences at the file level, differences at the function or method level, and more fine-grained differences in code lines. These difference data will serve as the basis for subsequent analysis.

[0100] Optionally, the extracted version difference data is preprocessed, such as filtering irrelevant differences (such as comments or format changes) and converting the difference data into a format that can be matched with entities and relationships in the knowledge graph. The preprocessed version difference data will be stored for integration and analysis with the knowledge graph information in subsequent steps.

[0101] Step S602, determining the impact scope of the difference data according to the version difference data and the knowledge graph;

[0102] Specifically, based on the version difference data, we query the relevant nodes and edges in the knowledge graph to identify the functions or methods affected by the version difference. Through graph query, we can accurately locate the change points in the code path and call relationship.

[0103] Specifically, for each function or method affected by the version difference, the weighted call chain is used to recursively analyze its impact range in the software system. This includes identifying the affected function call chain, related business modules, and possible code packages and files involved.

[0104] Specifically, based on the results of the recursive analysis, the possible impact of version differences on software functionality, performance, or stability is evaluated. This involves analyzing the weight values ​​in the weighted call chain to determine which areas require more careful testing attention.

[0105] Finally, determine the specific scope of impact of the version difference, including the affected functional modules, business logic, and interfaces or services that may need to be revalidated.

[0106] Step S603, determining a recommended test range according to the impact range of the difference data.

[0107] Specifically, analyze the impact of the difference data and determine which test scenarios need to be re-evaluated and executed to determine the recommended test scope. This involves regression testing, interface testing, and scenario testing of the affected business modules.

[0108] Optionally, in step S104, the test recommendation result includes a recommended test case, and determining the test recommendation result according to the knowledge graph further includes:

[0109] Step S701, using a preset code comparison strategy to determine version difference data;

[0110] Specifically, a preset code comparison strategy is used to perform difference analysis on the new and old code versions to determine version difference data.

[0111] Step S702, determine the recommended test cases based on the version difference data and the weight data in the knowledge graph.

[0112] Specifically, after determining the version difference data, combined with the weight information in the knowledge graph, the system can intelligently recommend test cases to ensure that key areas are fully covered.

[0113] Specifically, the version difference data is matched with the weight data in the knowledge graph to find the functions and methods with higher weights in the affected call links. The weight information reflects the importance of each entity in the call link and the priority of the test.

[0114] Specifically, by querying the knowledge graph, we analyze the degree of association between each affected function or method and the existing test cases, that is, the "use case-function call chain" mapping relationship recorded in the weight information. A test case with a high degree of association means that it covers more key functions and complex call chains, so it has a higher priority in test recommendation.

[0115] Specifically, the test cases that are most closely associated with the functions and methods with higher weights in the version difference data will be selected as recommended test cases. These test cases will be executed first to ensure the stability and normal function of the software system after the change.

[0116] Optionally, the recommended test cases are prioritized based on the weight data. Usually, test cases with higher weights will be ranked first, which helps to quickly locate and fix possible problems.

[0117] Optionally, based on the recommended test cases and their priorities, a detailed test plan is generated, including the execution order of the test cases, the required test environment configuration, and the allocation suggestions for test resources.

[0118] Optionally, in step S104, the test recommendation result includes a recommended test scope and a recommended test case, and the test recommendation result is determined according to the knowledge graph, further comprising:

[0119] Step S801, determining the impact range of the difference according to the knowledge graph and the preset code comparison strategy;

[0120] Specifically, the new and old code versions are compared, and a preset code comparison strategy (such as Git's Diff tool) is used to determine the differences in the code, including new or modified functions, parameter changes, logic path adjustments, etc.

[0121] Specifically, through the results of code version comparison, the specific code differences are located, such as file names, code line numbers, etc., and these differences are mapped to the call chain knowledge graph to confirm which functions or methods are affected.

[0122] Specifically, the knowledge graph is used to recursively analyze the call chain relationship of the function or method where the difference is located, as well as the related business modules and code structures. This process will help identify other functional modules or services that are indirectly affected by the change.

[0123] Through the above analysis, the impact scope of the difference is determined, including the scope of direct impact of the code difference and the area of ​​indirect impact.

[0124] Step S802: Determine the recommended test scope and recommended test cases according to the difference impact scope.

[0125] Specifically, based on the impact scope of the difference, combined with the function call relationship and weight data in the call chain knowledge graph, the functional modules, business logic and interfaces that need to be retested are determined. The weight data reflects the importance and test priority of each entity in the call chain, which helps the system intelligently select the key test scope.

[0126] Specifically, analyze the degree of correlation between each function or method in the difference impact range and the existing test cases. By querying the knowledge graph, find the test cases that are closely related to the functions or methods with higher weights in the difference impact range, that is, the test cases with higher weights. These test cases will be recommended for execution first.

[0127] Finally, a test plan containing recommended test scope and recommended test cases is generated. The recommended test scope usually includes modules, interfaces and services that need to be retested, while the recommended test cases are prioritized according to their relevance to the scope of the difference.

[0128] In an embodiment of the present invention, a software testing method is also provided. Figure 3 FIG. 1 is a first flow chart of a software testing method according to one embodiment of the present invention. Figure 3 As shown, static scanning and dynamic instrumentation operations are performed on the original business code respectively, the static function call chain is determined by static scanning, and the use case-function call chain weight is determined by dynamic instrumentation. The static function call chain and the use case-function call chain weight are combined to generate a knowledge graph, and the knowledge graph is used to implement test recommendations, including test scope recommendations and test case recommendations.

[0129] In an embodiment of the present invention, a software testing method is also provided. Figure 4 FIG. 1 is a second flow chart of a software testing method according to one embodiment of the present invention. Figure 4As shown in the figure, the process of generating a knowledge graph by combining static scanning and dynamic tracking is demonstrated in detail. The generated knowledge graph is used to guide the software testing process.

[0130] In an embodiment of the present invention, a software testing method is also provided. Figure 5 is a third flow chart of a software testing method according to one embodiment of the present invention, such as Figure 5 As shown in the figure, the specific process of implementing test scope recommendation based on static scanning is demonstrated. This process includes: static scanning of the original code, using AST (abstract syntax tree) scanning to obtain the basic call chain of the function, obtaining the function nodes and call relationships; parsing the original data, obtaining the graph data of the call chain, traversing and converting it into the cypher query language required for storage in Neo4j, and then deeply traversing each call link, collecting the corresponding relationship of each package, file, function, as well as the path, location, input and output parameters, comments, code lines and other information, and writing them into Neo4j; obtaining version differences through Git's open API; graph positioning scope, tracing up the graph to query the complete call chain, and finally obtaining the affected interface range; test scope recommendation, redirecting the output of Git Diff to a file, and using the imgdiff command to convert it into a picture, so as to display the version code comparison and the affected interface (server), page (client) and other information on a visual page.

[0131] In an embodiment of the present invention, a software testing method is also provided. Figure 6 is a fourth flow chart of a software testing method according to one embodiment of the present invention, such as Figure 6 As shown in the figure, the specific process of implementing test case recommendation based on dynamic tracing is demonstrated. The specific steps of this process are as follows: embed trace calls through bytecode injection, and pass in the signatures of test cases and business methods in the calls; execute test cases through proxy services, collect trace logs, obtain all test cases and method call links, establish the association relationship between test cases and methods, and collect the mapping relationship of "use case-call chain"; collect the weight of "use case-function call chain", perform weighted calculation on the association relationship, and store it in Neo4j, using the weighted number of calls and business module weighted algorithms; obtain version differences, obtain the modified function nodes through code diff, and then obtain recommended test cases through weight calculation; if it is a business case, automatically create a test plan and associate test cases; if it is an automated test case, automatically import the file and function information of the case.

[0132] In the embodiment of the present invention, a software testing device is also provided, which is used to implement the above-mentioned embodiment and preferred implementation mode, and the descriptions have been made no further. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.

[0133] Figure 7 is a structural block diagram of a software testing device 200 according to one embodiment of the present invention. Figure 7 As shown, the device includes: an acquisition module 201, used to acquire data to be tested, wherein the data to be tested includes code data and test cases; a determination module 202, used to determine call chain data based on the data to be tested; a construction module 203, used to construct a knowledge graph based on the call chain data; an output module 204, used to determine a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

[0134] Optionally, the determination module 202 is further used to: use a scanning algorithm to scan the code data to determine the function nodes and function call relationships; and determine the call chain data according to the function nodes and function call relationships.

[0135] Optionally, the determination module 202 is also used to: perform code instrumentation on the code data, inject a preset call tracking component into the code data, wherein the parameters of the preset call tracking component include test cases and business methods; execute the test cases using a preset proxy service, and collect log data of the preset call tracking component; and determine the call chain data based on the log data.

[0136] Optionally, the construction module 203 is also used to: obtain detailed data corresponding to the call chain data based on the call chain data, the detailed data including: the correspondence between the code package, code file and function corresponding to each call link, as well as the path, location, input and output parameters, comments, and code lines; and construct a knowledge graph based on the detailed data.

[0137] Optionally, the construction module 203 is also used to: use a preset weighted algorithm to perform weighted processing on the call chain data to obtain a weighted call chain; and determine a knowledge graph based on the weighted call chain.

[0138] Optionally, the test recommendation result includes a recommended test scope, and the output module 204 is also used to: determine the version difference data using a preset code comparison strategy; determine the impact scope of the difference data based on the version difference data and the knowledge graph; and determine the recommended test scope based on the impact scope of the difference data.

[0139] Optionally, the test recommendation result includes recommended test cases, and the output module 204 is further used to: determine version difference data using a preset code comparison strategy; and determine recommended test cases based on the version difference data and weight data in the knowledge graph.

[0140] Optionally, the test recommendation results include a recommended test scope and recommended test cases, and the output module 204 is also used to: determine the difference impact scope based on the knowledge graph and the preset code comparison strategy; determine the recommended test scope and recommended test cases based on the difference impact scope.

[0141] An embodiment of the present invention further provides an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the software testing method described in any of the above embodiments is executed when the program is running.

[0142] Optionally, in this embodiment, the processor in the electronic device may be configured to run an executable program to perform the following steps:

[0143] Step S101, obtaining data to be tested, wherein the data to be tested includes code data and test cases;

[0144] Step S102, determining the call chain data according to the data to be tested;

[0145] Step S103, constructing a knowledge graph based on the call chain data;

[0146] Step S104, determining a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

[0147] Optionally, the processor in the above electronic device can be configured to run an executable program to perform the following steps: use a scanning algorithm to scan the code data to determine function nodes and function call relationships; determine call chain data based on the function nodes and function call relationships.

[0148] Optionally, the processor in the above-mentioned electronic device can be configured to run an executable program to perform the following steps: perform code stubbing on the code data, inject a preset call tracking component into the code data, wherein the parameters of the preset call tracking component include test cases and business methods; execute the test cases using a preset proxy service, and collect log data of the preset call tracking component; and determine the call chain data based on the log data.

[0149] Optionally, the processor in the above-mentioned electronic device can be configured to run an executable program to perform the following steps: based on the call chain data, obtain detailed data corresponding to the call chain data, the detailed data including: the correspondence between the code package, code file and function corresponding to each call link, as well as the path, location, input and output parameters, comments, and code lines; based on the detailed data, construct a knowledge graph.

[0150] Optionally, the processor in the above electronic device can be configured to run an executable program to perform the following steps: weighted processing of the call chain data using a preset weighted algorithm to obtain a weighted call chain; and determining a knowledge graph based on the weighted call chain.

[0151] Optionally, the test recommendation result includes a recommended test range, and the processor in the above-mentioned electronic device can be configured to run an executable program to perform the following steps: determine the version difference data using a preset code comparison strategy; determine the impact scope of the difference data based on the version difference data and the knowledge graph; determine the recommended test range based on the impact scope of the difference data.

[0152] Optionally, the test recommendation results include recommended test cases, and the processor in the above-mentioned electronic device can be configured to run an executable program to perform the following steps: determine version difference data using a preset code comparison strategy; determine recommended test cases based on the version difference data and weight data in the knowledge graph.

[0153] Optionally, the test recommendation results include a recommended test scope and recommended test cases, and the processor in the above-mentioned electronic device can be configured to run an executable program to perform the following steps: determine the difference impact scope based on the knowledge graph and the preset code comparison strategy; determine the recommended test scope and recommended test cases based on the difference impact scope.

[0154] An embodiment of the present invention further provides a computer-readable storage medium, the computer-readable storage medium including a stored executable program, wherein when the executable program is running, the device where the storage medium is located is controlled to execute the software testing method described in any of the above embodiments.

[0155] Optionally, in this embodiment, the above executable program may be configured to store an executable program for performing the following steps:

[0156] Step S101, obtaining data to be tested, wherein the data to be tested includes code data and test cases;

[0157] Step S102, determining the call chain data according to the data to be tested;

[0158] Step S103, constructing a knowledge graph based on the call chain data;

[0159] Step S104, determining a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

[0160] Optionally, the above executable program can be configured to store an executable program for executing the following steps: using a scanning algorithm to scan code data to determine function nodes and function call relationships; and determining call chain data based on function nodes and function call relationships.

[0161] Optionally, the above-mentioned executable program can be configured to store an executable program for executing the following steps: performing code instrumentation on the code data, injecting a preset call tracking component into the code data, wherein the parameters of the preset call tracking component include test cases and business methods; executing the test cases using a preset proxy service, and collecting log data of the preset call tracking component; and determining the call chain data based on the log data.

[0162] Optionally, the above-mentioned executable program can be configured to store an executable program for performing the following steps: based on the call chain data, obtaining detailed data corresponding to the call chain data, the detailed data including: the correspondence between the code package, code file and function corresponding to each call link, as well as the path, location, input and output parameters, comments, and code lines; based on the detailed data, constructing a knowledge graph.

[0163] Optionally, the above-mentioned executable program can be configured to store an executable program for executing the following steps: using a preset weighted algorithm to weight the call chain data to obtain a weighted call chain; and determining a knowledge graph based on the weighted call chain.

[0164] Optionally, the test recommendation result includes a recommended test scope, and the above-mentioned executable program can be configured to store an executable program for executing the following steps: determining the version difference data using a preset code comparison strategy; determining the impact scope of the difference data based on the version difference data and the knowledge graph; and determining the recommended test scope based on the impact scope of the difference data.

[0165] Optionally, the test recommendation results include recommended test cases, and the above-mentioned executable program can be configured to store an executable program for executing the following steps: determining version difference data using a preset code comparison strategy; determining recommended test cases based on the version difference data and weight data in the knowledge graph.

[0166] Optionally, the test recommendation results include a recommended test scope and recommended test cases, and the above-mentioned executable program can be configured to store an executable program for executing the following steps: determining the difference impact scope based on the knowledge graph and a preset code comparison strategy; determining the recommended test scope and recommended test cases based on the difference impact scope.

[0167] An embodiment of the present invention further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the software testing method described in any of the above embodiments is implemented.

[0168] Optionally, in this embodiment, the above computer program implements the following steps when executed by a processor:

[0169] Step S101, obtaining data to be tested, wherein the data to be tested includes code data and test cases;

[0170] Step S102, determining the call chain data according to the data to be tested;

[0171] Step S103, constructing a knowledge graph based on the call chain data;

[0172] Step S104, determining a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

[0173] Optionally, the above computer program implements the following steps when executed by a processor: using a scanning algorithm to scan code data to determine function nodes and function call relationships; and determining call chain data based on the function nodes and function call relationships.

[0174] Optionally, the above-mentioned computer program implements the following steps when executed by the processor: code stubbing is performed on the code data, and a preset call tracking component is injected into the code data, wherein the parameters of the preset call tracking component include test cases and business methods; the test cases are executed using a preset proxy service, and log data of the preset call tracking component is collected; and the call chain data is determined based on the log data.

[0175] Optionally, the above-mentioned computer program implements the following steps when executed by the processor: according to the call chain data, obtain detailed data corresponding to the call chain data, the detailed data including: the correspondence between the code package, code file and function corresponding to each call link, as well as the path, location, input and output parameters, comments, and code lines; based on the detailed data, construct a knowledge graph.

[0176] Optionally, the above-mentioned computer program implements the following steps when executed by the processor: using a preset weighted algorithm to perform weighted processing on the call chain data to obtain a weighted call chain; and determining a knowledge graph based on the weighted call chain.

[0177] Optionally, the test recommendation result includes a recommended test scope, and the above-mentioned computer program implements the following steps when executed by the processor: determine the version difference data using a preset code comparison strategy; determine the impact scope of the difference data based on the version difference data and the knowledge graph; determine the recommended test scope based on the impact scope of the difference data.

[0178] Optionally, the test recommendation results include recommended test cases, and the above-mentioned computer program implements the following steps when executed by the processor: using a preset code comparison strategy to determine version difference data; determining recommended test cases based on the version difference data and weight data in the knowledge graph.

[0179] Optionally, the test recommendation results include a recommended test scope and recommended test cases. The above computer program implements the following steps when executed by the processor: determine the difference impact scope based on the knowledge graph and the preset code comparison strategy; determine the recommended test scope and recommended test cases based on the difference impact scope.

[0180] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0181] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0182] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, 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 units or modules, which can be electrical or other forms.

[0183] 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 over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0184] 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0185] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or 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: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0186] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A software testing method, characterized in that: include: Acquire data to be tested, wherein the data to be tested includes code data and test cases; Determine call chain data according to the data to be tested; Constructing a knowledge graph based on the call chain data; According to the knowledge graph, a test recommendation result is determined, wherein the test recommendation result is used to guide the software testing process.

2. The software testing method according to claim 1, characterized in that: The step of determining the call chain data according to the data to be tested includes: Scan the code data using a scanning algorithm to determine function nodes and function call relationships; The call chain data is determined according to the function node and the function call relationship.

3. The software testing method according to claim 1, characterized in that: The step of determining the call chain data according to the data to be tested includes: Performing code instrumentation on the code data, injecting a preset call tracking component into the code data, wherein parameters of the preset call tracking component include the test case and the business method; Executing the test case using a preset proxy service and collecting log data of the preset call tracking component; The call chain data is determined according to the log data.

4. The software testing method according to claim 2, characterized in that: The step of constructing a knowledge graph according to the call chain data includes: According to the call chain data, detailed data corresponding to the call chain data is obtained, wherein the detailed data includes: the corresponding relationship between the code package, code file and function corresponding to each call link, as well as the path, location, input and output parameters, comments and code lines; The knowledge graph is constructed based on the detailed data.

5. The software testing method according to claim 3, characterized in that: The step of constructing a knowledge graph according to the call chain data includes: Using a preset weighting algorithm, weighted processing is performed on the call chain data to obtain a weighted call chain; The knowledge graph is determined according to the weighted call chain.

6. The software testing method according to claim 2, characterized in that: The test recommendation result includes a recommended test scope, and determining the test recommendation result according to the knowledge graph includes: Use the preset code comparison strategy to determine the version difference data; Determine the impact scope of the difference data according to the version difference data and the knowledge graph; The recommended test range is determined according to the impact range of the difference data.

7. The software testing method according to claim 5, characterized in that: The test recommendation result includes a recommended test case, and determining the test recommendation result according to the knowledge graph includes: Use the preset code comparison strategy to determine the version difference data; The recommended test case is determined based on the version difference data and the weight data in the knowledge graph.

8. The software testing method according to claim 1, characterized in that: The test recommendation result includes a recommended test scope and a recommended test case, and the determining the test recommendation result according to the knowledge graph includes: Determine the impact scope of the difference according to the knowledge graph and the preset code comparison strategy; The recommended test scope and the recommended test cases are determined according to the difference impact scope.

9. A software testing device, characterized in that: include: An acquisition module, used for acquiring data to be tested, wherein the data to be tested includes code data and test cases; A determination module, used to determine the call chain data according to the data to be tested; A construction module, used to construct a knowledge graph based on the call chain data; An output module is used to determine a test recommendation result based on the knowledge graph, wherein the test recommendation result is used to guide the software testing process.

10. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 8 when running.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 8.

12. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Electronic intelligent management method for enterprise certificates

    CN120952555A