Test case code file generation method, device and equipment

By recording interface request messages and using large language models to generate test case code files, the problem of low test case code generation efficiency in the existing technology is solved, automation and accuracy are improved, and the ability to adapt to complex test scenarios is achieved.

CN118550823APending Publication Date: 2024-08-27ZHEJIANG ZEEKR INTELLIGENT TECH CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410640281.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing software testing technology relies on manually writing test case code files, which is inefficient and error-prone, and cannot adapt to complex testing scenarios.

Method used

By recording interface request messages, extract metadata information, use large language models to generate test case code files, and combine vector similarity algorithms with interface documents and requirements documents to automate test case code generation.

Benefits of technology

It realizes automated test case code generation, improves testing efficiency, reduces manual errors, can adapt to complex test scenarios, and generate more accurate and comprehensive test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550823A
    Figure CN118550823A
Patent Text Reader

Abstract

The embodiment of the invention provides a test case code file generation method, device and equipment, and relates to the technical field of large language models. The method comprises the following steps: recording a current interface request message in response to a recording operation initiated by a user, and generating a recording file; sending the recorded file to an extractor, and extracting metadata information associated with the current interface request message; determining first text information according to the metadata information; generating a test case code file based on a preset large language model and the first text information; wherein the test case code file is used for testing the validity of the response result of the current interface request message. By adopting the technical scheme, the test case code file can be automatically generated without depending on scripts, so that the method can adapt to relatively complex test scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the technical field of large language models, and in particular to a method, apparatus and device for generating a test case code file. Background Art

[0002] In existing software testing technologies, the generation of test case code files mainly relies on manual writing, which requires understanding of test requirements, reading of interface documents, and setting of interface parameters. This method is inefficient, error-prone, and difficult to maintain. Existing automated testing technologies are mainly based on scripts or templates, which require pre-setting of test paths and parameters and cannot adapt to complex test scenarios.

[0003] Therefore, there is an urgent need for a test case code file generation method that can automatically generate test case code files and is independent of scripts, thereby being able to adapt to more complex test scenarios. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide a method, apparatus and device for generating a test case code file.

[0005] A first aspect of an embodiment of the present disclosure provides a method for generating a test case code file, the method comprising:

[0006] In response to a recording operation initiated by a user, the current interface request message is recorded and a recording file is generated; wherein the recording operation is used to indicate that the current interface request message is recorded and a recording file is generated;

[0007] Sending the recording file to an extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents a uniform resource locator, a request body or a return body in the current interface request message;

[0008] Determine first text information according to the metadata information;

[0009] A test case code file is generated based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message.

[0010] In one example, after sending the recording file to the extractor, the method further includes:

[0011] Extract remark information associated with the current interface request message; wherein the remark information is associated with the metadata information.

[0012] In one example, determining the first text information according to the metadata information includes:

[0013] Sending the metadata information to a generator, performing vectorization processing on the metadata information, and generating a first vector value; wherein the first vector value is used to represent the vector value of the metadata information;

[0014] According to the first vector value, the generator calls a vector similarity algorithm to retrieve first text information associated with the first vector value from a preset vector database.

[0015] In one example, the generator calls a vector similarity algorithm according to the first vector value to retrieve first text information associated with the first vector value from a preset vector database, including:

[0016] According to the first vector value, the vector similarity algorithm is called by the generator, and the preset vector database is traversed to search for a second vector value; wherein the second vector value is a vector value whose similarity with the first vector value satisfies a preset condition;

[0017] According to the second vector value, the first text information associated with the second vector value is determined in a vector value text association table.

[0018] In one example, before retrieving the first text information associated with the first vector value from the preset vector database, the method further includes:

[0019] Obtain at least one interface document and a product requirement document associated with each of the interface documents;

[0020] The interface document and the product requirement document are vectorized to obtain a third vector value, and the third vector value is stored in the preset vector database.

