Test case completion method and system and electronic equipment

By analyzing the software source code and generating use case completion suggestions, improving test cases, solving the problem of insufficient software testing coverage, improving the reliability and stability of the software, and reducing the complexity of the test.

CN118916274APending Publication Date: 2024-11-08广域铭岛数字科技有限公司 +1
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410958277.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

Traditional software testing methods are insufficiently tested in complex systems with rapid iteration, resulting in limitations in software quality assurance and affecting software reliability and stability.

Method used

By obtaining the source code of the software to be tested, analyzing the method call relationship library, performing code coverage analysis, generating use case completion suggestions for uncovered code, and improving test cases based on these suggestions, covering untested code lines and branches.

Benefits of technology

It improves the reliability and stability of the software, ensures that all parts of the software are fully tested, overcomes the problem of insufficient test coverage, reduces test complexity and uncertainty, and improves code coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916274A_ABST
    Figure CN118916274A_ABST
Patent Text Reader

Abstract

The invention relates to the field of software development, and discloses a test case completion method and system and electronic device.The test case completion method comprises the steps that a source code of software to be tested is analyzed, and a method calling relation library is obtained; code coverage analysis is carried out on the to-be-tested software, coverage codes and uncovered codes of the to-be-tested software are obtained, and the uncovered codes at least comprise the conditions that code lines and code branches are not covered respectively; calling the relation library based on the method to query to obtain a parameter association relation graph of a complete calling link, and generating a use case complementation suggestion of an uncovered code; and perfecting an executable test case of the to-be-tested software based on the case completion suggestion, and covering uncovered codes in the to-be-tested software. According to the method, trial case design blind spots are reversely speculated through the code coverage condition, information such as links and parameter association is called through the method, and uncovered code test case supplementary suggestions are provided in combination with an intelligent auxiliary programming tool, so that the test cases are effectively supplemented, and the problems of design insufficiency and low code coverage rate are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software development technology, and in particular to a test case completion method, system and electronic device. Background Art

[0002] With the rapid development of information technology, software has become an indispensable infrastructure for all walks of life. In the field of industrial production, software systems have penetrated into multiple links such as automated production lines, equipment monitoring, quality control, and logistics management. With the development of Industry 4.0 and intelligent manufacturing, the quality of software systems has become a core factor in ensuring production efficiency, product quality, and factory safety. Software failures in industrial production environments may not only cause production lines to stop, resulting in production delays and material waste, but may also cause equipment damage, safety hazards, and even threaten the lives of employees. Therefore, ensuring the quality of software online is the key to avoiding these potential risks.

[0003] However, traditional software testing methods can identify and prevent software failures to a certain extent. However, when dealing with complex systems with rapid iterations, the assurance of software quality has gradually become dependent on engineers' personal experience accumulation and understanding of business logic and system architecture. Its limitations have gradually emerged, and insufficient test coverage has become a major challenge affecting software quality. Therefore, more efficient and intelligent testing strategies are urgently needed to overcome this challenge. Summary of the invention

[0004] In view of the above-mentioned shortcomings of the prior art, the present application discloses a test case completion method, system and electronic device for overcoming the problem of software quality being affected by insufficient test coverage in software testing.

[0005] The first aspect of the present application discloses a test case completion method, comprising: obtaining software to be tested, and analyzing the source code of the software to be tested to obtain the method call relationship library, wherein the method call relationship library includes the method call relationship, parameter association information and entry method identification of the software to be tested; performing code coverage analysis on the software to be tested to obtain the covered code and uncovered code of the software to be tested, wherein the uncovered code at least includes the situations where code lines and code branches are not covered respectively; querying based on the method call relationship library to obtain a parameter association relationship diagram of the complete call link, and generating a test case completion suggestion for the uncovered code, wherein the complete call link is obtained by concatenating each method call relationship according to the entry method identification, and each method call relationship carries corresponding parameter association information; based on the use case completion suggestion, completing the executable test case of the software to be tested to cover the uncovered code in the software to be tested.

[0006] In certain embodiments of the first aspect of the present application, the source code of the software to be tested is analyzed to obtain the method call relationship library, including: obtaining file identification information of the software to be tested; pulling the source code of the software to be tested from a code repository based on the file identification information; calling a source code analysis service to perform static analysis and dynamic analysis on the source code of the software to be tested, identify method call relationships, and construct a method call relationship library based on the static analysis results and the dynamic analysis results.

[0007] In certain embodiments of the first aspect of the present application, code coverage analysis is performed on the software to be tested to obtain covered code and uncovered code of the software to be tested, including: starting the software to be tested and collecting the execution status of code lines and code branches during the execution of the test case; marking the code lines and code branches in the source code that execute the test case as coverage labels, and marking the code lines and code branches in the source code that do not execute the test case as uncovered labels; distinguishing according to the coverage labels and the uncovered labels to obtain the covered code and uncovered code of the software to be tested.

[0008] In certain embodiments of the first aspect of the present application, a query is performed based on the method call relationship library to obtain a parameter association relationship diagram of the complete call link, and a use case completion suggestion for the uncovered code is generated, including: querying the method call relationship library, concatenating the method call relationships obtained by the query according to the entry method identifier, determining the complete call link and the parameter association relationship diagram of the complete call link, the parameter association relationship diagram including the logical relationship of the above code information of the uncovered code line, and the association relationship between the variables in the above code and the parameters in the interface; identifying the parameter association relationship diagram of the complete call link, and the syntax and semantics in the above code information of the code line or branch of the uncovered code, and determining the purpose and intent of the code logic; performing use case prediction based on the purpose and intent of the code logic, and generating use case completion suggestions using natural language processing.

