Code testing method, device, equipment, intelligent agent and storage medium

By analyzing the environment requirements of the intelligent agent generation environment, configuring the environment to generate the intelligent agent generation script, and building the test environment, the problem of blind looping in building code test environments in existing technologies is solved, and efficient test environment construction and test execution are achieved.

CN122261998APending Publication Date: 2026-06-23BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING BAIDU NETCOM SCI & TECH CO LTD
Filing Date
2026-03-23
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing technologies, building a code testing environment relies on expert experience, which can easily lead to a blind cycle of environment building and exploration iteration, making it difficult to build a complete and complex testing environment.

Method used

The analysis agent analyzes the information of the code to be tested to generate environment requirement information. The environment configuration agent generates the environment configuration script, the environment building agent builds the test environment, and the test execution agent executes the test, thus achieving self-correction and environment reuse and improving build efficiency.

Benefits of technology

It can quickly build an effective test environment, improve the efficiency of test environment construction and testing, reduce redundant information interference, and improve the success rate of construction and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122261998A_ABST
    Figure CN122261998A_ABST
Patent Text Reader

Abstract

The disclosure provides a code testing method, device, equipment, intelligent agent and storage medium, the artificial intelligence technical field, especially relates to the big model, intelligent agent, software engineering technical field. The specific implementation scheme of the code testing method is: the information of the to-be-tested code is analyzed by using an analysis intelligent agent, and environment requirement information is obtained; wherein the environment requirement information indicates the configuration requirement of the test environment used for constructing the to-be-tested code matched with the programming language of the to-be-tested code; a test environment is constructed based on the environment requirement information; and the to-be-tested code is tested in the test environment, and a test result is obtained; wherein the test result indicates the running state of the to-be-tested code in the effective test environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence technology, and more particularly to the fields of large models, intelligent agents, and software engineering technology, specifically to code testing methods, apparatus, devices, intelligent agents, and storage media. Background Technology

[0002] With the increasing application of large language models in software engineering, tasks such as code repository retrieval and code repair can be accomplished. However, the testing environment used to run these tasks still heavily relies on expert experience, easily falling into a blind cycle of environment construction and exploration iteration, making it difficult to build an effective environment for the code under test. Summary of the Invention

[0003] This disclosure provides a code testing method, apparatus, device, intelligent agent, and storage medium.

[0004] According to one aspect of this disclosure, a code testing method is provided, comprising: analyzing information of the code to be tested using an analytical agent to obtain environmental requirement information; wherein the environmental requirement information indicates the configuration requirements for constructing a test environment for the code to be tested that matches the programming language of the code to be tested; constructing a test environment based on the environmental requirement information; and executing tests on the code to be tested in the test environment to obtain test results; wherein the test results indicate the running state of the code to be tested in the effective test environment.

[0005] According to another aspect of this disclosure, a code testing apparatus is provided, comprising: an analysis module, a build module, and a test module.

[0006] The analysis module is used to analyze information about the code to be tested using an analytical agent to obtain environmental requirement information. The environmental requirement information indicates the configuration requirements for building the test environment that are compatible with the programming language of the code to be tested.

[0007] The build module is used to construct the test environment based on environmental requirements information.

[0008] The testing module is used to execute tests on the code to be tested in a test environment and obtain test results; the test results indicate the running status of the code to be tested in a valid test environment.

[0009] According to another aspect of this disclosure, an intelligent agent for code testing is provided, comprising: an input module, a processing module, and an output module. The input module receives information about the code to be tested. The processing module determines a target task based on the information about the code to be tested received by the input module, determines a target large-scale model based on the target task, and executes the code testing method described above by calling the target large-scale model to obtain test results. The output module outputs the test results obtained by the processing module.

[0010] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method described above.

[0011] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform the methods described above.

[0012] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described above.

[0013] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0014] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:

[0015] Figure 1 This illustration schematically shows an exemplary system architecture for applying code testing methods and apparatus according to embodiments of the present disclosure;

[0016] Figure 2 A flowchart illustrating a code testing method according to an embodiment of the present disclosure is shown schematically;

[0017] Figure 3 A schematic diagram illustrating the automated construction of a test environment according to an embodiment of the present disclosure is shown.

[0018] Figure 4 This illustration schematically shows a diagram of self-correcting instructions given by an environment-building agent during the building process according to an embodiment of the present disclosure;

[0019] Figure 5The illustration schematically depicts multi-agent interaction to construct an effective testing environment according to embodiments of the present disclosure;

[0020] Figure 6 The illustration shows a schematic diagram of running a test configuration script in a built test environment to verify whether the test environment is missing, according to an embodiment of the present disclosure;

[0021] Figure 7 A schematic diagram illustrating an environment reuse mechanism according to an embodiment of the present disclosure is shown.

[0022] Figure 8 A block diagram of a code testing apparatus according to an embodiment of the present disclosure is shown schematically;

[0023] Figure 9 A block diagram illustrating an intelligent agent for code testing according to embodiments of the present disclosure is shown schematically.

[0024] Figure 10 A block diagram of an electronic device suitable for implementing a code testing method according to an embodiment of the present disclosure is shown schematically. Detailed Implementation

[0025] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0026] In related examples, test environments are usually built based on expert experience, which can easily lead to a blind cycle of environment building and exploration iteration, making it difficult to fully build complex environment dependencies.

[0027] In view of this, the embodiments of this disclosure utilize an analytical agent to analyze the information of the code to be tested, thereby obtaining configuration requirements for building a test environment that matches the programming language of the code to be tested. Based on these configuration requirements, an effective test environment for code testing can be quickly built. This at least solves the problem in related examples where it is difficult to build a complete and complex environment dependency due to a lack of comprehensive analysis of the information of the code to be tested and environment operation planning, and further improves the efficiency of test environment construction and testing.

[0028] Figure 1 An exemplary system architecture for applying code testing methods and apparatus according to embodiments of this disclosure is illustrated.

[0029] It is important to note that Figure 1The examples shown are merely examples of system architectures that can be applied to the embodiments of this disclosure, to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments, or scenarios. For example, in another embodiment, an exemplary system architecture to which the code testing methods and apparatus can be applied may include a terminal device, but the terminal device can implement the code testing methods and apparatus provided by the embodiments of this disclosure without interacting with the server.

