Method call chain generation method and device, electronic equipment and storage medium

By generating a call chain and combining coverage of full and incremental reports, the problem that coverage report in the existing technology cannot reflect the internal logic of the code is solved, and the accuracy and efficiency of code testing are improved.

CN120578596APending Publication Date: 2025-09-02AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510697847.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

In the prior art, coverage report cannot intuitively reflect the internal logic of the code, making it difficult to detect missing codes in code testing, and insufficient testing efficiency and accuracy.

Method used

By statically compiling the code, the bytecode file is generated, the direct call relationship between the method is parsed, the call chain is generated, and the coverage is determined in the call chain is determined, so that testers can intuitively adjust the test direction.

Benefits of technology

It improves the accuracy and efficiency of code testing, can timely discover redundant codes and adjust the test direction to ensure the accuracy of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120578596A_ABST
    Figure CN120578596A_ABST
Patent Text Reader

Abstract

The invention discloses a method call chain generation method and device, electronic equipment and a storage medium. The method comprises the following steps: statically compiling a first code to obtain a byte code file; analyzing the byte code file to obtain at least one method and a first relationship; generating a first call chain according to the at least one method and the first relationship; determining a total coverage rate and an increment coverage rate of each method in the first call chain according to a pre-acquired total report and an increment report; and taking the full coverage rate and the incremental coverage rate of the method as information of the method, and storing the information in the first call chain to obtain a second call chain. According to the technical scheme, the second call chain containing the code coverage rate of each method is generated, so that during code testing, the test range can be locked by means of the second call chain, uncovered codes can be checked, and the accuracy and efficiency in the software testing process are optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of code testing technology, and in particular to a method call chain generation method, device, electronic device and storage medium. Background Art

[0002] Code testing is a key step in the software development process, aimed at verifying whether the code conforms to the intended design, discovering potential defects, and ensuring that the software quality meets the requirements.

[0003] At this stage, testing solutions based on coverage reports have become increasingly mature. However, there is no mature solution that can intuitively reflect the connection between the coverage in the report and the internal logic of the code. How to conduct coverage analysis in-depth into the code to speed up code testing and find out the missed code during the testing process has become a key issue in code testing. Summary of the Invention

[0004] The present invention provides a method, device, electronic device and storage medium for generating a method call chain to optimize the accuracy and efficiency in the software testing process.

[0005] According to one aspect of the present invention, a method for generating a method call chain is provided, the method comprising:

[0006] Static compile the first code to obtain a bytecode file; the first code is the entire code of the current version;

[0007] Parsing the bytecode file to obtain at least one method and a first relationship, where the first relationship is a one-to-one direct calling relationship between methods;

[0008] Generate a first call chain according to the at least one method and the first relationship;

[0009] Based on the full report and incremental report obtained in advance, the full coverage and incremental coverage of each method in the first call chain are determined; the incremental coverage is the coverage of the difference code between the first code and the second code; the second code is the code of the previous version; the coverage rate indicates the proportion of the tested code to the entire code during the test process; the full report is the test report obtained after the first code is tested as a whole; the incremental report is the test report obtained after the difference code between the first code and the second code is tested as a whole;

[0010] The full coverage and incremental coverage of the method are used as information of the method and stored in the first call chain to obtain the second call chain.

[0011] According to another aspect of the present invention, there is provided a method call chain generating device, comprising:

[0012] A first code compilation module is used to statically compile the first code to obtain a bytecode file; the first code is the entire code of the current version;

[0013] a method determination module, configured to parse the bytecode file to obtain at least one method and a first relationship, wherein the first relationship is a one-to-one direct calling relationship between methods;

[0014] a call chain generating module, configured to generate a first call chain according to at least one method and a first relationship;

