Test code generation method and device, storage medium and equipment

By using third-party artificial intelligence databases to generate test codes, the problems of low efficiency and inconsistent quality of test code writing in the existing technology are solved, efficient and unified test code generation is achieved, and maintenance costs are reduced.

CN120144433APending Publication Date: 2025-06-13GUANGZHOU SIX CIRCLE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311670874.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-07
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

In the prior art, during software testing, testers need to manually write test code, resulting in low writing efficiency, inconsistent code quality and high maintenance costs.

Method used

By obtaining the object code and test requirement files to be tested, generating test code generation prompt information, and calling the data interface of a third-party artificial intelligence database, the artificial intelligence database is used to generate test code to reduce or eliminate the need for manual writing.

Benefits of technology

It improves the efficiency of test code generation, improves the code quality, makes the generated test code style unified, and reduces subsequent maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144433A_ABST
    Figure CN120144433A_ABST
Patent Text Reader

Abstract

The invention relates to a test code generation method and device, a storage medium and equipment, and the method comprises the steps: obtaining a to-be-tested target code and a test demand file, generating test code generation prompt information corresponding to the target code according to the test demand file, and calling a data interface of a third-party artificial intelligence database, the calling instruction is sent to the third-party artificial intelligence database through the data interface, the third-party artificial intelligence database is used for obtaining the test code data, and therefore the test code corresponding to the target code is obtained, a tester does not need to manually write the test code, the writing efficiency of the test code can be improved, and the test efficiency is improved. And the maintenance cost of the test code is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software development, and in particular, to a method, device, storage medium, and equipment for generating test code. Background Art

[0002] When testing software in the prior art, it is usually the testers who write the test code and conduct the tests. Writing test code requires the testers to have certain coding skills, and limited by personal skill levels and experience, the quality and style of the test code written by different testers are different, and the subsequent maintenance cost is relatively high. Summary of the Invention

[0003] The embodiments of the present application provide a method, device, storage medium, and equipment for generating test code, which can improve the efficiency of generating test code, enhance the code quality, and reduce the maintenance cost of the test code.

[0004] In a first aspect, the embodiments of the present application provide a method for generating test code, including the following steps:

[0005] Obtain the target code to be tested and the test requirement file;

[0006] Generate test code generation prompt information corresponding to the target code according to the test requirement file;

[0007] Call the data interface of a third-party artificial intelligence database, and send a call instruction to the third-party artificial intelligence database through the data interface; wherein, the call instruction includes the test code generation prompt information;

[0008] Obtain the test code data returned by the third-party artificial intelligence database through the data interface, and obtain the test code corresponding to the target code according to the test code data.

[0009] In a second aspect, the embodiments of the present application provide a device for generating test code, and the device includes:

[0010] A target code acquisition module, configured to obtain the target code to be tested and the test requirement file;

[0011] A prompt information generation module, configured to generate test code generation prompt information corresponding to the target code according to the test requirement file;

[0012] A call module, configured to call the data interface of a third-party artificial intelligence database, and send a call instruction to the third-party artificial intelligence database through the data interface; wherein, the call instruction includes the test code generation prompt information;

[0013] A test code acquisition module, configured to acquire test code data returned by the third-party artificial intelligence database through the data interface, and acquire the test code corresponding to the target code according to the test code data.

[0014] Thirdly, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the test code generation method described in any one of the above are implemented.

[0015] Fourthly, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable by the processor;

[0016] When the processor executes the computer program, the steps of the test code generation method described in any one of the above are implemented.

[0017] In the embodiment of the present application, by acquiring the target code to be tested and the test requirement file, generating test code generation prompt information corresponding to the target code according to the test requirement file, then calling the data interface of the third-party artificial intelligence database, sending a call instruction to the third-party artificial intelligence database through the data interface, and using the third-party artificial intelligence database to acquire test code data, so as to obtain the test code corresponding to the target code. The present application does not require testers to manually write test codes, which can improve the writing efficiency of test codes. At the same time, the writing quality and writing style of the test codes written by the third-party artificial intelligence database are relatively unified, which can effectively reduce the maintenance cost of the test codes in the subsequent process.

[0018] For better understanding and implementation, the present invention will be described in detail below with reference to the accompanying drawings. Description of the Drawings

[0019] Figure 1 It is a flowchart of a test code generation method in an embodiment of the present invention;