[0030] like Figure 1 As shown, the system architecture 100 according to this embodiment may include: an analysis agent 110. The information of the code to be tested may come from a code repository. A code repository is a digital carrier specifically used for centrally storing and managing all the code and related auxiliary files of the project to which the code to be tested belongs. Related auxiliary files may include, for example, configuration files, project documents, build scripts, static resources, etc.

[0031] The analysis agent 110 can traverse various file information in the target code repository corresponding to the code under test to obtain an analysis report. This analysis report includes at least the functional description information of the project to which the code under test belongs, the programming language environment information used when developing the code under test, the dependency package information related to the programming environment, the project's file structure information, and the one-way test execution method information.

[0032] Environment configuration requirements can include at least programming language environment information and programming environment-related dependency package information.

[0033] Since the environment configuration requirements are obtained by analyzing the information of the code to be tested, compared with the subjective experience of experts, it can provide an objective basis for the selection of the basic environment in the early stage of test environment construction, and provide an effective direction for the retrieval of key information for environment installation in the exploration iteration cycle, thereby further improving the efficiency of automated test environment construction.

[0034] Based on the environment configuration requirements, an effective test environment 101 for code testing can be quickly built so that tests can be performed on the code to be tested in this test environment, and the running status of the code to be tested can be obtained to characterize the running status of the code to be tested in the effective test environment.

[0035] Figure 2 A flowchart illustrating a code testing method according to an embodiment of the present disclosure is shown schematically.

[0036] like Figure 2 As shown, the method 200 includes operations S210 to S230.

[0037] When operating S210, the analytical agent analyzes the information of the code to be tested to obtain environmental requirement information.

[0038] When operating the S220, a test environment is built based on environmental requirements information.

[0039] By operating the S230, tests are executed on the code to be tested in the test environment, and the test results are obtained.

[0040] The information about the code to be tested can refer to the code repository information of the project to which the code to be tested belongs. This code repository information can include at least: all the code and related auxiliary files of the project to which the code to be tested belongs, such as configuration files, project documents, build scripts, static resources, etc.

[0041] The analysis agent can be a large language model used to perform codebase analysis tasks. For example, a prompt can be pre-configured for performing codebase analysis tasks. This prompt can include reference information about the requirements of the reference environment obtained from the analysis of the reference codebase. This allows the analysis agent to refer to the analysis process in the prompt and comprehensively analyze the information of the code to be tested to plan the construction direction of the test environment, thereby further improving the success rate of building an effective test environment.

[0042] For example, by using an analytical agent to analyze the information of the code to be tested, information about the programming language environment and the dependency packages related to the programming environment can be obtained.

[0043] In this embodiment of the disclosure, key information used to construct the test environment, such as programming language environment information and related dependency package information, is referred to as environment requirement information. Environment requirement information indicates the configuration requirements for constructing the test environment that matches the programming language of the code under test.

[0044] The embodiments disclosed herein can support multiple programming languages, such as Python, Go, Java and more than 10 other mainstream programming languages, and can adapt to different testing needs to build a rich testing environment.

[0045] In some embodiments, the environment requirement information may also indicate the base image version information in the configuration file of the project to which the code under test belongs. For example, the base image information for Python classes is stored in the setup.py configuration file. The base image information for Java classes is stored in the pom.xml file.

[0046] Therefore, the analytical agent can retrieve the base image version information from the information of the code under test based on the programming language type. When the configuration file includes multiple base image versions, higher version image data has higher compatibility, so it can be prioritized as the base image, thereby further improving the success rate of building the test environment.

[0047] Although the environment requirements information provides key configuration requirements for building a test environment, build failures may still occur due to issues such as missing dependencies or image version conflicts.

[0048] In some embodiments, before building the test environment, the analysis agent can be used to check for missing dependency packages or image version conflicts based on the generated environment requirement information, thereby overcoming potential problems during the building process in advance during the planning stage and further improving the building efficiency of the test environment.

[0049] After building the test environment, you can run the code to be tested within it to verify that the environment configuration is correct and effective. If running the code to be tested in the built test environment fails, it may be due to missing environment dependencies or incorrect test instructions.

[0050] In some embodiments, attribution analysis can be used to determine the cause of test failure. When it is determined that the test failure is caused by a missing environment dependency, the test environment can be rebuilt, or the existing test environment can be modified based on the cause of failure, until a valid test environment is obtained.

[0051] Finally, only by executing tests on the code under test in a valid test environment can we obtain test results that indicate the running status of the code under test in a valid test environment.

[0052] This embodiment of the disclosure analyzes the information of the code to be tested using an analytical agent to obtain the configuration requirements for building a test environment that matches the programming language of the code to be tested. Based on these configuration requirements, an effective test environment for code testing can be quickly built. This at least solves the problem in related examples where it is difficult to build a complete and complex environment dependency due to the lack of comprehensive analysis of the information of the code to be tested and environment operation planning, and further improves the efficiency of test environment construction and testing.

[0053] The following is combined with Figure 3 The specific embodiments of the above operation S220 will be described in detail.

[0054] According to embodiments of this disclosure, constructing a test environment based on environmental requirement information may include the following operations: using an environment configuration agent to generate an environment configuration script based on the environmental requirement information; and using an environment construction agent to construct the test environment by running the environment configuration script.

[0055] Figure 3 A schematic diagram illustrating an automated test environment construction according to an embodiment of the present disclosure is shown.

[0056] like Figure 3 As shown, the environment configuration agent 120 can generate environment configuration scripts based on environment requirement information.

[0057] The environment configuration agent 120 can be a large language model used to perform environment configuration script generation tasks. For example, a prompt can be pre-configured for performing the environment configuration script generation task. This prompt can include reference information for generating a reference environment configuration script based on reference environment requirements, so that the environment configuration agent can refer to the generation process in the prompt to generate an environment configuration script for building a test environment.

[0058] In some embodiments, the environment configuration script may include multiple initial executable instructions for building the test environment. These initial executable instructions may be instructions for installing environment dependency packages to be executed when building the test environment. These installation instructions may be retrieved from information in the code to be tested, such as a Python requirements.txt file, a Java pom.xml file, etc.

[0059] The environment configuration agent 120 sends the environment configuration script to the environment building agent 130. The environment building agent 130 is mainly used to run multiple initial execution instructions in the environment configuration script, install environment dependency packages, and then build the test environment.