[0021] In one example, the generating of a test case code file based on a preset large language model and the first text information further includes:

[0022] The generator inputs the first text information into a context task of a preset large language model to generate a prompt word;

[0023] Based on the preset large language model, a test case code file is generated according to the prompt words.

[0024] In one example, the method further includes:

[0025] Inputting the test case code file into the code interpreter, and verifying whether the test case code file is valid through the code interpreter;

[0026] If the test case code file is invalid, sending invalid report information to the preset vector database;

[0027] Determine second text information associated with the first vector value in the preset vector database according to the invalidation report information; wherein the second text information is different from the first text information.

[0028] In one example, the method further includes:

[0029] If the test case code file is valid, the test case code file is output.

[0030] A second aspect of an embodiment of the present disclosure provides a test case code file generating device, the device comprising:

[0031] A recording module, used to record the current interface request message and generate a recording file in response to a recording operation initiated by a user; wherein the recording operation is used to instruct to record the current interface request message and generate a recording file;

[0032] A first extraction module, used for sending the recording file to an extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents a uniform resource locator system, a request body or a return body in the current interface request message;

[0033] A first determining module, used to determine first text information according to the metadata information;

[0034] A generation module is used to generate a test case code file based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message.

[0035] In one example, the apparatus further comprises:

[0036] The second extraction module is used to extract remark information associated with the current interface request message; wherein the remark information is associated with the metadata information.

[0037] In one example, the first determining module includes:

[0038] A processing submodule, used for sending the metadata information to a generator, performing vectorization processing on the metadata information, and generating a first vector value; wherein the first vector value is used to represent the vector value of the metadata information;

[0039] The retrieving submodule is used to call the vector similarity algorithm through the generator according to the first vector value, and retrieve the first text information associated with the first vector value in a preset vector database.

[0040] In one example, the calling submodule includes:

[0041] A search unit, configured to call a vector similarity algorithm through the generator according to the first vector value, and traverse the preset vector database to search for a second vector value; wherein the second vector value is a vector value whose similarity with the first vector value satisfies a preset condition;

[0042] A determining unit is used to determine the first text information associated with the second vector value in a vector value text association table according to the second vector value.

[0043] In one example, the acquisition module is used to acquire at least one interface document and a product requirement document associated with each of the interface documents;

[0044] A processing module is used to vectorize the interface document and the product requirement document to obtain a third vector value, and store the third vector value in the preset vector database.

[0045] In one example, the generating module further includes:

[0046] An input submodule, used for inputting the first text information into a context task of a preset large language model through the generator to generate a prompt word;

[0047] A generation submodule is used to generate a test case code file according to the prompt words based on the preset large language model.

[0048] In one example, the apparatus further comprises:

[0049] A verification module, used for inputting the test case code file into the code interpreter, and verifying whether the test case code file is valid through the code interpreter;

[0050] A sending module, used for sending invalid report information to the preset vector database if the test case code file is invalid;

[0051] A second determination module is used to determine second text information associated with the first vector value in the preset vector database according to the invalidation report information; wherein the second text information is different from the first text information.

[0052] In one example, the apparatus further comprises:

[0053] An output module is used to output the test case code file if the test case code file is valid.

[0054] A third aspect of an embodiment of the present disclosure provides an electronic device, the server comprising: a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method of the first aspect above.

[0055] A fourth aspect of an embodiment of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of the first aspect described above can be implemented.

[0056] The disclosed embodiment provides a test case code file generation method, device and equipment, the method comprising: in response to a recording operation initiated by a user, recording the current interface request message and generating a recording file; wherein the recording operation is used to indicate recording the current interface request message and generating a recording file; sending the recording file to an extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents the uniform resource locator system, request body or return body in the current interface request message; determining the first text information according to the metadata information; generating a test case code file based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message. By adopting this technical solution, a test case code file can be automatically generated, and it can be independent of scripts, and thus can adapt to more complex test scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0059] Figure 1 It is a flowchart of a method for generating a test case code file provided in the first embodiment of the present disclosure;