[0015] A coverage determination module is configured to determine the full coverage and incremental coverage of each method in the first call chain based on a pre-acquired full report and incremental report; the incremental coverage is the coverage of the difference code between the first code and the second code; the second code is the code of the previous version; the coverage indicates the proportion of the tested code to the entire code during the test process; the full report is a test report obtained after an overall test of the first code; the incremental report is a test report obtained after an overall test of the difference code between the first code and the second code;

[0016] The call chain update module is used to store the full coverage and incremental coverage of the method as information of the method in the first call chain to obtain the second call chain.

[0017] According to another aspect of the present invention, an electronic device is provided, comprising:

[0018] at least one processor; and

[0019] a memory communicatively connected to the at least one processor; wherein,

[0020] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method call chain generation method described in any embodiment of the present invention.

[0021] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method call chain generation method described in any embodiment of the present invention when executed.

[0022] The technical solution of the embodiment of the present invention obtains a bytecode file by statically compiling the first code; the first code is the overall code of the current version; by parsing the bytecode file, at least one method and a first relationship are obtained, which can ensure that each method can be determined as much as possible, thereby ensuring that the first relationship can be determined without omission, so that the call chain finally generated can more accurately reflect the call logic of the method in the code, thereby improving the test effect of the code test; by generating the first call chain based on at least one method and the first relationship, the call relationship between the various methods in the first code can be directly represented by the first call chain, and then This allows the code tester to accelerate the test efficiency through the intuitive first relationship while ensuring the accuracy of the test results during code testing; by determining the full coverage and incremental coverage of each method in the first call chain based on the pre-acquired full report and incremental report; by storing the full coverage and incremental coverage of the method as the method's information in the first call chain, a second call chain is obtained, which enables the tester to intuitively determine the coverage of each method during the test process, and then, when performing subsequent code testing, timely adjust the test direction or timely feedback whether there is redundant code during the code running process, thereby improving the effect of code testing.

[0023] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0025] Figure 1 This is a flowchart of a method call chain generation method provided according to the first embodiment of the present invention;

[0026] Figure 2 This is a flowchart of another method call chain generation method provided in accordance with the second embodiment of the present invention;

[0027] Figure 3 2 is a schematic diagram of a structure of a method call chain generation device provided according to a third embodiment of the present invention;

[0028] Figure 4 It is a structural diagram of an electronic device for implementing the method for generating a method call chain according to an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions 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 embodiments described 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 making creative efforts should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first", "second", etc. in the description 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 numbers 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 clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0031] Example 1

[0032] Figure 1 A flowchart of a method call chain generation method is provided for the first embodiment of the present invention. This embodiment is applicable to situations where a method call chain including coverage needs to be generated during code testing to improve the code testing effect. The method can be executed by a method call chain generation device, which can be implemented in the form of hardware and / or software. The method call chain generation device can be configured in an electronic device with data processing capabilities. Figure 1 As shown, the method includes:

[0033] S110. Statically compile the first code to obtain a bytecode file; the first code is the entire code of the current version.

[0034] A bytecode file is a code file that is not directly executed by computer hardware. Instead, it is interpreted and executed by a virtual machine (such as the Java Virtual Machine (JVM)) or an interpreter. Bytecode files are in binary format and compatible with different hardware and operating systems. A bytecode file consists of a file header, a constant pool, and a method table. The method table contains the bytecode instructions that form the execution logic of the method.

[0035] Code testing is a key step in the software development process. Its purpose is to verify that the code implements the intended functionality, identify logical vulnerabilities in the code, and identify code that was not executed during testing. Therefore, determining the calling relationships between methods in the code and the coverage of each method during testing is crucial. The calling relationships between methods clearly represent the operating logic of the methods in the code. The coverage of methods during testing reflects the completeness and effectiveness of the code testing process. The higher the coverage, the more comprehensive the testing of the logical branches in the code.

[0036] S120: Parse the bytecode file to obtain at least one method and a first relationship, where the first relationship is a one-to-one direct calling relationship between methods.