[0060] The environment building agent 130 can determine the image startup container that matches the programming voice environment based on the environment requirement information, and then install the dependency packages in the image startup container through multiple initial execution instructions in the runtime environment configuration script to build the test environment.

[0061] Since the environment configuration script is generated based on environment requirements, compared with the subjective experience of experts, it can provide an objective basis for the selection of the basic environment in the early stage of test environment construction, and provide an effective direction for the retrieval of key information for environment installation in the exploration iteration cycle, thereby further improving the efficiency of automated test environment construction.

[0062] In some embodiments, the initial execution of instructions may fail due to various reasons during the test environment construction process. Therefore, by monitoring the execution status of the initial execution instructions in real time and dynamically adjusting them, the smoothness of the test environment construction process can be further improved.

[0063] In this embodiment of the disclosure, building an intelligent agent using an environment and constructing a test environment by running an environment configuration script may include the following operations: building an intelligent agent using an environment to execute multiple initial instructions to be executed; in response to detecting that any one of the multiple initial instructions to be executed has failed, building an intelligent agent using an environment to correct at least one of the multiple initial instructions to be executed; and building an intelligent agent using an environment to construct a test environment by executing the corrected instructions to be executed.

[0064] Figure 4 The illustration shows a schematic diagram of self-correcting instructions given by an environment-building agent during the building process according to an embodiment of the present disclosure.

[0065] like Figure 4 As shown, the environment building agent 130 can monitor the execution status of each initial instruction to be executed in real time. This execution status indicates whether the initial instruction to be executed was successful, and the reason for its success or failure. These reasons may include, for example, image version conflicts.

[0066] Since image version information is stored in configuration files in the code repository, when an image version conflict occurs, the environment build agent can dynamically adjust the initial execution instructions based on the reason for the failure. For example, the instruction to install the environment dependency package of version 2.0 can be changed to the instruction to install the environment dependency package of version 1.0.

[0067] Then, the test environment can be built by executing the revised instructions. During the instruction revision process, multiple iterations can be performed; for example, if an instruction fails to execute, the instruction can be revised and then re-executed. This continues until all instructions execute successfully, completing the test environment build.

[0068] By leveraging the self-correcting capabilities of intelligent agents built from the environment, the execution status of initial instructions to be executed is monitored in real time during the construction of the test environment, and the initial instructions to be executed are dynamically adjusted to further improve the smoothness of the test environment construction process.

[0069] In some embodiments, a maximum number of loop interactions can be set to prevent the environment building agent from performing multiple invalid corrections, which could affect the building process.

[0070] For example, if re-executing the corrected instructions successfully completes the test environment construction within the maximum number of loop interactions, then the testing phase can begin. If re-executing the corrected instructions still fails after reaching the maximum number of loop interactions, it indicates that the cause of the environment construction failure is something the environment construction agent itself cannot correct. In this case, it is necessary to return to the planning phase, re-analyze the cause of the environment failure, and regenerate the environment configuration script.

[0071] Figure 5 The illustration schematically depicts multi-agent interaction to construct an effective testing environment according to embodiments of the present disclosure.

[0072] like Figure 5 As shown, when the environment building agent 130 reaches the maximum number of loop interactions, it determines whether the test environment has been successfully built. If the building still fails, it is necessary to analyze the collaborative correction of the environment configuration script by agent 110 and environment configuration agent 120.

[0073] In some embodiments, the environment building agent 130 builds a test environment by running an environment configuration script, and may further include the following operations: in response to detecting a test environment building failure, the analysis agent 110 performs attribution analysis on a first log during the execution of the environment configuration script to obtain a first cause of failure; the environment configuration agent 120 corrects the environment configuration script based on environment requirement information and the first cause of failure; and the environment building agent 130 runs the corrected environment configuration script to build the test environment.

[0074] The first log can be the log collected by the environment building agent 130 during the execution of the initial environment configuration script. The initial environment configuration script can be generated by the environment configuration agent 120 based on the environment requirement information. Since the environment building agent 130 has failed to resolve the test environment construction failure issue despite multiple self-corrections, performing attribution analysis on the logs of the original environment configuration script during its execution can reduce the interference of redundant information introduced during the self-correction process of the environment building agent 130 on the attribution analysis results.

[0075] For example, by using the analytical agent 110 to perform attribution analysis on the first log during the execution of the environment configuration script, the first reason for failure may be that the "pip install wechaty==0.1.6" command could not find the corresponding executable installation data package during installation.

[0076] Using the environment configuration agent 120, based on the environment requirements information and the first reason for failure, the command to be executed in the environment configuration script is corrected to "pip install wechaty>=0.1.6".

[0077] Then, when the environment building agent 130 runs the modified environment configuration script, it can install environment dependency packages of version 0.1.6 or higher, thereby further improving the robustness of environment dependency package installation during the test environment building process.

[0078] In some embodiments, the environment building agent 130 may have fixed some problems during its self-correction process. Therefore, using the environment building agent to build a test environment by running an environment configuration script may further include the following operations: in response to detecting a failure to build the test environment based on the corrected environment configuration script, using an analysis agent to perform attribution analysis on the second logs during the execution of the corrected environment configuration script to obtain a second failure reason; using the analysis agent to correct the environment requirement information based on the second failure reason and the information of the code to be tested; and using the environment configuration agent to generate an environment configuration script to be run based on the corrected environment requirement information.

[0079] The second log may be the log collected by the environment building agent 130 during the execution of the revised environment configuration script. The revised environment configuration script may be obtained by the environment building agent 130 itself correcting the instructions to be executed during the execution of the initial environment configuration script.

[0080] In some embodiments, the modified environment configuration script can be modified a second time based on the second reason for failure. If the modified environment configuration script still fails to execute, the process can be traced back to the initial environment requirement analysis stage, and the analysis agent can be used to modify the environment requirement information.

[0081] To improve the accuracy of agent analysis, when analyzing agent 110 and re-analyzing environmental requirements, a comprehensive analysis of the information of the code to be tested and environmental operation planning can be carried out based on the second failure reason and the information of the code to be tested. During the analysis and planning process, the second failure reason should be given special attention to reduce the probability of the test environment failing to be rebuilt.

[0082] For example, when performing analysis, the analysis agent 110 can focus on retrieving configuration files related to the second cause of failure from the information of the code under test, and extract key information related to building the test environment, and send it to the environment configuration agent 120 so that the environment configuration agent can generate an environment configuration script to be run based on the key information, thereby reducing the probability of the execution failure of the instruction under test from the root.