[0060] Figure 2 It is a flowchart of another test case code file generation method provided in the second embodiment of the present disclosure;

[0061] Figure 3 It is a structural schematic diagram of a test case code file generating device provided by Embodiment 3 of the present disclosure;

[0062] Figure 4 It is a structural schematic diagram of an electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0063] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0064] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0065] Figure 1 1 is a flow chart of a method for generating a test case code file provided in the first embodiment of the present disclosure, and the method can be executed by an electronic device. The electronic device can be exemplarily understood as a device such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, a smart TV, etc. Figure 1 As shown, the method provided in this embodiment includes the following steps:

[0066] S101. In response to a recording operation initiated by a user, a current interface request message is recorded and a recording file is generated; wherein the recording operation is used to instruct to record the current interface request message and generate a recording file.

[0067] In one example, the current interface request message may be an HTTP interface request message. The recording file may be a scene file, such as a HAR file. HAR stands for HTTP Arch i ve format, which is a file format used to record HTTP communications between a browser and a server. A HAR file usually contains a series of HTTP interface request messages and response results. That is, the recording file includes the response results to the HTTP interface request message. For example, the HTTP interface request message may be a login request message, and then the page jumps to the login interface, then the recording file includes the page jump process.

[0068] S102. Send the recorded file to the extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents the Uniform Resource Locator, request body or return body in the current interface request message.

[0069] In one example, the extractor may be an Extractor, specifically, an Extractor is a series of program logic codes that extracts specific target information from a file. In this embodiment, the recording file is sent to the extractor, and the extractor extracts metadata information associated with the current interface request message, wherein the metadata information may be a uniform resource locator, a request body, or a return body in the current interface request message.

[0070] In one example, after sending the recording file to the extractor, the method further includes:

[0071] Extract remark information associated with the current interface request message; wherein the remark information is associated with the metadata information.

[0072] In an example, the remark information represents information pre-configured in the current interface request message. The remark information is related to the metadata information and is used to assist in interpreting the current interface request message.

[0073] S103: Determine first text information according to the metadata information.

[0074] In one example, the first text information may be text information related to the metadata information. Specifically, there is more than one first text information, and the more the first text information, the better.

[0075] S104. Generate a test case code file based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message.

[0076] In one example, the preset large language model is an artificial intelligence algorithm. It applies a neural network technology with a large number of parameters and uses a self-supervised learning technology to process and understand human language or text. The first text information is processed by the preset large language model to obtain a test case code file, and then the test case code file is verified to determine the final result.

[0077] The disclosed embodiment provides a method for generating a test case code file, the method comprising: in response to a recording operation initiated by a user, recording a current interface request message and generating a recording file; wherein the recording operation is used to indicate recording the current interface request message and generating a recording file; sending the recording file to an extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents a uniform resource locator system, a request body or a return body in the current interface request message; determining a first text information according to the metadata information; generating a test case code file based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message. By adopting the present technical solution, the interface can be analyzed through a large language model, so that the semantics of the interface can be understood, and the source and meaning of the interface parameters can be determined, thereby generating a more accurate test case.

[0078] Figure 2 The flowchart of another test case code file generation method provided by the second embodiment of the present disclosure is shown. The present embodiment is optimized on the basis of the above embodiment, and the present embodiment can be combined with various optional solutions in one or more of the above embodiments.

[0079] like Figure 2 As shown, the test case code file generation method may include the following steps:

[0080] S201. In response to a recording operation initiated by a user, a current interface request message is recorded and a recording file is generated; wherein the recording operation is used to instruct to record the current interface request message and generate a recording file.

[0081] In an example, this step may refer to step S101 and will not be described in detail here.

[0082] S202. Send the recorded file to the extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents the Uniform Resource Locator, request body or return body in the current interface request message.