[0037] A method is a block of code that is called during code execution to implement a predefined function. A method consists of an access modifier, a return type, a method signature, a parameter list, and an exception list. Method calls are implemented using bytecode instructions.

[0038] The bytecode file is parsed to determine each bytecode instruction in the bytecode file, the bytecode instructions are screened to determine method call instructions, and each method and the first relationship are determined based on the method call instructions. The bytecode instructions may be a low-level instruction set executed by a Java virtual machine (JVM) to implement various operations of a Java program. The method call instruction may be an instruction in the bytecode instructions for calling a method. The method call instruction may be any of the following: calling an instance method (invokevirtual), calling an interface method (invokeinterface), calling a constructor, a private method, a parent class method (invokespecial), calling a static method (invokestatic), and dynamic language support (invokedynamic).

[0039] By parsing the bytecode file, at least one method and a first relationship are obtained, which can ensure that each method can be determined as much as possible, thereby ensuring that the first relationship is not missed when it is determined, so that the final generated call chain can more accurately reflect the calling logic of the method in the code, thereby improving the test effect of the code test.

[0040] In an optional solution, parsing the bytecode file to obtain at least one method and the first relationship may include steps A1-A3:

[0041] Step A1: Parse the bytecode file based on the reflection mechanism to determine at least one method.

[0042] Step A2: Determine the method information of the method according to the calling instruction inside the method. The method information includes the class, method name and method descriptor.

[0043] Step A3: Determine the first relationship between the methods based on the method information of each method.

[0044] The reflection mechanism may be a mechanism provided by the Java language for parsing bytecode files, which can dynamically obtain class information when the code is running and operate the class information when the code is running.

[0045] The bytecode file is parsed through a reflection mechanism to determine the constant pool, method table, and field table. The constant pool includes string constants such as class names, method names, and field names; the method table includes method signatures, access modifiers, and bytecode instructions; and the field table includes field types and access modifiers. The parsed constant pool, method table, and field table are filtered to determine the bytecode instructions. The bytecode instructions are filtered to obtain method call instructions. Based on the symbolic reference of each method call instruction, the class, method name, and method descriptor of the method are determined. Based on the class, method name, and method descriptor of the method, the calling relationship between the various methods is determined as the first relationship.

[0046] By parsing the bytecode file through the reflection mechanism, each method can be determined more flexibly and accurately; the method information of the method can be determined based on the calling instructions within the method; the first relationship between methods can be determined based on the method information of each method, which can ensure that the determination of the first relationship is more accurate and reduce the omission of the first relationship.

[0047] In an optional solution, parsing the bytecode file based on a reflection mechanism to determine at least one method may include steps B1-B3:

[0048] Step B1: Based on the reflection mechanism, the bytecode file is parsed and at least one bytecode instruction in the bytecode file is determined.

[0049] Step B2: Screen each bytecode instruction to determine the method call instruction.

[0050] Step B3: Determine at least one method according to the method call instruction.

[0051] The bytecode file is parsed using a reflection mechanism to obtain a constant pool, method table, and field table. The method table is screened to identify at least one bytecode instruction. Each bytecode instruction is screened to identify a method call instruction. Based on the method call instruction, the symbolic reference in the method call instruction is determined to determine the class, method name, and method descriptor of the method. Based on the class, method name, and method descriptor of the method, at least one method is identified.

[0052] Parsing the bytecode file through the reflection mechanism can more flexibly and accurately determine each method, thereby improving the efficiency of method determination.

[0053] S130: Generate a first call chain according to at least one method and a first relationship.

[0054] After obtaining the calling relationships between the various methods and the methods, a first calling chain can be constructed with the methods as nodes and the first relationships as the connection relationships between the nodes to generate a first calling chain representing the calling relationships between the methods in the overall code of the first code.