[0020] Figure 2 It is a flowchart of step S110 in an embodiment of the present invention;

[0021] Figure 3 It is a flowchart of step S113 in an embodiment of the present invention;

[0022] Figure 4 It is a flowchart of a test code generation method in another embodiment of the present invention;

[0023] Figure 5 It is a schematic structural diagram of a test code generation device in an embodiment of the present invention;

[0024] Figure 6Schematic diagram of a structure of an electronic device in an embodiment of the present invention. Detailed implementation manners

[0025] To make the objectives, technical solutions, and advantages of the present application clearer, the following will further describe in detail the embodiments of the present application in conjunction with the accompanying drawings.

[0026] It should be clear that the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope protected by the embodiments of the present application.

[0027] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present application. The singular forms "a", "the", and "said" used in the embodiments of the present application and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term " / and / " as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0028] When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims. In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and do not have to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific circumstances.

[0029] In addition, in the description of the present application, unless otherwise specified, "a plurality of" means two or more. " / and / " describes the corresponding relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.

[0030] Please refer to Figure 1 , the present application provides a test code generation method, including the following steps:

[0031] S110: Obtain the target code to be tested and the test requirement file;

[0032] The target code can be part or all of the code of the application to be developed. The test requirement file is a relevant file used to determine the requirements that need to be met during the testing of the target code. The test requirement file can include a test code template, a test assertion strategy, and a prompt information configuration file.

[0033] S120: Generate test code generation prompt information corresponding to the target code according to the test requirement file;

[0034] The test code generation prompt information is used to prompt a third-party artificial intelligence database to generate corresponding test code. The test code generation prompt information can include information such as package names, dependency references, class names, methods, lists, etc.

[0035] S130: Invoke the data interface of the third-party artificial intelligence database, and send an invocation instruction to the third-party artificial intelligence database through the data interface; wherein, the invocation instruction contains the test code generation prompt information;

[0036] The third-party artificial intelligence database can be an existing artificial intelligence database such as ChatGPT or Wenxin Yiyan. In response to the invocation instruction, the third-party artificial intelligence database automatically generates corresponding test code data according to the test code generation prompt information, so that users do not need to write test code by themselves, improving the efficiency of test code generation. Moreover, the writing styles of the test codes generated by the artificial intelligence database are unified, making it more convenient for later personnel to maintain the test codes.

[0037] S140: Obtain the test code data returned by the third-party artificial intelligence database through the data interface, and obtain the test code corresponding to the target code according to the test code data.

[0038] The test code data is the test code data automatically generated by the third-party artificial intelligence database in response to the invocation instruction according to the test code generation prompt information.

[0039] The test code can be used to test the target code, thereby verifying the functionality and correctness of the target code.

[0040] In an embodiment of the present application, by obtaining the target code to be tested and the test requirement file, generating test code generation prompt information corresponding to the target code according to the test requirement file, then calling the data interface of the third-party artificial intelligence database, sending a call instruction to the third-party artificial intelligence database through the data interface, and using the third-party artificial intelligence database to obtain test code data, so as to obtain the test code corresponding to the target code. The present application does not require testers to manually write test code, which can improve the writing efficiency of test code. At the same time, the writing quality and writing style of the test code written by the third-party artificial intelligence database are relatively unified, which can effectively reduce the maintenance cost of the test code in the subsequent process.

[0041] The execution subject of the test code generation method of the present application can be a server. The server runs the test code generation method of the present application to obtain the test code corresponding to the target code. The server can communicate with the clients where relevant personnel such as developers and testers are located. The target code and the test requirement file can be uploaded by the relevant personnel to the server through the client.

[0042] As Figure 2 shown, specifically, the steps of obtaining the target code to be tested and the test requirement file specifically include:

[0043] S111: In response to a test project creation instruction, receive the file to be tested and the test requirement file sent by the client;

[0044] The test project creation instruction can be an instruction for creating a test project sent by the client. The client can create a test project for the application to be developed through the web page and upload the file to be tested and the test requirement file of the project to the server through the web page.

[0045] The file to be tested is a file uploaded by the client. The file to be tested can include files such as binary files, compilation link map files, and version information. Among them, the binary file can refer to files such as apk files, jar files, aar files, so files, and exe files. The compilation link map file is a file generated by the compiler during the compilation and linking process. It contains various information of the program, such as function names, variable names, addresses, sizes, etc. The map file shows the function variables contained in each file in the program in text form, as well as which segments these function variables are allocated to, what the addresses are, and the space size they occupy.