[0083] In an example, this step may refer to step S102 and will not be described in detail here.

[0084] S203, sending the metadata information to a generator, performing vectorization processing on the metadata information, and generating a first vector value; wherein the first vector value is used to represent the vector value of the metadata information.

[0085] In one example, the metadata information is sent to the generator, that is, the uniform resource locator, request body or return body in the current interface request message is sent to the generator, and then the uniform resource locator, request body or return body in the current interface request message is vectorized to generate a first vector value.

[0086] S204: According to the first vector value, a vector similarity algorithm is called by a generator to retrieve first text information associated with the first vector value from a preset vector database.

[0087] In one example, according to the first vector value, the generator calls a vector similarity algorithm to retrieve first text information associated with the first vector value from a preset vector database, including:

[0088] According to the first vector value, a vector similarity algorithm is called by a generator, and a preset vector database is traversed to search for a second vector value; wherein the second vector value is a vector value whose similarity with the first vector value satisfies a preset condition;

[0089] According to the second vector value, first text information associated with the second vector value is determined in the vector value text association table.

[0090] In one example, after determining the first vector value, the preset vector database is traversed in sequence, and the second vector value is found through the vector similarity algorithm. For example, the second vector value can be a vector value with a similarity value of 90% with the first vector value. The first text information is searched in the vector value text association table according to the second vector value, and the first text information is then associated with the first vector value.

[0091] In one example, before retrieving the first text information associated with the first vector value from a preset vector database, the method further includes:

[0092] Obtain at least one interface document and a product requirement document associated with each interface document;

[0093] The interface document and the product requirement document are vectorized to obtain a third vector value, and the third vector value is stored in a preset vector database.

[0094] In this embodiment, at least one interface document and a product requirement document associated with each interface document can be obtained from a preset interface database; then the interface document and the product requirement document are vectorized to obtain a third vector value, and the third vector value is stored in the preset vector database. The third vector value can be used for subsequent query and matching.

[0095] S205: Input the first text information into a context task of a preset large language model through a generator to generate a prompt word.

[0096] In one example, the prompt word is an input or prompt provided by the preset large language model to guide the preset large language model to generate a specific output. The prompt word in this embodiment can be a plurality of text information.

[0097] S206: Generate a test case code file based on the preset large language model and the prompt words.

[0098] In one example, the test case code file is used to test the validity of the response result of the current interface request message.

[0099] In one example, after the prompt word is obtained, the prompt word is processed based on a preset large language model to generate a test case code file.

[0100] S207: Input the test case code file into the code interpreter, and verify whether the test case code file is valid through the code interpreter.

[0101] In one example, a code interpreter receives a test case code file and dynamically executes the test case code file during runtime to verify whether the test case code file is valid.

[0102] S208. If the test case code file is invalid, an invalid report message is sent to a preset vector database.

[0103] In one example, if the test case code file is invalid, it means that an error occurs in the test case code file, and an invalid report message is sent to a preset vector database. The invalid report message records in detail the location where the error in the test case code file occurs and the code execution path that caused the error. It usually includes error information, function call path, specific line number and other information.

[0104] S209. Determine, in a preset vector database according to the invalidation report information, second text information associated with the first vector value; wherein the second text information is different from the first text information.

[0105] In one example, the first text information is removed from a preset vector database, and then the vector similarity algorithm is called again through the generator based on the first vector value to retrieve the second text information associated with the first vector value from the preset vector database. The process of searching for the second text information is similar to the process of searching for the first text information, and will not be repeated here.

[0106] S210. If the test case code file is valid, output the test case code file.

[0107] In one example, if the test case code file is valid, the test of the test case code file is output directly.

