A method of code testing and program product

CN122614722APending Publication Date: 2026-08-21BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610748013.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-27
Publication Date
2026-08-21

AI Technical Summary

Technical Problem

然而,通过该种方式开发的项目中,其一个组件往往会被多个页面引用,形成复杂的页面与组件依赖

Benefits of technology

当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本文中任一所述的代码测试方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122614722A_ABST
    Figure CN122614722A_ABST
Patent Text Reader

Abstract

The present application provides a code testing method and a program product, and relates to the technical field of computer processing. The method comprises the following steps: in response to a first trigger operation, obtaining a first code file of a first project; determining a first code unit and first hierarchical association information according to the first code file, wherein the first hierarchical association information comprises an association relationship between the first code unit and a second code unit; and testing the first code unit according to the first hierarchical association information. According to the method, the testing of the first code unit is performed according to the first hierarchical association information, all reference scenarios and associated pages of the first code unit are covered, the problems of missed testing caused by multi-page reuse and multi-level indirect dependence of the first code unit are avoided, the testing comprehensiveness and accuracy are improved, the testing range is highly matched with the actual influence range of the first code unit, invalid testing is avoided, and the testing efficiency and quality are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer processing technology, and in particular to a code testing method and a program product. Background Technology

[0002] Before a project is released as an application software after development is completed, code testing is required to ensure the reliability of the code's functionality in actual use.

[0003] Currently, project development largely relies on component-based page development frameworks. However, in projects developed using this approach, a single component is often referenced by multiple pages, creating complex page-component dependencies. Existing code testing methods are no longer suitable for testing code with such complex dependencies, leading to issues such as incomplete code location and incomplete scenario coverage in test scripts. This results in missed tests, impacting the accuracy and comprehensiveness of code testing. Summary of the Invention

[0004] This document provides a code testing methodology and program product that significantly improves the accuracy and comprehensiveness of code testing.

[0005] In one scenario, this article provides a code testing method that includes: In response to the first trigger operation, retrieve the first code file of the first project; Based on the first code file, a first code unit and a first-level association information are determined, wherein the first-level association information includes the association relationship between the first code unit and the second code unit; The first code unit is tested based on the first level of association information.

[0006] In one scenario, this paper also provides a code testing apparatus, including: The first acquisition module is used to acquire the first code file of the first project in response to the first trigger operation; The first determining module is used to determine a first code unit and a first-level association information based on the first code file, wherein the first-level association information includes the association relationship between the first code unit and the second code unit; The test execution module is used to test the first code unit based on the first-level association information.

[0007] In one instance, this document also provides an electronic device comprising: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the code testing methods as described in any of these documents.

[0008] In another scenario, this document also provides a computer program product, including a computer program that, when executed by a processor, implements the code testing methods described in any of the documents herein.

[0009] The technical solution described above involves obtaining the first code file of the first project in response to a first trigger operation; determining the first code unit and first-level association information based on the first code file, whereby the first-level association information includes the association relationship between the first code unit and the second code unit; and testing the first code unit based on the first-level association information. Using this method, the first code unit with testing requirements is accurately identified based on the first code file, and first-level association information that comprehensively reflects the direct references, indirect dependencies, and usage paths of the first code unit in the first project is obtained. This provides data support to avoid test omissions due to the inability to identify indirectly affected pages. Executing tests on the first code unit according to the first-level association information covers all reference scenarios and associated pages of the first code unit, solving the problem of traditional testing focusing only on code execution while ignoring differences in reference scenarios. This avoids test omissions caused by multi-page reuse and multi-level indirect dependencies of the first code unit, improving the comprehensiveness and accuracy of testing. Furthermore, it ensures a high degree of match between the test scope and the actual impact of the first code unit, making code testing more targeted, avoiding invalid testing, and thus improving testing efficiency and quality. Attached Figure Description

[0010] The above and other features, advantages, and aspects of the embodiments described herein will become more apparent when taken in conjunction with the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0011] Figure 1 This is a scenario diagram illustrating an application scenario involving code testing using code testing methods. Figure 2 This is a flowchart illustrating a code testing method under one scenario. Figure 3 A screenshot of the display interface involved in the code testing method is provided for one scenario; Figure 4 A screenshot of the display interface involved in the code testing method in another scenario is provided. Figure 5 This is a flowchart illustrating another code testing method under different circumstances. Figure 6 This is a flowchart illustrating a code testing method in another scenario; Figure 7a and Figure 7b A flowchart illustrating an optional example of a code testing method for one scenario; Figure 8 This is a schematic diagram of a code testing device under one scenario. Figure 9 A schematic diagram of the structure of an electronic device used to implement the interface display method is shown. Detailed Implementation

[0012] The embodiments will now be described in more detail with reference to the accompanying drawings. While some embodiments are shown in the drawings, it should be understood that the technical solutions can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the technical solutions herein. It should be understood that the illustrated drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the technical solutions.

[0013] It should be understood that the steps described in the method implementation may be performed in different orders and / or in parallel. Furthermore, the method implementation may include additional steps and / or omit the steps shown. The scope of this document is not limited in this respect.

[0014] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one situation" means "at least one situation"; the term "another situation" means "at least one additional situation"; the term "some situations" means "at least some situations". Definitions of other terms will be given in the following description.

[0015] It should be noted that the concepts of "first" and "second" mentioned are only used to distinguish different devices, modules or units, and are not used to limit the order of the functions performed by these devices, modules or units or their interdependencies.

[0016] It should be noted that the terms "one" and "more" used in this document are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0017] The names of messages or information exchanged between multiple devices in this document are for illustrative purposes only and are not intended to limit the scope of these messages or information.

[0018] It is understood that before using the technical solutions disclosed in the various embodiments of this document, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this document in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.

[0019] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as electronic devices, applications, servers, or storage media, that perform the operations described herein, based on the prompt message.

[0020] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0021] It is understood that the above notification and user authorization process is merely illustrative and does not limit the implementation method described in this article. Other methods that comply with relevant laws and regulations may also be applied to the implementation method described in this article.