[0046] S112: Parse the file to be tested to obtain the source code;

[0047] When parsing the file to be tested, a pre-set parsing script can be used to parse the file to be tested. Alternatively, in another embodiment, the file to be tested may include a parsing script, and the server uses this parsing script to parse the file to be tested. The parsing script can be a pre-set parsing script corresponding to the type of the target code, or the parsing script can also be a custom parsing script submitted by the user through the client. This custom parsing script can better adapt to the parsing operation requirements of the file to be tested and improve the parsing efficiency of the file to be tested.

[0048] In the embodiments of the present application, when obtaining the source code, the binary file can be parsed according to the compilation link map file first to obtain the source code directory and source files; among them, the source files can include files such as.class,.dex,.asm, or.s. Then the source code is obtained from the source files.

[0049] S113: Obtain the target code to be tested from the source code.

[0050] The target code can be all or part of the code in the source code.

[0051] In the embodiments of the present application, the target code is part of the source code. As Figure 3 shown, the steps of obtaining the target code to be tested from the source code specifically include:

[0052] S113a: Obtain a cleaning configuration file, and clear the invalid content in the source code according to the cleaning configuration file;

[0053] S113b: Obtain a filtering configuration file, and filter the unnecessary content in the source code according to the filtering configuration file to obtain the target code to be tested.

[0054] The cleaning configuration file is used to screen out the invalid content from the source code and perform a cleaning operation. The invalid content can be content irrelevant to the target code.

[0055] The filtering configuration file is used to screen out the target code to be tested from the original code and perform a filtering operation on the unnecessary content that does not need to be tested. The unnecessary content can be content that is irrelevant to the normal execution of the target code but needs to be retained in the original code and cannot be cleared. When performing a filtering operation on the unnecessary content, corresponding marks can be added to the unnecessary content to screen out the target code to be tested.

[0056] The cleaning configuration file and the filtering configuration file can be stored in the target area and read from the target area when needed. The cleaning configuration file and the filtering configuration file can be files pre-stored by the user in the target area, or alternatively, can be the cleaning configuration file and the filtering configuration file uploaded by the user through the client. After receiving the cleaning configuration file and the filtering configuration file, the server stores them in the target area.

[0057] In the embodiments of the present application, the cleaning configuration file and the filtering configuration file can be included in the test requirement file, and the cleaning configuration file and the filtering configuration file are obtained from the test requirement file uploaded by the user.

[0058] In the embodiments of the present application, by using the cleaning configuration file to clear the invalid content in the source code and using the filtering configuration file to filter the unnecessary content, the data volume of the target code for testing is reduced, and the generation efficiency of the test code is improved.

[0059] In the embodiments of the present application, the test requirement file can include a test code template, a test assertion policy, and a prompt information configuration file.

[0060] Specifically, according to the test requirement file, the steps of generating test code generation prompt information corresponding to the target code specifically include:

[0061] According to the test code template, the test assertion policy, and the prompt information configuration file, generate test code generation prompt information corresponding to the target code.

[0062] The test assertion policy is used to detect whether the code meets the expectations to ensure the correctness of the code. When the code executes to the position of the assertion, the corresponding assertion should be true. If the assertion is not true, the program will abort the execution and give an error message. The test assertion policy can be used to verify whether the input parameters, object attributes, object states, output parameters, and boundary conditions meet the expectations. The test assertion policy can include various common test methods such as boundary value checking method and equivalence class partitioning method. Through the test assertion policy, the test coverage and test quality of the target code can be improved.

[0063] The prompt information configuration file is a relevant configuration file for generating test code generation prompt information. Specifically, the prompt information configuration file can include existing natural language processing tools, for example, can include a keyword extraction tool, and generate test code generation prompt information by extracting keywords from the test code template, the test assertion policy, and the target code.

[0064] When the test code data is large, problems such as data loss or processing errors are likely to occur during the transmission process. Therefore, as Figure 4As shown, in the embodiment of the present application, before obtaining the test code data returned by the third-party artificial intelligence database through the data interface, it further includes:

[0065] S210: Obtain the data volume of the test code data and generate a data identifier;