[0083] When performing attribution analysis, the second log of the modified environment configuration script during its execution is analyzed, which can reduce the need for repeated modification operations on the modified commands.

[0084] To verify the effectiveness of the constructed test environment, embodiments of this disclosure perform tests on the code to be tested in the test environment and obtain test results. This may include the following operations: using a test configuration agent to generate a test configuration script based on code structure information and an environment configuration script; and using a test execution agent to execute tests on the code to be tested in the test environment by running the test configuration script and obtaining test results.

[0085] The information for the code to be tested includes code structure information, which can be stored in the project file structure information in the code repository.

[0086] The following is combined with Figure 6 A detailed description of a specific embodiment of operation S230 described above will be provided.

[0087] Figure 6 The illustration shows a schematic diagram of running a test configuration script in a built test environment to verify whether the test environment is missing, according to an embodiment of the present disclosure.

[0088] like Figure 6 As shown, during the planning phase, the analysis agent 110 can be used to analyze the information of the code to be tested to obtain code structure information. Then, the code structure is sent to the test configuration agent 140 to generate the test configuration script.

[0089] The test configuration script can include multiple initial test instructions for the code to be tested. Unlike the environment configuration script generation process, the test configuration agent 140 needs to retrieve the test-related configuration files from the information of the code to be tested based on the code structure, and combine them with the environment configuration script to generate a test configuration script that can be executed in a pre-configured test environment.

[0090] During the planning phase, environment configuration agent 120 generates an environment configuration script based on environmental requirement information. During the environment construction phase, the operations related to using environment construction agent 130 to run the environment configuration script to build the test environment have been described previously and will not be repeated here.

[0091] In addition, since the test configuration script can only run in the test environment, when generating the test configuration script, it is necessary to restrict the execution of multiple initial test commands only if the test environment is successfully built.

[0092] Finally, during the testing phase, test execution agent 150 is used to run test configuration scripts in the test environment built on the terminal to execute tests on the code under test and obtain test results.

[0093] The test configuration agent combines the environment configuration script to generate test configuration scripts that can be executed in a pre-configured test environment, further improving the consistency between the environment configuration logic and the test verification logic.

[0094] According to embodiments of this disclosure, using a test execution agent to execute tests on the code under test in a test environment by running a test configuration script and obtaining test results may include the following operations: using the test execution agent to execute multiple initial test instructions; in response to detecting that any one of the multiple initial test instructions has failed to execute, using the test execution agent to correct at least one of the multiple initial test instructions; and using the test execution agent to obtain test results by executing the corrected test instructions.

[0095] like Figure 6 As shown, the test execution agent 150 can monitor the execution status of each initial test instruction in real time. This execution status indicates whether the initial test instruction was executed successfully, and the reason for its success or failure. These reasons may include, for example, test instruction conflicts.

[0096] The test execution agent 150 can be used to execute large models of test instructions, and can be equipped with the ability to self-correct test instructions through pre-configured reference prompts. For example, when a conflict in test instructions is detected, it can automatically adjust the execution order of multiple test instructions.

[0097] Then, the code under test can be tested by executing the revised test instructions. During the instruction revision process, multiple iterations can be performed; for example, if the initial test instruction fails, the revised instruction can be executed, and then the revised instruction can be re-executed. This continues until all test instructions execute successfully, completing the test.

[0098] By leveraging the self-correcting capabilities of the test execution agent, the initial test instructions are dynamically adjusted in real time during the testing process to verify whether the constructed test environment meets the testing requirements.

[0099] In some embodiments, a maximum number of loop interactions can be set to prevent the test execution agent from performing multiple invalid corrections, which would affect the test process.

[0100] For example: if the test can be successfully completed by re-executing the modified test instruction within the maximum number of loop interactions, but still fails after re-executing the modified test instruction once the maximum number of loop interactions is reached, it indicates that the cause of the test failure is something the test execution agent itself cannot correct. In this case, it is necessary to return to the planning phase and re-analyze the cause of the test failure.

[0101] According to embodiments of this disclosure, a test execution agent is used to execute tests on the code under test in a test environment by running a test configuration script and obtaining test results. This can include the following operations: in response to a test result indicating test failure, an analysis agent is used to analyze third logs from multiple initial test commands during execution to obtain a third reason for failure; in response to a third reason for failure indicating a missing test environment, an environment configuration agent is used to correct the environment configuration script based on the third reason for failure; an environment building agent is used to update the test environment based on the corrected environment configuration script; and a test execution agent is used to run the test configuration script in the updated test environment.

[0102] like Figure 6 As shown, in the event of a test failure, the third log can be the log collected by the test execution agent 150 during the execution of the initial test command. The initial test command can be generated by the test configuration agent 140 based on environmental requirement information and a revised environment configuration script. The revised environment configuration script can represent the environment configuration script associated with the currently built test environment.

[0103] Since the test execution agent 150 failed to resolve the test failure issue despite multiple self-corrections, attribution analysis of the logs of the initial test configuration script associated with the currently constructed test environment during runtime can reduce the interference of redundant information introduced by the test execution agent 150 during its self-correction process on the attribution analysis results.

[0104] In the relevant examples, due to the lack of verification of the built test environment during test execution, it is impossible to determine whether the test failure is due to the environment configuration or the test configuration.

[0105] Therefore, when the analytical agent 110 performs attribution analysis on the third log in the embodiments of this disclosure, the root cause of the test failure can be accurately determined. This allows for targeted adjustments to the configuration script based on the root cause of the failure.

[0106] If the test failure is determined to be due to a missing test environment, such as an uninstalled dependency or an incompatibility between the installed dependency and the test instructions, the process can return to the planning phase. Environment configuration agent 120 can then be used to correct the environment configuration script based on the third reason for failure. Then, environment building agent 130 can be used to update the test environment based on the corrected environment configuration script.

[0107] During the test environment update process, if any installation command in the environment configuration script fails to execute correctly, the environment building agent 130 can still automatically correct the installation command until the test environment is built. This building process is the same as the initial test environment build and will not be described in detail here.

[0108] If the test environment update is successful, the testing phase will proceed again, using test execution agent 150 to execute the test configuration script. During the testing phase, you can choose to execute the test configuration script that failed in the previous execution to verify the rebuilt test environment.