[0022] It is understood that the data involved in the technical solutions in this article (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.

[0023] Figure 1 This is a scenario diagram illustrating an application scenario involving code testing methods. In some cases, the provided solution can be applied to this scenario. For example... Figure 1 As shown, the system involved in this application scenario may include client 101 and server 102. Client 101 may include, but is not limited to, web applications such as browsers, applications (Apps), Hyper Text Markup Language (HTML) applications, lightweight applications (also known as mini-programs, a type of lightweight application), or cloud applications. Client 101 may be deployed on an electronic device and relies on the operation of that device or certain applications on the device to implement its functions. The electronic device may be, for example, a device with a display screen that supports information browsing, such as a smartphone, tablet, personal computer, or other client terminal. For ease of understanding, Figure 1The client is primarily represented by a device. Other applications can also be configured on the electronic device, such as e-shopping and entertainment applications, media content publishing applications, and conversational applications. Server 102 can be one or more servers providing various services. That is, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server; furthermore, it can be a server for a distributed system, a server integrating blockchain technology, a cloud server, or an intelligent cloud computing server or intelligent cloud host deployed with machine learning models, etc.

[0024] The code testing method described in this paper can be implemented through interaction between client 101 and server 102, such as receiving or sending messages. For example, in this paper, client 101 can serve as a testing platform for project code testing, while server 102 can acquire and store the first code file. When client 101 has the need to execute code testing, it responds to a first trigger operation to acquire the first code file of the first project. Based on the first code file, it determines the first code unit and the first-level association information, which includes the association relationship between the first code unit and the second code unit. Based on the first-level association information, it tests the first code unit. Furthermore, after the code test passes, client 101 can publish the project through interaction with server 102. After the project is published, client 101 can also serve as the project's runtime environment, ensuring the normal operation of the functional applications involved in the project through interaction with server 102.

[0025] It should be noted that the code testing method can be executed on client 101, and the corresponding code testing device can be deployed on client 101. During the execution of the code testing method, client 101 and server 102 can achieve data interaction and functional collaboration through network communication. It should be understood that... Figure 1 The number of clients and servers shown is for illustrative purposes only. Any number of clients and servers can be configured to meet specific implementation requirements.

[0026] Figure 2 This is a flowchart illustrating a code testing method for one scenario. This method is applicable to code testing scenarios, particularly when a component in a project is indirectly referenced by at least one page. This code testing method can be executed by a code testing device, which can be implemented in software and / or hardware, optionally through an electronic device such as a mobile terminal or computer. Figure 2 As shown, the code test method may specifically include: S201. In response to the first trigger operation, obtain the first code file of the first project.

[0027] In one scenario, the electronic device executing the method provided herein can be considered an execution terminal such as a test analysis terminal, code parsing server, or test platform. The first project can be considered a test project object developed based on a development framework, containing code resources such as pages, components, and functional functions. The specific project type corresponding to this first project can vary depending on the business domain and product form. This document does not specifically limit the first project; it can be any code project, web application project, or cross-platform application project developed based on a component-based architecture that requires code change verification and functional regression testing.

[0028] In one scenario, the first triggering operation can be considered as an operation, instruction, or event that initiates testing of the first code file involved in the first project. In another scenario, the generation condition for this first triggering operation can be based on code event triggering, such as after code commit, merging, updating, and / or incremental modification events occur; the generation condition can also be based on interactive object operation triggering, such as after detecting that testers or developers actively click a button in the test interface to execute a test start instruction; the generation condition can also be based on automatic detection and timing rules triggering, such as automatically generating it when the project build is completed, continuous integration and continuous delivery / deployment processes are successfully executed, specified components / files are changed, a preset timing period is reached, and / or a test task is started (such as creating a new test task or initiating regression testing). By supporting multiple triggering methods to obtain the first code file, it can adapt to various testing scenarios, improving the automation level and applicability of test analysis.

[0029] In one scenario, the first code file can be considered as a collection of code data that is loaded and parsed in response to the first trigger operation and is obtained for the first project. The first code file corresponds to the project structure and test objectives of the first project and contains the code information required for performing dependency analysis and scenario link construction.

[0030] In one implementation, the first code file can be dynamically determined based on whether the first project already has hierarchical association information. For example, when it is detected that the first project is not associated with hierarchical association information, the first code file is the full source code file of the first project; when it is detected that the first project is associated with hierarchical association information, the first code file is the modified code file of the first project.

[0031] In one implementation, the first code file can be obtained by pulling data from the code repository. For example, this could include reading from a local code repository, pulling from a remote code repository, extracting from build artifacts, obtaining from a continuous integration and continuous delivery / deployment pipeline, or filtering from a code cache. For example, when the first triggering operation is a code commit, the first code file can be a collection of newly added, modified, or deleted code files obtained by comparing the versions before and after changes in the code repository.

[0032] S202. Based on the first code file, determine the first code unit and the first level association information, wherein the first level association information includes the association relationship between the first code unit and the second code unit.

[0033] In one scenario, the first code unit can be considered as a code unit parsed from the first code file that meets the testing requirements, i.e., the core test object. Optionally, the first code unit can be a component code unit. The second code unit can be considered as other code units in the first project that have dependencies, references, nesting, and / or calling relationships with the first code unit. For example, page code units, component code units, and functional code units can all be regarded as second code units, used to form a complete project dependency relationship together with the first code unit.

[0034] In one scenario, the first-level association information can be understood as information that fully includes direct dependencies, indirect dependencies, multi-level references, and calls between the first code unit and various second code units in the first project. This information is used to comprehensively reflect all direct and indirect referenced pages, dependency paths, and execution scenarios of the first code unit in the first project, so as to accurately determine the scope of influence of the first code unit and thus determine the accurate test scope.

[0035] In one implementation, the method for determining the association information between the first code unit and the first level based on the first code file can be as follows: First, parse the first code file to extract the dependency relationship between the second code units. Then, select the second code units with testing requirements, such as component code units, from all the second code units as the first code units. Next, generate a directed relationship graph of the first project and the relationship links corresponding to the second code units in the first project based on the dependency relationship. The first level association information is obtained based on the directed relationship graph and the relationship links.

[0036] For example, the second code unit can be all the component, page, and function code units contained in the first code file, and correspondingly, the first code unit can be all the component code units contained in the first code file; or, the second code unit can be the change-related code unit contained in the first code file, and correspondingly, the first code unit can be the component code unit among the change-related code units. For example, the method of parsing the first code file to obtain the dependencies between code units can be an abstract syntax tree parsing method, or it can be a static code analysis tool, such as a plugin, a compiler-type checking application programming interface, etc.

[0037] S203. Test the first code unit based on the first-level association information.

[0038] In one scenario, this step can be considered a test execution method that replaces traditional code coverage based on complete dependency chain and scenario coverage rules. This test execution is based on the first-level association information. The test scope is determined and the test is executed based on the full reference scenarios and full-link impact scope of the first code unit contained in the first-level association information, so as to achieve accurate testing without omissions or blind spots.

[0039] In one scenario, testing the first code unit based on the first-level association information can be considered as conducting tests and verifications sequentially in all reference scenarios according to all the relationship links corresponding to the first code unit in the first-level association information, ensuring that the first code unit is effectively covered in every link, every page, and every reuse scenario.

[0040] In one implementation, testing the first code unit based on the first-level association information can be done by: obtaining the set of relationship links corresponding to the first code unit based on the first-level association information; generating or matching a test execution script that can cover the entire set of relationship links based on the set of relationship links; and then performing functional verification, interaction verification, and rendering verification tests on the first code unit using the test execution script. In another implementation, testing the first code unit based on the first-level association information can also be done by: obtaining the set of relationship links corresponding to the first code unit based on the first-level association information; having the first code unit first tested according to the existing test script; then checking whether the existing test script already contains all the relationship links in the set of relationship links; if not, generating a test execution script based on the set of relationship links for the relatively uncovered or untested relationship links; and then continuing to test the first code unit in the corresponding scenario using this test execution script.

[0041] The above technical description describes a method that, in response to a first trigger operation, obtains the first code file of a first project; based on the first code file, determines the first code unit and its first-level association information, which includes the association relationship between the first code unit and the second code unit; and tests the first code unit based on the first-level association information. Using this method, the first code unit with testing requirements is accurately identified based on the first code file, and first-level association information that comprehensively reflects the direct references, indirect dependencies, and usage paths of the first code unit in the first project is obtained. This provides data support to avoid test omissions due to the inability to identify indirectly affected pages. Executing tests on the first code unit according to the first-level association information covers all reference scenarios and associated pages of the first code unit, solving the problem of traditional testing focusing only on code execution while ignoring differences in reference scenarios. This avoids test omissions caused by multi-page reuse and multi-level indirect dependencies of the first code unit, improving the comprehensiveness and accuracy of testing. Furthermore, it ensures a high degree of match between the test scope and the actual impact of the first code unit, making code testing more targeted, avoiding invalid testing, and thus improving testing efficiency and quality.

[0042] As an optional implementation, in response to a second triggering operation, a list of links is displayed, wherein each link entry in the list corresponds to a relationship link of the first code unit. The list of links is generated based on the first-level association information and is used for test guidance of the first code unit.

[0043] In one scenario, it can be assumed that before performing this step, a test assistance interface has already been displayed in the provided interactive interface based on a trigger operation response. This trigger operation can be considered an interface wake-up operation, which can be generated through interactive methods such as clicking a specified functional control, selecting the corresponding operation menu, or triggering with a shortcut key. The test assistance interface can be understood as an interface oriented towards code testing, used to provide visual interaction and present visual test guidance content. Optionally, the content presented in the test assistance interface can remain at the level of the previous search, or it can default to displaying the full directed relationship graph formed based on the first-level association information. Simultaneously, the test assistance interface includes a search box for retrieving the first code unit, allowing testers or developers to quickly locate the first code unit to be tested.

[0044] Based on this, in one scenario, the second triggering operation can be considered as a triggering operation performed on the presented test assistance interface, centered around displaying the list of links associated with the first code unit. For example, the second triggering operation could be a search operation performed by entering the name of the first code unit in the search box of the test assistance interface; the second triggering operation could also be a click on the first code unit as a node in the directed relationship graph displayed on the test assistance interface; the second triggering operation could also be an operation of selecting the first code unit through a drop-down list in the test assistance interface and triggering controls such as viewing details.

[0045] In one scenario, the display interface is the one shown after responding to the second trigger operation. It is used to specifically present a list of links associated with the first code unit, providing visual guidance for the testing process. The list of links is in structured form, including at least one link entry. Each link entry uniquely corresponds to a relationship link of the first code unit in the first project. These relationship links are composed of code units and are used to visually present the full reference scenarios formed by the direct and indirect references of the first code unit by the second code unit, clearly defining the dependency hierarchy and the location information of the first code unit in each scenario.

[0046] The above technical description, by visually displaying all the relationship links of the first code unit in the form of a link list on the display interface, enables testers to intuitively and quickly grasp all the test scenarios of the first code unit, including direct reference scenarios and indirect reference scenarios. It clarifies the test objects and test scope corresponding to each link, avoiding missed tests and misunderstandings caused by unclear relationship links and ambiguous test scope, thereby improving the intuitiveness of test guidance and the accuracy of test execution, and further improving the efficiency of testing and regression testing.

[0047] In one scenario, the link entries in the link list are associated with test status information, which represents the test status of the corresponding related links in the first code unit test.

[0048] In one scenario, the test status information can be considered as markers used to intuitively identify and provide feedback on the current testing stage and execution result of the relationship link during the testing of the first code unit. It is associated with and synchronously displayed one-to-one with each link entry, corresponding to the test execution process of this relationship link. This clearly indicates to testers the actual test progress and results of this relationship link, such as whether the test has been completed or whether there are any anomalies such as test failures, thereby improving regression testing efficiency and avoiding missed tests. For example, the test status information can be in the form of text markers, icon markers, color markers, and / or status labels. The test status information can include not tested, testing in progress, tested, and test failed.

[0049] To better display the linked list shown in the interface, Figure 3 A screenshot of the user interface displayed in a code testing method under one scenario is provided. For example... Figure 3 As shown, the display interface 3 includes a link list 31, where a link entry 310 corresponds to a relationship link of the first code unit. For example, the name of the first code unit can be "card". The relationship links are code unit hierarchical links formed by sequentially connecting one or more code units according to actual reference relationships or dependencies. In the link list, they can be represented by the name of the code unit or a sequence of unique identifiers.

[0050] In one scenario, the method provided herein may further include: in response to a third triggering operation, displaying a directed relation graph, wherein a first node link is highlighted in the directed relation graph, the first node link corresponding to a first relation link in the link list, and the third triggering operation being associated with a first triggering event for the first relation link.

[0051] In one scenario, the interface displaying the link list can also display a directed relationship graph, where the nodes in the directed relationship graph are code units in the first project. The directed relationship graph can be considered as a mesh dependency structure graph constructed based on the first-level association information. The nodes in the graph correspond to various types of code units in the first project, including component code units, page code units, and functional code units. The directed edges in the graph are used to represent the dependency relationships between nodes. For example, the node corresponding to the page code unit points to the node corresponding to the component code unit it depends on, and the node corresponding to the component code unit points to the functional code unit it depends on. This is used to intuitively and globally reflect the dependency distribution and influence range of code units in the first project.

[0052] In one scenario, the third triggering operation can be considered an interactive operation by the interactive object on the list of links in the display interface, associated with the first triggering event corresponding to the first relationship link. The first relationship link can be understood as a relationship link that meets the requirement of viewing the corresponding first node link in the directed relationship graph. For example, the first triggering event may include events such as selecting the first relationship link in the link list and hovering over the first relationship link. The first node link is a combination of nodes and paths corresponding to the first relationship link in the directed relationship graph. By highlighting the first node link, the reference path involved in the first code unit corresponding to the first relationship link can be accurately located in the entire directed relationship graph. For example, the highlighting method may include highlighting, bolding, color changing, flashing, and / or marking connections.

[0053] In one scenario, the method provided herein may further include displaying a first preview page in response to a fourth triggering operation, the first preview page corresponding to a second relationship link in the link list; wherein the first preview page is generated based on the rendering of the first code unit, the page element corresponding to the first code unit is highlighted on the first preview page, and the fourth triggering operation is associated with a second triggering event for the second relationship link.

[0054] In one scenario, the fourth trigger operation can be understood as an interactive operation on the link list of the display interface, associated with the second trigger event corresponding to the second relationship link. The second relationship link can be understood as a relationship link that requires viewing the corresponding first preview page; the second relationship link may be the same as or different from the first relationship link. The second trigger event may include events such as selecting the first relationship link in the link list and hovering over the first relationship link, which are different from the first trigger event. The first preview page can be considered as the page view corresponding to the second relationship link, used to intuitively display the actual rendering effect of the first code unit in the second relationship link, that is, to intuitively display the actual running environment and page position of the first code unit under this relationship link. Optionally, the first relationship link and the second relationship link are the same, the first node link and the first preview page both correspond to the same relationship link in the link list, and the two maintain the same data source and scene synchronization, realizing the linkage of the relationship link, the first node link and the first preview page.

[0055] In one scenario, the page element can be considered as a visual element actually rendered by the first code unit within the application page, such as a user interface area, control, module, or document object model element. For example, highlighting page elements can be achieved using methods such as highlighting outlines, color blocks, selection boxes, and transparency emphasis, allowing interactive objects to quickly and intuitively locate the specific position of the first code unit under test on the first preview page, avoiding difficulties in finding it on complex pages. For example, highlighting the page element can be achieved by drawing a rectangle based on the rendering position (coordinates) and rendering size (width and height) corresponding to the first code unit.

[0056] It is understandable that the first preview page needs to be predetermined. For example, this can be achieved by taking a screenshot of the page and capturing the rendering position information of the first code unit during a pre-conducted interactive test. Based on the screenshot and rendering position information, the first preview page can be generated under the corresponding relationship chain. If no predetermined first preview page exists under the second relationship chain, the first preview page will be blank in response to the fourth trigger operation. To avoid this, the first preview page can be generated by guiding the interaction based on the first-level association information, ensuring the comprehensive coverage of the first preview page. The pre-conducted interactive test can also be performed on the electronic device provided in this paper. To enable interactive testing, the code file corresponding to the first project can be obtained from the code repository when the project starts. Based on the code file, the first project can be deployed to the electronic device and the corresponding runtime environment can be configured, thereby providing a test interactive interface that can be used for test execution. The interactive object can be operated on the test interactive interface to test the first code unit.

[0057] The above technical description, by displaying a directed relationship graph and highlighting the first node link in response to the third trigger operation, and realizing the linked display of the first preview page in response to the fourth trigger operation, allows users to intuitively see the dependency location of the first code unit and the actual page effect, quickly locate the test target, significantly reduce the understanding cost and search cost, improve the completeness and operational efficiency of test guidance, and enhance the user experience.

[0058] In one scenario, the method provided herein may further include: in response to a fifth triggering operation, displaying code unit attribute information associated with a page element, the fifth triggering operation being associated with a third triggering event for the page element.

[0059] In one scenario, the fifth triggering operation can be considered as an interactive operation performed on a page element in the first preview page. For example, the fifth triggering operation includes mouse click, mouse hover, mouse over, long press, touch, double-click, and right-click menu activation. The code unit attribute information can be understood as the detailed project information of the first code unit. For example, it may include component name, reference relationships, and descriptions of changes, facilitating quick verification and location of the first code unit. The third triggering event can be understood as an event associated with the fifth triggering operation, and may include events such as click, hover, touch, long press, mouse over, double-click, and / or shortcut key triggering on page elements.

[0060] The above technical description, by highlighting page elements in the first preview page and supporting the viewing of code unit attribute information associated with page elements and direct jump to the real rendering interface in the test environment, reduces the cost of finding pages and components of interactive objects, the cost of understanding information, and the cost of switching operations, thereby improving the intuitiveness, accuracy, and efficiency of regression testing.

[0061] In one scenario, the method provided herein may further include: in response to a sixth triggering operation, displaying a project rendering interface, wherein the project rendering interface is formed by rendering the first project according to the second relationship chain, and the sixth triggering operation is associated with a fourth triggering event for the page element.

[0062] In one scenario, the sixth triggering operation can be understood as an interactive operation performed on page elements in the first preview page, different from the fifth triggering operation. This can also include mouse clicks, mouse hovers, mouse ingress, long presses, touches, double-clicks, and right-click menu activation. The project rendering interface can be considered a visual interactive page formed by realistically rendering the first project according to the second relationship chain. That is, it is the actual application page where the first code unit under the second relationship chain is located, directly jumpd to based on the triggering of page elements, and has a complete runtime environment loaded, supporting the interactive objects to perform actual interactive test operations. The fourth triggering event can be understood as an event associated with the sixth triggering operation.

[0063] To better display the content presented on the interface, Figure 4 A screenshot showing the user interface in another scenario where the code testing method is used is provided. For example... Figure 4 As shown, the display interface 4 includes a link list 41, a directed relationship graph 42, and a first preview page 43. The link list 41 includes a first relationship link 410 and other relationship links 411 besides the first relationship link. After the operator triggers the first relationship link 410 in the link list 41, the first node link 420 associated with the first relationship link can be highlighted in the directed relationship graph on the display interface. Similarly, the first preview page 43 associated with the first relationship link can also be displayed on the display interface. Corresponding to the first relationship link 410 in the link list, the first preview page 43 can also highlight the page element 430 corresponding to the first code unit. For example, if the page element 430 corresponding to the first code unit is a card element, the card element is highlighted here.

[0064] In one scenario, a command-line interface can be used instead of a visual interface to output information such as the test scope and the rendering location of the first code, which can also provide testers with test assistance to improve test efficiency and user experience.

[0065] As another optional implementation, the method provided in the text may further include: in response to a seventh triggering operation, obtaining code unit rendering information and page rendering information of the first code unit, wherein the seventh triggering operation is triggered by a rendering event associated with the first code unit; and generating a preview page of the first code unit under the corresponding relationship link based on the code unit rendering information, page rendering information, and the first hierarchical association information.

[0066] In one scenario, a rendering event can be considered a system event generated when the first code unit is rendered during the execution of the first project. This rendering event can be triggered by an interactive object performing interactive testing on the first code unit in a test environment. Code unit rendering information can be considered information that uniquely identifies the rendering subject and scene of the first code unit, used to associate the preview page with the corresponding relationship chain. For example, code unit rendering information may include the currently rendering first code unit, the page to which the currently rendering first code unit belongs, and the influence chain information corresponding to the first code unit. Page rendering information can be understood as visual data synchronously acquired based on the rendering behavior of the first code unit, used to restore the actual display effect of the first code unit on the page. For example, page rendering information may include a screenshot of the current page's actual rendering and the rendering position of the first code unit on that page.

[0067] In one scenario, the method for obtaining the code unit rendering information and page rendering information of the first code unit can be as follows: during the execution of the first project, an event capturing function, such as a hook function or a document object model function, pre-injected in the code framework is called to automatically obtain the rendering events associated with the first code unit; after obtaining any rendering event associated with the first code unit, the code unit rendering information and page rendering information are determined.

[0068] For example, when the event capture function is a hook function and the first code unit is a component code unit, upon recognizing the completion of rendering of any component code unit, it can be considered that the rendering event associated with the first code unit has been obtained, i.e., the seventh trigger operation is triggered. In response to the seventh trigger operation, a screenshot of the page to which the currently rendered component code unit belongs can be taken through the browser's application programming interface (API) to obtain visual information about the page. The screenshot file can be converted to a set format and stored in association with the current page's route address, rendering time, etc. Furthermore, the component tree of the current page can be obtained, and all component nodes in the component tree can be traversed from the root node using a depth-first search. The name of each component code unit can be identified. For each component node, the rendering position of the page element in the page after the component code unit is rendered can be obtained through the browser's native API functions, including the horizontal coordinate (the horizontal distance of the top-left corner of the page element relative to the left side of the browser viewport), the vertical coordinate (the vertical distance of the top-left corner of the page element relative to the top of the browser viewport), the actual rendering width of the page element, and the actual rendering height of the page element. Additionally, the page route of the page to which the component code unit belongs, the name of the parent component code unit, etc., can be recorded to form code unit rendering information.

[0069] For example, when the event capturing function is a document object model function and the first code unit is a component code unit, the rendering position of the page element rendered by the component code unit in the viewport and the corresponding code unit rendering information can be obtained by traversing the document object model tree.

[0070] In one scenario, one implementation of generating a preview page for the first code unit under a corresponding relationship link based on the code unit rendering information, page rendering information, and the first-level association information can be described as follows: based on the code unit rendering information, determine the relationship link matching the first code unit from the first-level association information; establish the association between the page rendering information and the relationship link, and generate a preview page for the first code unit under the relationship link.

[0071] In one scenario, based on the name of the first code unit, the page routing, and the influence link information in the code unit rendering information, a matching search is performed in the generated first-level association information to filter out the target relationship link that completely corresponds to the current rendering behavior. This target relationship link is then identified as the relationship link matching the first code unit, ensuring a precise correspondence between the rendering scene and the dependent links, avoiding scene confusion or link mismatch. Next, the captured real-world rendering screenshot of the current page, the rendering position of the first code unit on that page, and other page rendering information are associated with the matching relationship links. This ensures that each relationship link has a corresponding real-world rendering page display and a first code unit rendering position marker, thereby generating a preview page for testing, viewing, and positioning guidance for the first code unit within that relationship link. This preview page can be directly displayed in the display interface corresponding to the associated relationship link, providing testers with a realistic and intuitive rendering view.

[0072] The above technical description describes a method that, in response to a seventh trigger operation triggered by a rendering event associated with a first code unit, obtains page rendering information containing real-time rendering data and code unit rendering information representing dependency relationship links. Based on the code unit rendering information, page rendering information, and the first-level association information, the association between the preview page and the relationship link can be automatically established, thereby improving the generation efficiency and display accuracy of the preview page and providing reliable visualization support for subsequent testing.

[0073] Figure 5 This is a flowchart illustrating a code testing method under another scenario. In this scenario, the first code file represents the source code file of the first project. It is applicable to scenarios involving the initial full dependency analysis, full code unit scanning, and full relationship construction of the first project. Specifically, the first project does not have associated first-level relationship information, requiring the parsing of the entire code from scratch. This scenario's technical solution can be combined with implementation methods from other scenarios. For identical or related parts, descriptions from other scenarios can be used, and will not be repeated here. Figure 5 As shown, the method in this case may specifically include: S501. In response to the first triggering operation, if it is detected that the first project is not associated with the second-level association information, the source code file of the first project is obtained and the source code file is recorded as the first code file. The second-level association information represents the first-level association information that has been determined for the first project.

[0074] In one scenario, the second-level association information is used to characterize the first-level association information that the first project has already determined and stored through the historical analysis process. This includes data such as historically generated relationship links and directed relationship graphs.

[0075] In one scenario, if this step detects that the first project is not associated with any established first-level association information (i.e., second-level association information), it can be determined that a full code analysis is required to establish the first-level association information corresponding to the first project for the first time. Based on this, the full source code files of the first project can be directly obtained, such as the page files, component files, and function files under the corresponding target, and these full source code files are considered as the first code files, serving as the foundational data for this full parsing and dependency analysis. Optionally, after obtaining the source code files, invalid files, such as configuration files and log files, can be pre-filtered, and different types of source code files can be pre-processed to unify the code format and ensure compatibility for subsequent parsing.

[0076] S502. Parse the first code file to determine the first dependency information between code units in the first project.

[0077] In one scenario, the method for parsing the first code file and determining the first dependency relationship information between code units in the first project can be: parsing the first code file to obtain the first abstract syntax tree, and obtaining the first dependency relationship information between code units in the first project based on the first abstract syntax tree.

[0078] In one scenario, the first abstract syntax tree (BST) can be understood as a data structure generated from the source code file that clearly expresses the relationships between code, such as references, calls, and nesting levels, serving as the basis for extracting dependencies between code units. The first dependency information can be considered a complete record of the hierarchical and relational relationships between code units.

[0079] In one scenario, the first abstract syntax tree (BST) can be obtained by statically parsing the acquired first code file. In another implementation, tools such as code parsers used in code development parse the first code file, transforming the text-based file into a structured BST based on its file type.

[0080] In one implementation, a depth-first traversal of the first abstract syntax tree (BLT) can be used to collect the import dependencies of each first code file, construct a dependency mapping table, and record the associations between code units in the first code files. For example, the names of component code units imported from page files are associated with the page code unit, and functional code units imported from component files are associated with the component code units. Next, by traversing import nodes, declaration nodes, and call nodes in the BLT, and analyzing elements under specific fields (such as import content and import source path fields) in the nodes, the dependencies between various code units can be identified, thus obtaining the first dependency information between code units in the first project. Optionally, the smallest parsing granularity is the component code unit. For example, by analyzing specific fields in the nodes, the component code units that each page code unit depends on, the other component code units that each component code unit depends on, and the functional code units are extracted, thereby clarifying the hierarchical and association relationships between page code units, component code units, and functional code units, thus obtaining the first dependency information between code units.

[0081] S503. Generate a directed relationship graph of the first project based on the first dependency relationship information, and determine the relationship link corresponding to the code unit based on the directed relationship graph. The code unit includes page code unit, component code unit and function code unit, and the second code unit is contained in the code unit.

[0082] In one scenario, code units are treated as nodes, and directional edges are formed between nodes based on the first dependency information between code units. These edges represent the actual dependency and reference directions. For example, the node corresponding to a page code unit points to the node corresponding to the component code unit it depends on, and the node corresponding to a component code unit points to the node corresponding to the functional code unit it depends on. A directed relation graph of the entire first project is constructed using graph structure data (such as an adjacency list), thereby fully presenting the dependency transitive relationship, component reuse relationship, page reference relationship, and multi-level nesting relationship of all code units in the first project.

[0083] In one implementation, based on the constructed directed relationship graph, a path traversal is performed on each code unit. Taking the code unit as the starting point or ending point, a depth-first or breadth-first search is performed in the directed relationship graph to determine all reference paths involved by the code unit in the first project (including directly referenced pages and indirectly referenced pages; for example, if component code unit A is referenced by component code unit B, and component code unit B is referenced by page code unit C, then page code unit C is an indirect reference scenario of component code unit A). According to the actual reference relationship or dependency relationship between the code units on each reference path, the code units are connected in sequence to form a complete path, that is, the relationship link corresponding to the code unit is formed, that is, each reference path corresponds to one relationship link.

[0084] S504. Extract the component code unit from the code unit as the first code unit, and generate the first-level association information based on the directed relationship graph and relationship links.

[0085] In one scenario, the component code unit is a code unit with testing requirements. In this case, the component code unit can be selected and extracted from all code units and designated as the first code unit. Additionally, directed relationship graphs and relationship chains can be integrated to generate first-level association information.

[0086] In one implementation, the relationship links in the first-level association information can be associated and stored with the corresponding first code units using a key-value pair structure. This allows for the classification, storage, and management of multi-page reference scenarios for the first code units, thereby supporting quick querying of all reference scenarios based on component code units. For example, a relationship link index can be constructed using the unique identifier such as the name of the first code unit (e.g., a component code unit) as the key and all relationship links corresponding to the first code unit in the first-level association information as the values. Simultaneously, a bidirectional mapping relationship between page code units and component code units can be stored, facilitating querying associated component code units based on page code units, and vice versa. For example, the storage location can be a local database or cache, etc., and this embodiment is not limited to this.

[0087] In another implementation, the relationship links in the first-level association information can be associated and stored with the corresponding code units through a key-value pair structure, with the unique identifier such as the name of the code unit as the key and all the relationship links corresponding to the code unit in the first-level association information as the value.

[0088] The above technical description provides an implementation method for generating first-level association information. By generating first-level association information corresponding to the first project, which includes a full directed relationship graph and relationship links, it is possible to completely and accurately determine the entire scope of influence of the first code unit in the first project. This provides a unified and complete data foundation for subsequent determination of the test scope of the first code unit, generation of test scripts, and guidance of test execution.

[0089] S505. Based on the first-level association information, obtain the set of relationship links for the first code unit.

[0090] In one scenario, based on the generated and stored first-level association information, the name of the first code unit currently under test can be obtained. Then, by matching and querying the key-value pair structure using the relationship link index, all relationship links (i.e., all reference scenarios) corresponding to this first code unit can be extracted, forming a relationship link set. This relationship link set can accurately define the entire testing scope affected by the first code unit, ensuring no omissions or blind spots.

[0091] S506. Based on the set of relational links, obtain the test execution script for the first code unit.

[0092] In one scenario, one implementation of obtaining the test execution script of the first code unit based on the relationship link set can be described as follows: generating a test script set based on the relationship link set; using the first test script in the test script set as the test execution script; or, obtaining existing test scripts that have participated in the testing of the first code unit, filtering out the existing test scripts from the test script set to obtain a second test script, and using the second test script as the test execution script.

[0093] In one scenario, the first test script can be considered as each test script in the test script set; the second test script can be understood as the incremental test script obtained after filtering out existing test scripts that have participated in the first code unit test from the test script set; existing test scripts can be understood as test scripts that have been used for the first code unit test, and these scripts correspond to the relationship links that have been tested in the relationship link set. The test execution script can be considered as a script used to test and verify the first code unit in a test environment or a real page environment. For example, the test execution script may include related test content such as rendering verification, functional verification, interaction verification, and / or style verification to verify the rendering correctness, functional stability, and interactive usability of the first code unit in the corresponding interactive pages and application scenarios under the corresponding relationship links.

[0094] In one scenario, generating a test script set based on the set of relationship links can be achieved by: for each relationship link in the set, matching, generating, or filtering at least one corresponding test script based on page information, component information, dependency path information, and rendering scene information contained in the relationship link; and integrating the test scripts to generate a test script set that corresponds one-to-one with the set of relationship links. Alternatively, generating a test script set based on the set of relationship links can be achieved by: reading existing test scripts, parsing the existing relationship links covered by the existing test scripts, comparing the existing relationship links with each relationship link in the set, identifying any uncovered missing relationship links in the set, obtaining supplementary test scripts based on the missing relationship links, and generating a test script set based on the supplementary test scripts and existing test scripts. Obtaining supplementary test scripts based on missing relationship links can be achieved by: generating and displaying test script improvement information based on the missing relationship links; and obtaining the supplementary test scripts corresponding to the test script improvement information. The supplementary test scripts can be obtained by the interactive object inputting supplementary test scripts into the interactive interface based on the test script improvement information.

[0095] In one implementation, after generating the test script set, each test script in the test script set (i.e., the first test script) can be used as a test execution script. In another implementation, one scenario is that the first code unit has already been tested using existing test scripts corresponding to the first code unit. In this case, it can be determined by comparison whether the existing test scripts completely cover each test script in the test script set. If they do not completely cover all test scripts, the existing test scripts are removed from the test script set to obtain the second test scripts, which are the test scripts not covered by the existing test scripts. The second test scripts are then used as test execution scripts for further supplementary testing.

[0096] S507. Test the first code unit using the test execution script.

[0097] In one scenario, artificial intelligence can automatically call test execution scripts sequentially to perform tests on the first code unit in the corresponding relationship chain under the page scene, rendering environment, and dependency structure.

[0098] The above technical description takes into account both full regression testing and incremental change testing scenarios, avoiding the repetitive writing of test scripts and reducing invalid test executions. Based on the relationship chain set of the first code unit, it accurately defines the scope of influence and test boundaries of the first code unit. It automatically generates effective and comprehensive test execution scripts, and tests the first code unit based on the test execution scripts. This solves the problems of inaccurate test scope definition, missed tests and redundancy, and low script generation efficiency caused by the traditional method of manually sorting out dependencies to generate test execution scripts. It improves the completeness of code test scenario coverage and the adaptability and execution efficiency of automated testing.

[0099] Figure 6 This is a flowchart illustrating a code testing method in another scenario. In this technical solution, the first code file represents the code change file of the first project. It is suitable for incremental analysis scenarios where the first project already has first-level association information and only local code changes. Therefore, it is not necessary to re-parse the entire source code; only local incremental updates and corresponding tests are needed for the code change file. In this embodiment, the existing first-level association information is recorded as second-level association information. This technical solution can be combined with implementation methods in other scenarios. For the same or related parts, they can be combined with the descriptions of other scenarios, and will not be repeated here. Figure 6 As shown, the method in this case may specifically include: S601. In response to the first trigger operation, if it is detected that the first project is associated with second-level association information, the code change file of the first project is obtained and the code change file is recorded as the first code file.

[0100] In one scenario, the code change file can be understood as the source code file in the first project whose content has been added, modified, deleted, or logically adjusted during the iterative update process. It differs from the full source code file of the first project, representing the local code file involved in this change. The second-level association information contains a first-precedence, full-length directed relationship graph and relationship links for the first project. This step responds to the first trigger operation. If the second-level association information of the first project is detected, there is no need to perform a full source code analysis again. Only the code change file generated by the first project in this iteration can be identified, and this code change file is recorded as the first code file, serving as the target analysis object for subsequent incremental dependency analysis and incremental testing, thereby improving the efficiency of generating the subsequent first-level association information.

[0101] S602. Based on the first code file and the second-level association information, determine the relevant code units to be changed, and determine the second dependency information between the relevant code units to be changed.

[0102] In one scenario, the directed relationship graph and the code association file of the first code file can be obtained from the second-level association information. The first code file and the code association file are parsed to obtain the second abstract syntax tree and change-related code units. Based on the second abstract syntax tree, the second dependency information between the change-related code units is obtained.

[0103] In one scenario, the directed relationship graph built prior to the first project can be directly retrieved from the stored second-level association information, preserving the overall dependency architecture of the second code unit existing in the first project. Simultaneously, based on the file path and import / reference relationships of the modified code file, other code files with import, dependency, and reference relationships with that modified code file can be traced and located; these are denoted as the code-related files of the modified code file. In other words, code-related files can be understood as peripheral code files affected by the modified code file and having related coupling; they are objects that must be included in the incremental analysis simultaneously.

[0104] In one scenario, static parsing can be performed on the first code file (the code change file) and the matched associated code files. Lexical and syntactic analysis can be completed using a syntax parsing engine or tool to generate a second abstract syntax tree. Alternatively, the code change file and associated code files can be parsed to directly identify the code entities contained within them, extracting change-related code units. These change-related code units cover page code units, component code units, and functional code units, corresponding to all code units directly involved and indirectly related to this code change. Next, the import nodes, declaration nodes, and call nodes of the second abstract syntax tree can be traversed, parsing elements under specific fields, such as import items under the import content field and dependency paths under the import source path field. This extracts newly added, modified, and invalidated references and dependency associations between change-related code units, obtaining second dependency information to accurately depict the dependency structure changes brought about by local code changes.

[0105] S603. Take the component code unit in the relevant code unit as the first code unit, and update the second-level association information according to the second dependency information to obtain the first-level association information.

[0106] In one scenario, a component code unit is a code unit with testing requirements. In this case, the component code unit can be selected and extracted from all change-related code units, and it can be identified as the first code unit for this incremental test and analysis.

[0107] In one scenario, the method for updating the second-level association information based on the second dependency information to obtain the first-level association information can be as follows: update the directed relationship graph based on the second dependency information to obtain the updated directed relationship graph, determine the relationship links of the relevant code units based on the updated directed relationship graph, and generate the first-level association information based on the updated directed relationship graph and the relationship links.

[0108] In one scenario, the original directed graph in the second-level association information is locally updated using incremental iterations, based on the second dependency information as an incremental basis. During the update process, only the nodes and directed edges corresponding to the code units involved in the change are added, modified, removed, or reconstructed. Existing code units and original dependency structures that have not been changed or affected by the first project are retained and reused, forming the updated directed graph.

[0109] In one implementation, based on the updated directed relationship graph, for each change-related code unit, a graph structure path traversal method is used to retrieve the reference path, dependency transitive path, and nested association path of each change-related code unit in the first project, thus determining the relationship link corresponding to each change-related code unit. This relationship link is composed of page code units, component code units, and functional code units connected sequentially according to actual reference or dependency relationships, synchronously adapting the reference logic, dependency hierarchy, and call path after the code change.

[0110] In one scenario, the original relationship links in the second-level association information can be incrementally updated based on the relationship links of the changed relevant code units. Then, the updated directed relationship graph and the newly determined full relationship links are integrated to generate the first-level association information adapted to the code change.

[0111] In one implementation, the relationship links in the first-level association information can be associated and stored with the corresponding first code units using a key-value pair structure. In another implementation, the relationship links in the first-level association information can also be associated and stored with the corresponding code units using a key-value pair structure. The code units include the original code units in the second-level association information that are not affected by the code increment change and the change-related code units. The specific implementation of the association storage can be found in step S504, and will not be elaborated here.

[0112] S604. Test the first code unit based on the first-level association information.

[0113] The above technical description addresses a code iteration scenario in the first project where second-level dependency information has been associated. By identifying and extracting change-related code units based on code change files and their associated code files, and then accurately extracting the second dependency information between these change-related code units using a second abstract syntax tree, the original directed relationship graph is locally updated based on incremental dependencies. This accurately and efficiently locates the scope affected by the code change, avoiding the resource overhead and redundant computation of a full refactoring. Based on the updated directed relationship graph, the relationship links corresponding to each change-related code unit are accurately determined. Component code units are selected from these change-related code units as the first code unit, and first-level dependency information adapted to the code change scenario is generated. Finally, the test execution of the first code unit is completed based on the first-level dependency information. This ensures the real-time and accuracy of the hierarchical dependency information update after the code change, as well as the targeting and execution efficiency of the incremental regression test of the first code unit. This allows for rapid analysis and automated testing of frequent code changes during the iterative development of the first project.

[0114] Figure 7a and Figure 7b This is a flowchart illustrating an optional example of a code testing method for one scenario. For example... Figure 7a and Figure 7b As shown, the test scenario for the code testing method can be optimized into a test terminal 7 with testing capabilities. This test terminal 7 can provide a test system 70 for code testing, which can also be considered a test platform. Based on the execution logic of the code testing method provided in this paper, the test system 70 can preferably include three execution layers: a code testing layer 71, a test decision layer 72, and a visual interaction layer 73. The code testing layer 71, after deploying the test environment for the project, can support the project's startup and operation, participating in the actual testing of the code. The test decision layer 72 is used to determine the relevant data required for code testing and provide test decisions. The visual interaction layer 73 can provide an interactive interface for test assistance, displaying relevant content to guide code testing.

[0115] For example, such as Figure 7a As shown, the steps to implement one of the execution logics of the code testing method provided in this article through this testing system can be described as follows: S701, the code testing layer runs the deployed first project and displays the functional interface of the first project after it starts through the visual interaction layer, so as to respond to the interactive operations of the functional applications in the first project.

[0116] S702. The test decision layer responds to the test trigger operation and determines whether the hierarchical association information required for the test already exists. If not, execute S703; if yes, execute S706.

[0117] S703. Obtain the source code file of the first project, parse the source code file, obtain the first abstract syntax tree, and determine the first dependency relationship information between the code units contained in the first project based on the first abstract syntax tree.

[0118] S704. Generate a first directed relation graph for the first project based on the first dependency information, and determine the first relation link corresponding to the code unit in the first project based on the first directed relation graph.

[0119] S705, Extract component code units from code units as code units to be tested, and generate and store the first-level association information of the first project based on the first directed relationship graph and the first relationship link, and then jump to execute S710.

[0120] S706. Obtain the code change file of the first project, and record the existing hierarchical association information as the second hierarchical association information. Obtain the second directed relationship graph in the second hierarchical association information and obtain the code association file of the code change file.

[0121] S707. Parse the code change file and code association file to obtain the second abstract syntax tree and the change-related code units in the first project, and obtain the second dependency relationship information between the change-related code units based on the second abstract syntax tree.

[0122] S708. Update the second directed relation graph according to the second dependency information to obtain the first directed relation graph formed after the update, and determine the second relation link of the change-related code unit according to the first directed relation graph.

[0123] S709. Extract the component code unit from the change-related code unit as the code unit to be tested, and generate and store the first-level association information of the first project based on the first directed relationship graph and the second relationship link.

[0124] S710. Based on the first-level association information, obtain the set of relationship links of the code unit to be tested, and obtain the test execution script of the code unit to be tested according to the set of relationship links.

[0125] S711, The test decision layer provides the test execution script to the code test layer.

[0126] S712, The code testing layer tests the code unit under test through test execution scripts.

[0127] It can be seen that, Figure 7a The main points are: the test decision layer determines the code to be tested for the first project, and the hierarchical association information required for testing the code to be tested is given. It also provides the logic for determining the test script for the code to be tested based on the hierarchical association information, so as to provide the code testing layer with the logic for code testing.

[0128] Through the above execution logic, the complete location of the code under test can be guaranteed at the underlying implementation of code testing, and the completeness of scenario coverage of code testing can also be achieved.

[0129] Building upon this, the code testing method presented in this article also offers another test assistance feature: visualizing the status information, link information, and page component information involved in the code test to more intuitively assist and guide the effective completion of the code test.

[0130] For example, such as Figure 7b As shown, the steps for implementing another execution logic of the code testing method provided in this article through this testing system can be described as follows: The S720 code testing layer runs the first deployed project and displays the functional interface of the first project after it starts through the visual interaction layer, in order to respond to interactive operations for the functional applications in the first project.

[0131] S721, the code testing layer performs test operations on the code unit under test through test execution scripts.

[0132] S722. The test decision layer obtains the code unit rendering information and page rendering information of the target code unit during the process of responding to interactive operations and / or test operations for the first project in the code test layer through a specific function. The target code unit is any component code unit in the first project that has triggered a rendering event.

[0133] S723. Based on the code unit rendering information, determine the third relationship link that matches the target code unit from the first-level association information.

[0134] S724. Establish the association between page rendering information and the third relationship link, and generate a preview page of the target code unit under the third relationship link.

[0135] S725. During the process of the code testing layer responding to test operations, the test decision layer obtains the test status information of the code unit to be tested.

[0136] S726. The visual interaction layer responds to the guidance trigger operation and displays the display interface. The display interface presents the first content for code testing guidance. The first content is generated based on the first-level association information determined by the test decision layer.

[0137] The first content can be presented as a list of links, where each link entry corresponds to a relationship link of the code unit under test. Alternatively, the first content can be presented as a directed relationship graph, which is contained within the first-level association information, and its nodes are the code units in the first project.

[0138] The link entries in the link list are associated with test status information, which represents the test status of the corresponding link in the unit test of the code under test and is obtained by the test decision layer.

[0139] S727, the visual interaction layer responds to the highlight trigger operation, displays the first node link in the presented directed relationship graph, obtains the first preview page constructed by the test decision layer, and displays the first preview page on the display interface.

[0140] The first node link is composed of nodes and directed edges in the directed relationship graph. The first node link corresponds to the first relationship link in the link list, and the first preview page corresponds to the second relationship link in the link list. When the first relationship link and the second relationship link are the same, the highlight trigger operation is associated with the trigger event for the first relationship link (second relationship link). The first preview page is generated by the test decision layer based on the rendering event of the first code unit.

[0141] In this preview, page elements are highlighted and displayed in the first preview page. Page elements are the visual elements corresponding to the code unit to be tested in the first preview page.

[0142] S728, the visual interaction layer responds to the first display trigger operation and displays the code unit attribute information of the unit to be tested involved in the page element.

[0143] The first display trigger operation is associated with the trigger event for displaying information on page elements.

[0144] S729, The visual interaction layer responds to the second display trigger operation, renders and displays the project rendering interface of the first project.

[0145] The project rendering interface is the rendering page of the first project related to the second relationship chain, and is formed by rendering the first project according to the second relationship chain. The second display trigger operation is associated with the trigger events for page elements used for page display.

[0146] As can be seen, in the implementation of the test guidance content visualization method provided in this paper, the content to be displayed is determined by the test decision layer, and the display logic is responded to by the visual interaction layer.

[0147] It should be noted that the steps in the diagrams provided above do not necessarily have to be performed sequentially; they can also be performed simultaneously, as long as the entire code testing process can achieve accurate and comprehensive testing.

[0148] Figure 8 This is a schematic diagram of a code testing device under one scenario, such as... Figure 8 As shown, the device includes a first acquisition module 81, a first determination module 82, and a test execution module 83.

[0149] The first acquisition module 81 is used to acquire the first code file of the first project in response to the first trigger operation; The first determining module 82 is used to determine the first code unit and the first hierarchical association information based on the first code file, wherein the first hierarchical association information includes the association relationship between the first code unit and the second code unit; Test execution module 83 is used to test the first code unit based on the first level association information.

[0150] The aforementioned code testing device, in response to a first trigger operation, acquires the first code file of the first project; based on the first code file, it determines the first code unit and the first-level association information, which includes the association relationship between the first code unit and the second code unit; and tests the first code unit based on the first-level association information. Using this device, the device accurately identifies the first code unit with testing requirements based on the first code file and obtains first-level association information that comprehensively reflects the direct references, indirect dependencies, and usage paths of the first code unit in the first project. This provides data support to avoid test omissions due to the inability to identify indirectly affected pages. Executing tests on the first code unit according to the first-level association information covers all reference scenarios and associated pages of the first code unit, solving the problem of traditional testing focusing only on code execution while ignoring differences in reference scenarios. This avoids test omissions caused by multi-page reuse and multi-level indirect dependencies of the first code unit, improving the comprehensiveness and accuracy of testing. Furthermore, it ensures a high degree of match between the test scope and the actual impact of the first code unit, making code testing more targeted, avoiding invalid testing, and thus improving testing efficiency and quality.

[0151] In one scenario, the device may further include a link list display module, which is specifically used to: display a link list in response to a second trigger operation, wherein each link entry in the link list corresponds to a relational link of the first code unit, and the link list is generated based on the first-level association information for testing guidance of the first code unit.

[0152] In one scenario, the link entries in the link list are associated with test status information, which represents the test status of the corresponding related links in the first code unit test.

[0153] In one scenario, the device may further include a directed relationship graph display module, which is specifically used to: display a directed relationship graph in response to a third triggering operation, wherein a first node link is highlighted in the directed relationship graph, the first node link corresponding to a first relationship link in the link list, and the third triggering operation is associated with a first triggering event for the first relationship link.

[0154] In one scenario, the device may further include a preview page display module, which is specifically configured to: display a first preview page in response to a fourth triggering operation, the first preview page corresponding to a second relationship link in the link list; wherein the first preview page is generated based on the rendering of the first code unit, the page element corresponding to the first code unit is highlighted on the first preview page, and the fourth triggering operation is associated with a second triggering event for the second relationship link.

[0155] In one scenario, the device may further include an attribute information display module, which is specifically used to: display the attribute information of the code unit associated with the page element in response to a fifth triggering operation, the fifth triggering operation being associated with a third triggering event for the page element.

[0156] In one scenario, the device may further include a project rendering interface display module, which is specifically used to: display a project rendering interface in response to a sixth triggering operation, wherein the project rendering interface is formed by rendering the first project according to the second relationship chain, and the sixth triggering operation is associated with a fourth triggering event for the page element.

[0157] In one embodiment, the device may further include a preview page generation module, the preview page generation module comprising: The acquisition unit is used to acquire the code unit rendering information and page rendering information of the first code unit in response to the seventh triggering operation, wherein the seventh triggering operation is triggered by the rendering event associated with the first code unit; The preview page generation unit is used to generate a preview page of the first code unit under the corresponding relationship link based on the code unit rendering information, page rendering information and the first level association information.

[0158] In one scenario, the preview page generation unit can specifically be used for: Based on the rendering information of the code unit, determine the relationship link that matches the first code unit from the first-level association information; Establish the association between the page rendering information and the relationship link, and generate a preview page of the first code unit under the relationship link.

[0159] In one scenario, the first acquisition module 81 can specifically be used for: If it is detected that the first project is not associated with second-level association information, the source code file of the first project is obtained and recorded as the first code file; If the first project is found to be associated with the second-level association information, the code change file of the first project is obtained and recorded as the first code file; The second-level association information represents the first-level association information that has been determined for the first item.

[0160] In one scenario, the first item does not have any associated first-level information; The first determining module 82 can be specifically used for: Parse the first code file to determine the first dependency relationship information between code units in the first project; A directed relationship graph of the first project is generated based on the first dependency relationship information, and the relationship link corresponding to the code unit is determined based on the directed relationship graph. The code unit includes page code unit, component code unit and function code unit, and the second code unit is included in the code unit. Extract the component code unit from the code unit as the first code unit, and generate the first-level association information based on the directed relationship graph and the relationship link.

[0161] In one scenario, the first item already has first-level related information, and this first-level related information is denoted as second-level related information; The first determining module 82 can also be used specifically for: Based on the first code file and the second-level association information, the relevant code units for change are determined, and the second dependency relationship information between the relevant code units for change is determined; The component code unit in the change-related code unit is taken as the first code unit, and the second-level association information is updated according to the second dependency information to obtain the first-level association information.

[0162] In one scenario, the test execution module 83 may specifically include: The set acquisition unit is used to acquire the set of relationship links of the first code unit based on the first-level association information; The script acquisition unit is used to acquire the test execution script of the first code unit based on the set of relationship links; A test unit is used to test the first code unit using the test execution script.

[0163] In one scenario, the script acquisition unit can specifically be used for: A set of test scripts is generated based on the aforementioned set of relationship links; Use the first test script in the set of test scripts as the test execution script; or... Obtain existing test scripts that have participated in the first code unit test, filter out the existing test scripts from the test script set to obtain the second test script, and use the second test script as the test execution script.

[0164] The above-described code testing device can execute the code testing methods provided in any of the embodiments described herein, and has the corresponding functional modules and beneficial effects for executing code testing methods.

[0165] It is worth noting that the various units and modules included in the above-mentioned code testing device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments described herein.

[0166] The following is for reference. Figure 9 This document illustrates a schematic diagram of an electronic device (e.g., a terminal device or server) 900 suitable for implementing the above-described methods. The terminal device referred to herein may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), tablet computers (PADs), portable multimedia players (PMPs), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital televisions and desktop computers. Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments described herein.