[0066] S220: If the data volume of the test code data exceeds the target data volume, assign the data identifier to the first target value;

[0067] S230: If the data volume of the test code data does not exceed the target data volume, assign the data identifier to the second target value;

[0068] S240: If the data identifier is assigned to the first target value, split the prompt information generated by the test code, obtain the data volume of the test code data of the split prompt information generated by the test code. If the data volume of the test code data of the split prompt information generated by the test code does not exceed the target data volume, assign the data identifier to the second target value.

[0069] The target data volume can be determined according to the performance of the server. Specifically, the target data volume can be determined according to the size of the token. The token can be used as an identifier for the request side to make a request and is used for verifying the identity of the request side. When the request side sends a request to the requested side, the token can be carried. After receiving the request, the requested side verifies the token and returns the corresponding request data after successful verification.

[0070] The data identifier is used to determine whether the data volume of the test code data exceeds the target data volume. The data identifier is assigned according to whether the data volume of the test code data exceeds the target data volume. The first target value and the second target value can be set according to user requirements. For example, in the present application, the first target value can be set to True and the second target value can be set to False.

[0071] When the data identifier is assigned to the first target value, it means that the data volume of the test code data exceeds the target data volume. At this time, the data volume of the test code data can be reduced by splitting the prompt information generated by the test code. Specifically, the bisection method or other existing splitting methods can be used to split the prompt information generated by the test code. After splitting, the data interface of the third-party artificial intelligence database is called again to obtain the test code data, and the assignment of the data identifier is determined according to the size of the data volume of the re-obtained test code data.

[0072] If the data volume of the test code data obtained after splitting still exceeds the target data volume, repeat the above splitting steps to split the prompt information generated by the test code until the data volume of the test code data of the prompt information generated by the split test code does not exceed the target data volume.

[0073] When the assignment of the data identifier is the second target value, a call instruction including the currently generated prompt information of the test code is sent to the third-party artificial intelligence database through the data interface, so as to obtain corresponding test code data from the third-party artificial intelligence database.

[0074] In the embodiment of the present application, the data identifier is assigned according to whether the data volume of the test code data exceeds the target data volume. If the data identifier is assigned the first target value, the prompt information generated by the test code is split, so that the data volume of the returned test code data never exceeds the target data volume, ensuring the reliability of the transmission of the test code data.

[0075] In the embodiment of the present application, in addition to obtaining the test code by calling the third-party artificial intelligence database, the corresponding test code can also be automatically generated according to the test code template. Specifically, after obtaining the target code to be tested and the test requirement file, the following steps are further included:

[0076] Obtain a test code template and a test code generation script;

[0077] According to the test code template and the test requirement file, generate the test code corresponding to the target code according to the test code generation script.

[0078] The test code template is used to generate the corresponding test code. For different types of target codes, their test code templates can be different. When obtaining the test code template, the corresponding test code template can be obtained according to the type of the target code. The test code template can be pre-stored in the database.

[0079] The test code generation script can generate the corresponding test code according to information such as the version information of the target code, the test code template, and the test assertion strategy. Preferably, the test code can include unit test codes for all classes and test codes for combined classes. Users can select to call the unit test codes for all classes or the test codes for combined classes according to their needs to test the target code. The test codes for combined classes can include unit test codes for at least one class selected by the user according to their needs.

[0080] The test code template and the test code generation script of the present application can be set according to user needs. Users can expand the test code template and the test requirement file according to different application scenarios at any time, so as to meet the generation requirements of test codes in different application scenarios.

[0081] The test code generated by this application is used to test the target code. The testing process of the target code can be executed on the server or on the client. The test code generation method further includes the following steps:

[0082] Run the test code, obtain the test result of the target code, and generate a test report based on the test result;

[0083] This test result can reflect the verification situation of the development requirements of the target code. A corresponding test report is generated based on this test result. Preferably, the test report generated by the server can be sent to the client, and the test report is displayed on the client to facilitate the user to timely understand the testing situation of the target code.

[0084] Alternatively, the testing process of the target code can also be executed on the client. The test code generation method further includes the following steps:

[0085] Send the test code to the client and receive the test report of the client; the test report is generated by the client based on the test result obtained by running the test code.

[0086] The client can test the target code according to the received test code, so as to verify whether the function of the target code meets the development requirements. Specifically, the client can be pre-set with development tools (such as IDE, etc.) for running the test code. After receiving the test code, the client uses the pre-set development tool to run the test code to obtain the test result.