[0108] A method for generating a test case code file provided by an embodiment of the present disclosure includes: inputting a first text message into a context task of a preset large language model through a generator to generate a prompt word, generating a test case code file according to the prompt word based on the preset large language model, inputting the test case code file into a code interpreter, verifying whether the test case code file is valid through the code interpreter, and sending an invalid report message to a preset vector database if the test case code file is invalid. By adopting this technical solution, the efficiency of test case code file generation is improved, and the errors of manual writing are reduced. By analyzing the interface through a large language model, a more accurate test case code file can be generated. By combining multi-source information, a more comprehensive test case code file can be generated to improve the coverage of the test.

[0109] Figure 3 1 is a schematic diagram of the structure of a test case code file generation device provided in the third embodiment of the present disclosure. The test case code file generation device can be understood as the above electronic device or a part of the functional modules in the above electronic device. Figure 3 As shown, the test case code file generating device 30 includes:

[0110] The recording module 301 is used to record the current interface request message and generate a recording file in response to a recording operation initiated by a user; wherein the recording operation is used to indicate that the current interface request message is recorded and a recording file is generated;

[0111] The first extraction module 302 is used to send the recording file to the extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents the uniform resource locator system, request body or return body in the current interface request message;

[0112] A first determination module 303, configured to determine first text information according to metadata information;

[0113] The generating module 304 is used to generate a test case code file based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message.

[0114] In one example, the device 30 further includes:

[0115] The second extraction module 305 is used to extract the remark information associated with the current interface request message; wherein the remark information is associated with the metadata information.

[0116] In one example, the first determining module 303 includes:

[0117] A processing submodule, used for sending the metadata information to the generator, performing vectorization processing on the metadata information, and generating a first vector value; wherein the first vector value is used to represent the vector value of the metadata information;

[0118] The retrieving submodule is used to call the vector similarity algorithm through the generator according to the first vector value, and retrieve the first text information associated with the first vector value in a preset vector database.

[0119] In one example, calling a submodule includes:

[0120] A search unit, configured to call a vector similarity algorithm through a generator according to the first vector value, and traverse a preset vector database to search for a second vector value; wherein the second vector value is a vector value whose similarity with the first vector value satisfies a preset condition;

[0121] The determining unit is used to determine the first text information associated with the second vector value in the vector value text association table according to the second vector value.

[0122] In one example, the acquisition module 306 is used to acquire at least one interface document and a product requirement document associated with each interface document;

[0123] The processing module 307 is used to vectorize the interface document and the product requirement document to obtain a third vector value, and store the third vector value in a preset vector database.

[0124] In one example, the generating module 304 further includes:

[0125] An input submodule, used for inputting the first text information into a context task of a preset large language model through a generator to generate a prompt word;

[0126] The generation submodule is used to generate test case code files according to prompt words based on the preset large language model.

[0127] In one example, the apparatus 30 further includes:

[0128] A verification module 308 is used to input the test case code file into the code interpreter and verify whether the test case code file is valid through the code interpreter;

[0129] The sending module 309 is used to send invalid report information to a preset vector database if the test case code file is invalid;

[0130] The second determination module 310 is used to determine second text information associated with the first vector value in a preset vector database according to the invalidation report information; wherein the second text information is different from the first text information.

[0131] In one example, the apparatus 30 further includes:

[0132] The output module 311 is used to output the test case code file if the test case code file is valid.

[0133] The device provided in this embodiment can execute the method of any of the above embodiments, and its execution method and beneficial effects are similar, which will not be repeated here.

[0134] An embodiment of the present disclosure further provides an electronic device, which includes: a memory, in which a computer program is stored; and a processor, which is used to execute the computer program. When the computer program is executed by the processor, the method of any of the above embodiments can be implemented.