[0167] like Figure 9As shown, the electronic device 900 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the electronic device 900. The processing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0168] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 An electronic device 900 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0169] In particular, according to embodiments of this document, the processes described in the above-referenced flowcharts can be implemented as computer software programs. For example, the technical solutions of this document include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by a processing device 901, it performs the functions defined in the methods of the embodiments of this document.

[0170] The names of messages or information exchanged between multiple devices in this document are for illustrative purposes only and are not intended to limit the scope of these messages or information.

[0171] The electronic device provided in this embodiment and the code testing method provided in the above technical solutions belong to the same inventive concept. Technical details not described in detail in this document can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.

[0172] This article provides a computer storage medium on which a computer program is stored, which, when executed by a processor, implements the code testing method provided in the above embodiments.

[0173] It should be noted that the computer-readable medium mentioned above can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory (EPROM, also known as flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this document, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0174] Based on one or more scenarios described herein, Example 1 provides a code testing method, comprising: in response to a first triggering operation, obtaining a first code file of a first project; determining a first code unit and first-level association information based on the first code file, wherein the first-level association information includes the association relationship between the first code unit and a second code unit; and testing the first code unit based on the first-level association information.

[0175] According to one or more scenarios in this article, Example 2 provides the method of Example 1, and further includes: optionally, in response to a second triggering operation, displaying a link list, wherein one link entry in the link list corresponds to a relational link of the first code unit, the link list being generated based on the first-level association information and used for test guidance of the first code unit.