[0009] In certain embodiments of the first aspect of the present application, the executable test cases of the software under test are improved based on the use case completion suggestions to cover the uncovered code in the software under test, including: supplementing the above code information of the code lines or branches of the uncovered code based on the use case completion suggestions to improve the executable test cases of the software under test; and testing the improved software under test again to verify the uncovered code to cover the uncovered code in the software under test.

[0010] In certain embodiments of the first aspect of the present application, the improved software to be tested is tested again to verify the uncovered code to cover the uncovered code in the software to be tested, and also includes: if the uncovered code still cannot execute the test case after the test case is completed, the verification fails, and it is determined whether the currently completed uncovered code is a discarded code; if the currently completed uncovered code is a discarded code, an alarm message carrying the discarded code is issued, and the developer is notified to delete it after review; if the uncovered code can execute the test case after the test case is completed, the verification passes, and it is determined that the uncovered code in the software to be tested is covered by the test case completion.

[0011] In certain embodiments of the first aspect of the present application, after obtaining the software to be tested, it also includes: obtaining a first code path set obtained by running the software to be tested in a production environment and a second code path set obtained by running test cases in a test environment, wherein any code path set includes at least one code path; obtaining a missing code path based on the first code sub-path set and the second code sub-path set; for any missing code path, calculating the similarity between the missing code path and any code path in the second code path set to obtain a reference code path that meets the similarity requirements; and fusing the first test case corresponding to the reference code path and the second test case of the software to be tested corresponding to the test case completion suggestion to obtain a completed test case.

[0012] In certain embodiments of the first aspect of the present application, the covered code and the uncovered code of the software to be tested are obtained by distinguishing between the covered label and the uncovered label, and also include: merging and summarizing the execution status of each of the test cases, and generating a software source code coverage analysis file according to the covered label and the uncovered label; and using different text colors or text background colors in the software source code coverage analysis file to distinguish between the covered code and the uncovered code.

[0013] The second aspect of the present application discloses a test case completion system, including: a relationship library acquisition module, used to obtain the software to be tested, and analyze the source code of the software to be tested to obtain the method call relationship library, the method call relationship library includes the method call relationship, parameter association information and entry method identification of the software to be tested; a coverage analysis module, used to perform code coverage analysis on the software to be tested, and obtain the covered code and uncovered code of the software to be tested, the uncovered code at least includes the situation that the code line and the code branch are not covered respectively; a completion suggestion module, based on the query of the method call relationship library, obtains the parameter association relationship diagram of the complete call link, and generates a use case completion suggestion for the uncovered code, wherein the complete call link is obtained by connecting each method call relationship in series according to the entry method identification, and each method call relationship carries corresponding parameter association information; a use case completion module, based on the use case completion suggestion, completes the executable test case of the software to be tested, and covers the uncovered code in the software to be tested.

[0014] The third aspect of the present application discloses an electronic device, comprising: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the above method.

[0015] The beneficial effects of the present application are as follows: first, the software to be tested is obtained, and the source code of the software to be tested is analyzed to obtain the method call relationship library, and code coverage analysis is performed on the software to be tested to obtain the covered code and uncovered code of the software to be tested, wherein the uncovered code at least includes the situations where the code lines and code branches are not covered respectively; this helps to discover potential defects and vulnerabilities, and can also ensure that all parts of the software are fully tested, thereby improving the reliability and stability of the software; secondly, a query is performed based on the method call relationship library to obtain a parameter association relationship diagram of the complete call link, and a use case completion suggestion for the uncovered code is generated; based on the use case completion suggestion, the executable test case of the software to be tested is improved to cover the uncovered code in the software to be tested, On the one hand, the blind spots of test case design can be inferred through code coverage, and supplementary suggestions for test cases for uncovered code can be provided through information such as method call links and parameter associations combined with AI-assisted programming tools. The effective supplementation of test cases can overcome the problems of insufficient design and low code coverage. On the other hand, in the process of software system testing, code coverage is used to supplement test cases, and the supplemented test cases are used to improve code coverage. The two complement each other and can effectively ensure that the software system can be fully tested and verified. On the other hand, newly introduced problems can be discovered and fixed in time through test case completion to maintain the stability and quality of the software. At the same time, it also reduces the testing workload, making the testing process more systematic, repeatable and predictable, which helps to reduce the complexity and uncertainty of testing work. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 This is an application environment diagram of a test case completion system in an embodiment of the present application;

[0017] Figure 2 It is a flowchart of a test case completion method in an embodiment of the present application;

[0018] Figure 3 It is a schematic diagram of the actual process of a test case completion method in an embodiment of the present application;

[0019] Figure 4 This is a method call relationship diagram obtained by analyzing source code in an embodiment of the present application;

[0020] Figure 5 This is a flow chart of printing the life stage of a user according to the user's age in an embodiment of the present application;

[0021] Figure 6 This is a use case completion suggestion logic diagram in an embodiment of the present application;

[0022] Figure 7 is a schematic diagram of a test case completion system in an embodiment of the present application;

[0023] Figure 8 It is a structural diagram of a test case completion system in an embodiment of the present application;

[0024] Fig. 9 It is a structural schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0025] The following describes the implementation methods of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, 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 application. It should be noted that the following embodiments and sub-samples in the embodiments can be combined with each other without conflict.

[0026] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application 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 at will, and the component layout may also be more complicated.

[0027] In the following description, a lot of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application 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 application difficult to understand.

[0028] The terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure 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 terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.

[0029] Unless otherwise stated, the term "plurality" means two or more.

[0030] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.