[0055] By generating a first call chain based on at least one method and a first relationship, the calling relationship between the various methods in the first code can be directly represented through the first call chain, thereby accelerating the testing efficiency of the code through the intuitive first relationship during code testing while ensuring the accuracy of the test results.

[0056] S140. Determine the full coverage and incremental coverage of each method in the first call chain based on the pre-acquired full report and incremental report.

[0057] The incremental coverage is the coverage of the difference code between the first code and the second code; the second code is the previous version of the code; the coverage indicates the ratio of the tested code to the overall code during the test process; the full report is the test report obtained after the first code is tested as a whole; the incremental report is the test report obtained after the difference code between the first code and the second code is tested as a whole.

[0058] A full report is a comprehensive report describing the test results after a complete code test, including test coverage, test results, code quality, and other multi-dimensional information. An incremental report is a comprehensive report describing the test results after testing the differences between two versions of the code, including test coverage, test results, code quality, and other multi-dimensional information.

[0059] Since the full report and the incremental report record the coverage of each method in the first code during the test process, parsing the full report and the incremental report can determine the full coverage and incremental coverage of each method in the first call chain.

[0060] S150. The full coverage and incremental coverage of the method are stored as information of the method in the first call chain to obtain a second call chain.

[0061] After obtaining the full coverage and incremental coverage of each method, each full coverage and incremental coverage is stored in the node of the corresponding method, thereby converting the first call chain into the second call chain.

[0062] By storing the full coverage and incremental coverage of the method as the information of the method in the first call chain, and obtaining the second call chain, the tester can intuitively determine the coverage of each method during the test process, and then, when performing subsequent code testing, the test direction can be adjusted in time or feedback can be provided in time whether there is redundant code during the code running process, thereby improving the effect of code testing.

[0063] According to the technical solution of the present application, a bytecode file is obtained by statically compiling the first code; the first code is the overall code of the current version; at least one method and a first relationship are obtained by parsing the bytecode file, so that each method can be determined as much as possible, thereby ensuring that the first relationship is not missed when it is determined, so that the call chain finally generated can more accurately reflect the call logic of the method in the code, thereby improving the test effect of the code test; by generating the first call chain based on at least one method and the first relationship, the call relationship between the various methods in the first code can be directly represented by the first call chain, and then This allows the code tester to accelerate the test efficiency through the intuitive first relationship while ensuring the accuracy of the test results during code testing; by determining the full coverage and incremental coverage of each method in the first call chain based on the pre-acquired full report and incremental report; by storing the full coverage and incremental coverage of the method as the method's information in the first call chain, a second call chain is obtained, which enables the tester to intuitively determine the coverage of each method during the test process, and then, when performing subsequent code testing, timely adjust the test direction or timely feedback whether there is redundant code during the code running process, thereby improving the effect of code testing.

[0064] Example 2

[0065] Figure 2 The present invention provides a flowchart of another method call chain generation method. This embodiment further optimizes the process after statically compiling the first code to obtain the bytecode file in the above embodiment. This embodiment can be combined with various optional solutions in one or more of the above embodiments. Figure 2 As shown, the method call chain generation method of this embodiment may include the following steps:

[0066] S210. Statically compile the first code to obtain a bytecode file; the first code is the entire code of the current version.

[0067] S220: Determine the operating capacity of the server or container.

[0068] S230: If the running load is less than the preset load, reduce the concurrency of bytecode file parsing.

[0069] The server or container is used to execute each step in the method call chain generation.

[0070] Before statically compiling the first code, it is necessary to determine whether the memory state can withstand the expected concurrency to prevent memory overflow caused by a large number of concurrent file readings. Therefore, it is necessary to determine the operating load of the server or container. If the operating load is less than the preset load, the concurrency of the bytecode file parsing is reduced to avoid the occurrence of this problem. The judgment of whether the operating load is less than the preset load is achieved through a resource control mechanism. After determining that the operating load is less than the preset load, the concurrency of the bytecode file parsing is reduced in the form of a global lock. Among them, the resource control mechanism obtains the status of the server or container where the system is located through the JAVA native class OperatingSystemMXBean, and uses the pre-configured concurrency and the maximum file reading value as input to determine whether the memory can withstand the next operation. If it cannot withstand it, it attempts to obtain a global lock to limit and delay the input flow. The record of obtaining the lock is stored in Redis for queuing operations. The maximum waiting time can be adjusted to prevent a poor user experience due to excessive queuing time.