[0176] According to one or more scenarios in this article, Example 3 provides the method of Example 2, which further includes: Optionally, the link entries in the link list are associated with test status information, the test status information representing the test status of the corresponding relationship link in the first code unit test.

[0177] According to one or more scenarios in this document, Example 4 provides the method of Example 2, which further includes: optionally, in response to a third triggering operation, displaying a directed relationship graph, wherein the directed relationship graph highlights a first node link, the first node link corresponding to a first relationship link in the link list, and the third triggering operation is associated with a first triggering event for the first relationship link.

[0178] According to one or more scenarios in this document, Example 5 provides the method of Example 2, which further includes: optionally, in response to a fourth triggering operation, displaying a first preview page, the first preview page corresponding to a second relationship link in the link list; wherein, the first preview page is generated based on the rendering of the first code unit, the page element corresponding to the first code unit is highlighted on the first preview page, and the fourth triggering operation is associated with a second triggering event for the second relationship link.

[0179] According to one or more scenarios in this document, Example Six provides the method of Example Five, which also includes: optionally, in response to a fifth triggering operation, displaying code unit attribute information associated with the page element, the fifth triggering operation being associated with a third triggering event for the page element.

[0180] According to one or more scenarios in this document, Example 7 provides the method of Example 5, which further includes: optionally, in response to a sixth triggering operation, displaying a project rendering interface, the project rendering interface being formed by rendering the first project according to the second relationship chain, the sixth triggering operation being associated with a fourth triggering event for the page element.