[0087] This test result can reflect the verification situation of the development requirements of the target code. Specifically, a corresponding test report can be further generated based on this test result and displayed on the client to facilitate the user to timely understand the testing situation of the target code.

[0088] As Figure 5 shown, an embodiment of this application further provides a test code generation device, and the device includes:

[0089] A target code acquisition module 110, configured to acquire a target code to be tested and a test requirement file;

[0090] A prompt information generation module 120, configured to generate a test code generation prompt information corresponding to the target code according to the test requirement file;

[0091] A calling module 130, configured to call the data interface of a third-party artificial intelligence database, and send a calling instruction to the third-party artificial intelligence database through the data interface; wherein, the calling instruction includes the test code generation prompt information;

[0092] A test code acquisition module 140, configured to acquire test code data returned by the third-party artificial intelligence database through the data interface, and acquire the test code corresponding to the target code according to the test code data.

[0093] In one embodiment, the target code acquisition module 110 includes:

[0094] A file acquisition unit, configured to receive a file to be tested and a test requirement file sent by a client in response to a test project creation instruction;

[0095] An analysis unit, configured to analyze the file to be tested to obtain source code;

[0096] A target code acquisition unit, configured to acquire the target code to be tested from the source code.

[0097] In one embodiment, the target code acquisition unit includes:

[0098] A cleaning unit, configured to acquire a cleaning configuration file and clear invalid content in the source code according to the cleaning configuration file;

[0099] A filtering unit, configured to acquire a filtering configuration file and filter unnecessary content in the source code according to the filtering configuration file to obtain the target code to be tested.

[0100] In one embodiment, the test code generation device further includes:

[0101] A data volume acquisition module, configured to acquire the data volume of the test code data and generate a data identifier;

[0102] A first assignment module, configured to assign the data identifier to a first target value if the data volume of the test code data exceeds a target data volume;

[0103] A second assignment module, configured to assign the data identifier to a second target value if the data volume of the test code data does not exceed the target data volume;

[0104] A splitting module, configured to split the test code generation prompt information if the data identifier is assigned to the first target value, acquire the data volume of the test code data of the split test code generation prompt information, and assign the data identifier to the second target value if the data volume of the test code data of the split test code generation prompt information does not exceed the target data volume.

[0105] In one embodiment, the test code generation device further includes:

[0106] A test code template acquisition module, configured to acquire a test code template and a test code generation script;

[0107] A test code generation module, configured to generate test code corresponding to the target code according to the test code template, the test requirement file, and a test code generation script.

[0108] In one embodiment, the test requirement file includes a test code template, a test assertion policy, and a prompt message configuration file.

[0109] A prompt message generation module 120 is configured to generate test code generation prompt messages corresponding to the target code according to the test code template, the test assertion policy, and the prompt message configuration file.

[0110] In one embodiment, the test code generation device further includes:

[0111] A first test report generation module, configured to run the test code, obtain a test result of the target code, and generate a test report according to the test result.

[0112] Alternatively, in one embodiment, the test code generation device further includes:

[0113] A second test report generation module, configured to send the test code to a client and receive a test report from the client; the test report is generated by the client according to a test result obtained by running the test code.

[0114] It should be noted that when the test code generation device provided in the above embodiment executes the test code generation method, only the above division of each functional module is used for illustration. In actual application, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the test code generation device provided in the above embodiment and the test code generation method in the above embodiment belong to the same concept. The implementation process is shown in the method embodiment and will not be elaborated here.

[0115] The present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the test code generation method described in any one of the above are implemented.

[0116] The present application may be in the form of a computer program product implemented on one or more storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) that contain program code. Computer-readable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information may be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include but are not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.

[0117] As Figure 6 shown, the present application also provides an electronic device 200, including a memory 210, a processor 220, and a computer program stored in the memory 210 and executable by the processor 220;

[0118] When the processor 220 executes the computer program, the steps of the test code generation method described in any one of the above are implemented.

[0119] The memory 210 includes read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc memories, magnetic disk memories, magnetic tape memories, or any other computer-readable medium capable of carrying or storing data.