[0031] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.

[0032] Combination Figure 1 As shown, an embodiment of the present disclosure provides a system architecture diagram for implementing a test case completion system, including a user end and a server end, wherein the user end and the server end are connected to a network and communicate with each other. In this application, the user end is the front end and the server end is the back end, which will not be repeated.

[0033] The embodiment of the present application provides a test case completion system, which can be applied to a terminal, a server, or software running in a terminal or a server. In some embodiments, the terminal can be at least one of a computer device, a desktop device, a smart phone, and a tablet device; the server can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms; the software can be an application for test case completion, etc., but is not limited to the above forms.

[0034] For example, see Figure 1 , is an implementation environment diagram of a test case completion system provided by the present application. The test case completion system in the present application is exemplarily as follows: Figure 1 As shown, the execution body of the system provided in the embodiment of the present application is mainly arranged at the user end, and the user end responds to the test case completion system.

[0035] Combination Figure 2 As shown, the embodiment of the present disclosure provides a flow chart of a test case completion method, including:

[0036] Step S201, obtaining the software to be tested, and analyzing the source code of the software to be tested to obtain the method call relationship library, the method call relationship library including the method call relationship, parameter association information and entry method identification of the software to be tested;

[0037] It should be noted that the software under test refers to the software program or system that is currently being tested or evaluated for its performance, function, security, stability and other characteristics during the software development or testing process. The software under test can be a newly developed software application or an updated or modified version of an existing software.

[0038] Specifically, the file identification information of the software to be tested is obtained; the source code of the software to be tested is pulled from the code repository based on the file identification information; the source code analysis service is called to perform static analysis and dynamic analysis on the source code of the software to be tested, identify method call relationships, and build a method call relationship library based on the static analysis results and the dynamic analysis results.

[0039] For example, the file identification information of the software to be tested is obtained, and accessed through the URL (Uniform Resource Locator) of a distributed warehouse, a centralized warehouse, or other version control system. For example, commands such as command line or script execution (for Git warehouse) are used to pull the source code, pull specific files or directories, and specify the path to match the source code of the software to be tested.

[0040] For example, select a suitable static analysis tool (such as Java's Checkstyle, FindBugs, SonarQube, Python's PyLint, Flake8, etc.) to analyze the source code according to the language and technology stack of the software to be tested, and run it to generate static analysis results, and collect the static analysis results (such as code quality reports, potential defect lists, etc.) for subsequent processing.

[0041] For example, by writing or selecting test cases that can cover the main functions of the software to be tested, using a test framework (such as JUnit, pytest, etc.) to execute the test cases, recording the behavior of the software to be tested at runtime, capturing and collecting runtime data such as method call stacks, memory usage, response time, etc., dynamic analysis results are formed.

[0042] Based on the static analysis results and dynamic analysis results, especially the data related to method calls, a method call relationship graph is constructed using graph theory algorithms (such as adjacency lists and adjacency matrices) for storage, namely the method call relationship library.

[0043] Step S202, performing code coverage analysis on the software to be tested to obtain covered code and uncovered code of the software to be tested, wherein the uncovered code at least includes situations where code lines and code branches are not covered;

[0044] Specifically, branch coverage, code path coverage is a measure of software test coverage, which indicates whether different execution paths in the code are covered during the test. Specifically, code path coverage measures the proportion of code paths actually executed in the test to all possible code paths. Path coverage: used to measure whether the test covers different branch paths in the code. Branch coverage focuses on conditional branches in the code, such as if statements, switch statements, etc., and whether each branch is executed at least once in the test.

[0045] It should be understood that the software to be tested is started, and the execution status of code lines and code branches during the execution of the test case is collected; the code lines and code branches in the source code that execute the test case are marked as coverage labels, and the code lines and code branches in the source code that do not execute the test case are marked as uncovered labels; and the covered code and uncovered code of the software to be tested are obtained by distinguishing based on the covered labels and the uncovered labels.

[0046] For example, the execution status of code lines and code branches during the execution of the test case is collected through an Agent tool, the code lines and code branches in the source code that do not execute the test case are marked as uncovered labels, and the covered code and uncovered code of the software to be tested are obtained. After analysis through the code coverage collection service, the coverage status of the code lines and code branches and the uncovered status are obtained.

[0047] Step S203: querying based on the method call relationship library to obtain a parameter association relationship diagram of a complete call link, and generating a use case completion suggestion for the uncovered code, wherein the complete call link is obtained by connecting the method call relationships in series according to the entry method identifier, and each method call relationship carries corresponding parameter association information;

[0048] Specifically, the method call relationship library is queried, and the method call relationships obtained by the query are connected in series according to the entry method identifier to determine a complete call link and a parameter association relationship graph of the complete call link, wherein the parameter association relationship graph includes a logical relationship of the above code information of the uncovered code line, and an association relationship between the variables in the above code and the parameters in the interface;

[0049] Identify the parameter association relationship diagram of the complete call link, as well as the syntax and semantics in the above code information of the code line or branch of the uncovered code, and determine the purpose and intent of the code logic;

[0050] Use case prediction is performed based on the purpose and intent of the code logic, and use of natural language processing is used to generate use case completion suggestions.

[0051] It should be noted that first, ensure a clear entry method identifier as the starting point for tracing the call chain, then use the entry method identifier as the query condition to retrieve all related method call relationships from the method call relationship library; then connect the queried method call relationships in series according to the actual execution order to form a complete call chain, which should clearly show the call relationship between methods. In the process of connecting the call chain, track the source and destination of the parameters of each method call. This includes how the parameters are passed from one method to another; based on the parameter transfer path, build a parameter association relationship diagram, which should include the parameter transfer relationship between method calls, as well as the relationship between the variables and interface parameters in the above code that does not cover the code line.