[0181] According to one or more scenarios in this article, Example 8 provides the method of Example 1, which further includes: optionally, in response to a seventh triggering operation, obtaining code unit rendering information and page rendering information of the first code unit, wherein the seventh triggering operation is triggered by a rendering event associated with the first code unit; and generating a preview page of the first code unit under the corresponding relationship link based on the code unit rendering information, page rendering information and the first hierarchical association information.

[0182] According to one or more scenarios in this document, Example 9 provides the method of Example 8, which optionally further includes: generating a preview page of the first code unit under the corresponding relationship link based on the code unit rendering information, page rendering information, and the first hierarchical association information, including: determining a relationship link matching the first code unit from the first hierarchical association information based on the code unit rendering information; establishing an association between the page rendering information and the relationship link; and generating a preview page of the first code unit under the relationship link.

[0183] Based on one or more scenarios described herein, Example 10 provides the method of Example 1, which optionally further includes: obtaining the first code file of the first project, comprising: detecting that the first project is not associated with second-level association information, obtaining the source code file of the first project, and recording the source code file as the first code file; detecting that the first project is associated with second-level association information, obtaining the code modification file of the first project, and recording the code modification file as the first code file; the second-level association information represents the first-level association information that the first project has determined.

[0184] Based on one or more scenarios described in this article, Example 11 provides the method of Example 1, which optionally further includes: the first project does not have associated first-level association information; determining the first code unit and the first-level association information based on the first code file includes: parsing the first code file to determine the first dependency relationship information between code units in the first project; generating a directed relationship graph of the first project based on the first dependency relationship information, and determining the relationship link corresponding to the code unit based on the directed relationship graph, wherein the code unit includes page code unit, component code unit and functional code unit, and the second code unit is included in the code unit; extracting the component code unit in the code unit as the first code unit, and generating the first-level association information based on the directed relationship graph and the relationship link.