[0109] In some embodiments, using a test execution agent to run a test configuration script in an updated test environment may further include the following operations: using the test configuration agent to generate a target test configuration script based on the revised environment configuration script and code structure information; and using the test execution agent to run the target test configuration script in the updated test environment.

[0110] For example, test configuration agent 140 can be used to regenerate the test configuration script, i.e., the target test configuration script, based on the revised environment configuration script and code structure information, to ensure consistency between the verification logic and the environment logic. Then, test execution agent 150 is used to run the target test configuration script in the rebuilt test environment.

[0111] When the cause of test failure is determined to be the lack of a test environment, the test environment is redesigned based on the cause of failure. This fundamentally solves the ineffective cycle caused by blind exploration and iteration, provides clear guidance for building a test environment, and further improves the efficiency of building an effective test environment.

[0112] If the test failure is determined to be due to an incorrect test command, it means that the currently built test environment is valid; the problem lies in command conflicts within multiple test commands in the test configuration script generated by the test configuration agent. These command conflicts may stem from incompatibility with the currently built test environment. Therefore, the test configuration script needs to be corrected.

[0113] According to embodiments of this disclosure, a test execution agent is used to execute tests on the code to be tested in a test environment by running a test configuration script and obtaining test results. The test execution agent may also include the following operations: in response to a third failure reason indicating that the test command is incorrect, the test configuration agent is used to correct the test configuration script based on the third failure reason; and the test execution agent is used to run the corrected test configuration script in the test environment and obtain test results.

[0114] like Figure 6 As shown, the test configuration agent 140 can be used to modify the test configuration script based on the third failure reason, so as to improve the matching degree between each test command in the modified test configuration script and the built test environment.

[0115] In some embodiments, the third failure reason, code structure information, test configuration script, and environment configuration script associated with the built test environment can be used as input to the test configuration agent 140, so that the test configuration agent 140 can determine the correction direction based on the third failure reason and make targeted corrections to the test configuration script according to the correction direction, thereby further improving the correction efficiency and reducing the number of interactions between agents.

[0116] Then, using test execution agent 150, the modified test configuration script is run in the built test environment to obtain the test results.

[0117] In some embodiments, the process of modifying the test configuration script may also be executed repeatedly until all test commands in the test configuration script are successfully executed.

[0118] In some embodiments, a maximum number of loop interactions can be set for the correction process of the test configuration script or environment configuration script. If the test still fails when the maximum number of loop interactions is reached, the process can return to the planning phase where the analysis agent generates the environment configuration requirements, and regenerate the environment configuration requirements based on the reason for the failure.

[0119] Based on the collaborative interaction between multiple intelligent agents, test instructions are dynamically adjusted according to feedback logs, which further improves the verification efficiency of the test environment, and thus enables the rapid and automated construction of an effective test environment.

[0120] In the relevant examples, the test environment is built from scratch for any test scenario, which is not only time-consuming, but also reduces the reuse rate of available resources.

[0121] Therefore, in this embodiment of the disclosure, the historical environment configuration script corresponding to the valid test environment that has been tested and verified can be stored in the resource pool. When it is necessary to build a test environment, the historical environment configuration script that matches the environment requirement information can be obtained; the historical environment configuration script can be modified to obtain the target environment configuration script that matches the environment requirement information; and the test environment can be built based on the target environment configuration script.

[0122] Figure 7 A schematic diagram illustrating an environment reuse mechanism according to an embodiment of the present disclosure is shown.

[0123] like Figure 7 As shown, this embodiment is similar to Figure 6 The difference in the illustrated embodiment is that the environment configuration agent 120 is replaced by an environment correction agent 160 in order to correct the historical environment configuration script.

[0124] In some embodiments, modifying a historical environment configuration script to obtain a target environment configuration script that matches the environment requirement information may include the following operations: using an analysis agent to analyze the historical code information and the information of the code to be tested associated with the historical environment configuration script to obtain environment requirement difference information; and using an environment correction agent to modify the historical environment configuration script based on the environment requirement difference information to obtain the target environment configuration script.

[0125] like Figure 7 As shown, initially, the analysis agent 110 can be used to analyze the differences in environmental requirements between historical code information and the information of the code to be tested. Then, the environment correction agent 160 is used to correct the historical environment configuration script based on the differences in environmental requirements. Since a valid test environment has already been successfully built when the historical environment configuration script was used, the parts of the valid test environment that are the same as the requirements of the current environment can be reused, reducing the probability of correcting the environment configuration script during the environment building process.

[0126] Furthermore, by modifying historical environment configuration scripts based on differences in environmental requirements, even if issues arise during subsequent environment building where installation commands fail to execute, only the commands in the modified scripts need to be corrected. Compared to building a test environment from scratch, the number of commands requiring correction is reduced. Therefore, the target environment configuration script further improves the success rate of building a valid test environment and increases the utilization rate of historically available resources compared to the environment configuration script generated when building a test environment from scratch.

[0127] Of course, referencing environment reuse mechanisms cannot completely guarantee the smooth progress of the testing phase, and there is still a possibility of test failure.

[0128] Therefore, in response to the test result indicating test failure, the analysis agent is used to analyze the fourth log during the execution of the code under test to obtain the fourth reason for failure.

[0129] The fourth log is collected when the code under test is run in the test environment built based on the target environment configuration script. Reasons for the fourth failure can include missing test environment settings and incorrect test commands.

[0130] like Figure 7 As shown, when the cause of test failure is determined to be the lack of a test environment, for example, when modifying the historical environment configuration script based on differences in environment requirements, the image version in the historical environment configuration script is lower, and the differences in environment requirements do not indicate differences in image version. Therefore, it may be possible that the lower version of the test environment has poor compatibility with the test commands during the test, resulting in test failure.

[0131] In some embodiments, in response to a fourth failure reason indicating a missing test environment, an environment correction agent is used to correct the target environment configuration script based on the fourth failure reason.

[0132] At this point, the environment correction agent 160 can be used to determine the correction direction based on the fourth failure reason, such as improving the image version. The installation instructions in the environment configuration script are then corrected according to this direction, thereby improving the compatibility of test commands. In the test environment rebuilt according to the target environment configuration script, the test commands are executed successfully.

[0133] It should be noted that the number of installation instructions corrected at this stage is usually very small, which is significantly reduced compared to the number of installation instruction correction operations required when building a test environment from scratch, further improving the efficiency of building a valid environment.