[0071] S240: Parse the bytecode file to obtain at least one method and a first relationship, where the first relationship is a one-to-one direct calling relationship between methods.

[0072] S250: Generate a first call chain according to at least one method and a first relationship.

[0073] In an optional method, before generating the first call chain according to the at least one method and the first relationship, the method further includes:

[0074] Compress and store the first relationship and the method corresponding to the first relationship to obtain a one-to-one call relationship text;

[0075] Accordingly, according to the at least one method and the first relationship, a first call chain is generated, including:

[0076] Generate a first call chain according to the one-to-one call relationship text;

[0077] Accordingly, before generating the first call chain according to the one-to-one call relationship text, the method further includes:

[0078] Determine the operating capacity of the server or container;

[0079] If the running load is less than the preset load, the concurrency when generating the first call chain is reduced.

[0080] Since the code is generally updated over time, as the code changes, the methods and the first relationships corresponding to the methods will change with the changes in the code version. Therefore, before generating the first call chain, the first relationship and the method corresponding to the first relationship can be compressed and stored to obtain a one-to-one call relationship text. When the first call chain needs to be generated later, the one-to-one call relationship text can be used to generate it.

[0081] In addition, since the call chain generation stage requires reading multiple one-to-one call relationship texts, a resource control mechanism is still required to determine whether the memory state can withstand the expected concurrency. If the running load is less than the preset load, the concurrency when the first call chain is generated will be reduced.

[0082] To compress the generated one-to-one call relationship text, Lempel-Ziv-Welch (LZW) compression is used. This compression technology offers a higher compression ratio than other file formats, reducing storage space requirements. When generating the one-to-one call relationship text, interfaces and implementation classes, Runnable implementation class thread calls, Callable implementation class thread calls, Thread subclass thread calls, lambda expressions, Stream calls, subclass calls to parent class implementation methods, and parent class calls to subclass implementation methods, obtained when parsing the bytecode file, are also stored in the one-to-one call relationship text.

[0083] Brief compression process of LZW algorithm:

[0084] First, initialize the dictionary: The LZW algorithm uses a dictionary table to store codes and corresponding strings. Initially, the dictionary typically contains all possible values ​​for a single character, as well as some predefined control codes. For efficiency and fast lookups, a hash table is used to store the dictionary. This allows for fast key-based lookups and insertions. This paper uses a HashMap as the dictionary storage structure for the LZW algorithm.

[0085] Scanning and encoding: Starting from the beginning of the input text, the algorithm scans the input character sequence and combines the sequences already in the dictionary with the new character into a longer sequence. If this longer sequence (i.e., the old-new combination) finds a corresponding encoding in the dictionary, the algorithm uses this longer sequence as the new old sequence and continues to add the next character. If a corresponding encoding is not found, the algorithm outputs the existing sequence, adds the combination to the dictionary, and resets the sequence to the new character.

[0086] Output encoding: When the algorithm finds a sequence that does not exist in the dictionary, it outputs the encoding of the existing sequence and adds the new sequence to the dictionary. This encoding can be the original input characters, the characters that make up the new sequence, or the encoding of a sequence already in the dictionary.

[0087] Update dictionary and repeat: The algorithm will continue to repeat the scanning and encoding process described above until the entire input text is scanned. During this process, the dictionary will be continuously updated and expanded.