[0052] When constructing the parameter association diagram, pay special attention to the context of the uncovered code lines, understand the logical relationships of these codes, such as conditional judgments, loop structures, etc., and how they affect the value and transfer of parameters. Perform an in-depth analysis of the parameter association diagram of the complete call link, especially the context of the code lines or branches of the uncovered code, and understand the function and purpose of the code by parsing the syntax and semantics of these codes. Combine the logical structure and control flow of the code (such as if statements, loops, etc.) to understand how the code is executed and decided, which helps to infer the intent and expected behavior of the code.

[0053] Based on the purpose and intent of the code logic, predict which test cases can cover the uncovered code lines or branches. These test cases should be able to trigger the corresponding code paths and verify the correctness of the code. Using natural language processing (NLP) technology, the predicted test cases are converted into human-readable descriptions or templates. These suggestions can include key information such as test steps, input data, and expected results.

[0054] The generated test case completion suggestions need to be verified to ensure that they can effectively cover the target code, and make appropriate adjustments when necessary. Put the generated test case completion suggestions into practice, execute these test cases in the test environment, and collect the results. Adjust the test cases and completion suggestions based on the test results to improve coverage and test effectiveness; at the same time, use the test results and feedback as the basis for future iterations and improvements.

[0055] Through the above approach, the method call relationship library and code analysis technology can be effectively used to identify uncovered code and generate targeted test case completion suggestions.

[0056] Step S204: completing the executable test cases of the software to be tested based on the use case completion suggestions to cover the uncovered code in the software to be tested.

[0057] Specifically, based on the use case completion suggestions, the above code information of the code lines or branches of the uncovered code is supplemented to improve the executable test cases of the software to be tested; the improved software to be tested is tested again to verify the uncovered code to cover the uncovered code in the software to be tested.

[0058] Through the above method, first, the software to be tested is obtained, and the source code of the software to be tested is analyzed to obtain the method call relationship library, and code coverage analysis is performed on the software to be tested to obtain the covered code and uncovered code of the software to be tested, and the uncovered code at least includes the situations where the code lines and code branches are not covered respectively; this helps to discover potential defects and loopholes, and can also ensure that all parts of the software are fully tested, thereby improving the reliability and stability of the software; secondly, based on the method call relationship library, a query is performed to obtain a parameter association relationship diagram of the complete call link, and a use case completion suggestion for the uncovered code is generated; based on the use case completion suggestion, the executable test case of the software to be tested is improved to cover the uncovered code in the software to be tested, and a On the one hand, the blind spots of test case design can be inferred through code coverage, and supplementary suggestions for test cases for uncovered code can be provided through information such as method call links and parameter associations combined with AI-assisted programming tools. The effective supplementation of test cases overcomes the problems of insufficient design and low code coverage. On the other hand, in the software system testing process, the code coverage situation is used to supplement test cases, and the supplemented test cases are used to improve the code coverage. The two complement each other and can effectively ensure that the software system can be fully tested and verified. On the other hand, through test case completion, newly introduced problems can be discovered and fixed in time to maintain the stability and quality of the software. At the same time, it also reduces the testing workload, making the testing process more systematic, repeatable and predictable, which helps to reduce the complexity and uncertainty of the testing work.

[0059] Optionally, in some embodiments, the improved software to be tested is tested again to verify the uncovered code to cover the uncovered code in the software to be tested, further comprising:

[0060] If the uncovered code still cannot execute the test case after completing the test case, the verification fails, and it is determined whether the uncovered code after the current completion is an abandoned code; if the uncovered code after the current completion is an abandoned code, an alarm message carrying the abandoned code is issued, and the developer is notified to delete it after review;

[0061] If the uncovered code can execute the test case after completing the test case, the verification passes, and it is determined that the uncovered code in the software to be tested is covered by the test case completion.

[0062] On the basis of the above embodiments, by testing the improved software to be tested again and verifying the uncovered code, it is possible to detect abandoned code in the program, reversely infer deficiencies in the architecture and code design, and help developers clarify the logical relationship of the code and improve code quality.

[0063] Optionally, in some embodiments, after obtaining the software to be tested, the method further includes:

[0064] Obtaining a first code path set obtained by running the software under test in a production environment and a second code path set obtained by running a test case in a test environment, wherein each code path set includes at least one code path;

[0065] Obtaining a missing code path based on the first code sub-path set and the second code sub-path set;

[0066] For any missing code path, similarity calculation is performed between the missing code path and any code path in the second code path set to obtain a reference code path that meets the similarity requirement;

[0067] A first test case corresponding to the reference code path and a second test case of the software to be tested corresponding to the case completion suggestion are merged to obtain a completed test case.

[0068] It should be noted that, during any code path collection process, if a loop statement path marker is detected and the subpath currently collected is a subpath already recorded in the current code path, the subpath currently collected is not included in the current code path.

[0069] Specifically, the loop statement path is a loop structure existing in a sub-path in a code path, such as for and while statements. Regardless of whether these sub-paths are looped once or multiple times in a code path, these sub-paths belong to the same test scenario. In the collection and detection, the sub-path currently collected is the sub-path recorded in the current code path, and the sub-path currently collected is not recorded.

