Code testing method and device, computer equipment and storage medium

By analyzing interface keywords in project code and automatically generating test cases using AI big models, the problem of low efficiency of manual design test cases in the existing technology is solved, and more efficient and accurate code testing is achieved.

CN119441060APending Publication Date: 2025-02-14SHENZHEN LEXIN SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411771008.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

Existing code testing methods rely on manual analysis of exception scenarios and manually designing test cases, resulting in low testing efficiency and easy to miss exception testing scenarios, making it difficult to accurately conduct code testing.

Method used

Determine the interface keywords by analyzing the interface code blocks in the project code, automatically generate test cases using the preset AI model and target prompt database, and detect and update the abnormal test cases through the AI ​​model to improve the prompt words Library to guide code testing for the next test cycle.

Benefits of technology

Improve the generation efficiency of test cases and the accuracy of code testing, ensure more comprehensive test coverage, and enhance the efficiency and reliability of code testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441060A_ABST
    Figure CN119441060A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a code testing method and device, computer equipment and a storage medium. The method comprises the steps of obtaining a current project code of a current test period of a target project; determining an interface keyword corresponding to each interface code block; determining the cue word corresponding to the interface keyword in the target cue word bank as the cue word corresponding to the interface code block; based on a preset AI large model, respectively constructing test cases of the interface code blocks according to the corresponding cue words, and executing the test cases; performing cue word detection processing on a target interface code block corresponding to the abnormal test case through an AI large model to obtain a target cue word corresponding to the target interface code block, and updating a target cue word library according to the target cue word, the updated target prompt word bank is used for guiding the AI large model to carry out code testing on the project code of the next test period of the target project. By implementing the method provided by the embodiment of the invention, the code testing efficiency is improved, and code testing is more accurately carried out.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a code testing method, apparatus, computer equipment and storage medium. Background Art

[0002] Before a project product is put into use, in order to reduce the frequency of failures during use, it is often necessary to test each interface. The testing of the interface depends on the design of test cases.

[0003] Abnormal scenarios in the code are high-risk areas. However, current code testing mostly relies on testers to analyze abnormal scenarios and manually design test cases based on the analysis results. This not only has low testing efficiency, but it is also easy to have incomplete consideration of abnormal test scenarios, resulting in incomplete test case design and difficulty in accurately testing code. Summary of the invention

[0004] The embodiments of the present application provide a code testing method, apparatus, computer device, and storage medium, which can improve code testing efficiency and perform code testing more accurately.

[0005] In a first aspect, an embodiment of the present application provides a code testing method, which includes: obtaining a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks;

[0006] Determine the interface keywords corresponding to each of the interface code blocks by analyzing each of the interface code blocks in the current project code;

[0007] According to the interface keywords corresponding to the interface code blocks, the prompt words corresponding to the interface keywords in the target prompt word library are determined as the prompt words corresponding to the interface code blocks, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to a plurality of interface keywords respectively;

[0008] Based on the preset AI big model, test cases of each interface code block are constructed according to the prompt words of each interface code block, and each test case is executed to obtain the case execution results corresponding to each test case;

[0009] Determine the test case whose test case execution result is a test case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as a target interface code block;

[0010] The target interface code block is processed by the AI ​​big model for prompt word detection to obtain the target prompt word corresponding to the target interface code block, and the target prompt word library is updated according to the target prompt word and the target interface keyword corresponding to the target interface code block. The updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

[0011] In a second aspect, an embodiment of the present application further provides a code testing device, which includes:

[0012] A transceiver unit, used to obtain a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks;

[0013] The processing unit is used to determine the interface keywords corresponding to each interface code block by analyzing each interface code block in the current project code; according to the interface keywords corresponding to each interface code block, determine the prompt words corresponding to the interface keywords in the target prompt word library as the prompt words of the corresponding interface code block, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to multiple interface keywords; based on the preset AI big model, construct test cases for each interface code block according to the prompt words of each interface code block, and execute each test case to obtain the test case execution results corresponding to each test case; determine the test case whose test case execution result is a test case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as a target interface code block; perform prompt word detection processing on the target interface code block through the AI ​​big model to obtain the target prompt word corresponding to the target interface code block, and update the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block, and the updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