[0088] Through the above steps, the LZW algorithm will generate a new output sequence containing the encoding and update the dictionary based on this sequence. The generated new file is placed in the root directory of the project code for subsequent call chain functions to decompress and read, and use the dictionary to restore the original text data based on the encoding.

[0089] Through the resource control mechanism, it can avoid the relatively low utilization rate of the method call relationship generated by the user each time. The information concerned in each build is part of the project, and the storage capacity consumed each time is much greater than that of file storage.

[0090] S260. Determine the full coverage and incremental coverage of each method in the first call chain based on the pre-acquired full report and incremental report.

[0091] The incremental coverage is the coverage of the difference code between the first code and the second code; the second code is the previous version of the code; the coverage indicates the ratio of the tested code to the overall code during the test process; the full report is the test report obtained after the first code is tested as a whole; the incremental report is the test report obtained after the difference code between the first code and the second code is tested as a whole.

[0092] In an optional solution, determining the full coverage and incremental coverage of each method in the first call chain based on the pre-acquired full report and incremental report includes:

[0093] The full report and incremental report are parsed through the document object model to obtain the full coverage and incremental coverage of each method in the first call chain.

[0094] The Document Object Model (DOM) is a programming interface for representing and manipulating structured documents such as HTML and XML. It parses documents into a tree structure, enabling programs to dynamically access and modify the document's content, structure, and style through scripts (such as JavaScript).

[0095] Use DOM technology to read the full report and incremental report, compare and query the full coverage and incremental coverage of the methods in the first call chain, and then store them in the first call chain to obtain a tree-like call chain containing coverage as the second call chain.

[0096] By parsing the full report and the incremental report through the document object model, the parsing effect of the full report and the incremental report can be guaranteed, thereby making the determination of the full coverage and the incremental coverage more accurate.

[0097] S270. The full coverage and incremental coverage of the method are stored as information of the method in the first call chain to obtain a second call chain.

[0098] Optionally, a first interface list is determined through the second call chain; wherein the first interface is an interface affected when the code is modified, including:

[0099] Obtain the difference between the first code and the second code based on Git;

[0100] determining, based on the first code and the difference code, at least one method corresponding to the difference code;

[0101] According to the at least one method corresponding to the difference code and the second call chain, a method that calls the at least one method corresponding to the difference code is searched upward in the second call chain to determine the first interface list.

[0102] Optionally, a second interface list is determined through a second call chain, wherein the second interface is an interface whose coverage rate during the test is lower than a preset coverage rate, including:

[0103] Determine the number of uncovered lines of code based on the delta report;

[0104] Determining a method corresponding to the uncovered code according to the first code and the uncovered code;

[0105] According to the method corresponding to the uncovered code, the method that calls the method corresponding to the uncovered code is searched upward in the second call chain to determine the second interface list.

[0106] By adopting the technical solution of the present application, the running load capacity of the server or container is determined; when the running load capacity is less than the preset load capacity, the concurrency of bytecode file parsing is reduced, which can effectively avoid the memory overflow caused by the concurrency of bytecode file parsing being greater than the preset load capacity, thereby causing the second call chain determination error and affecting the accuracy of code testing.

[0107] Example 3

[0108] Figure 3 The present invention provides a structural block diagram of a method call chain generation device. This embodiment is applicable to situations where a method call chain including coverage needs to be generated during code testing to improve the code testing effect. The method call chain generation device can be implemented in the form of hardware and / or software. The method call chain generation device can be configured in an electronic device with data processing capabilities. Figure 3As shown, the method call chain generation device of this embodiment may include: a first code compilation module 310, a method determination module 320, a call chain generation module 330, a coverage determination module 340, and a call chain update module 350. Among them:

[0109] A first code compiling module 310 is used to statically compile the first code to obtain a bytecode file; the first code is the entire code of the current version;

[0110] A method determination module 320 is configured to parse the bytecode file to obtain at least one method and a first relationship, where the first relationship is a one-to-one direct calling relationship between methods;

