Code testing method, device, equipment, storage medium and program product
Patent Information
- Application Number
- CN202610708622.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-21
- Publication Date
- 2026-09-11
AI Technical Summary
[0003]在多端应用场景下,当子应用接入不同的母应用(比如,Web游戏接入不同的终端应用(APP,Application Program))时,通常需要将涉及多端交互(即子应用与母应用交互)的测试用例在该子应用接入的所有母应用上进行重复测试验证,传统的测试流程通常需在所有母应用上重复执行全部测试用例,即不涉及多端交互的测试用例也需要重复验证,从而导致测试周期长,测试效率低下
Smart Images

Figure CN122733705A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a code testing method, apparatus, device, storage medium, and program product. Background Technology
[0002] Code testing before application deployment is a crucial line of defense for ensuring product quality and user experience. Its necessity is reflected in three aspects: First, it helps to discover and fix logical errors, security vulnerabilities, or performance bottlenecks, preventing online failures from causing user churn or data leaks; second, it verifies through automated testing whether code modifications break the original functionality, reducing regression risks; and finally, testing provides an objective assessment of code quality, helping the team build confidence in the release version and ensuring that the application runs stably on real devices, in network environments, and under concurrent scenarios, avoiding the high costs of emergency fixes and damage to brand reputation due to hasty deployment.
[0003] In multi-terminal application scenarios, when a sub-application is connected to different parent applications (for example, a web game is connected to different terminal applications (APP, Application Program)), test cases involving multi-terminal interaction (i.e., interaction between the sub-application and the parent application) usually need to be repeatedly tested and verified on all parent applications connected to the sub-application. Traditional testing processes usually require all test cases to be executed repeatedly on all parent applications, meaning that test cases that do not involve multi-terminal interaction also need to be repeatedly verified, resulting in long testing cycles and low testing efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a code testing method, apparatus, device, storage medium, and program product that can improve the efficiency of multi-terminal adaptation testing of sub-applications in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a code testing method, the method comprising:
[0006] Filter out target files from the unreleased code of the sub-application that have been modified compared to the released code of the sub-application, and filter out candidate lines of code that have been modified from the target files;
[0007] Identify the target code lines related to the interaction with the parent application from the candidate code lines;
[0008] Locate the target node containing the target code line from each abstract syntax tree obtained from each of the target files, and insert a cross-end verification prompt node before the target node;
[0009] On the first parent application connected to the sub-application, candidate test cases for the code to be released are executed. For each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, cross-platform verification prompt information is generated, and the candidate test case is marked as a target test case that needs to be cross-platform verified. The cross-platform verification prompt information is used to instruct the execution of the target test case on at least one second parent application connected to the sub-application.
[0010] In one embodiment, the step of filtering target files from the unreleased code of the sub-application that have been modified compared to the released code of the sub-application includes:
[0011] In response to the command to obtain the changed file path, the file paths of the changed files that have been modified compared to the released code of the sub-application are filtered from the code to be released of the sub-application.
[0012] In response to the command to retrieve the changed file, the changed file is retrieved from the code to be released based on the file path;
[0013] Based on a preset blacklist of file formats corresponding to non-code files, filter the non-code files in the modified files to obtain the target file.
[0014] In one embodiment, the file format blacklist includes at least one file format selected from .meta, .png, .mp3, .prefab, and .json.
[0015] In one embodiment, identifying the target code line related to the interaction with the parent application from the candidate code lines includes:
[0016] Obtain a preset keyword list; the keyword list contains at least one keyword related to the interaction with the parent application;
[0017] Perform regular expression matching between the candidate code lines and each of the keywords in the keyword list;
[0018] The candidate code lines that successfully match are identified as target code lines that are related to the interaction with the parent application.
[0019] In one embodiment, for each abstract syntax tree, each candidate node in the abstract syntax tree corresponds to a line number; for each candidate node in the abstract syntax tree, the line number information corresponding to the candidate node includes the node line numbers of all lines of code in the candidate node;
[0020] After the step of identifying the target code line related to the interaction with the parent application from the candidate code lines, the method further includes:
[0021] Store the target code line number of the target code line;
[0022] Locating the target node containing the target code line from each abstract syntax tree obtained from each of the target files includes:
[0023] For each target file, candidate nodes in the abstract syntax tree converted from the target file whose line numbers match the target line number are identified as target nodes containing the target line number.
[0024] In one embodiment, the method further includes:
[0025] In the test interface, the cross-platform verification prompt information is displayed in the form of a prompt box; the cross-platform verification prompt information is displayed in the prompt box.
[0026] In one embodiment, the prompt box is a non-blocking prompt box; the non-blocking prompt box disappears automatically after being displayed in the test interface for a preset duration.
[0027] Secondly, this application provides a code testing apparatus, the apparatus comprising:
[0028] The filtering module is used to filter out target files that have been modified from the released code of the sub-application compared with the released code of the sub-application, and to filter out candidate lines of code that have been modified from the target files;
[0029] The identification module is used to identify target code lines related to the interaction with the parent application from the candidate code lines;
[0030] The positioning module is used to locate the target node containing the target code line from each abstract syntax tree obtained by converting each target file, and insert a cross-end verification prompt node before the target node;
[0031] The execution module is used to execute candidate test cases for the code to be released on the first parent application connected to the sub-application. For each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, cross-platform verification prompt information is generated, and the candidate test case is marked as a target test case that needs to be cross-platform verified. The cross-platform verification prompt information is used to instruct the execution of the target test case on at least one second parent application connected to the sub-application.
[0032] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the various method embodiments of this application.
[0033] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the various method embodiments of this application.
[0034] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the various method embodiments of this application.
[0035] The aforementioned code testing method, apparatus, device, storage medium, and program product filter target files that have changed compared to the released code of the sub-application from the code to be released, and filter candidate lines of code with changes from the target files; identify target lines of code related to interaction with the parent application from the candidate lines of code; locate target nodes containing target lines of code from the abstract syntax trees converted from each target file, and insert cross-platform verification prompt nodes before the target nodes; execute candidate test cases for the code to be released on the first parent application connected to the sub-application; for each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, generate cross-platform verification prompt information and mark the candidate test case as a target test case requiring cross-platform verification; the cross-platform verification prompt information is used to instruct the execution of the target test cases on at least one second parent application connected to the sub-application. Compared with traditional testing methods, this application accurately filters target lines of code that have changed and are related to interaction with the parent application, and automatically inserts cross-platform verification prompt nodes based on the abstract syntax tree, marking test cases requiring cross-platform verification only when the execution path reaches the node. Therefore, while ensuring the quality of test coverage, it avoids repeatedly executing all test cases for all parent applications in multi-terminal access scenarios, significantly reducing redundant testing workload, shortening the testing cycle, improving the verification efficiency of multi-terminal adaptation of sub-applications, and ensuring that code changes related to multi-terminal interaction are verified in a targeted manner. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a diagram illustrating the application environment of a code testing method in one embodiment;
[0038] Figure 2 This is a flowchart illustrating a code testing method in one embodiment;
[0039] Figure 3This is a schematic diagram illustrating the display of cross-platform verification prompts in a non-blocking prompt box on the test interface in one embodiment.
[0040] Figure 4 This is a schematic diagram of the system architecture of a code testing method in one embodiment;
[0041] Figure 5 This is a timing diagram of a code testing method in one embodiment;
[0042] Figure 6 This is a structural block diagram of a code testing device in one embodiment;
[0043] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0045] The code testing methods provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. The data storage system can be set up separately and can store the data that server 104 needs to process. The data storage system can be integrated into server 104 or placed on the cloud or other servers. Terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, and in-vehicle terminals. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, cloud security, host security and other network security services, CDN, and basic cloud computing services such as big data and artificial intelligence platforms. Terminal 102 and server 104 can be directly or indirectly connected via wired or wireless communication, which is not limited herein.
[0046] Terminal 102 can obtain the release code and released code of the sub-application from server 104, and filter out target files that have changed compared to the released code of the sub-application from the release code of the sub-application, and filter out candidate code lines that have changed from the target files. Terminal 102 can identify target code lines related to interaction with the parent application from the candidate code lines. Terminal 102 can locate the target node containing the target code line from each abstract syntax tree converted from each target file, and insert a cross-platform verification prompt node before the target node. Terminal 102 can execute candidate test cases for the release code on the first parent application connected to the sub-application. For each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, cross-platform verification prompt information is generated, and the candidate test case is marked as a target test case that needs cross-platform verification. The cross-platform verification prompt information is used to indicate that the target test case is executed on at least one second parent application connected to the sub-application.
[0047] It is understood that this embodiment does not limit this aspect. Figure 1 The application scenarios shown are for illustrative purposes only and are not limited to these.
[0048] In one embodiment, such as Figure 2 As shown, a code testing method is provided, which can be applied to a terminal and includes the following steps:
[0049] Step 202: Filter out target files that have changed compared to the released code of the sub-application from the code to be released, and filter out candidate lines of code that have changed from the target files.
[0050] In this scenario, a sub-application can be connected to at least two parent applications simultaneously. For example, a sub-application can be connected to parent applications A, B, and C at the same time, forming a multi-terminal application scenario. Each parent application can be understood as an application client. A sub-application is a modular program that is embedded in or depends on the parent application platform to run, and has relatively independent functions. The parent application is the host application that provides the basic framework, common resources, and runtime environment to support and manage the sub-applications. For example, in the scenario of a web game connecting to a multi-terminal app, the parent application refers to the terminal application that provides the native runtime environment, and the sub-application refers to the web game running in the container environment (such as WebView) provided by the parent application.
[0051] In one embodiment, the terminal can compare the code to be released (i.e. the requirement code branch) of the sub-application with the released code (i.e. the main code branch) of the sub-application, and filter out the target files that have changed compared to the released code from the code to be released, and filter out the candidate code lines that have changed compared to the released code from the target files.
[0052] Step 204: Identify the target lines of code that are related to the interaction with the parent application from the candidate lines of code.
[0053] Interacting with the parent application refers to the data interaction between the child application and the parent application it connects to.
[0054] In one embodiment, for each candidate code line, the terminal can determine whether the candidate code line contains keywords related to the interaction with the parent application. If it does, the candidate code line is identified as the target code line.
[0055] Step 206: Locate the target node containing the target code line from each abstract syntax tree obtained from each target file, and insert a cross-end verification prompt node before the target node.
[0056] Abstract Syntax Tree (AST) is an intermediate representation of the source code syntax structure using a tree-like data structure, where each node corresponds to a syntax construction in the code.
[0057] In one embodiment, for each target file, the terminal can convert the target file into an abstract syntax tree. Then, the terminal can locate each target node containing the target code lines from the abstract syntax tree and insert a cross-platform verification prompt node before each target node. The cross-platform verification prompt node is used to generate cross-platform verification prompt information when the execution path of the test case reaches the cross-platform verification prompt node.
[0058] Step 208: Execute candidate test cases for the code to be released on the first parent application connected to the sub-application. For each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, generate cross-platform verification prompt information and mark the candidate test case as the target test case that needs to be cross-platform verified. The cross-platform verification prompt information is used to instruct the execution of the target test case on at least one second parent application connected to the sub-application.
[0059] It is understandable that for each candidate test case, if the execution path of the candidate test case does not reach the cross-platform verification prompt node, it means that the execution path of the candidate test case will not reach the target code line related to the interaction with the parent application. In this case, the test interface will not generate cross-platform verification prompt information, and the candidate test case does not need to be executed repeatedly on the second parent application connected to the sub-application.
[0060] In the aforementioned code testing method, target files that have changed compared to the released code of the sub-application are selected from the code to be released, and candidate lines of code with changes are selected from the target files; target lines of code related to interaction with the parent application are identified from the candidate lines of code; target nodes containing target lines of code are located from the abstract syntax trees converted from each target file, and cross-platform verification prompt nodes are inserted before the target nodes; candidate test cases for the code to be released are executed on the first parent application connected to the sub-application; for each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, cross-platform verification prompt information is generated, and the candidate test case is marked as a target test case requiring cross-platform verification; the cross-platform verification prompt information is used to indicate that the target test cases are executed on at least one second parent application connected to the sub-application. Compared with traditional testing methods, this application accurately selects target lines of code that have changed and are related to interaction with the parent application, and automatically inserts cross-platform verification prompt nodes based on the abstract syntax tree, marking test cases requiring cross-platform verification only when the execution path reaches the node. Therefore, while ensuring the quality of test coverage, it avoids repeatedly executing all test cases for all parent applications in multi-terminal access scenarios, significantly reducing redundant testing workload, shortening the testing cycle, improving the verification efficiency of multi-terminal adaptation of sub-applications, and ensuring that code changes related to multi-terminal interaction are verified in a targeted manner.
[0061] In one embodiment, filtering target files that have changed compared to the released code of a sub-application from the code to be released includes: in response to a change file path retrieval command, filtering the file paths of changed files that have changed compared to the released code of the sub-application from the code to be released; in response to a change file retrieval command, retrieving the changed files from the code to be released based on the file paths; and filtering non-code files in the changed files according to a preset blacklist of file formats corresponding to non-code files to obtain the target files.
[0062] In the above embodiments, the modified code files are accurately selected and non-code files are automatically excluded through path acquisition and blacklist filtering mechanisms. This avoids interference from irrelevant files on test analysis, reduces the amount of data processed subsequently, and improves the efficiency and accuracy of code change identification and cross-platform verification triggering.
[0063] In one embodiment, the file format blacklist includes at least one file format selected from .meta, .png, .mp3, .prefab, and .json.
[0064] In the above embodiments, by setting a blacklist that includes common non-code file formats such as .meta, .png, .mp3, .prefab, and .json, non-logical files such as resources, configurations, and metadata can be accurately filtered, avoiding invalid files from interfering with test analysis and further improving the accuracy of code change screening and the efficiency of automated processing.
[0065] In one embodiment, identifying target code lines related to interaction with the parent application from candidate code lines includes: obtaining a preset keyword list; the keyword list contains at least one keyword related to interaction with the parent application; performing regular expression matching between candidate code lines and each keyword in the keyword list; and determining the successfully matched candidate code lines as target code lines related to interaction with the parent application.
[0066] Specifically, for each candidate line of code, the terminal can perform regular expression matching between the candidate line of code and each keyword in the keyword list. If the match is successful, the candidate line of code is determined as the target line of code related to the interaction with the parent application.
[0067] In the above embodiments, by using a preset list of interaction keywords and combining it with regular expression matching, the target code lines related to the interaction with the parent application are automatically and accurately identified from the candidate code lines. This avoids the omissions and inefficiencies of manual line-by-line review, improves the accuracy and automation level of cross-platform interaction code location, and lays the foundation for subsequent targeted testing.
[0068] In one embodiment, for each abstract syntax tree, each candidate node in the abstract syntax tree corresponds to a line number; for each candidate node in the abstract syntax tree, the line number information corresponding to the candidate node includes the node line number of all lines of code in the candidate node; after the step of identifying the target line of code related to the interaction with the parent application from the candidate lines of code, the method further includes: storing the target line number of the target line of code; locating the target node containing the target line of code from each abstract syntax tree converted from each target file, including: for each target file, determining the candidate node in the abstract syntax tree converted from the target file whose node line number is consistent with the target line number as the target node containing the target line of code.
[0069] In the above embodiments, by associating precise line number information with abstract syntax tree nodes and quickly locating the corresponding node based on pre-stored target line numbers, a precise mapping from changed line of code to syntax tree nodes is achieved. This avoids the complexity of traversal searching and improves the efficiency and accuracy of cross-platform validation prompt node insertion.
[0070] In one embodiment, the method further includes: displaying cross-platform verification prompt information in the form of a prompt box in the test interface; the cross-platform verification prompt information is displayed in the prompt box.
[0071] In the above embodiments, the cross-platform verification prompts are displayed intuitively in the test interface via a prompt box, clearly and promptly informing testers that the current test case needs to be executed on other parent applications. This non-intrusive reminder method reduces the risk of information omission and improves the visibility and ease of execution of cross-platform verification.
[0072] In one embodiment, the prompt is a non-blocking prompt; the non-blocking prompt disappears automatically after being displayed in the test interface for a preset duration.
[0073] Among them, the non-blocking toast is a lightweight feedback control that is short-lived, disappears automatically, and does not interrupt the user's current operation. Its characteristic is that it can close automatically without user interaction.
[0074] In one embodiment, such as Figure 3 As shown, the terminal displays cross-platform verification prompts in a non-blocking dialog box within the test interface. The prompts state, "The current test case involves multiple platforms; please cover other platforms." This cross-platform verification prompt indicates to testers that the test case needs to be verified again on other parent applications (i.e., the second parent application) connected to the sub-application.
[0075] In the above embodiments, a non-blocking prompt box is used to display cross-platform verification information. The prompt box disappears automatically after a preset duration, ensuring effective communication of key information while avoiding prolonged obscuring of the test interface or interruption of the test process. This helps improve the continuity of test operations and the user-friendliness of the interface, thereby increasing the efficiency of cross-platform verification.
[0076] In one embodiment, such as Figure 4As shown, a child application can simultaneously connect to four parent applications, namely, parent application 1, parent application 2, parent application 3, and parent application 4, which serve as the host applications for the child application. Data interaction between the child application and these four parent applications can be achieved through a pre-packaged JS bridging tool. During code testing, the terminal can use code comparison tools to filter out target files that have changed compared to the released code of the sub-application from the code-to-be-released code of the sub-application, and then filter out candidate lines of code that have changed from the target files; identify target lines of code related to the interaction with the parent application from the candidate lines of code; locate the target nodes containing the target lines of code from the abstract syntax trees converted from each target file, and insert cross-platform verification prompt nodes (i.e., insert stub code nodes) before the target nodes; execute candidate test cases for the code-to-be-released code on the first parent application connected to the sub-application; for each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, generate cross-platform verification prompt information, mark the candidate test case as a target test case that needs cross-platform verification, and color the target test case; wherein, the cross-platform verification prompt information is used to indicate that the target test case is executed on at least one second parent application connected to the sub-application.
[0077] In one embodiment, such as Figure 5As shown, the terminal can, based on the development platform's response to the command to retrieve changed file paths, filter out the file paths of changed files that have been modified compared to the already released code of the sub-application from the code to be released in the distributed version control system (i.e., Git tool); respond to the command to retrieve changed files, retrieve the changed files from the code to be released based on the file paths; filter out non-code files in the changed files according to a preset blacklist of file formats corresponding to non-code files to obtain the target file, and filter out candidate lines of code that have been modified from the target file; the file format blacklist includes at least one file format among .meta, .png, .mp3, .prefab, and .json. The system uses a keyword matching engine to obtain a pre-defined keyword list. This list contains at least one keyword related to interaction with the parent application. Candidate code lines are matched against each keyword in the keyword list using regular expressions. Successfully matched candidate code lines are identified as target code lines related to interaction with the parent application. The target code line number is stored. For each target file, the BabelAST engine (Abstract Syntax Tree engine) identifies candidate nodes in the abstract syntax tree (AST) that match the target code line number, identifying these as target nodes containing the target code line. A cross-platform verification prompt node is then inserted before the target node. The test case execution platform executes candidate test cases for the code to be released on the first parent application connected to the sub-application. For each candidate test case, if the execution path reaches the cross-platform verification prompt node, a cross-platform verification prompt is generated and displayed in the test interface in a non-blocking prompt format. The cross-platform verification prompt is displayed in the non-blocking prompt, marking the candidate test case as a target test case requiring cross-platform verification. The cross-platform verification prompt indicates that the target test case should be executed on at least one second parent application connected to the sub-application.
[0078] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially, these steps are not necessarily executed in that order. Unless otherwise expressly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the above embodiments may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0079] Based on the same inventive concept, this application also provides a code testing apparatus for implementing the code testing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more code testing apparatus embodiments provided below can be found in the limitations of the code testing method described above, and will not be repeated here.
[0080] In one embodiment, such as Figure 6 As shown, a code testing device 600 is provided, which specifically includes:
[0081] The filtering module 602 is used to filter out target files that have been changed from the released code of the sub-application to be released, and to filter out candidate lines of code that have been changed from the target files.
[0082] The identification module 604 is used to identify target code lines related to the interaction with the parent application from candidate code lines;
[0083] The positioning module 606 is used to locate the target node containing the target code line from each abstract syntax tree converted from each target file, and insert a cross-end verification prompt node before the target node;
[0084] The execution module 608 is used to execute candidate test cases for the code to be released on the first parent application connected to the sub-application. For each candidate test case, if the execution path of the candidate test case reaches the cross-end verification prompt node, cross-end verification prompt information is generated and the candidate test case is marked as the target test case that needs to be cross-end verified. The cross-end verification prompt information is used to instruct the execution of the target test case on at least one second parent application connected to the sub-application.
[0085] In one embodiment, the filtering module 602 is further configured to, in response to the change file path acquisition command, filter out the file paths of the changed files that have changed compared to the released code of the sub-application from the code to be released; in response to the change file acquisition command, acquire the changed files from the code to be released based on the file paths; and filter the non-code files in the changed files according to a preset blacklist of file formats corresponding to non-code files to obtain the target file.
[0086] In one embodiment, the file format blacklist includes at least one file format selected from .meta, .png, .mp3, .prefab, and .json.
[0087] In one embodiment, the identification module 604 is further configured to obtain a preset keyword list; the keyword list contains at least one keyword related to the interaction with the parent application; perform regular expression matching between the candidate code line and each keyword in the keyword list; and determine the successfully matched candidate code line as the target code line related to the interaction with the parent application.
[0088] In one embodiment, for each abstract syntax tree, each candidate node in the abstract syntax tree corresponds to a line number; for each candidate node in the abstract syntax tree, the line number information corresponding to the candidate node includes the line numbers of all lines of code in the candidate node; the identification module 604 is also used to store the target line number of the target line; the positioning module 606 is also used to, for each target file, determine the candidate nodes in the abstract syntax tree converted from the target file whose line numbers match the target line numbers as the target nodes containing the target line.
[0089] In one embodiment, the execution module 608 is further configured to display cross-platform verification prompt information in the form of a prompt box in the test interface; the cross-platform verification prompt information is displayed in the prompt box.
[0090] In one embodiment, the prompt is a non-blocking prompt; the non-blocking prompt disappears automatically after being displayed in the test interface for a preset duration.
[0091] The aforementioned code testing device filters target files that have changed compared to the released code of the sub-application from the code to be released, and then filters candidate lines of code with changes from the target files; it identifies target lines of code related to interaction with the parent application from the candidate lines of code; it locates the target nodes containing the target lines of code from the abstract syntax trees converted from each target file, and inserts a cross-platform verification prompt node before the target node; it executes candidate test cases for the code to be released on the first parent application connected to the sub-application; for each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, it generates cross-platform verification prompt information and marks the candidate test case as a target test case requiring cross-platform verification; the cross-platform verification prompt information is used to instruct the execution of the target test cases on at least one second parent application connected to the sub-application. Compared with traditional testing methods, this application accurately filters target lines of code that have changed and are related to interaction with the parent application, and automatically inserts cross-platform verification prompt nodes based on the abstract syntax tree, marking test cases requiring cross-platform verification only when the execution path reaches the node. Therefore, while ensuring the quality of test coverage, it avoids repeatedly executing all test cases for all parent applications in multi-terminal access scenarios, significantly reducing redundant testing workload, shortening the testing cycle, improving the verification efficiency of multi-terminal adaptation of sub-applications, and ensuring that code changes related to multi-terminal interaction are verified in a targeted manner.
[0092] Each module in the aforementioned code testing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0093] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a code testing method. The display unit of the computer device is used to form a visually visible image. It can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0094] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0095] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0096] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0097] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0098] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0099] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0100] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0101] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A code testing method, characterized in that, The method includes: Filter out target files from the unreleased code of the sub-application that have been modified compared to the released code of the sub-application, and filter out candidate lines of code that have been modified from the target files; Identify the target code lines related to the interaction with the parent application from the candidate code lines; Locate the target node containing the target code line from each abstract syntax tree obtained from each of the target files, and insert a cross-end verification prompt node before the target node; On the first parent application connected to the sub-application, candidate test cases for the code to be released are executed. For each candidate test case, if the execution path of the candidate test case reaches the cross-platform verification prompt node, cross-platform verification prompt information is generated, and the candidate test case is marked as a target test case that needs to be cross-platform verified. The cross-platform verification prompt information is used to instruct the execution of the target test case on at least one second parent application connected to the sub-application.
2. The method according to claim 1, characterized in that, The step of selecting target files from the unreleased code of the sub-application that have been modified compared to the released code of the sub-application includes: In response to the command to obtain the changed file path, the file paths of the changed files that have been modified compared to the released code of the sub-application are filtered from the code to be released of the sub-application. In response to the command to retrieve the changed file, the changed file is retrieved from the code to be released based on the file path; Based on a preset blacklist of file formats corresponding to non-code files, filter the non-code files in the modified files to obtain the target file.
3. The method according to claim 2, characterized in that, The file format blacklist includes at least one file format selected from .meta, .png, .mp3, .prefab, and .json.
4. The method according to claim 1, characterized in that, The step of identifying target code lines related to the interaction with the parent application from the candidate code lines includes: Obtain a preset keyword list; the keyword list contains at least one keyword related to the interaction with the parent application; Perform regular expression matching between the candidate code lines and each of the keywords in the keyword list; The candidate code lines that successfully match are identified as target code lines that are related to the interaction with the parent application.
5. The method according to claim 1, characterized in that, For each abstract syntax tree, each candidate node in the abstract syntax tree corresponds to a line number information; for each candidate node in the abstract syntax tree, the line number information corresponding to the candidate node includes the node line numbers of all lines of code in the candidate node; After the step of identifying the target code line related to the interaction with the parent application from the candidate code lines, the method further includes: Store the target code line number of the target code line; Locating the target node containing the target code line from each abstract syntax tree obtained from each of the target files includes: For each target file, candidate nodes in the abstract syntax tree converted from the target file whose line numbers match the target line number are identified as target nodes containing the target line number.
6. The method according to claim 1, characterized in that, The method further includes: In the test interface, the cross-platform verification prompt information is displayed in the form of a prompt box; the cross-platform verification prompt information is displayed in the prompt box.
7. The method according to claim 6, characterized in that, The prompt box is a non-blocking prompt box; the non-blocking prompt box disappears automatically after being displayed in the test interface for a preset duration.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.