[0014] In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.

[0015] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program includes program instructions, and wherein the program instructions can implement the above method when executed by a processor.

[0016] The embodiment of the present application provides a code testing method, device, computer equipment and storage medium. On the one hand, after obtaining the current project code of the target project, the present application will determine the interface keywords of each interface code block by analyzing each interface code block in the current project code, and then determine the prompt words corresponding to each interface code block through the target prompt word library corresponding to the target project, and automatically generate test cases for each interface code block through the AI ​​big model and the prompt words corresponding to each interface code block, thereby improving the efficiency of test case generation and thus improving the efficiency of code testing; on the other hand, for the target interface code block with test exceptions, the present application will further perform prompt word detection on the target code block through the AI ​​big model, and update the target prompt word library based on the detected prompt words to improve the prompt words of the target project. In the next test cycle of the target project, based on the updated target prompt word library, the AI ​​big model can be guided to generate more comprehensive test cases, and the code can be tested based on more comprehensive test cases, so that the code can be tested more accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A schematic diagram of an application scenario of the code testing method provided in an embodiment of the present application;

[0019] Figure 2 A flowchart of a code testing method provided in an embodiment of the present application;

[0020] Figure 3 A flowchart of a code testing method provided by another embodiment of the present application;

[0021] Figure 4 A schematic block diagram of a code testing device provided in an embodiment of the present application;

[0022] Figure 5 A schematic block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0024] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0025] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0026] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0027] Embodiments of the present application provide a code testing method, apparatus, computer equipment, and storage medium.

[0028] The executor of the code testing method may be the code testing device provided in the embodiment of the present application, or a computer device integrating the code testing device, wherein the code testing device may be implemented in hardware or software, the computer device may be a terminal or a server, and the terminal may be a smart phone, a tablet computer, a PDA, or a laptop computer, etc.

[0029] See also Figure 1 , Figure 1 Schematic diagram of an application scenario of the code testing method provided in the embodiment of the present application. The code testing method is applied to Figure 1In the computer device, an AI big model is preset in the computer device. When the computer device obtains the current project code of the current test cycle of the target project, the current project code includes multiple interface code blocks; then the interface code blocks in the current project code are analyzed to determine the interface keywords corresponding to each interface code block; then according to the interface keywords corresponding to each interface code block, the prompt words corresponding to the interface keywords in the target prompt word library are determined as the prompt words corresponding to the interface code block, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to multiple interface keywords; based on the preset AI big model, test cases for each interface code block are constructed according to the prompt words of each interface code block , and execute each test case to obtain the case execution results corresponding to each test case; determine the test case whose case execution result is a case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as the target interface code block; perform prompt word detection processing on the target interface code block through the AI ​​big model to obtain the target prompt word corresponding to the target interface code block, and update the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block. The updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project. In addition, the abnormal test case is analyzed and processed by the AI ​​big model to output the target test result.

[0030] Among them, before the project code of a project is completed, it needs to go through multiple rounds of testing (the embodiment of the present application defines one round of testing as a testing cycle) during the process of improving the project code and adding functions. The embodiment of the present application can gradually improve the prompt vocabulary library corresponding to the project during multiple rounds of testing to generate more comprehensive test cases.

[0031] The computer device provided in the present application can perform code testing for project codes of multiple different projects, and set different prompt word libraries for different projects. The initial prompt word library for each project can be set by the tester, or it can be generated by the AI ​​big model when initially testing the project code of the corresponding project.

[0032] For ease of understanding, taking the target prompt word library as an example, the following examples are given to illustrate the interface keywords in the prompt word library and the prompt words corresponding to each interface keyword:

[0033] The interface keywords in the target prompt word library include at least one of an input interface keyword, an output interface keyword, a database interface keyword, a cache interface keyword, and a queue interface keyword.