[0111] A call chain generating module 330, configured to generate a first call chain according to at least one method and a first relationship;

[0112] The coverage determination module 340 is used to determine the full coverage and incremental coverage of each method in the first call chain based on the pre-acquired full report and incremental report; the incremental coverage is the coverage of the difference code between the first code and the second code; the second code is the previous version of the code; the coverage indicates the ratio of the tested code to the entire code during the test process; the full report is the test report obtained after the entire first code is tested; the incremental report is the test report obtained after the entire difference code between the first code and the second code is tested;

[0113] The call chain updating module 350 is used to store the full coverage and incremental coverage of the method as information of the method in the first call chain to obtain a second call chain.

[0114] Based on the above embodiment, optionally, the method determination module 320 includes:

[0115] Based on the reflection mechanism, the bytecode file is parsed to determine at least one method;

[0116] According to the calling instructions inside the method, the method information of the method is determined, and the method information includes the class, method name and method descriptor;

[0117] A first relationship between the methods is determined based on the method information of each method.

[0118] Based on the above embodiment, optionally, the bytecode file is parsed based on a reflection mechanism to determine at least one method, including:

[0119] Based on the reflection mechanism, the bytecode file is parsed and at least one bytecode instruction in the bytecode file is determined;

[0120] Filter each bytecode instruction to determine the method call instruction;

[0121] At least one method is determined according to the method call instruction.

[0122] Based on the above embodiment, optionally, the call chain generation module 330 includes:

[0123] According to the first relationship, determine the calling order of each method;

[0124] Determine the first call chain based on the calling sequence.

[0125] Based on the above embodiment, optionally, before the method determination module 320, the following further includes:

[0126] Determine the operating capacity of the server or container;

[0127] If the running load is less than the preset load, the concurrency of bytecode file parsing is reduced.

[0128] Based on the above embodiment, optionally, before calling the chain generation module 330, the following steps are included:

[0129] Compress and store the first relationship and the method corresponding to the first relationship to obtain a one-to-one call relationship text;

[0130] Accordingly, the call chain generation module 330 includes:

[0131] Generate a first call chain according to the one-to-one call relationship text;

[0132] Accordingly, before generating the first call chain according to the one-to-one call relationship text, the method further includes:

[0133] Determine the operating capacity of the server or container;

[0134] If the running load is less than the preset load, the concurrency when generating the first call chain is reduced.

[0135] Based on the above embodiment, optionally, the coverage determination module 340 includes:

[0136] The full report and incremental report are parsed through the document object model to obtain the full coverage and incremental coverage of each method in the first call chain.

[0137] The method call chain generation device provided in the embodiment of the present invention can execute the method call chain generation method provided in any embodiment of the present invention, and obtains a bytecode file by statically compiling the first code; the first code is the overall code of the current version; by parsing the bytecode file, at least one method and a first relationship are obtained, which can ensure that each method can be determined as much as possible, thereby ensuring that the first relationship will not be missed when it is determined, so that the call chain finally generated can more accurately reflect the call logic of the method in the code, thereby improving the test effect of the code test; by generating the first call chain based on at least one method and the first relationship, the first call chain can be directly represented by the first call chain. The calling relationship between each method in the code can speed up the test efficiency of the code through the intuitive first relationship during code testing while ensuring the accuracy of the test results; determine the full coverage and incremental coverage of each method in the first call chain based on the full report and incremental report obtained in advance; store the full coverage and incremental coverage of the method as the information of the method in the first call chain to obtain the second call chain, which can enable testers to intuitively determine the coverage of each method in the test process, and then in the subsequent code testing, they can timely adjust the test direction or promptly feedback whether there is redundant code during the code running process, thereby improving the effect of code testing.

[0138] Example 4

[0139] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0140] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12 and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0141] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0142] The processor 11 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the method call chain generation method.