[0135] For example, Figure 4 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 4 , which shows a schematic diagram of the structure of an electronic device 1000 suitable for implementing the embodiment of the present disclosure. The electronic device 1000 in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0136] like Figure 4 As shown, the electronic device 1000 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1008 to a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the electronic device 1000 are also stored. The processing device 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0137] Typically, the following devices may be connected to the I / O interface 1005: an input device 1006 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1007 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1008 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the electronic device 1000 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 1000 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0138] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 1009, or installed from a storage device 1008, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0139] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0140] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0141] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0142] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: records the current interface request message in response to a recording operation initiated by a user, and generates a recording file; wherein the recording operation is used to indicate that the current interface request message is recorded and a recording file is generated; the recording file is sent to an extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents a uniform resource locator system, a request body or a return body in the current interface request message; the first text information is determined according to the metadata information; a test case code file is generated based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message.

[0143] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0144] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0145] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.

[0146] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0147] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0148] The embodiments of the present disclosure also provide a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of any of the above embodiments can be implemented. The execution method and beneficial effects are similar and will not be repeated here.

[0149] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0150] The above are only specific embodiments of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for generating a test case code file, characterized in that: include: In response to a recording operation initiated by a user, the current interface request message is recorded and a recording file is generated; wherein the recording operation is used to indicate that the current interface request message is recorded and a recording file is generated; Sending the recording file to an extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents a uniform resource locator, a request body or a return body in the current interface request message; Determine first text information according to the metadata information; A test case code file is generated based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message.

2. The method according to claim 1, characterized in that After sending the recording file to the extractor, the method further includes: Extract remark information associated with the current interface request message; wherein the remark information is associated with the metadata information.

3. The method according to claim 1, characterized in that The determining the first text information according to the metadata information includes: Sending the metadata information to a generator, performing vectorization processing on the metadata information, and generating a first vector value; wherein the first vector value is used to represent the vector value of the metadata information; According to the first vector value, the generator calls a vector similarity algorithm to retrieve first text information associated with the first vector value from a preset vector database.

4. The method according to claim 3, characterized in that The step of calling a vector similarity algorithm by the generator according to the first vector value to retrieve first text information associated with the first vector value from a preset vector database includes: According to the first vector value, the vector similarity algorithm is called by the generator, and the preset vector database is traversed to search for a second vector value; wherein the second vector value is a vector value whose similarity with the first vector value satisfies a preset condition; According to the second vector value, the first text information associated with the second vector value is determined in a vector value text association table.

5. The method according to claim 3, characterized in that: Before retrieving the first text information associated with the first vector value from the preset vector database, the method further includes: Obtain at least one interface document and a product requirement document associated with each of the interface documents; The interface document and the product requirement document are vectorized to obtain a third vector value, and the third vector value is stored in the preset vector database.

6. The method according to claim 1, characterized in that The generating of a test case code file based on a preset large language model and the first text information includes: The generator inputs the first text information into a context task of a preset large language model to generate a prompt word; Based on the preset large language model, a test case code file is generated according to the prompt words.

7. The method according to claim 1 or 6, characterized in that: The method further comprises: Inputting the test case code file into the code interpreter, and verifying whether the test case code file is valid through the code interpreter; If the test case code file is invalid, sending invalid report information to the preset vector database; Determine second text information associated with the first vector value in the preset vector database according to the invalidation report information; wherein the second text information is different from the first text information.

8. The method according to claim 7, characterized in that The method further comprises: If the test case code file is valid, the test case code file is output.

9. A test case code file generating device, characterized in that: The device comprises: A recording module, used to record the current interface request message and generate a recording file in response to a recording operation initiated by a user; wherein the recording operation is used to instruct to record the current interface request message and generate a recording file; A first extraction module, used for sending the recording file to an extractor to extract metadata information associated with the current interface request message; wherein the metadata information represents a uniform resource locator system, a request body or a return body in the current interface request message; A determination module, configured to determine the first text information according to the metadata information; A generation module is used to generate a test case code file based on a preset large language model and the first text information; wherein the test case code file is used to test the validity of the response result of the current interface request message.

10. An electronic device, characterized in that: include: A processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Verification of action

    WO2026193896A1