[0070] For example, in code path 1, assuming that node B is a for loop, nodes C and D are two decision nodes in the loop, assuming that a transaction loops twice, and the code path is A->B->C->B->C->G->H, then the subpath B->C->B->C is considered to be a repeated path, and only B->C is recorded once, then code path 1 is not recorded, and the final recorded code path 2 is: A->B->C->G->H; assuming that C and D are respectively walked in the loop twice, that is, code path 3 is A->B->C->B->D->G->H, at this time, the subpath B->C->B->D is not a repeated branch path, and code path 3 needs to be recorded.

[0071] The code paths in the first code path set and / or the second code path set are subjected to loop subpath simplification processing to obtain an updated first code path set and / or second code path set; wherein the loop subpath simplification processing is to delete repeated loop subpaths in any code path.

[0072] Specifically, after collecting the first code path set of the same software in a production environment and the second code path set of running test cases in a test environment, the loop sub-paths in the first code path set and the second code path set are deleted. By reducing the code path dimensionality, the problem of code path explosion in the existing solution is solved, and the problem of conditional branch coverage missing test scenarios is also avoided.

[0073] Specifically, for each missing code path, traverse the code paths in the second code path set (test environment), and use a similarity measurement method (such as edit distance, structural similarity, functional similarity, etc.) to calculate the similarity between them. From the code paths in the test environment, select those paths with the highest similarity to the missing code paths as reference code paths, for example, the path represents a function or logic similar to or related to the missing path. In-depth study of the test cases corresponding to each reference code path, understand its test purpose, input, output and execution process, and design new test cases based on the test cases of the reference code path to cover the missing code path. Including but not limited to modifying the input, output or execution path of existing test cases, or creating new test cases, merging the designed completion test cases (first test cases) with the existing second test case set to ensure that the test set comprehensively and effectively covers all important paths of the software to be tested.

[0074] Execute the newly completed test cases in the test environment to ensure that the missing code paths are triggered as expected. Check the test results to confirm that the missing code paths have been effectively covered and no new errors or issues have been introduced.

[0075] Optionally, in some embodiments, obtaining the covered code and uncovered code of the software under test by distinguishing the covered label from the uncovered label further includes:

[0076] The execution status of each of the test cases is combined and summarized, and a software source code coverage analysis file is generated according to the coverage labels and the uncovered labels;

[0077] The software source code coverage analysis file uses different text colors or text background colors to distinguish the covered code and the uncovered code.

[0078] It should be understood that the merged test case execution results are processed using code coverage tools (such as JaCoCo, coverage.py, etc.) to generate source code coverage data, for example, including the execution status of each file, each class, each method and even each line of code (i.e., whether it is covered).

[0079] Specifically, according to the generated source code coverage data, add a coverage label (such as "covered") or an uncovered label (such as "not covered") to each code line or code block in the source code, use a text editor or a special report generation tool to create a new file for displaying the source code coverage analysis results, copy the source code to the file, distinguish the code according to the coverage label, and set a specific text color or background color (such as green for covered) for the covered code lines or code blocks in the source code coverage analysis file; similarly, set another different color or background color (such as red for uncovered) for the uncovered code lines or code blocks; this can be achieved by using HTML tags in the file (if the file is in HTML format) or editor-specific syntax highlighting rules.

[0080] Sharing the generated source code coverage analysis file with team members in the above way helps to understand the test coverage and identify potential areas for improvement; using the file as a guide, write new test cases to cover uncovered code, thereby improving the overall quality of the software.

[0081] See also Figure 3 , is a schematic diagram of an actual flow chart of a test case completion method in an embodiment of the present application, which is described in detail as follows:

[0082] Step S301, obtaining the calling method, parameter source and other information of the method of the software system under test (i.e., the software to be tested) to obtain a method calling relationship library;

[0083] Step S302, executing the test case to obtain the code coverage of the tested software system;

[0084] Step S303, query the above code information, method call relationship library and other information of the uncovered code in the method, and then the AI ​​intelligent programming tool will give use case completion suggestions after understanding the association relationship;

[0085] Step S304: The tester constructs an executable test case according to the suggestion, and executes the test case on the software system under test to complete the coverage of the uncovered code.

[0086] Through the above method, this application has the following technical effects:

[0087] 1) This application infers the blind spots of test case design through code coverage, and provides supplementary suggestions for test cases for uncovered code through information such as method call links and parameter associations combined with AI-assisted programming tools, effectively supplementing test cases to overcome the problems of insufficient design and low code coverage.

[0088] 2) During the software system testing process, the code coverage is used to supplement the test cases, and the supplemented test cases are then used to improve the code coverage rate. The two complement each other and can effectively ensure that the software system can be fully tested and verified.

[0089] 3) The solution can also detect abandoned code in the program, reverse engineer deficiencies in the architecture and code design, and help developers clarify the logical relationships in the code and improve code quality.

[0090] See also Figure 4 , is a method call relationship diagram obtained by analyzing source code in an embodiment of the present application; the details are as follows:

[0091] Assume that the entry method of the interface / api / printUserInfo is entryMethod(User user). This method first checks whether the user's age is greater than or equal to 0. If the age is legal, it converts the age to int type and calls the printUserAgeStage method to print the user's age group. Secondly, it calls the printUserPlaceOfOrigin method to print the user's birthplace to obtain the source code.

[0092] By analyzing the source code, the method calling relationship is as follows (the relevant methods in the SDK do not need to be analyzed). Figure 4 It can be seen that:

[0093] Business code method

[0094] thirdPartyApI

[0095] Caller: printUserPlaceOfOnigin; Parameter source: idCard:pintUserPlaceOf0rigin.ldCardprintlserPlace0f0ngin

[0096] Caller: entryMethod; Parameter: iCard:entyMethod.UseridCand

[0097] printUserAgeStage

[0098] Caller: entryMethod; Parameter source: age:entryMethod.Userage->Integerparselhnt;

