A project code automatic testing method, device, medium and product
By using automated testing methods for project code and leveraging call chain diagrams and method coordinate information, changes can be quickly identified and test cases executed. This solves the problems of time-consuming and low-accuracy change analysis in existing technologies, thereby improving testing efficiency and intelligence.
Patent Information
- Application Number
- CN202610909702.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-23
- Publication Date
- 2026-11-03
AI Technical Summary
Existing project code change analysis methods are time-consuming, have low accuracy and efficiency, cannot fully cover test cases, and are difficult to accurately analyze the call chain affected by code changes.
By pre-recording the call chain diagram and method function coordinates of the project code, the system responds to automated test requests, identifies the call chain of changes in code commit records, and automatically executes relevant test cases, thereby enabling rapid identification of project code changes and adaptive automated testing.
It improves the efficiency and intelligence of project code testing, accurately analyzes the call chain affected by code changes, reduces human intervention, and lowers testing costs and time.
Smart Images

Figure CN123030489A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software development technology, and is applicable to the field of financial technology, particularly to a method, apparatus, medium, and product for automated testing of project code. Background Technology
[0002] As banking operations become increasingly complex, the impact of code changes on projects is easily overlooked, and conducting full regression testing is becoming increasingly difficult. To more accurately pinpoint the impact of code changes and improve testing efficiency, it is necessary to accurately analyze the call chain affected by the code changes. However, existing code change analysis solutions suffer from problems such as being time-consuming, having low accuracy, low efficiency, and failing to fully cover test cases.
[0003] Therefore, how to quickly identify changes to project code and perform adaptive automated testing, accurately analyze the call chain affected by code changes, and improve testing efficiency are urgent problems to be solved. Summary of the Invention
[0004] This invention provides a method, apparatus, medium, and product for automated testing of project code, enabling rapid identification of changes and adaptive automated testing of project code, accurately analyzing the call chain affected by code changes, and improving testing efficiency.
[0005] According to one aspect of the present invention, a method for automated testing of project code is provided, comprising: In response to an automated test request for the code of the target project, the target archive file is determined, along with the call chain diagram and coordinate information of the method functions within the target archive file. If a new code commit record targeting the project code is detected, the modified call chain is determined, and the target test method function corresponding to the modified call chain is identified. Identify the target test cases corresponding to the target test method function to trigger the automated execution of the target test cases, thereby achieving automated testing after a new code submission in the project.
[0006] According to another aspect of the present invention, an automated testing apparatus for project code is provided, comprising: The information determination module is used to respond to automated testing requests for the code corresponding to the target project, determine the target archive file, and determine the call chain diagram and coordinate information of the method functions in the target archive file. The function determination module is used to determine the modified call chain and the target test method function corresponding to the modified call chain if a new code commit record for the project code of the target project is detected. The testing module is used to determine the target test cases corresponding to the target test method function, so as to trigger the automated execution of the target test cases and realize automated testing after the project code is newly submitted.
[0007] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: 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, which enables the at least one processor to perform the automated project code testing method according to any embodiment of the present invention.
[0008] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the automated testing method for project code according to any embodiment of the present invention.
[0009] According to another aspect of the present invention, a computer program product is also provided, the computer program product including a computer program that, when executed by a processor, implements the project code automated testing method of any embodiment of the present invention.
[0010] The technical solution of this invention, in response to an automated testing request for the project code corresponding to the target project, determines the target archive file, and determines the call chain diagram and coordinate information of the method functions in the target archive file. If a new code commit record for the project code of the target project is detected, the modified call chain is determined, and the target test method function corresponding to the modified call chain is determined. The target test case corresponding to the target test method function is determined to trigger the automated execution of the target test case, thereby realizing automated testing after a new project code commit. By quickly identifying changes after a new project code commit based on the call chain diagram and method coordinates, the call chain affected by the code changes can be accurately analyzed and test cases matched for automated testing, improving the efficiency and intelligence level of project code testing.
[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a flowchart of an automated testing method for project code provided in an embodiment of the present invention; Figure 2 This is a flowchart of an automated testing method for project code provided in an embodiment of the present invention; Figure 3 This is a structural block diagram of an automated testing device for project code provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0014] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0015] It should be noted that the terms "first," "second," "target," "candidate," and "alternative," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the invention described herein can be practiced in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus. The acquisition, storage, use, and processing of data in the technical solutions of this application comply with relevant laws and regulations.
[0016] It should be noted that in related technologies, unit testing, integration testing, and system testing can be used to verify whether the modified test results meet expectations. However, the granularity of obtaining differences is at the line-by-line level, requiring analysis to identify the modified methods. Static code scanning can also be used to traverse the call stack information of API calls to obtain the call chain diagram, and aspect-based analysis can be used to obtain API call records and analyze these records to obtain the call chain diagram. However, static code scanning is time-consuming, aspect-based analysis of call records is incomplete, and verification of changes depends on the coverage of test cases, making it difficult to guarantee that no test cases are missed for the affected scope. Finally, the process of analyzing the impact of changes and verifying the correctness of the impact is disconnected, relying on human intervention and resulting in low efficiency. To address these issues, this invention, by pre-recording the call chain diagram and coordinate information, can quickly identify changes after a new code submission, accurately analyze the call chain affected by the code changes, and match test cases for automated testing, improving the efficiency and intelligence of project code testing. Specific implementation methods will be described in detail in subsequent embodiments.
[0017] Example 1 Figure 1 This is a flowchart of a project code automation testing method provided by an embodiment of the present invention. This embodiment is applicable to situations where, based on the link diagram and method coordinates, changes are quickly identified after a new project code submission, the call chain affected by the code changes is accurately analyzed, and test cases are matched for automated testing. This method can be executed by a project code automation testing device, which can be implemented in hardware and / or software. The project code automation testing device can be configured in an electronic device, such as... Figure 1 As shown, the automated testing methods for this project's code include: S101. In response to the automated testing request for the project code corresponding to the target project, determine the target archive file, and determine the call chain diagram of the target archive file and the coordinate information of the method functions in the target archive file.
[0018] The target project can refer to a project that implements business functions in a banking application scenario. This project may involve the underlying code that implements the business functions, i.e., the project code. An automated test request refers to a request to perform automated testing on changes each time a new commit record for the project code appears after uploading the project code. The target archive file refers to a single executable archive file generated after compiling and packaging the project code based on a preset compilation language. A call chain graph is a graph structure representing the call relationships between different methods and functions in the target archive file. The call chain graph can be stored using an adjacency list. The call chain graph can be represented by the order of methods and functions and arrows, such as "Contro.transfer()→TransferService.validate()→AccountDAO.updateBalance()". A method function refers to a function defined in the code that implements the corresponding functionality. Coordinate information can include at least one of the following: the class name of the method function, the method name, the start line number of the method function, and the end line number of the method function.
[0019] Optionally, the target archive file is determined, and the call chain diagram of the target archive file is determined, including: scanning the project code of the target project and compiling it to package the project code and dependencies into a single executable file to obtain the target archive file; determining the file type of the target archive file; and using the corresponding call chain diagram determination strategy according to the file type to determine the call chain diagram of the project code.
[0020] The target archive file may include archive files of different file types, including at least one of the following: compiled business logic files, configuration files, and resource files; the business logic files are in .class format; the configuration files are in .xml format; and the resource files are in .properties format.
[0021] Optionally, the link graph determination strategy for file types that are business logic files is: a link graph determination strategy based on abstract syntax trees; the link graph determination strategy for file types that are configuration files is: a link graph determination strategy based on document object models; and the link graph determination operation may not be performed for target archive files that are file types that are resource files.
[0022] It should be noted that the above-mentioned technical solution of the present invention can adaptively determine the accurate call link diagram corresponding to the project code by performing different link diagram determination operations for archive files of different document types, which facilitates the rapid and effective determination of the link affected by subsequent modification points.
[0023] Optionally, a corresponding call chain diagram determination strategy is adopted according to the file type to determine the call chain diagram of the project code, including: for target archive files of business logic file type, analysis is performed based on abstract syntax tree to determine the method call relationship in the target archive file; for target archive files of configuration file type, analysis is performed based on document object model to determine the method call relationship in the target archive file; the method call relationship in target archive files of different file types is matched, and the call chain diagram of the project code is generated based on the matching results and the storage format of the adjacency list.
[0024] Optionally, for target archive files whose file type is business logic file, preprocessing can be performed based on Abstract Syntax Tree (AST) to determine parent and child class information and record the calling relationship between parent and child classes; for classes involving inheritance, the interface calls to the implementation class methods are recorded; for abstract methods, they are added to the abstract parent class to determine the method calling relationship in the business logic file.
[0025] Optionally, the parent class in the business logic file can be obtained through preset code instructions. The inheritance tree can be constructed recursively. For classes that implement interfaces, the mapping between interface methods and implementation class methods is recorded. For abstract methods, when the method function evaluates to true, it is bound to the abstract parent class and all subclass implementations are linked in the call chain, thereby constructing a method-level call relationship graph and obtaining the method call relationship in the business logic file.
[0026] Optionally, for target archive files whose file type is configuration file, a DOM (Document Object Model) parser can be used to read the entire configuration file into memory, construct a complete DOM, analyze the DOM tree, find the nodes that expose externally (remember the nodes whose tags contain identity attributes), match the methods in the class with the same name, add the matched methods to the parent class, record the call relationship, and thus determine the method call relationship in the configuration file.
[0027] Optionally, the method call relationships with the same ID (Identification) name in target archive files of different file types can be matched, and a call chain diagram of the project code can be generated based on the matching results and the storage format of the adjacency list.
[0028] It should be noted that the above-mentioned technical solution of the present invention, by providing the case where the file types are business logic files and configuration files respectively, uses abstract syntax tree and document object model to analyze the call relationship and perform matching to generate a call chain, can determine an accurate and effective call chain diagram.
[0029] Optionally, determine the coordinate information of the method functions in the target archive file, including: determining the method functions contained in the target archive file, and determining the class name, method name, start line number, and end line number of each method function; and determining the coordinate information of the method functions in the target archive file based on the class name, method name, start line number, and end line number of each method function in the target archive file.
[0030] Optionally, the coordinate information of a method function may also include a method signature. For each method function, a method signature can be uniquely determined based on the class name to which the method function belongs, the method name of the method function, and the parameter types, such as "com.icbc.TransferService.transfer(String,String,double)".
[0031] Optionally, project code can be stored on a repository hosting server, while coordinate information and call chain diagrams can be stored in a separate analytics database.
[0032] It should be noted that the above technical solution of the present invention further enriches the content of the coordinate information by limiting the coordinate information to include the method name, class name, start and end line numbers of the method function, which helps to locate the position of the modification point based on the coordinate information.
[0033] S102. If a new code commit record for the project code of the target project is detected, the modified call chain is determined, and the target test method function corresponding to the modified call chain is determined.
[0034] Among them, code commit records are records of project code adjustments and updates made by relevant personnel and then re-uploaded; the change call chain refers to the chain of changes or impacts that the new commit code in the code commit record has on the original project code; and the target test method function refers to the method function involved in the change call chain that is affected by the changes.
[0035] Optionally, if a new code commit record for the target project's code is detected, the modification call chain is determined, including: connecting to the repository hosting server via a preset application programming interface (API), and detecting whether a new code commit record for the target project's code exists based on feedback information from the repository hosting server; if so, the modification call chain is determined based on the new commit code, the target project's code, coordinate information, and the call chain diagram. Here, the new commit code refers to code newly committed to the project code in the repository hosting server.
[0036] It should be noted that the above-mentioned technical solution of the present invention identifies whether there are update records for the project code by connecting to the repository hosting server, and determines the modified call chain based on the code before and after, method coordinate information and call chain when there is an update. This can identify changes to the project code in a timely manner and quickly determine the links affected by the changes.
[0037] Optionally, based on the newly submitted code, the target project's code, coordinate information, and the call chain diagram, determine the modified call chain and the target test method function corresponding to the modified call chain. This includes: comparing the newly submitted code with the target project's code and determining the modified line based on the comparison results; determining the modified method function to which the modified line belongs based on the coordinate information and the number of modified lines corresponding to the modified line; determining the modified call chain based on the upstream information of the modified method function in the call chain diagram, and identifying the method function involved in the modified call chain as the target test method function.
[0038] Here, "line number modified" refers to the line number of the modified line in the target archive file. "Modification method function" refers to the method function corresponding to the modified line.
[0039] For example, you can compare the code before and after the submission, locate the line numbers that differ (e.g., AccountDAO.java:15-20), and then, based on the coordinate information, find the method to which the line number belongs, such as AccountDAO.updateBalance(), thus determining the modified method function.
[0040] Optionally, after determining the method function to be modified, a preset link analysis algorithm can be used to trace back upstream from the point of modification in the call chain graph to determine the call path to be modified. For example, the call path to be modified can be "TransferService.validate()→TransferController.transfer()→UserInterface.submitRequest()".
[0041] It should be noted that the above-mentioned technical solution of the present invention determines the modified line, the number of modified lines, and the modified method function in sequence, and further determines the upstream information of the modification by combining the call chain diagram, thereby determining the modification chain and the target test method function. This provides an implementation method for determining the modification chain, which can quickly and accurately determine the modification chain and the corresponding target test method function to be tested.
[0042] S103. Determine the target test cases corresponding to the target test method function to trigger the automated execution of the target test cases and realize automated testing after the project code is newly submitted.
[0043] Among them, target test cases refer to test cases used to test whether the target test method function meets the expected functionality.
[0044] Optionally, you can perform automated testing after a new code submission by executing the target test cases to verify whether the modified test results meet expectations.
[0045] Optionally, determining the target test case corresponding to the target test method function includes: determining the test interface associated with the target test method function; and determining the target test case corresponding to the test interface based on the test interface and the preset interface-test case mapping library, thus determining it as the target test case corresponding to the target test method function.
[0046] The pre-defined mapping library between interfaces and test cases is essentially a list of historically accumulated interface assets, such as interface signature → test case ID.
[0047] Optionally, for each target test method function, a test list of these methods can be output based on the corresponding method signature and the accumulation of interface assets, that is, the target test cases can be determined. Specifically, the target test cases are determined by matching the signature path of the target test method function that affects the test interface.
[0048] Optionally, the test interface can be used to query the asset database and output associated test cases, such as TC001 - successful interbank transfer, TC002 - insufficient balance exception, and TC003 - account does not exist exception.
[0049] For example, if the determined change call path is "TransferService.validate()→TransferController.transfer()→UserInterface.submitRequest()", then the corresponding target test method functions are TransferService.validate(), TransferController.transfer(), and UserInterface.submitRequest(). Since TransferController.transfer() exposes the descriptive state transfer interface to the front end, it can be determined that the test interface associated with the target test method function is the interface corresponding to TransferController.transfer().
[0050] It should be noted that the above-mentioned technical solution of the present invention analyzes the test interface corresponding to the target test method function, combines it with a preset mapping library, and matches the test cases for testing the target test method function. This can automatically determine the test cases for testing the target test method function, thereby improving the efficiency of automated testing.
[0051] The technical solution of this invention, in response to an automated testing request for the project code corresponding to the target project, determines the target archive file, and determines the call chain diagram and coordinate information of the method functions in the target archive file. If a new code commit record for the project code of the target project is detected, the modified call chain is determined, and the target test method function corresponding to the modified call chain is determined. The target test case corresponding to the target test method function is determined to trigger the automated execution of the target test case, thereby realizing automated testing after a new project code commit. By quickly identifying changes after a new project code commit based on the call chain diagram and method coordinates, the call chain affected by the code changes can be accurately analyzed and test cases matched for automated testing, improving the efficiency and intelligence level of project code testing.
[0052] Example 2 Figure 2 This is a flowchart of an automated testing method for project code provided in an embodiment of the present invention. Based on the above embodiments, this embodiment provides a preferred example for quickly identifying changes after a new submission of project code, accurately analyzing the call chain affected by the code changes, and matching test cases for automated testing, using a link diagram and method coordinates. Figure 2 As shown, the method includes: S201. In response to an automated test request for the project code corresponding to the target project, scan the project code of the target project and compile it to package the project code and dependencies into a single executable file to obtain the target archive file.
[0053] S202. Determine the file type of the target archive file. For the target archive file whose file type is business logic file, analyze it based on the abstract syntax tree to determine the method call relationship in the target archive file.
[0054] S203. For target archive files whose file type is configuration file, analyze based on document object model to determine the method call relationships in the target archive file.
[0055] S204. Match the method call relationships in target archive files of different file types, and generate a call chain diagram of the project code based on the matching results and the storage format of the adjacency list.
[0056] S205. Determine the methods and functions contained in the target archive file, and determine the coordinate information of the methods and functions in the target archive file based on the class name, method name, start line number, and end line number of each method and function.
[0057] S206. Connect to the repository hosting server through the preset application programming interface, and detect whether there are new code commit records for the project code of the target project based on the feedback information from the repository hosting server.
[0058] S207. If so, then it is determined that a new code commit record for the project code of the target project has been detected. The new commit code is compared with the project code of the target project, and the line of modification is determined based on the comparison result.
[0059] S208. Based on the coordinate information and the number of modified rows corresponding to the modified row, determine the modification method function to which the modified row belongs, and determine the modification call chain based on the upstream information of the modification method function in the call chain graph.
[0060] S209. Identify the method functions involved in the modified call chain as the target test method functions, and determine the test interface associated with the target test method functions.
[0061] S210. Based on the test interface and the preset interface-test case mapping library, determine the target test case corresponding to the test interface, and determine the target test case corresponding to the target test method function.
[0062] S211. Trigger the automated execution of the target test case based on the target test case to achieve automated testing after a new code submission in the project.
[0063] It should be noted that the technical solution of this invention, before implementing major code changes, identifies the scope of impact through change point analysis, which helps assess the feasibility of the changes and avoids R&D and testing risks caused by an excessively large impact. Furthermore, by automatically outputting the scope of impact and test list through commit records and project call chain diagrams, automated testing is performed, avoiding omissions in the scope of impact analysis and reducing manpower costs. Finally, in the project build call chain diagram, methods that are not entry points and have no upstream calls can be further analyzed to determine if they are obsolete code, and iterative iterations can be arranged for their safe removal, helping to maintain code cleanliness and maintainability. In summary, this invention brings significant benefits in feasibility assessment, automated testing, improved code quality, and enhanced team collaboration. These effects work together in the software development process, contributing to improved overall software quality and development and testing efficiency.
[0064] Example 3 Figure 3This is a structural block diagram of a project code automated testing device provided in an embodiment of the present invention. This embodiment is applicable to situations where, based on the link diagram and method coordinates, changes are quickly identified after a new project code submission, the call chain affected by the code changes is accurately analyzed, and test cases are matched for automated testing. The project code automated testing device provided by the present invention can execute the project code automated testing method provided in any embodiment of the present invention, possessing the corresponding functional modules and beneficial effects of the execution method. This project code automated testing device can be implemented in hardware and / or software and configured in an electronic device with project code automated testing functionality, such as... Figure 3 As shown, the automated code testing device for this project may specifically include: The information determination module 301 is used to respond to the automated testing request for the project code corresponding to the target project, determine the target archive file, and determine the call chain diagram of the target archive file and the coordinate information of the method functions in the target archive file; The function determination module 302 is used to determine the modified call chain and the target test method function corresponding to the modified call chain if a new code commit record for the project code of the target project is detected. Test module 303 is used to determine the target test cases corresponding to the target test method function, so as to trigger the automated execution of the target test cases and realize automated testing after the project code is newly submitted.
[0065] The technical solution of this invention, in response to an automated testing request for the project code corresponding to the target project, determines the target archive file, and determines the call chain diagram and coordinate information of the method functions in the target archive file. If a new code commit record for the project code of the target project is detected, the modified call chain is determined, and the target test method function corresponding to the modified call chain is determined. The target test case corresponding to the target test method function is determined to trigger the automated execution of the target test case, thereby realizing automated testing after a new project code commit. By quickly identifying changes after a new project code commit based on the call chain diagram and method coordinates, the call chain affected by the code changes can be accurately analyzed and test cases matched for automated testing, improving the efficiency and intelligence level of project code testing.
[0066] Furthermore, the information determination module 301 is specifically used for: Scan the target project's code and compile it to package the project code and dependencies into a single executable file, resulting in the target archive file; Determine the file type of the target archive file; the file type includes at least one of the following: business logic file, configuration file, and resource file; Based on the file type, the corresponding link diagram determination strategy is adopted to determine the call link diagram of the project code.
[0067] Furthermore, the information determination module 301 is specifically used for: For target archive files that are business logic files, analyze them based on abstract syntax trees to determine the method call relationships in the target archive files; For target archive files with configuration files as the file type, the method call relationships in the target archive files are determined based on the document object model. The method call relationships in target archive files of different file types are matched, and based on the matching results and the storage format of the adjacency list, a call chain diagram of the project code is generated.
[0068] Furthermore, the function determination module 302 is specifically used for: Connect to the repository hosting server via a pre-defined application programming interface (API), and detect whether there are any new code commit records for the target project's code based on the feedback information from the repository hosting server. If so, determine the changes to the call chain based on the newly submitted code, the target project's code, coordinate information, and call chain diagram.
[0069] Furthermore, the function determination module 302 is specifically used for: Compare the newly submitted code with the target project's code, and determine the lines of code to be changed based on the comparison results; Based on the coordinate information and the number of modified rows corresponding to the modified row, determine the modification method function to which the modified row belongs, and determine the modification call chain based on the upstream information of the modification method function in the call chain graph; The function determination module 302 is also used to: determine the method function involved in the modified call chain as the target test method function.
[0070] Furthermore, test module 303 is specifically used for: Determine the test interface associated with the target test method function; Based on the test interface and the preset mapping library of interfaces and test cases, determine the target test cases corresponding to the test interface, and determine the target test cases corresponding to the target test method functions.
[0071] Furthermore, the information determination module 301 is specifically used for: Identify the methods and functions contained in the target archive file, and determine the class name, method name, start line number, and end line number of each method and function; Based on the class name, method name, start line number, and end line number of each method function in the target archive file, determine the coordinate information of the method functions in the target archive file.
[0072] Example 4 Figure 4 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Figure 4 A schematic diagram of an electronic device 10, which can be used to implement embodiments 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 processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0073] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory 12 or a random access memory 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the read-only memory 12 or loaded from storage unit 18 into the random access memory 13. The random access memory 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, read-only memory 12, and random access memory 13 are interconnected via a bus 14. An input / output interface 15 is also connected to the bus 14.
[0074] Multiple components in electronic device 10 are connected to input / output 15, including: input unit 16, such as a keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as a disk, optical disk, etc.; and communication unit 19, such as a network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0075] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing units, graphics processing units, various special-purpose artificial intelligence computing chips, various processors running machine learning model algorithms, digital signal processors, and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as automated testing methods for project code.
[0076] In some embodiments, the automated testing method for project code can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via read-only memory 12 and / or communication unit 19. When the computer program is loaded into random access memory 13 and executed by processor 11, one or more steps of the automated testing method for project code described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute the automated testing method for project code by any other suitable means (e.g., by means of firmware).
[0077] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays, application-specific integrated circuits (ASICs), application-specific standard products (ASICs), system-on-a-chip (SoCs), complex programmable logic devices (PLCs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0078] Computer programs used to implement 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 executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0079] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory, optical fibers, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0080] 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 cathode ray tube or liquid crystal display) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, 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 (e.g., voice input, speech input, or tactile input).
[0081] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0082] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product within the cloud computing service system to address the shortcomings of traditional physical hosts and virtual reality services, such as high management difficulty and weak business scalability.
[0083] In one embodiment, the present invention further includes a computer program product, which includes a computer program that, when executed by a processor, implements the project code automated testing method of any embodiment of the present invention.
[0084] In the implementation of a computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages as well as conventional procedural programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including local area networks (LANs) or wide area networks (WANs), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0085] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0086] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for automated testing of project code, characterized in that, include: In response to an automated testing request for the code of the target project, the target archive file is determined, along with the call chain diagram and coordinate information of the method functions within the target archive file. If a new code commit record targeting the project code is detected, the modified call chain is determined, and the target test method function corresponding to the modified call chain is identified. Identify the target test cases corresponding to the target test method function to trigger the automated execution of the target test cases, thereby achieving automated testing after a new code submission in the project.
2. The method according to claim 1, characterized in that, Identify the target archive file and determine the call chain graph of the target archive file, including: Scan the target project's code and compile it to package the project code and dependencies into a single executable file, resulting in the target archive file; Determine the file type of the target archive file; the file type includes at least one of the following: business logic file, configuration file, and resource file; Based on the file type, the corresponding link diagram determination strategy is adopted to determine the call link diagram of the project code.
3. The method according to claim 2, characterized in that, Based on the file type, a corresponding call chain diagram determination strategy is used to determine the call chain diagram of the project code, including: For target archive files that are business logic files, analyze them based on abstract syntax trees to determine the method call relationships in the target archive files; For target archive files with configuration files as the file type, the method call relationships in the target archive files are determined based on the document object model. The method call relationships in target archive files of different file types are matched, and based on the matching results and the storage format of the adjacency list, a call chain diagram of the project code is generated.
4. The method according to claim 1, characterized in that, If a new code commit record targeting the project's code is detected, the change call chain is determined, including: Connect to the repository hosting server via a pre-defined application programming interface (API), and detect whether there are any new code commit records for the target project's code based on the feedback information from the repository hosting server. If so, determine the changes to the call chain based on the newly submitted code, the target project's code, coordinate information, and call chain diagram.
5. The method according to claim 4, characterized in that, Based on the newly submitted code, the target project's code, coordinate information, and call chain diagram, determine the modified call chain, including: Compare the newly submitted code with the target project's code, and determine the lines of code to be changed based on the comparison results; Based on the coordinate information and the number of modified rows corresponding to the modified row, determine the modification method function to which the modified row belongs, and determine the modification call chain based on the upstream information of the modification method function in the call chain graph; Accordingly, the target test method function corresponding to the modified call chain is determined, including: identifying the method function involved in the modified call chain as the target test method function.
6. The method according to claim 1, characterized in that, Determine the target test cases corresponding to the target test method function, including: Determine the test interface associated with the target test method function; Based on the test interface and the preset mapping library of interfaces and test cases, determine the target test cases corresponding to the test interface, and determine the target test cases corresponding to the target test method functions.
7. The method according to claim 1, characterized in that, Determine the coordinate information of the method functions in the target archive file, including: Identify the methods and functions contained in the target archive file, and determine the class name, method name, start line number, and end line number of each method and function; Based on the class name, method name, start line number, and end line number of each method function in the target archive file, determine the coordinate information of the method functions in the target archive file.
8. An automated testing device for project code, characterized in that, include: The information determination module is used to respond to automated testing requests for the code corresponding to the target project, determine the target archive file, and determine the call chain diagram and coordinate information of the method functions in the target archive file. The function determination module is used to determine the modified call chain and the target test method function corresponding to the modified call chain if a new code commit record for the project code of the target project is detected. The testing module is used to determine the target test cases corresponding to the target test method function, so as to trigger the automated execution of the target test cases and realize automated testing after the project code is newly submitted.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the automated testing method for project code according to any one of claims 1-7.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the automated testing method for project code as described in any one of claims 1-7.