[0034] Among them, the prompt words corresponding to the input interface keywords include: general verification (including missing mandatory parameters, mandatory parameters are empty, field type does not match, length does not match, boundary value verification, non-enumeration value, default value verification, JSON format, parameter transmission error or multiple transmission, special characters, parameter combination verification and parameter dependency), amount verification (including unit conversion, amount precision, rounding method, processing of 0 data, processing of negative values ​​and business upper and lower limits), digital verification (including negative numbers, 0, oversized numbers, integers, decimals, digital types), date verification (including default values, considering -2880000 when transmitting timestamps, date comparison: pay attention to the format consistency of the time field, newly added date fields, historical data processing, special February verification) and other verifications (including concurrent locks, idempotence verification, status verification, retry strategy and conditional judgment);

[0035] The prompt words corresponding to the database interface keywords include data uniqueness (including processing duplicate data), data consistency (including data consistency of multiple tables), data association impact (including the impact of updating data on other related data and paging query of large amounts of data), master-slave query (including distinguishing master-slave query and preventing overload), data double writing (including data consistency verification and processing logic for double writing failure) and switching between new and old data tables (including data switching strategy and compatibility);

[0036] The prompt words corresponding to the cache interface keywords include: cache timeout (including cache expiration time and design consistency, cache timeout failure to return specified data), cache breakdown (including processing large concurrent access to cache data and concurrent access verification after cache data failure), cache preheating (including cache preheating time and timing verification and request update and query interface data correctness during preheating) and data consistency (concurrent execution of updates and queries, verification of functions and data consistency); the prompt words corresponding to the queue interface keywords include: message body parameter verification (including processing parameters that are empty, abnormal, etc.), message retransmission (including idempotence verification to ensure that messages are not consumed repeatedly), message loss (including message loss caused by network reasons, whether there is a retransmission mechanism) and failure retry; the prompt words for the output interface keywords include: abnormal output (including return field being empty, return field missing, new or changed return parameters (historical compatibility), whether abnormal return code processing is correct, response timeout processing, and error code and mapping (note unknown error code)).

[0037] Figure 2 Schematic diagram of the code testing method provided in the embodiment of the present application. Figure 2 As shown, the method includes the following steps S110-S160.

[0038] S110: Acquire a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks.

[0039] In this embodiment, the current project code is the project code that the target project currently needs to test, which is composed of multiple interface code blocks. When the tester needs to perform code testing on the current project code, the current test project is input into the code testing device, so that the code testing device obtains the current project code of the current test cycle of the target project.

[0040] In order to distinguish which project the current project code corresponds to, the acquired current project code also carries a project identifier, and the project identifier is used to determine a target prompt word library corresponding to the target project from multiple prompt word libraries.

[0041] S120: Determine interface keywords corresponding to each interface code block by analyzing each interface code block in the current project code.

[0042] In this embodiment, the source code of each interface code block can be analyzed based on the AI ​​big model to determine the keywords corresponding to each interface code block, and the source code of each interface code block can be identified based on other AI analysis modules (such as a keyword recognition model) to determine the keywords corresponding to each interface code block.

[0043] S130. According to the interface keywords corresponding to the interface code blocks, respectively, the prompt words corresponding to the interface keywords in the target prompt word library are determined as prompt words corresponding to the interface code blocks.

[0044] The target prompt word library is a prompt word library corresponding to the target item, and the target prompt word library includes prompt words corresponding to a plurality of interface keywords respectively.

[0045] In this embodiment, after determining the interface keywords corresponding to each interface code block, a target prompt word library corresponding to the target project is determined from multiple stored prompt word libraries, and then the prompt words corresponding to the interface keywords in the target prompt word library are determined as the prompt words corresponding to the interface code block.

[0046] S140. Based on the preset AI big model, test cases for each of the interface code blocks are constructed according to the prompt words of each of the interface code blocks, and each of the test cases is executed to obtain the case execution results corresponding to each of the test cases.

[0047] Specifically, for each interface code block, the AI ​​big model analyzes the source code of the corresponding interface code block under the guidance of the corresponding prompt words, and constructs test cases for the interface source code, where the AI ​​big model needs to construct multiple test cases for each interface code block.