[0099] entryMethod / api / printUserlnfo)

[0100] Caller: null (entry method); parameter definition: User: User entity class.

[0101] In the above business code, each method (except the entry method) records the upstream calling method, the source of parameters, and the processing of parameters in the upstream calling method. Connecting the upstream calling methods of a method one by one will form a complete calling chain from the entry method to a specific method and a parameter association diagram of the calling chain. Take the printUserAgeStage method as an example. Figure 5 As shown, it is a flowchart of printing the life stage of a user according to the user's age in an embodiment of the present application;

[0102] In the method call relationship

[0103] printuserAgeStage

[0104] Caller: entryMethod; Parameter source: age:entryMethod.Userage->Integer parselnt()

[0105] entryMethod

[0106] Caller: null (entry method); parameter definition: User: User entity class

[0107] Interface: / api / printUserInfo

[0108] Caller: null (external interface); parameter definition: user: User entity class.

[0109] In the call relationship logic diagram

[0110] For example, the method calling relationship and parameter association relationship are as follows:

[0111] 1. The printUserAgeStage method is called by the entryMethod method

[0112] 2. The entryMethod method is the entry method of the interface / api / printUserlnfo

[0113] 3. The input parameters of the entryMethod method come from the input parameters of the interface piprintUserlnfo

[0114] 4. The printUserAgeStage method parameter comes from the parameter association relationship entry Method parameter User entity class age attribute. The age attribute also needs to be converted to an integer using litegerparseint).

[0115] The instructions are as follows:

[0116] 1) First, the printUserAgeStage method is called by the entryMethod method;

[0117] 2) The relationship between the parameters of the printUserAgeStage method and the parameters of the caller entryMethod method: The parameters of the printUserAgeStage method come from the age attribute of the User entity class, which is the parameter of the entryMethod method. In addition, the age attribute of the User entity class needs to be converted to an integer using Integer.parseInt();

[0118] 3) Because the entryMethod method is the entry method of the interface / api / printUserInfo, the parameter User entity class of the entryMethod method is the parameter of the interface / api / printUserInfo. Assuming that the interface parameter is in json format, it is {"age":"","idCard":""}. Therefore, the execution logic of the printUserAgeStage method is related to the age field in the interface / api / printUserInfo input parameter.

[0119] Similarly, the printUserPlaceOfOrigin method is called by the entry method entryMethod. The parameter idCard comes from the idCard attribute of the User entity class in the entryMethod method parameter, which is related to the idCard field in the interface / api / printUserInfo input parameter.

[0120] Assume that after the test executes some test cases, the code line coverage of the printUserPlaceOfOrigin method is as follows (green indicates that the code line is covered, and red indicates that it is not covered):

[0121] Some code lines of the printUserPlaceOfOrigin method are not covered. Query the association relationship of the printUserPlaceOfOrigin method to obtain the complete call link and parameter association relationship from the entry method entryMethod to the printUserPlaceOfOrigin method. Combined with the AI ​​intelligent programming tool, the use case completion suggestion logic diagram is obtained. For details, see Figure 6 , is a use case completion suggestion logic diagram in an embodiment of the present application; the details are as follows:

[0122] 1) From the above code information of the uncovered code lines in the analysis method, it can be seen that the code lines are not covered because the condition in the code line "if (null! = idCard && idCard.length = 18)" is false. Combined with the analysis of the AI-assisted programming tool, the specific reason is obtained: the if condition (null! = idCard && idCard.length = 18) requires that idCard is not empty and the idCard string length must be 18, and the variable idCard in the if condition comes from the parameter idCard of the printUserPlaceOfOrigin method.

[0123] 2) By querying the method call relationship library, we can see that the printUserPlaceOfOrigin method is called by the entryMethod method, and the entryMethod method is the entry method of the interface / api / printUserInfo, so the complete call link is entryMethod—>printUserPlaceOfOrigin. Parameter association relationship between methods: The parameter idCard of the printUserPlaceOfOrigin method comes from the idCard attribute of the User entity class of the entryMethod method parameter, which is the idCard field in the interface / api / printUserInfo input parameter.

[0124] 3) Through AI-assisted programming tools combined with the above information analysis, the code line is not covered because the idCard in the code line "if (null! = idCard && idCard.length = 18)" is empty or the idCard string length is not equal to 18. The variable idCard comes from the idCard field in the interface / api / printUserInfo input parameter. Therefore, the uncovered code lines in the printUserPlaceOfOrigin method are covered. Recommended test cases. Supplementary suggestions: In the interface / api / printUserInfo, the parameter idCard should not be empty and the string length must be 18.

[0125] In addition, assuming that the test case request parameters before the use case supplement is {"age":"10","idCard":""}, according to the test case supplement instructions, when testing the interface / api / printUserInfo, you only need to supplement the idCard field in the request parameter with an 18-bit string {"age":"10","idCard":"500381190001011234"} and then test it to cover the uncovered code lines of the printUserPlaceOfOrigin method.

[0126] In addition, if a method throws an exception during execution, the exception information is combined with the above method call relationship library and the parameter association relationship between methods, and the AI-assisted programming tool can also recommend test cases. Take the above printUserPlaceOfOrigin method as an example.

[0127] Assume that the above print(placeOfOrigin) code line is not executed because the call to the third-party interface thirdPartyApi in the above text throws an exception, and the exception information is Invalid CheckCode (the identity card number verification code exception usually refers to the last digit of the identity card (or character X) not meeting the checksum calculated by the first 17 digits). Through the exception information and the parameter association relationship between the methods, the uncovered code lines in the printUserPlaceOfOrigin method are covered. The recommended test case supplementary suggestion is: enter the correct idCard in the interface / api / printUserInfo, that is, the last verification code of the parameter idCard must be a valid verification code.