[0143] In some embodiments, the method call chain generation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method call chain generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method call chain generation method in any other appropriate manner (e.g., by means of firmware).

[0144] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0145] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0146] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0147] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0148] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0149] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0150] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0151] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A method call chain generation method, characterized in that, include: Compiling the first code statically to obtain a bytecode file; The first code is the overall code of the current version; Parsing the bytecode file to obtain at least one method and a first relationship, where the first relationship is a one-to-one direct calling relationship between methods; Generate a first call chain according to the at least one method and the first relationship; Based on the full report and incremental report obtained in advance, the full coverage and incremental coverage of each method in the first call chain are determined; the incremental coverage is the coverage of the difference code between the first code and the second code; the second code is the code of the previous version; the coverage rate indicates the proportion of the tested code to the entire code during the test process; the full report is the test report obtained after the first code is tested as a whole; the incremental report is the test report obtained after the difference code between the first code and the second code is tested as a whole; The full coverage and incremental coverage of the method are used as information of the method and stored in the first call chain to obtain the second call chain.

2. The method according to claim 1, characterized in that Parsing the bytecode file to obtain at least one method and a first relationship includes: Based on the reflection mechanism, the bytecode file is parsed to determine at least one method; Determine method information of the method according to the calling instruction inside the method, wherein the method information includes the class, method name and method descriptor; A first relationship between the methods is determined based on the method information of each method.

3. The method according to claim 2, characterized in that Based on the reflection mechanism, the bytecode file is parsed to determine at least one method, including: Based on the reflection mechanism, the bytecode file is parsed and at least one bytecode instruction in the bytecode file is determined; Filter each bytecode instruction to determine the method call instruction; At least one method is determined according to the method call instruction.

4. The method according to claim 1, wherein Generating a first call chain according to at least one method and a first relationship includes: According to the first relationship, determine the calling order of each method; Determine the first call chain based on the calling sequence.

5. The method according to claim 1, wherein Before parsing the bytecode file, the method further includes: Determine the operating capacity of the server or container; If the running load is less than the preset load, the concurrency of bytecode file parsing is reduced.

6. The method according to claim 1, wherein Before generating the first call chain according to the at least one method and the first relationship, the method further includes: Compress and store the first relationship and the method corresponding to the first relationship to obtain a one-to-one call relationship text; Accordingly, according to the at least one method and the first relationship, a first call chain is generated, including: Generate a first call chain according to the one-to-one call relationship text; Accordingly, before generating the first call chain according to the one-to-one call relationship text, the method further includes: Determine the operating capacity of the server or container; If the running load is less than the preset load, the concurrency when generating the first call chain is reduced.

7. The method according to claim 1, characterized in that Based on the pre-obtained full and incremental reports, determine the full and incremental coverage of each method in the first call chain, including: The full report and incremental report are parsed through the document object model to obtain the full coverage and incremental coverage of each method in the first call chain.

8. A method call chain generating device, characterized in that, include: A first code compiling module, used for statically compiling the first code to obtain a bytecode file; The first code is the overall code of the current version; a method determination module, configured to parse the bytecode file to obtain at least one method and a first relationship, wherein the first relationship is a one-to-one direct calling relationship between methods; a call chain generating module, configured to generate a first call chain according to at least one method and a first relationship; A coverage determination module is configured to determine the full coverage and incremental coverage of each method in the first call chain based on a pre-acquired full report and incremental report; the incremental coverage is the coverage of the difference code between the first code and the second code; the second code is the code of the previous version; the coverage indicates the proportion of the tested code to the entire code during the test process; the full report is a test report obtained after an overall test of the first code; the incremental report is a test report obtained after an overall test of the difference code between the first code and the second code; The call chain update module is used to store the full coverage and incremental coverage of the method as information of the method in the first call chain to obtain the second call chain.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to execute the method call chain generation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method call chain generation method according to any one of claims 1 to 7 when executed.