[0185] Based on one or more scenarios described herein, Example Twelve provides the method of Example One, optionally further comprising: the first project already has first-level association information, which is denoted as second-level association information; determining the first code unit and the first-level association information based on the first code file includes: determining change-related code units based on the first code file and the second-level association information, and determining second dependency information between the change-related code units; taking the component code units in the change-related code units as the first code unit, and updating the second-level association information based on the second dependency information to obtain the first-level association information.

[0186] According to one or more scenarios in this article, Example Thirteen provides the method of Example One, which optionally further includes: testing the first code unit based on the first-level association information, including: obtaining a set of relationship links for the first code unit based on the first-level association information; obtaining a test execution script for the first code unit based on the set of relationship links; and testing the first code unit through the test execution script.

[0187] According to one or more scenarios in this document, Example Fourteen provides the method of Example Thirteen, which optionally further includes: obtaining the test execution script of the first code unit based on the relationship link set, including: generating a test script set based on the relationship link set; using the first test script in the test script set as the test execution script; or, obtaining existing test scripts that have participated in the testing of the first code unit, filtering out the existing test scripts from the test script set to obtain a second test script, and using the second test script as the test execution script.

[0188] According to one or more scenarios described herein, Example 15 provides a code testing apparatus, comprising: a first acquisition module, configured to acquire a first code file of a first project in response to a first trigger operation; a first determination module, configured to determine a first code unit and first hierarchical association information based on the first code file, wherein the first hierarchical association information includes the association relationship between the first code unit and a second code unit; and a test execution module, configured to test the first code unit based on the first hierarchical association information.