[0048] Among them, in order to facilitate the AI ​​big model to analyze the prompt words of each interface code block, after determining the prompt words of each interface code block, the method also includes:

[0049] Insert the prompt words of each interface code block into the corresponding interface code block as the code embedding point of the corresponding interface code block;

[0050] At this time, based on the preset AI big model, test cases of each interface code block are constructed according to the prompt words of each interface code block, including:

[0051] The AI ​​big model is used to scan the code points of each interface code block to determine the prompt words of each interface code block; the scenario simulation data of each interface code block is constructed according to the prompt words of each interface code block; and the test cases of each interface code block are determined according to the scenario simulation data of each interface code block.

[0052] Specifically, the above-mentioned scenario simulation data includes environmental parameters, input parameter data and corresponding output parameter data. In order to generate more comprehensive test cases, the AI ​​big model in this embodiment generates multiple scenario simulation data for each interface code block, and generates multiple test cases for each interface code block based on each scenario simulation data.

[0053] After the test cases are generated, each test case is executed through the AI ​​big model or an additional automated testing tool (such as WeTest) to obtain the test case execution results corresponding to each test case.

[0054] In this embodiment, each interface code block corresponds to multiple prompt words. When generating a test case, it is necessary to consider all prompt words corresponding to the interface code block, wherein each prompt word can represent an abnormal scenario.

[0055] Among them, the use case execution result includes use case execution exception or use case execution normal. Use case execution exception means that the execution output of the corresponding test case does not match the output parameter data specified in the test case. Use case execution normal means that the execution output of the corresponding test case matches the output parameter data specified in the test case.

[0056] When a test case is executed abnormally, there are usually two situations. The first is that the code itself is abnormal. The second is that the prompt words are not comprehensive enough and not all abnormal scenarios are considered when generating the test case.

[0057] For example, for a certain interface code block, the prompt words determined include missing required parameters, required parameters are empty, field type does not match, and length does not match. Then, corresponding test cases are generated for these prompt words. After executing the test case to test the interface code block, it is found that the output execution result does not match the expected result (output parameter data). At this time, it is necessary to perform further prompt word detection and processing on the interface code block through the AI ​​big model. The prompt words obtained after detection include missing required parameters, required parameters are empty, field type does not match, length does not match, and boundary value check. After comparison, it can be seen that the prompt word boundary value check is missing. The reason for the test abnormality may be that when generating the scenario simulation data for the test case, the abnormal test scenario was not fully considered, and the boundary value check was not considered.

[0058] S150: Determine the test case whose test case execution result is a test case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as a target interface code block.

[0059] In this embodiment, when the use case execution is abnormal, it may be because the prompt words are not comprehensive enough and not all abnormal scenarios are considered when generating the test case. Therefore, this embodiment needs to mark the interface code block corresponding to the abnormal test case as the target interface code block, and further perform prompt detection on the target interface code block through the AI ​​big model (which can also be understood as abnormal scenario detection).

[0060] In some embodiments, after determining the test case whose test case execution result is a test case execution exception as an abnormal test case, the method further includes:

[0061] The abnormal test cases are subjected to abnormal analysis processing by the AI ​​big model to obtain the code abnormality causes of the abnormal test cases; an abnormal test case set including each of the abnormal test cases and an abnormal analysis result including each of the code abnormality causes is generated; a target test result is generated according to the abnormal test case set and the abnormal analysis result; and the target test result is output.

[0062] The step of generating a target test result according to the abnormal test case set and the abnormal analysis result includes:

[0063] A target project template corresponding to the target project is determined from a plurality of preset project templates; and the abnormal test case set and the abnormal analysis result are templated based on the target project template to obtain the target test result.

[0064] Specifically, the target test result may be outputted by sending an email including the target test result to a corresponding user terminal, or by pushing a push message including the target test result to WeChat of the corresponding user terminal, and so on.

[0065] S160. Perform prompt word detection processing on the target interface code block through the AI ​​big model to obtain the target prompt word corresponding to the target interface code block, and update the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block. The updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