[0128] See also Figure 7 , is a schematic diagram of a test case completion system in an embodiment of the present application, including:

[0129] Before testing the software system under test, the source code of the software system under test is pulled for analysis, and the method call relationship library (including method callers, parameter sources and other related information) is output; secondly, the code coverage agent is configured before the software system under test is started, so that code coverage information can be continuously collected during the test process; finally, the uncovered code methods are analyzed, and the method call relationship library is queried to provide use case completion suggestions;

[0130] The test case completion system consists of three microservices: source code analysis service, code coverage collection service, and use case prediction service;

[0131] The source code analysis service pulls the source code of the software system under test from the code repository and obtains the method call relationship library through source code analysis. Before the software system under test is started, the code coverage agent is injected into the software system under test to continuously collect the code coverage of the software system under test during the execution of test cases. After analysis, the code coverage collection service obtains the coverage of code lines and branches;

[0132] After the use case prediction service identifies uncovered code lines or branches in a method, it queries the method's complete upstream call chain in the method call relationship library and obtains parameter association information in the call chain. It then uses AI intelligent programming tools to understand the uncovered code lines or branches in the method and the parameter association in the method call chain, and then gives use case completion suggestions.

[0133] Finally, the tester constructs the use case completion suggestions into executable test cases to test the software system under test and complete the testing of uncovered code.

[0134] Through the above method, after building the method call relationship library, the logical relationship of the previous code information of the uncovered code lines in the method, as well as the association between the variables in the previous code and the parameters in the interface, are used to recommend use cases in combination with AI-assisted programming tools. Among them, the AI-assisted programming tool mainly analyzes and processes the syntax and semantics of the code to understand the purpose and intention of the code logic, and can generate human-readable test case suggestions through technologies such as natural language processing (NLP).

[0135] See also Figure 8 , is a schematic diagram of the structure of a test case completion system in an embodiment of the present application, including:

[0136] The relationship library acquisition module 801 is used to acquire the software to be tested, and analyze the source code of the software to be tested to obtain the method call relationship library, which includes the method call relationship, parameter association information and entry method identification of the software to be tested;

[0137] A coverage analysis module 802 is used to perform code coverage analysis on the software under test to obtain covered code and uncovered code of the software under test, wherein the uncovered code at least includes situations where code lines and code branches are not covered;

[0138] The completion suggestion module 803 performs a query based on the method call relationship library to obtain a parameter association relationship diagram of a complete call link, and generates a use case completion suggestion for the uncovered code, wherein the complete call link is obtained by concatenating the method call relationships according to the entry method identifier, and each method call relationship carries corresponding parameter association information;

[0139] The use case completion module 804 improves the executable test cases of the software under test based on the use case completion suggestions to cover the uncovered code in the software under test.

[0140] It should be noted that the test case completion method of the present application corresponds one-to-one to the test case completion system, and the corresponding technical details and technical solutions refer to the above-mentioned test case completion system, which will not be repeated here.

[0141] Through the above method, first, the software to be tested is obtained, and the source code of the software to be tested is analyzed to obtain the method call relationship library, and code coverage analysis is performed on the software to be tested to obtain the covered code and uncovered code of the software to be tested, and the uncovered code at least includes the situations where the code lines and code branches are not covered respectively; this helps to discover potential defects and loopholes, and can also ensure that all parts of the software are fully tested, thereby improving the reliability and stability of the software; secondly, based on the method call relationship library, a query is performed to obtain a parameter association relationship diagram of the complete call link, and a use case completion suggestion for the uncovered code is generated; based on the use case completion suggestion, the executable test case of the software to be tested is improved to cover the uncovered code in the software to be tested, and a On the one hand, the blind spots of test case design can be inferred through code coverage, and supplementary suggestions for test cases for uncovered code can be provided through information such as method call links and parameter associations combined with AI-assisted programming tools. The effective supplementation of test cases overcomes the problems of insufficient design and low code coverage. On the other hand, in the software system testing process, the code coverage situation is used to supplement test cases, and the supplemented test cases are used to improve the code coverage. The two complement each other and can effectively ensure that the software system can be fully tested and verified. On the other hand, through test case completion, newly introduced problems can be discovered and fixed in time to maintain the stability and quality of the software. At the same time, it also reduces the testing workload, making the testing process more systematic, repeatable and predictable, which helps to reduce the complexity and uncertainty of the testing work.

[0142] In other embodiments, the present disclosure also provides an electronic device, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the above method.

[0143] Fig. 9 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Fig. 9 The computer system 900 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0144] like Fig. 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage part 508 to the random access memory (RAM) 903, such as the method in the above embodiment. In the random access memory 903, various programs and data required for system operation are also stored. The central processing unit 901, the read-only memory 902 and the random access memory 903 are connected to each other through a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0145] The following components are connected to the input / output interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the input / output interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed so that a computer program read therefrom is installed into the storage section 908 as needed.

[0146] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 909, and / or installed from a removable medium 911. When the computer program is executed by a central processing unit (CPU) 901, various functions defined in the system of the present application are executed.

[0147] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. Parts and subsamples of some embodiments may be included in or replace parts and subsamples of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and the claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of a stated sub-sample, whole, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other sub-samples, wholes, steps, operations, elements, components and / or groups of these. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.

[0148] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0149] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units can be 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 sub-samples can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other 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. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.

[0150] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the method, system and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.

Claims