[0120] The processor 220 is the control core (Control Unit) of the electronic device 200, connecting various components of the entire electronic device 200 through various interfaces and circuits. By running or executing programs or modules stored in the memory 210, and calling data stored in the memory 210, it performs various functions of the electronic device 200 and processes data. For example, when the processor 220 executes the computer program stored in the memory 210, all or part of the steps of the test code generation method described in the embodiments of the present application are implemented; or all or part of the functions of the test code generation device are implemented. The processor may be composed of integrated circuits. For example, it may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits with the same or different functions packaged, including a combination of one or more central processing units (Central Processing Unit, CPU), microprocessors, digital processing chips, graphics processors, and various control chips, etc.

[0121] The present invention is not limited to the above embodiments. If various changes or deformations to the present invention do not depart from the spirit and scope of the present invention, and if these changes and deformations fall within the scope of the claims of the present invention and equivalent technical scope, then the present invention also intends to include these changes and deformations.

Claims

1. A method for generating test code, characterized in that, it includes the following steps: Obtain the target code to be tested and the test requirement file; Generate test code generation prompt information corresponding to the target code according to the test requirement file; Call the data interface of the third-party artificial intelligence database, and send a call instruction to the third-party artificial intelligence database through the data interface; wherein, the call instruction includes the test code generation prompt information; Obtain the test code data returned by the third-party artificial intelligence database through the data interface, and obtain the test code corresponding to the target code according to the test code data.

2. The test code generation method according to claim 1, characterized in that, The step of obtaining the target code to be tested and the test requirement file specifically includes: In response to the test project creation instruction, receive the file to be tested and the test requirement file sent by the client; Parse the file to be tested to obtain the source code; Obtain the target code to be tested from the source code.

3. The test code generation method according to claim 2, characterized in that, The step of obtaining the target code to be tested from the source code specifically includes: Obtain the cleaning configuration file, and clear the invalid content in the source code according to the cleaning configuration file; Obtain the filtering configuration file, and filter the unnecessary content in the source code according to the filtering configuration file to obtain the target code to be tested.

4. The test code generation method according to claim 1, characterized in that, Before obtaining the test code data returned by the third-party artificial intelligence database through the data interface, it further includes: Obtain the data volume of the test code data and generate a data identifier; If the data volume of the test code data exceeds the target data volume, assign the data identifier to the first target value; If the data volume of the test code data does not exceed the target data volume, assign the data identifier to the second target value; If the data identifier is assigned to the first target value, split the test code generation prompt information, obtain the data volume of the test code data of the split test code generation prompt information, and if the data volume of the test code data of the split test code generation prompt information does not exceed the target data volume, assign the data identifier to the second target value.

5. The test code generation method according to claim 1, characterized in that, After obtaining the target code to be tested and the test requirement file, it further includes the following steps: Obtain the test code template and the test code generation script; Generate the test code corresponding to the target code according to the test code template and the test requirement file according to the test code generation script.

6. The test code generation method according to claim 5, characterized in that, The test requirement file includes a test code template, a test assertion strategy, and a prompt information configuration file; The step of generating the test code generation prompt information corresponding to the target code according to the test requirement file specifically includes: Generate test code generation prompt information corresponding to the target code according to the test code template, the test assertion strategy, and the prompt information configuration file.

7. The test code generation method according to any one of claims 1-6, characterized in that, further comprising the following steps: Run the test code, obtain the test result of the target code, and generate a test report according to the test result; Alternatively, send the test code to the client and receive the test report from the client; The test report is generated by the client according to the test result obtained by running the test code.

8. A test code generation device, characterized in that, the device comprises: A target code acquisition module, configured to acquire a target code to be tested and a test requirement file; A prompt information generation module, configured to generate test code generation prompt information corresponding to the target code according to the test requirement file; A call module, configured to call a data interface of a third-party artificial intelligence database, and send a call instruction to the third-party artificial intelligence database through the data interface; wherein, the call instruction includes the test code generation prompt information; A test code acquisition module, configured to acquire test code data returned by the third-party artificial intelligence database through the data interface, and acquire the test code corresponding to the target code according to the test code data.

9. A computer-readable storage medium, on which a computer program is stored, characterized in that: When the computer program is executed by a processor, the steps of the test code generation method according to any one of claims 1-7 are implemented.

10. An electronic device, characterized in that, comprising a memory, a processor, and a computer program stored in the memory and executable by the processor; When the processor executes the computer program, the steps of the test code generation method according to any one of claims 1-7 are implemented.