[0066] Specifically, the AI ​​big model detects the source code of the target interface code through preset prompt word detection rules to detect the target prompt word corresponding to the target interface code block from the source code, wherein the detected target prompt word corresponds to a line or an identifier in the source code.

[0067] Wherein, there are multiple target prompt words, and updating the target prompt word library according to the target prompt words and the target interface keywords corresponding to the target interface code block includes:

[0068] Determine whether the target prompt word library contains a prompt word corresponding to the target interface keyword; if the target prompt word library contains a prompt word corresponding to the target interface keyword, update the prompt word corresponding to the target interface keyword in the target prompt word library according to a plurality of the target prompt words; if the target prompt word library does not contain a prompt word corresponding to the target interface keyword, store the target interface keyword and a plurality of the target prompt words corresponding to the target interface keyword in the target prompt word library.

[0069] Specifically, for the interface code blocks that already exist in the project code of the previous test cycle of the current test cycle, the target prompt word library contains prompt words for the target interface keywords. For the newly added interface code blocks, the target prompt word library does not contain prompt words corresponding to the target interface keywords. Therefore, when updating the target prompt word library, for the existing interface code blocks, the newly detected target prompt words need to be added to the corresponding target keywords. For the newly added interface code blocks, the target interface keywords and all detected target prompt words need to be stored in the target prompt word library.

[0070] To summarize, on the one hand, after obtaining the current project code of the target project, the present application will determine the interface keywords of each interface code block by analyzing each interface code block in the current project code, and then determine the prompt words corresponding to each interface code block through the target prompt word library corresponding to the target project, and automatically generate test cases for each interface code block through the AI ​​big model and the prompt words corresponding to each interface code block, thereby improving the efficiency of test case generation and thus improving the efficiency of code testing; on the other hand, for the target interface code block with test exceptions, the present application will further perform prompt word detection on the target code block through the AI ​​big model, and update the target prompt word library based on the detected prompt words to improve the prompt words of the target project. In the next test cycle of the target project, based on the updated target prompt word library, the AI ​​big model can be guided to generate more comprehensive test cases, and the code can be tested based on more comprehensive test cases, so that the code can be tested more accurately.

[0071] Figure 3 FIG. 1 is a flowchart of a code testing method provided by another embodiment of the present application. Figure 3 As shown, the code testing method of this embodiment includes steps S210-S280:

[0072] S210, obtaining a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks;

[0073] S220, determining the interface keywords corresponding to the interface code blocks respectively by analyzing the interface code blocks in the current project code;

[0074] S230, according to the interface keywords corresponding to the interface code blocks, determining the prompt words corresponding to the interface keywords in the target prompt word library as the prompt words corresponding to the interface code blocks, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to a plurality of interface keywords respectively;

[0075] S240, based on the preset AI big model, construct test cases for each of the interface code blocks according to the prompt words of each of the interface code blocks, and execute each of the test cases to obtain the test case execution results corresponding to each of the test cases;

[0076] S250, determining the test case whose test case execution result is a test case execution exception as an abnormal test case, and determining the interface code block corresponding to the abnormal test case as a target interface code block;

[0077] S260. Perform prompt word detection processing on the target interface code block through the AI ​​big model to obtain the target prompt word corresponding to the target interface code block, and update the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block. The updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

[0078] Among them, steps S210-S260 are similar to steps S110-S160 in the above embodiment and are not repeated here.

[0079] S270: Obtain the code of the item to be tested in the next test cycle of the target item.

[0080] The project code to be tested in the next test cycle is the project code obtained by developers repairing the interface code block code and / or adding the interface code block code based on the current project code in the current test cycle.

[0081] When it is necessary to perform code testing on the code of the project to be tested in the next test cycle, the code of the project to be tested is input into the code testing device, so that the code testing device obtains the code of the project to be tested to perform code testing on the code of the project to be tested.

[0082] S280: Use the project code to be tested as the current project code, use the updated target prompt word library as the target prompt word library corresponding to the target project, and return to execute step S220.