[0189] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol, such as HTTP (Hypertext Transfer Protocol), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include Local Area Networks (LANs), Wide Area Networks (WANs), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0190] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0191] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: in response to a first trigger operation, acquire a first code file of a first item; determine a first code unit and first-level association information based on the first code file, wherein the first-level association information includes the association relationship between the first code unit and a second code unit; and test the first code unit based on the first-level association information.

[0192] Computer program code for performing the operations described herein can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" programming language or similar 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).

[0193] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this document. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0194] The modules or units described herein can be implemented in software or hardware. The names of modules or units do not necessarily constitute a limitation on the module or unit itself.

[0195] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include at least one of the following: Field-Programmable Gate Array (FPGA), Application-Specific Integrated Circuit (ASIC), Application-Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), etc.

[0196] In the context of this document, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. 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 (flash memory), optical fibers, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0197] The above description is merely a preferred embodiment and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure herein is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed herein that have similar functions.

[0198] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of this document. Certain features described in the context of individual implementations may also be implemented in combination in a single implementation. Conversely, various features described in the context of a single implementation may also be implemented individually or in any suitable sub-combination in multiple implementations.

[0199] Although the subject matter has been described using a programming language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims.

Claims

1. A code testing method, comprising: In response to the first trigger operation, retrieve the first code file of the first project; Based on the first code file, a first code unit and a first-level association information are determined, wherein the first-level association information includes the association relationship between the first code unit and the second code unit; The first code unit is tested based on the first level of association information.