[0134] Besides a missing test environment, test failure could also be caused by an incorrect test command. In some embodiments, in response to a fourth failure reason indicating an incorrect test command, the test configuration agent is used to correct the test configuration script based on the fourth failure reason.

[0135] like Figure 7 As shown, during the testing phase, the test execution agent 150 can modify the test configuration script based on its own repair capabilities. In the modification process, in addition to the fourth failure reason, the modified environment configuration script output by the environment modification agent 160 can also be considered. For example, the modified environment configuration script can also be used as the input of the test execution agent 150 to ensure the consistency between the modified verification logic and the environment configuration logic.

[0136] If the test still fails after reaching the maximum number of interactions, it can return to the planning phase. The test configuration agent 140 uses the fourth reason for failure to determine the correction direction and corrects the erroneous test commands in the test configuration script.

[0137] In test command repair scenarios, due to the introduction of an environment reuse mechanism, the number of test commands that need to be corrected in similar test environments is far less than the number of test commands that need to be corrected in a test environment built from scratch, further improving test efficiency.

[0138] Figure 8 A block diagram of a code testing apparatus according to an embodiment of the present disclosure is shown schematically.

[0139] like Figure 8 As shown, the code testing device 800 may include an analysis module 810, a construction module 820, and a testing module 830.

[0140] The analysis module 810 is used to analyze the information of the code to be tested using the analysis agent to obtain environmental requirement information; wherein, the environmental requirement information indicates the configuration requirements for building the test environment for the code to be tested that match the programming language of the code to be tested.

[0141] Module 820 is used to build a test environment based on environmental requirements information.

[0142] Test module 830 is used to execute tests on the code to be tested in a test environment and obtain test results; the test results indicate the running status of the code to be tested in a valid test environment.

[0143] According to embodiments of this disclosure, the construction module 820 may include a first generation submodule and a first construction submodule.

[0144] The first generation submodule is used to generate environment configuration scripts based on environment requirement information by utilizing the environment configuration agent.

[0145] The first construction submodule is used to build intelligent agents using the environment and to build a test environment by running environment configuration scripts.

[0146] According to embodiments of this disclosure, the environment configuration script includes a plurality of initial executable instructions for building a test environment; the first build submodule may include: a first execution unit, a first correction unit, and a first build unit.

[0147] The first execution unit is used to construct an intelligent agent using the environment and execute multiple initial instructions to be executed.

[0148] The first correction unit is configured to, in response to detecting that any one of the plurality of initial instructions to be executed has failed, use an environment-constructed agent to correct at least one of the plurality of initial instructions to be executed.

[0149] The first building unit is used to build an intelligent agent using the environment by executing the modified instructions to be executed to build a test environment.

[0150] According to embodiments of this disclosure, the construction module 820 may further include: a first analysis submodule, a first correction submodule, and a second construction submodule.

[0151] The first analysis submodule is used to respond to the detection of a test environment build failure by using an analysis agent to perform attribution analysis on the first log during the execution of the environment configuration script to obtain the first cause of failure.

[0152] The first correction submodule is used to use the environment configuration agent to correct the environment configuration script based on the environment requirement information and the first failure reason.

[0153] The second construction submodule is used to build intelligent agents using the environment and to run the modified environment configuration script to build the test environment.

[0154] According to embodiments of this disclosure, the construction module 820 may further include: a second analysis submodule, a second correction submodule, and a second generation submodule.

[0155] The second analysis submodule is used to respond to the detection of a failure to build a test environment based on the modified environment configuration script, and to use the analysis agent to perform attribution analysis on the second log during the operation of the modified environment configuration script to obtain the second cause of failure.

[0156] The second correction submodule is used to correct the environmental requirement information based on the second failure reason and the information of the code to be tested, using the analysis agent.

[0157] The second generation submodule is used to generate an environment configuration script to be run based on the corrected environment requirement information using an environment configuration agent.

[0158] According to embodiments of this disclosure, the information of the code to be tested includes code structure information; the test module 830 may include: a third generation submodule and a first execution submodule.

[0159] The third generation submodule is used to generate test configuration scripts based on code structure information and environment configuration scripts using a test configuration agent. The test configuration scripts include multiple initial test instructions for the code to be tested. These multiple initial test instructions are executed when the test environment is successfully built.

[0160] The first execution submodule is used to utilize the test execution agent to execute tests on the code under test in the test environment by running the test configuration script and obtain the test results.

[0161] According to embodiments of this disclosure, the first execution submodule includes: a second execution unit, a second correction unit, and a first test unit.

[0162] The second execution unit is used to execute multiple initial test instructions using the test execution agent.

[0163] The second correction unit is used to correct at least one of the multiple initial test instructions in response to detecting that any one of the multiple initial test instructions has failed to execute.

[0164] The first test unit is used to obtain test results by executing the modified test instructions using a test execution agent.

[0165] According to embodiments of this disclosure, the first execution submodule further includes: a first analysis unit, a third correction unit, a first update unit, and a first running unit.

[0166] The first analysis unit, in response to a test result indicating a test failure, uses an analysis agent to analyze the third logs during the execution of multiple initial test commands to obtain the third reason for the failure.

[0167] The third correction unit is used to correct the environment configuration script based on the third failure reason in response to the third failure reason indicating that the test environment is missing.

[0168] The first update unit is used to build an intelligent agent using the environment and update the test environment based on the corrected environment configuration script.

[0169] The first execution unit is used to run test configuration scripts in the updated test environment using the test execution agent.

[0170] According to embodiments of this disclosure, the first execution submodule further includes: a first generation unit and a second running unit.

[0171] The first generation unit is used to generate the target test configuration script based on the corrected environment configuration script and code structure information using the test configuration agent.

[0172] The second execution unit is used to run the target test configuration script in the updated test environment using the test execution agent.

[0173] According to embodiments of this disclosure, the first execution submodule further includes a fourth correction unit and a third running unit.

[0174] The fourth correction unit is used to correct the test configuration script based on the third failure reason in response to the test command error indicated by the third failure reason, using the test configuration agent.

[0175] The third execution unit is used to run the modified test configuration script in the test environment using the test execution agent to obtain the test results.

[0176] According to embodiments of this disclosure, the code testing apparatus may further include: an acquisition module, a correction module, and a reconstruction module.