[0083] To summarize, on the one hand, after obtaining the current project code of the target project, the present application will determine the interface keywords of each interface code block by analyzing each interface code block in the current project code, and then determine the prompt words corresponding to each interface code block through the target prompt word library corresponding to the target project, and automatically generate test cases for each interface code block through the AI ​​big model and the prompt words corresponding to each interface code block, thereby improving the efficiency of test case generation and thus improving the efficiency of code testing; on the other hand, for the target interface code block with test exceptions, the present application will further perform prompt word detection on the target code block through the AI ​​big model, and update the target prompt word library based on the detected prompt words to improve the prompt words of the target project. In the next test cycle of the target project, based on the updated target prompt word library, the AI ​​big model can be guided to generate more comprehensive test cases, and the code can be tested based on more comprehensive test cases, so that the code can be tested more accurately.

[0084] Figure 4 4 is a schematic block diagram of a code testing device 400 provided in an embodiment of the present application. Figure 4As shown, corresponding to the above code testing method, the present application also provides a code testing device 400. The code testing device 400 includes a unit for executing the above code testing method, and the code testing device 400 can be configured in a desktop computer, a tablet computer, a laptop computer, etc. Specifically, please refer to Figure 4 The code testing device 400 includes a transceiver unit 401 and a processing unit 402 .

[0085] The transceiver unit 401 is used to obtain the current project code of the current test cycle of the target project, wherein the current project code includes a plurality of interface code blocks;

[0086] The processing unit 402 is used to determine the interface keywords corresponding to each interface code block by analyzing each interface code block in the current project code; according to the interface keywords corresponding to each interface code block, determine the prompt words corresponding to the interface keywords in the target prompt word library as the prompt words corresponding to the interface code block, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to multiple interface keywords; based on the preset AI big model, construct test cases for each interface code block according to the prompt words of each interface code block, and execute each test case to obtain each The test cases respectively correspond to the test case execution results; the test case whose test case execution result is a test case execution exception is determined as an abnormal test case, and the interface code block corresponding to the abnormal test case is determined as the target interface code block; the target interface code block is processed by the AI ​​big model to obtain the target prompt word corresponding to the target interface code block, and the target prompt word library is updated according to the target prompt word and the target interface keyword corresponding to the target interface code block, and the updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

[0087] In some embodiments, after executing the step of determining the prompt words corresponding to the interface keywords in the target prompt word library as the prompt words corresponding to the interface code blocks according to the interface keywords respectively corresponding to the interface code blocks, the processing unit 402 is further used to:

[0088] Insert the prompt words of each interface code block into the corresponding interface code block as the code embedding point of the corresponding interface code block;

[0089] At this time, the processing unit 402 executes the preset AI big model to construct the test case steps of each interface code block according to the prompt words of each interface code block, specifically for:

[0090] The AI ​​big model is used to scan the code points of each interface code block to determine the prompt words of each interface code block; the scenario simulation data of each interface code block is constructed according to the prompt words of each interface code block, and the scenario simulation data includes environmental parameters, input parameter data and output parameter data; the test cases of each interface code block are determined according to the scenario simulation data of each interface code block.

[0091] In some embodiments, after the processing unit 402 executes the step of determining the test case whose test case execution result is a test case execution exception as an abnormal test case, the method further includes:

[0092] The abnormal test cases are subjected to abnormal analysis processing by the AI ​​big model to obtain the code abnormality causes of the abnormal test cases; an abnormal test case set including each of the abnormal test cases and an abnormal analysis result including each of the code abnormality causes is generated; a target test result is generated according to the abnormal test case set and the abnormal analysis result; and the target test result is output.

[0093] In some embodiments, when the processing unit 402 executes the step of generating a target test result according to the abnormal test case set and the abnormal analysis result, it is specifically used to:

[0094] A target project template corresponding to the target project is determined from a plurality of preset project templates; and the abnormal test case set and the abnormal analysis result are templated based on the target project template to obtain the target test result.

[0095] In some embodiments, after executing the step of updating the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block, the processing unit 402 is further configured to:

[0096] The code of the project to be tested of the next test cycle of the target project is obtained through the transceiver unit 401; the code of the project to be tested is used as the current project code, and the updated target prompt word library is used as the target prompt word library corresponding to the target project, and the step of determining the interface keywords corresponding to each interface code block respectively by analyzing each interface code block in the current project code is returned to execute.

[0097] In some embodiments, there are multiple target prompt words. When the processing unit 402 executes the step of updating the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block, it is specifically used to:

[0098] Determining whether the target prompt word library contains a prompt word corresponding to the target interface keyword;

[0099] If the target prompt word library contains a prompt word corresponding to the target interface keyword, updating the prompt word corresponding to the target interface keyword in the target prompt word library according to the plurality of target prompt words;

[0100] If the target prompt word library does not include the prompt word corresponding to the target interface keyword, the target interface keyword and a plurality of target prompt words corresponding to the target interface keyword are stored in the target prompt word library.

[0101] In some embodiments, the interface keywords in the target prompt vocabulary include at least one of an input interface keyword, an output interface keyword, a database interface keyword, a cache interface keyword, and a queue interface keyword.

[0102] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned code testing device and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.

[0103] The above code testing device can be implemented in the form of a computer program. Figure 5 Runs on the computer device shown.

[0104] See also Figure 5 , Figure 5 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.

[0105] See also Figure 5 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .

[0106] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a code testing method.

[0107] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .

[0108] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a code testing method.

[0109] The network interface 505 is used to communicate with other devices over the network. Figure 5 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0110] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:

[0111] Obtaining a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks;

[0112] Determine the interface keywords corresponding to each of the interface code blocks by analyzing each of the interface code blocks in the current project code;

[0113] According to the interface keywords corresponding to the interface code blocks, the prompt words corresponding to the interface keywords in the target prompt word library are determined as the prompt words corresponding to the interface code blocks, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to a plurality of interface keywords respectively;

[0114] Based on the preset AI big model, test cases of each interface code block are constructed according to the prompt words of each interface code block, and each test case is executed to obtain the case execution results corresponding to each test case;

[0115] Determine the test case whose test case execution result is a test case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as a target interface code block;

[0116] The target interface code block is processed by the AI ​​big model for prompt word detection to obtain the target prompt word corresponding to the target interface code block, and the target prompt word library is updated according to the target prompt word and the target interface keyword corresponding to the target interface code block. The updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

[0117] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0118] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0119] Therefore, the present application also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the following steps:

[0120] Obtaining a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks;

[0121] Determine the interface keywords corresponding to each of the interface code blocks by analyzing each of the interface code blocks in the current project code;

[0122] According to the interface keywords corresponding to the interface code blocks, the prompt words corresponding to the interface keywords in the target prompt word library are determined as the prompt words corresponding to the interface code blocks, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to a plurality of interface keywords respectively;

[0123] Based on the preset AI big model, test cases of each interface code block are constructed according to the prompt words of each interface code block, and each test case is executed to obtain the case execution results corresponding to each test case;

[0124] Determine the test case whose test case execution result is a test case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as a target interface code block;

[0125] The target interface code block is processed by the AI ​​big model for prompt word detection to obtain the target prompt word corresponding to the target interface code block, and the target prompt word library is updated according to the target prompt word and the target interface keyword corresponding to the target interface code block. The updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

[0126] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.

[0127] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0128] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0129] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present application can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0130] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.

[0131] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A code testing method, characterized in that: include: Obtaining a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks; Determine the interface keywords corresponding to each of the interface code blocks by analyzing each of the interface code blocks in the current project code; According to the interface keywords corresponding to the interface code blocks, the prompt words corresponding to the interface keywords in the target prompt word library are determined as the prompt words corresponding to the interface code blocks, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to a plurality of interface keywords respectively; Based on the preset AI big model, test cases of each interface code block are constructed according to the prompt words of each interface code block, and each test case is executed to obtain the case execution results corresponding to each test case; Determine the test case whose test case execution result is a test case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as a target interface code block; The target interface code block is processed by the AI ​​big model for prompt word detection to obtain the target prompt word corresponding to the target interface code block, and the target prompt word library is updated according to the target prompt word and the target interface keyword corresponding to the target interface code block. The updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