2. The method according to claim 1, further comprising: In response to the second triggering operation, a link list is displayed, wherein each link entry in the link list corresponds to a relationship link of the first code unit. The link list is generated based on the first-level association information and is used for test guidance of the first code unit.

3. The method according to claim 2, wherein the link entries in the link list are associated with test status information, and the test status information represents the test status of the corresponding related links in the first code unit test.

4. The method according to claim 2, further comprising: In response to a third triggering operation, a directed relationship graph is displayed, in which a first node link is highlighted. The first node link corresponds to a first relationship link in the link list, and the third triggering operation is associated with a first triggering event for the first relationship link.

5. The method according to claim 2, further comprising: In response to the fourth trigger operation, a first preview page is displayed, which corresponds to the second relationship link in the link list; The first preview page is generated based on the rendering of the first code unit, and the page element corresponding to the first code unit is highlighted on the first preview page. The fourth triggering operation is associated with the second triggering event for the second relationship link.

6. The method according to claim 5, further comprising: In response to the fifth triggering operation, the code unit attribute information associated with the page element is displayed, and the fifth triggering operation is associated with the third triggering event for the page element.

7. The method according to claim 5, further comprising: In response to the sixth triggering operation, a project rendering interface is displayed. The project rendering interface is formed by rendering the first project according to the second relationship link. The sixth triggering operation is associated with the fourth triggering event for the page element.

8. The method according to claim 1, further comprising: In response to the seventh triggering operation, the code unit rendering information and page rendering information of the first code unit are obtained, wherein the seventh triggering operation is triggered by the rendering event associated with the first code unit; Based on the code unit rendering information, page rendering information, and the first-level association information, a preview page of the first code unit under the corresponding relationship link is generated.

9. The method according to claim 8, wherein generating a preview page of the first code unit under the corresponding relationship link based on the code unit rendering information, page rendering information, and the first hierarchical association information comprises: Based on the rendering information of the code unit, determine the relationship link that matches the first code unit from the first-level association information; Establish the association between the page rendering information and the relationship link, and generate a preview page of the first code unit under the relationship link.

10. The method according to claim 1, wherein obtaining the first code file of the first project comprises: If it is detected that the first project is not associated with second-level association information, the source code file of the first project is obtained and recorded as the first code file; If the first project is found to be associated with the second-level association information, the code change file of the first project is obtained and recorded as the first code file; The second-level association information represents the first-level association information that has been determined for the first item.

11. The method according to claim 1, wherein the first item does not have associated first-level association information; The step of determining the first code unit and the first level association information based on the first code file includes: Parse the first code file to determine the first dependency relationship information between code units in the first project; A directed relationship graph of the first project is generated based on the first dependency relationship information, and the relationship link corresponding to the code unit is determined based on the directed relationship graph. The code unit includes page code unit, component code unit and function code unit, and the second code unit is included in the code unit. Extract the component code unit from the code unit as the first code unit, and generate the first-level association information based on the directed relationship graph and the relationship link.

12. The method according to claim 1, wherein the first item already has first-level association information, and the first-level association information is denoted as second-level association information; The step of determining the first code unit and the first level association information based on the first code file includes: Based on the first code file and the second-level association information, the relevant code units for change are determined, and the second dependency relationship information between the relevant code units for change is determined; The component code unit in the change-related code unit is taken as the first code unit, and the second-level association information is updated according to the second dependency information to obtain the first-level association information.

13. The method according to claim 1, wherein testing the first code unit based on the first hierarchical association information comprises: Based on the first-level association information, obtain the set of relationship links for the first code unit; Based on the set of relationship links, obtain the test execution script for the first code unit; The first code unit is tested using the test execution script.

14. The method according to claim 13, wherein obtaining the test execution script of the first code unit based on the relationship link set comprises: A set of test scripts is generated based on the aforementioned set of relationship links; The first test script in the test script set is used as the test execution script; or, Obtain existing test scripts that have participated in the first code unit test, filter out the existing test scripts from the test script set to obtain the second test script, and use the second test script as the test execution script.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the code testing method as described in any one of claims 1-14.