1. A test case completion method, characterized in that: include: Acquire the software to be tested, and analyze the source code of the software to be tested to obtain the method call relationship library, which includes the method call relationship, parameter association information and entry method identification of the software to be tested; Performing code coverage analysis on the software to be tested to obtain covered code and uncovered code of the software to be tested, wherein the uncovered code at least includes situations where code lines and code branches are not covered; A query is performed based on the method call relationship library to obtain a parameter association relationship diagram of a complete call link, and a use case completion suggestion for the uncovered code is generated, wherein the complete call link is obtained by concatenating the method call relationships according to the entry method identifier, and each method call relationship carries corresponding parameter association information; Based on the use case completion suggestion, the executable test case of the software to be tested is improved to cover the uncovered code in the software to be tested.

2. The method according to claim 1, characterized in that Analyzing the source code of the software to be tested to obtain the method call relationship library includes: Obtaining file identification information of the software to be tested; Pulling the source code of the software to be tested from a code repository based on the file identification information; The source code analysis service is called to perform static analysis and dynamic analysis on the source code of the software to be tested, identify method call relationships, and build a method call relationship library based on the static analysis results and the dynamic analysis results.

3. The method according to claim 1, characterized in that Performing code coverage analysis on the software to be tested to obtain covered code and uncovered code of the software to be tested includes: Starting the software to be tested, and collecting the execution status of code lines and code branches during the execution of the test case; Marking the code lines and code branches in the source code that execute the test case as covered labels, and marking the code lines and code branches in the source code that do not execute the test case as uncovered labels; The covered code and uncovered code of the software to be tested are obtained by distinguishing the covered code and the uncovered code according to the covered label and the uncovered label.

4. The method according to claim 1, characterized in that A query is performed based on the method call relationship library to obtain a parameter association relationship diagram of the complete call link, and a use case completion suggestion for the uncovered code is generated, including: The method call relationship library is queried, and the method call relationships obtained from the query are connected in series according to the entry method identifier to determine a complete call link and a parameter association relationship diagram of the complete call link, wherein the parameter association relationship diagram includes a logical relationship of the above code information of the uncovered code line, and an association relationship between the variables in the above code and the parameters in the interface; Identify the parameter association relationship diagram of the complete call link, as well as the syntax and semantics in the above code information of the code line or branch of the uncovered code, and determine the purpose and intent of the code logic; Use case prediction is performed based on the purpose and intent of the code logic, and use of natural language processing is used to generate use case completion suggestions.

5. The method according to claim 4, characterized in that The executable test cases of the software to be tested are improved based on the use case completion suggestions to cover the uncovered code in the software to be tested, including: Based on the use case completion suggestion, the above code information of the code line or branch of the uncovered code is supplemented to improve the executable test case of the software to be tested; The improved software to be tested is tested again to verify the uncovered code so as to cover the uncovered code in the software to be tested.

6. The method according to claim 5, characterized in that Testing the improved software to be tested again to verify the uncovered code to cover the uncovered code in the software to be tested, further comprising: If the uncovered code still cannot execute the test case after completing the test case, the verification fails, and it is determined whether the uncovered code after the current completion is an abandoned code; if the uncovered code after the current completion is an abandoned code, an alarm message carrying the abandoned code is issued, and the developer is notified to delete it after review; If the uncovered code can execute the test case after completing the test case, the verification passes, and it is determined that the uncovered code in the software to be tested is covered by the test case completion.

7. The method according to claim 1, characterized in that After obtaining the software to be tested, it also includes: Obtaining a first code path set obtained by running the software under test in a production environment and a second code path set obtained by running a test case in a test environment, wherein each code path set includes at least one code path; Obtaining a missing code path based on the first code sub-path set and the second code sub-path set; For any missing code path, similarity calculation is performed between the missing code path and any code path in the second code path set to obtain a reference code path that meets the similarity requirement; A first test case corresponding to the reference code path and a second test case of the software to be tested corresponding to the case completion suggestion are merged to obtain a completed test case.

8. The method according to claim 3, characterized in that Differentiating the covered code and the uncovered code according to the covered label and the uncovered label to obtain the covered code and the uncovered code of the software to be tested, further comprising: The execution status of each of the test cases is combined and summarized, and a software source code coverage analysis file is generated according to the coverage labels and the uncovered labels; The software source code coverage analysis file uses different text colors or text background colors to distinguish the covered code and the uncovered code.

9. A test case completion system, characterized in that: include: A relationship library acquisition module is used to acquire the software to be tested and analyze the source code of the software to be tested to obtain the method call relationship library, which includes the method call relationship, parameter association information and entry method identification of the software to be tested; A coverage analysis module, used to perform code coverage analysis on the software under test, and obtain covered code and uncovered code of the software under test, wherein the uncovered code at least includes situations where code lines and code branches are not covered; A completion suggestion module performs a query based on the method call relationship library to obtain a parameter association relationship diagram of a complete call link, and generates a use case completion suggestion for the uncovered code, wherein the complete call link is obtained by concatenating the method call relationships according to the entry method identifier, and each method call relationship carries corresponding parameter association information; A use case completion module improves the executable test cases of the software to be tested based on the use case completion suggestions to cover the uncovered code in the software to be tested.

10. An electronic device, characterized in that: include: Processor and memory; The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Software code case generation method and device, storage medium and electronic equipment

    CN120256316A

  • Method and device for generating use cases of software code, storage medium, and electronic device

    CN120256316B

  • Chaotic test scene supplementing method and device, equipment and storage medium

    CN121029608A

  • Coverage rate database merging method, electronic equipment and storage medium

    CN121070889A