[0177] The acquisition module is used to retrieve historical environment configuration scripts that match the environment requirements information.

[0178] The correction module is used to correct historical environment configuration scripts to obtain target environment configuration scripts that match the environment requirements.

[0179] Rebuild the module to build the test environment based on the target environment configuration script.

[0180] According to embodiments of this disclosure, the correction module may include a difference analysis submodule and a script correction submodule.

[0181] The difference analysis submodule is used to analyze historical code information and test code information associated with historical environment configuration scripts using an analysis agent to obtain information on differences in environment requirements.

[0182] The script correction submodule is used to modify the historical environment configuration script based on the difference information of environment requirements using the environment correction agent, so as to obtain the target environment configuration script.

[0183] According to embodiments of this disclosure, the code testing apparatus may further include: an attribution analysis module and an environment correction module.

[0184] The attribution analysis module is used to analyze the fourth log during the execution of the code under test in response to test result indications of test failure, and obtain the fourth reason for failure by using the analysis agent.

[0185] The environment correction module is used to correct the target environment configuration script based on the fourth failure reason when the test environment is missing, using the environment correction agent.

[0186] According to embodiments of this disclosure, the code testing apparatus may further include: a configuration correction module, configured to, in response to a fourth failure reason indicating a test command error, use a test configuration agent to correct the test configuration script based on the fourth failure reason.

[0187] Figure 9 A block diagram of an agent for code testing according to an embodiment of the present disclosure is shown schematically.

[0188] like Figure 9 As shown, in the embodiments of this disclosure, inspired by the von Neumann architecture in modern computer theory, such as... Figure 9 As shown, the AI ​​agent 900 may include three core modules: an input module 910, an output module 920, and a processing module 930. The processing module 930 may include a control unit 931, a storage unit 932, and a computing unit 933.

[0189] The input module 910 is responsible for receiving or sensing information such as queries, requests, instructions, signals, or data from the outside world (e.g., users or the external environment), and converting it into a format that the AI ​​agent 900 can understand and process. The input module 910 is the primary link for the AI ​​agent 900 to interact with the outside world. It enables the AI ​​agent 900 to efficiently and accurately obtain the necessary "sensory" information from the outside world and respond to this information.

[0190] In the example, the input information received by the input module 910 can be the information of the code to be tested described above.

[0191] In the example, the processing module 930 is the core support for the AI ​​agent 900's ability to handle complex tasks. The processing module 930 can determine the target task based on the input information received by the input module 910, determine the large model based on the target task, execute the code testing method based on the large model described above by calling the large model, and output the test results.

[0192] In the example, the control unit 931 in the processing module 930 will continuously interact with the storage unit 932, the arithmetic unit 933, and / or the output module 920 during operation. However, it should be noted that in the embodiments of this disclosure, the control unit 931 initiates communication with the storage unit 932, the arithmetic unit 933, and / or the output module 920 as a single initiator, and there is no communication coupling between the storage unit 932, the arithmetic unit 933, and the output module 920.

[0193] In the example, the performance of the control unit 931 is closely related to the large model on which the AI ​​agent 900 is based. To fully leverage the capabilities of the large language model, the internal structure of the control unit 931 can be designed to be highly configurable and scalable to handle various types of tasks and requirements in real-world scenarios.

[0194] Storage unit 932 can be responsible for remembering information such as historical dialogues and event streams. Configuration information, target text, and data resources generated in each round can be included in storage unit 932.

[0195] In the example, after receiving a configuration generation request, the AI ​​agent 900 can determine the configuration intent from the initial text using an intent recognition model. The configuration intent can be stored in storage unit 932. The AI ​​agent 900 can retrieve relevant data resources from storage unit 932 and feed them back to control unit 931. Then, control unit 931 can use the returned data resources to obtain configuration data corresponding to the initial text. It can also retrieve relevant text data from storage unit 932 and feed it back to control unit 931. Then, control unit 931 can use the returned text data to obtain test results and pass these test results to output module 920.

[0196] The arithmetic unit 933 can be viewed as a predefined tool library. Renderers and display controls, as mentioned earlier, can be included in the arithmetic unit 933.

[0197] In the example, when the AI ​​agent 900 needs to render multiple output data, it can call the relevant renderer and display controls from the computing unit 933 and feed them back to the control unit 932. Then, the control unit 932 can use the fed-back renderer and display controls to render the first search result and pass it to the output module 920. It's understandable that although large language models have excellent language understanding and generation capabilities, like humans, the tasks they can solve without any tools are very limited. When the AI ​​agent 900 is given the ability to call tools, it can perform tasks such as using a calculator to complete mathematical calculations, using Python to perform data analysis, and using a search engine to complete prediction tasks.

[0198] In the example, output module 920 can output the test results described above.

[0199] The AI ​​agent 900 according to embodiments of this disclosure can simply and effectively improve the level of intelligence, as well as enhance flexibility and versatility.

[0200] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0201] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the methods described above.

[0202] According to embodiments of the present disclosure, a non-transitory computer-readable storage medium stores computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described above.

[0203] According to an embodiment of this disclosure, a computer program product includes a computer program that, when executed by a processor, implements the method described above.

[0204] Figure 10 A schematic block diagram of an example electronic device 1000 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0205] like Figure 10 As shown, device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in read-only memory (ROM) 1002 or a computer program loaded into random access memory (RAM) 1003 from storage unit 1008. The RAM 1003 may also store various programs and data required for the operation of device 1000. The computing unit 1001, ROM 1002, and RAM 1003 are interconnected via bus 1004. Input / output (I / O) interface 1005 is also connected to bus 1004.

[0206] Multiple components in device 1000 are connected to I / O interface 1005, including: input unit 1006, such as keyboard, mouse, etc.; output unit 1007, such as various types of monitors, speakers, etc.; storage unit 1008, such as disk, optical disk, etc.; and communication unit 1009, such as network card, modem, wireless transceiver, etc. Communication unit 1009 allows device 1000 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0207] The computing unit 1001 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 performs the various methods and processes described above, such as code testing methods. For example, in some embodiments, the code testing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on device 1000 via ROM 1002 and / or communication unit 1009. When the computer program is loaded into RAM 1003 and executed by the computing unit 1001, one or more steps of the code testing method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute code testing methods by any other suitable means (e.g., by means of firmware).