2. The method according to claim 1, characterized in that After determining the prompt words corresponding to the interface keywords in the target prompt word library as the prompt words corresponding to the interface code blocks according to the interface keywords respectively corresponding to the interface code blocks, the method further includes: Insert the prompt words of each interface code block into the corresponding interface code block as the code embedding point of the corresponding interface code block; The method based on the preset AI big model and according to the prompt words of each interface code block respectively constructs the test cases of each interface code block, including: Scan the code embedding points of each of the interface code blocks by using the AI ​​big model to determine the prompt words of each of the interface code blocks; According to the prompt words of each interface code block, the scene simulation data of each interface code block is respectively constructed, and the scene simulation data includes environmental parameters, input parameter data and output parameter data; The test cases of each of the interface code blocks are determined according to the scenario simulation data of each of the interface code blocks.

3. The method according to claim 1, characterized in that After determining the test case whose test case execution result is a test case execution exception as an abnormal test case, the method further includes: Performing abnormal analysis and processing on the abnormal test case by using the AI ​​big model to obtain the code abnormality cause of the abnormal test case; Generate an exception test case set including each of the exception test cases, and an exception analysis result including each of the code exception causes; Generate a target test result according to the abnormal test case set and the abnormal analysis result; Output the target test result.

4. The method according to claim 3, characterized in that Generating a target test result according to the abnormal test case set and the abnormal analysis result includes: Determining a target project template corresponding to the target project from a plurality of preset project templates; The abnormal test case set and the abnormal analysis result are templated based on the target project template to obtain the target test result.

5. The method according to claim 1, characterized in that After updating the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block, the method further includes: Obtaining the code of the project to be tested in the next test cycle of the target project; The project code to be tested is used as the current project code, the updated target prompt word library is used as the target prompt word library corresponding to the target project, and the step of determining the interface keywords corresponding to each interface code block respectively by analyzing each interface code block in the current project code is returned to execute.

6. The method according to claim 1, characterized in that There are multiple target prompt words, and updating the target prompt word library according to the target prompt words and the target interface keywords corresponding to the target interface code block includes: Determining whether the target prompt word library contains a prompt word corresponding to the target interface keyword; If the target prompt word library contains a prompt word corresponding to the target interface keyword, updating the prompt word corresponding to the target interface keyword in the target prompt word library according to the plurality of target prompt words; If the target prompt word library does not include the prompt word corresponding to the target interface keyword, the target interface keyword and a plurality of target prompt words corresponding to the target interface keyword are stored in the target prompt word library.

7. The method according to any one of claims 1 to 6, characterized in that The interface keywords in the target prompt word library include at least one of an input interface keyword, an output interface keyword, a database interface keyword, a cache interface keyword, and a queue interface keyword.

8. A code testing device, characterized in that: include: A transceiver unit, used to obtain a current project code of a current test cycle of a target project, wherein the current project code includes a plurality of interface code blocks; The processing unit is used to determine the interface keywords corresponding to each interface code block by analyzing each interface code block in the current project code; according to the interface keywords corresponding to each interface code block, determine the prompt words corresponding to the interface keywords in the target prompt word library as the prompt words of the corresponding interface code block, wherein the target prompt word library is the prompt word library corresponding to the target project, and the target prompt word library includes prompt words corresponding to multiple interface keywords; based on the preset AI big model, construct test cases for each interface code block according to the prompt words of each interface code block, and execute each test case to obtain the test case execution results corresponding to each test case; determine the test case whose test case execution result is a test case execution exception as an abnormal test case, and determine the interface code block corresponding to the abnormal test case as a target interface code block; perform prompt word detection processing on the target interface code block through the AI ​​big model to obtain the target prompt word corresponding to the target interface code block, and update the target prompt word library according to the target prompt word and the target interface keyword corresponding to the target interface code block, and the updated target prompt word library is used to guide the AI ​​big model to perform code testing on the project code of the next test cycle of the target project.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the code testing method according to any one of claims 1 to 7 is implemented.

10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the code testing method according to any one of claims 1 to 7.