[0208] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0209] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0210] In the context of this disclosure, 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 (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

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

[0212] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0213] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, distributed system servers, or servers incorporating blockchain technology.

[0214] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0215] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A code testing method, comprising: An analytical agent analyzes information about the code to be tested to obtain environmental requirement information; wherein, the environmental requirement information indicates the configuration requirements for building a test environment that matches the programming language of the code to be tested. The test environment is constructed based on the aforementioned environmental requirements information; and The code to be tested is tested in the test environment to obtain test results; wherein the test results indicate the running status of the code to be tested in the effective test environment.

2. The method according to claim 1, wherein, The construction of the test environment based on the environmental requirements information includes: Using an environment configuration agent, an environment configuration script is generated based on the aforementioned environment requirement information; and The intelligent agent is constructed using the environment, and the test environment is built by running the environment configuration script.

3. The method according to claim 2, wherein, The environment configuration script includes multiple initial executable instructions for building the test environment; The process of building an intelligent agent using an environment, and constructing the test environment by running the environment configuration script, includes: An intelligent agent is constructed using the environment to execute the multiple initial instructions to be executed; In response to detecting that any one of the plurality of initial instructions to be executed has failed, an agent is constructed using the environment to correct at least one of the plurality of initial instructions to be executed; and An intelligent agent is constructed using the environment described above, and the test environment is built by executing the modified instructions to be executed.

4. The method according to claim 2 or 3, wherein, The method of constructing an intelligent agent using an environment, and constructing the test environment by running the environment configuration script, further includes: In response to the detection of a test environment construction failure, the analytical agent performs attribution analysis on the first log of the environment configuration script during its execution to obtain the first cause of failure. Using the environment configuration agent, the environment configuration script is modified based on the environment requirement information and the first failure reason; and The intelligent agent is constructed using the environment described above, and the modified environment configuration script is run to construct the test environment.

5. The method according to claim 4, wherein, The method of constructing an intelligent agent using an environment, and constructing the test environment by running the environment configuration script, further includes: In response to the detection that the test environment failed to be built based on the modified environment configuration script, the analysis agent is used to perform attribution analysis on the second log during the operation of the modified environment configuration script to obtain the second reason for failure. Using the analytical agent, the environmental requirement information is corrected based on the second failure reason and the information of the code under test; and Using the aforementioned environment configuration agent, an environment configuration script to be run is generated based on the corrected environment requirement information.

6. The method according to any one of claims 1-5, wherein, The information of the code to be tested includes code structure information; The test results obtained by performing tests on the code to be tested in the test environment include: Using a test configuration agent, a test configuration script is generated based on the code structure information and the environment configuration script; wherein, the test configuration script includes multiple initial test instructions for the code to be tested; the multiple initial test instructions are executed when the test environment is successfully built; and The test execution agent is used to run the test configuration script to perform tests on the code to be tested in the test environment and obtain the test results.

7. The method according to claim 6, wherein, The method of utilizing a test execution agent to run the test configuration script and perform tests on the code under test in the test environment to obtain the test results includes: The test execution agent is used to execute the plurality of initial test instructions; In response to detecting that any one of the plurality of initial test instructions has failed to execute, the test execution agent corrects at least one of the plurality of initial test instructions; and The test execution agent is used to obtain the test results by executing the modified test instructions.

8. The method according to claim 6 or 7, wherein, The method of utilizing a test execution agent to run the test configuration script and perform tests on the code under test in the test environment to obtain the test results includes: In response to the test result indicating test failure, the analysis agent analyzes the third logs of the multiple initial test commands during execution to obtain the third reason for failure. In response to the third failure reason indicating a missing test environment, the environment configuration agent is used to modify the environment configuration script based on the third failure reason. An intelligent agent is constructed using the aforementioned environment, and the test environment is updated based on the corrected environment configuration script; and The test configuration script is run in the updated test environment using the test execution agent.

9. The method according to claim 8, wherein, The step of using the test execution agent to run the test configuration script in the updated test environment further includes: Using the test configuration agent, based on the revised environment configuration script and the code structure information, a target test configuration script is generated; and The target test configuration script is run in the updated test environment using the test execution agent.

10. The method according to claim 8 or 9, wherein, The step of utilizing a test execution agent to execute tests on the code under test in the test environment by running the test configuration script and obtaining the test results further includes: In response to the third failure reason indicating a test command error, the test configuration agent is used to correct the test configuration script based on the third failure reason; and The test execution agent is used to run the modified test configuration script in the test environment to obtain the test results.

11. The method according to any one of claims 1-10, further comprising: Obtain historical environment configuration scripts that match the environmental requirements information; The historical environment configuration script is modified to obtain a target environment configuration script that matches the environment requirement information; and The test environment is constructed based on the target environment configuration script.

12. The method according to claim 11, wherein, The historical environment configuration script is modified to obtain a target environment configuration script that matches the environment requirement information, including: The analytical agent analyzes historical code information associated with the historical environment configuration script and information about the code to be tested to obtain environmental requirement difference information; and An environment correction agent is used to correct the historical environment configuration script based on the environmental requirement difference information to obtain the target environment configuration script.

13. The method according to claim 11 or 12, further comprising: In response to the test result indicating test failure, the analysis agent is used to analyze the fourth log of the code under test during its execution to obtain the fourth reason for failure. as well as In response to the fourth failure reason indicating a missing test environment, the environment correction agent is used to correct the target environment configuration script based on the fourth failure reason.

14. The method according to claim 13, further comprising: In response to the fourth failure reason indicating an error in the test command, the test configuration agent is used to correct the test configuration script based on the fourth failure reason.

15. A code testing apparatus, comprising: An analysis module is used to analyze information about the code to be tested using an analytical agent to obtain environmental requirement information; wherein, the environmental requirement information indicates the configuration requirements for building a test environment that matches the programming language of the code to be tested. A construction module is used to construct the test environment based on the environmental requirements information; and The testing module is used to perform tests on the code under test in the testing environment and obtain test results; wherein the test results indicate the running status of the code under test in the effective testing environment.

16. An intelligent agent for code testing, comprising: The input module is used to receive information about the code to be tested; The processing module is configured to determine a target task based on the information of the code to be tested received by the input module, determine a target large model based on the target task, and execute the method described in any one of claims 1-14 by calling the target large model to obtain test results; as well as An output module is used to output the test results obtained by the processing module.

17. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-14.

18. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-14.

19. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-14.