Script generation method and device, equipment and storage medium

CN122903320APending Publication Date: 2026-10-13CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611165945.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-03
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

在模式(2)中,虽然可以避免脚本开发调试过程中熟悉模块时间成本、沟通交流时间成本,但是模块负责人需要同时承担手工测试和自动化脚本开发

Benefits of technology

[0036]上述脚本生成方法、装置、计算机设备和计算机可读存储介质,通过响应于针对目标测试用例的脚本生成请求,获取目标测试用例中记载的测试步骤、预期结果以及功能接口;根据功能接口,从预设的知识库中获取与功能接口相匹配的测试接口;将测试步骤、预期结果以及测试接口,输入预先构建的提示词模板,以生成与目标测试用例相匹配的提示词;将提示词输入至测试脚本生成模型中,获得测试脚本;如此,本申请通过从预设的知识库中匹配出与功能接口对应的测试接口,借助测试脚本生成模型,基于测试用例的测试步骤、预期结果和测试接口,自动生成测试脚本,提高了测试脚本生成效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122903320A_ABST
    Figure CN122903320A_ABST
Patent Text Reader

Abstract

The application relates to a script generation method, device and equipment and a storage medium. The method comprises the following steps: in response to a script generation request for a target test case, obtaining a test step, an expected result and a function interface recorded in the target test case; according to the function interface, obtaining a test interface matched with the function interface from a preset knowledge base; inputting the test step, the expected result and the test interface into a pre-constructed prompt word template to generate a prompt word matched with the target test case; and inputting the prompt word into a test script generation model to obtain a test script, thereby improving the test script generation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software testing technology, and in particular to a script generation method, apparatus, computer device, and computer-readable storage medium. Background Technology

[0002] Software testing is a crucial part of the software lifecycle. Whether the software testing covers all scenarios, whether the test results are accurate, and whether the testing time is controllable directly affect the product release time and whether it can run stably after release.

[0003] In related technologies, there are generally two modes for automated script development: (1) dedicated script developers are responsible for script development; (2) module testers are responsible for script development. In mode (1), dedicated script developers will directly develop scripts according to the test steps of the test cases, rarely or never participating in functional testing, resulting in unfamiliarity with the corresponding functional modules. They need to become familiar with the corresponding functions during the development process, and the module manager usually needs to assist in debugging the scripts. In mode (2), although the time cost of becoming familiar with the modules and the time cost of communication during the script development and debugging process can be avoided, the module manager needs to undertake both manual testing and automated script development. For both modes, script development and debugging require a certain amount of time, which may result in situations where automated testing cannot be carried out from the beginning of the project, resulting in a certain lag.

[0004] Therefore, there is a problem of low efficiency in test script development during software testing. Summary of the Invention

[0005] Therefore, it is necessary to provide a script generation method, apparatus, computer device, and computer-readable storage medium that can improve the efficiency of generating test scripts, in order to address the above-mentioned technical problems.

[0006] Firstly, this application provides a script generation method, the method comprising:

[0007] In response to a script generation request for the target test case, obtain the test steps, expected results, and functional interfaces recorded in the target test case;

[0008] Based on the functional interface, retrieve the test interface that matches the functional interface from the preset knowledge base;

[0009] Input the test steps, expected results, and test interfaces into a pre-built prompt word template to generate prompt words that match the target test case;

[0010] Input the prompt words into the test script generation model to obtain the test script.

[0011] In one embodiment, the knowledge base stores multiple test interfaces and semantic vectors corresponding to each test interface; based on the functional interface, a test interface matching the functional interface is obtained from the preset knowledge base, including:

[0012] Obtain the semantic vector corresponding to the functional interface;

[0013] Obtain the semantic vector corresponding to the functional interface and the similarity between it and the semantic vector corresponding to each test interface. Select the test interface with a similarity greater than or equal to the preset similarity threshold as the test interface that matches the functional interface.

[0014] In one embodiment, after obtaining the similarity between the semantic vector corresponding to the functional interface and the semantic vector corresponding to each candidate test interface, the method further includes obtaining the test interface corresponding to the test step:

[0015] If all similarity levels are less than the preset similarity threshold, the functional interface is input into the interface generation model to obtain a test interface that matches the functional interface.

[0016] In one embodiment, after obtaining a test interface that matches the functional interface, the method further includes:

[0017] Receive user feedback on the test interface;

[0018] Based on the feedback, optimize the test interface and obtain the optimized test interface;

[0019] Add the optimized test interface to the knowledge base to update the knowledge base.

[0020] In one embodiment, before retrieving a test interface matching the functional interface from a preset knowledge base based on the functional interface, the method further includes:

[0021] Obtain the test interface file, parse the test interface file, and obtain multiple test interfaces;

[0022] Obtain the semantic features of each test interface, vectorize the semantic features, and obtain the semantic vector corresponding to each test interface;

[0023] A pre-defined knowledge base is constructed based on each test interface and its corresponding semantic vector.

[0024] In one embodiment, after obtaining the test script, the method further includes:

[0025] Perform syntax checking on the test script and obtain the syntax checking results;

[0026] If the syntax detection results indicate that the test script contains syntax errors, the large language model is invoked to adjust the test script until a test script without syntax errors is obtained.

[0027] In one embodiment, the test script is subjected to syntax checking to obtain syntax checking results, including:

[0028] Using a syntax detector, the test script is checked for parentheses, variables, and commands, and mismatched parentheses, incorrect variable usage, and command errors are identified and recorded.

[0029] Secondly, this application also provides a script generation apparatus, the apparatus comprising:

[0030] The test step acquisition module is used to respond to script generation requests for target test cases and acquire the test steps, expected results, and functional interfaces recorded in the target test cases.

[0031] The test interface acquisition module is used to retrieve test interfaces that match the functional interfaces from a preset knowledge base.

[0032] The prompt word generation module is used to input test steps, expected results, and test interfaces into a pre-built prompt word template to generate prompt words that match the target test case;

[0033] The test script acquisition module is used to input prompt words into the test script generation model to obtain the test script.

[0034] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method steps of the first aspect.

[0035] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method steps of the first aspect.

[0036] The aforementioned script generation method, apparatus, computer device, and computer-readable storage medium, in response to a script generation request for a target test case, obtain the test steps, expected results, and functional interfaces recorded in the target test case; based on the functional interfaces, obtain a test interface matching the functional interface from a preset knowledge base; input the test steps, expected results, and test interfaces into a pre-built prompt word template to generate prompt words matching the target test case; input the prompt words into a test script generation model to obtain a test script; thus, this application improves the efficiency of test script generation by automatically generating test scripts based on the test steps, expected results, and test interfaces of the test case, by matching the test interface corresponding to the functional interface from a preset knowledge base and using a test script generation model. Attached Figure Description

[0037] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is an application environment diagram generated by a script in one embodiment;

[0039] Figure 2 This is a flowchart illustrating a script generation method in one embodiment;

[0040] Figure 3 This is a schematic diagram of the architecture of a script generation method in one embodiment;

[0041] Figure 4 This is a structural block diagram of a script generation device in one embodiment;

[0042] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0044] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0045] Software testing: Software testing is the process of verifying whether software meets user requirements, using either manual operation (manual testing) or automated operation (automated testing).

[0046] Automated testing: Automated testing, as opposed to manual testing, refers to converting complex testing tasks from manual to automated execution by machines using test code or third-party tools.

[0047] AIGC (Artificial Intelligence Generated Content) refers to the use of artificial intelligence technology to automatically generate various types of content, such as articles and code. Applying AIGC to automated script development can quickly and massively generate high-quality code, thereby reducing the manpower and time required for test code development.

[0048] The script generation method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 responds to a script generation request for a target test case by obtaining the test steps, expected results, and functional interfaces recorded in the target test case; based on the functional interfaces, it retrieves a test interface matching the functional interface from a preset knowledge base; it inputs the test steps, expected results, and test interfaces into a pre-built prompt word template to generate prompt words matching the target test case; and it inputs the prompt words into the test script generation model to obtain the test script. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, and tablets.

[0049] In one embodiment, such as Figure 2 As shown, a script generation method is provided. This embodiment applies this method to... Figure 1 Taking terminal 102 as an example, the method includes the following steps:

[0050] Step S210: In response to the script generation request for the target test case, obtain the test steps, expected results and functional interfaces recorded in the target test case.

[0051] The target test case refers to the test case for which the test script is to be generated.

[0052] Test cases refer to functional test cases for each module written based on software system requirements documents and design documents. Test cases include, but are not limited to, test case number, test case name, and test case content. Test case content includes, but is not limited to, test description, test steps, expected results, and functional interfaces.

[0053] For example, test case number: 001, test case title: Test User Login, test description: test user login function, test steps: Step 1: enter the correct username and password, Step 2: enter the correct username and incorrect password, expected results: Expect 1: user logs in normally, Expect 2: user cannot log in, functional interface: user login, detect user login result.

[0054] In this embodiment, the user can trigger a script generation request for the target test case through the terminal's interactive interface. The terminal responds to the script generation request by parsing the target test case to obtain the test steps, expected results, and functional interfaces. Test interfaces encapsulated by dedicated script developers can be obtained.

[0055] Step S220: Based on the functional interface, obtain the test interface that matches the functional interface from the preset knowledge base.

[0056] The test interface refers to the interface that the test steps need to call when generating the test script. The test interface includes, but is not limited to, the interface name, interface function, interface parameters and other information.

[0057] The knowledge base stores multiple test interfaces.

[0058] In this embodiment of the application, the functional interface can be semantically matched with each test interface in the knowledge base to obtain a test interface that matches the functional interface.

[0059] In step S230, the test steps, expected results, and test interfaces are input into a pre-built prompt word template to generate prompt words that match the target test case.

[0060] The prompt word templates include, but are not limited to, reference script examples and script generation rules. Reference script examples are used to standardize the format of generated test scripts. Script generation rules are used to indicate the constraints for generating test scripts.

[0061] In this embodiment, the test steps, expected results, and test interfaces are filled into the corresponding positions of the prompt word template and concatenated with the reference script example and script generation rules to obtain the prompt words.

[0062] Taking the prompt "Test user login function" as an example, the prompt specifically includes:

[0063] "You are an automation test engineer, and I need you to write test scripts based on the pytest framework and generate test reports using Allure. I will provide you with a usable reference script and the interfaces used in developing the script. Please refer to the example reference script to develop your script:"

[0064] @pytest.mark.A1

[0065] @allure.epic("XXX")

[0066] @allure.feature("XXX")

[0067] @allure.story("XXX")

[0068] class XXX:

[0069] @allure.title("XXX")

[0070] def test_01_login(self):

[0071] with allure.step("XXX"):

[0072] PASS

[0073] Please carefully understand the API functionality, parameter descriptions, and parameter value formats I have provided. You do not need to write an API test function. The test API is as follows:

[0074] def login(user_name,user_pwd):

[0075] “””

[0076] Function: User Login

[0077] :param user_name: Username; Parameter type: String

[0078] :param user_pwd: User password. Parameter type: string

[0079] :return:

[0080] “””

[0081] def check_user_login_status(user_name,expected):

[0082] “””

[0083] Function: Detect user login

[0084] :param user_name: Username; Parameter type: String

[0085] :param expected: The user's expected login result. Parameter type: Boolean. True indicates normal login, False indicates failure to log in normally.

[0086] :return:

[0087] “””

[0088] Please carefully understand the script generation rules, and then generate the script according to the use case steps.

[0089] Script generation rules:

[0090] 1. Replace @allure.feature("XXX"), @allure.story("XXX"), and class XXX in the generated script according to the test content.

[0091] 2. The description preceding the expected result in the test case steps is the test content.

[0092] 3. A test step is a complete test case and needs to be within the same test method.

[0093] 4. Usernames must contain uppercase and lowercase letters, numbers, periods, and underscores, and must not exceed 15 characters in length; user information descriptions must contain Chinese characters, uppercase and lowercase letters, numbers, and special characters, and must not exceed 64 characters in length.

[0094] Test steps: 1. Enter the correct username and password. Expected result: User logs in successfully.

[0095] 2. Enter the correct username and the wrong password; Expected result: The user cannot log in.

[0096] Step S240: Input the prompt words into the test script generation model to obtain the test script.

[0097] The test script generation model can be a trained AIGC model used to generate test scripts.

[0098] In this embodiment of the application, a model is generated by a test script, and the test script is output based on the prompt words.

[0099] In an optional embodiment, based on the test case number and test case name, a script file name, test class name, and test method name are generated. Test descriptions are added to the comments of the generated test methods, explaining the functionalities tested by the test case. For example, a file named 001_user_login_test.py is generated based on the example. The file contains a test class Test_User_Login(), which defines a test method test_user_login(). The content of the example test case generation file is as follows:

[0100] class Test_User_Login():

[0101] def test_user_login(self):

[0102] """

[0103] Test user login function

[0104] """

[0105] XXX

[0106] The generated test script is saved to the file 001_user_login_test.py.

[0107] The aforementioned script generation method, in response to a script generation request for a target test case, obtains the test steps, expected results, and functional interfaces recorded in the target test case; based on the functional interfaces, it retrieves test interfaces matching the functional interfaces from a pre-set knowledge base; it inputs the test steps, expected results, and test interfaces into a pre-built prompt word template to generate prompt words matching the target test case; and it inputs the prompt words into a test script generation model to obtain the test script. Thus, this application improves test script generation efficiency by automatically generating test scripts based on the test steps, expected results, and test interfaces of the test case, by matching test interfaces corresponding to the functional interfaces from a pre-set knowledge base and utilizing a test script generation model.

[0108] In one embodiment, the knowledge base stores multiple test interfaces and semantic vectors corresponding to each test interface; based on the functional interface, a test interface matching the functional interface is retrieved from the preset knowledge base, including:

[0109] Step S310: Obtain the semantic vector corresponding to the functional interface.

[0110] In this embodiment, the functional interface is semantically parsed to obtain semantic features. These semantic features are then vectorized to obtain the semantic vector corresponding to the functional interface.

[0111] Step S320: Obtain the semantic vector corresponding to the functional interface and the similarity between it and the semantic vector corresponding to each test interface. Select the test interface with a similarity greater than or equal to the preset similarity threshold as the test interface that matches the functional interface.

[0112] The preset similarity threshold can be set according to actual needs.

[0113] The degree of similarity can be measured by the cosine similarity of vectors.

[0114] In this embodiment of the application, test interfaces with a similarity greater than or equal to a preset similarity threshold can be used as test interfaces that match the functional interfaces.

[0115] Alternatively, test interfaces with a similarity level greater than or equal to a preset similarity threshold can be used as candidate test interfaces. The candidate test interfaces can be sorted from high to low according to their similarity level, and the preset number of candidate test interfaces at the top of the sorting can be used as test interfaces that match the functional interface.

[0116] This application embodiment stores automatically encapsulated test interfaces in a preset knowledge base, and based on a semantic matching process, it can ensure that the test interfaces can be accurately used when generating test scripts, thereby improving the accuracy of test script generation.

[0117] In one embodiment, after obtaining the semantic vector corresponding to the functional interface and the similarity between it and the semantic vectors corresponding to each candidate test interface, the method further includes obtaining the test interface corresponding to the test step.

[0118] Step S410: If all similarities are less than the preset similarity threshold, input the functional interface into the interface generation model to obtain a test interface that matches the functional interface.

[0119] The interface generation model can be a large language model, used to generate test interfaces.

[0120] In this embodiment of the application, if there is no test interface in the preset knowledge base with a semantic similarity greater than or equal to the preset similarity threshold, then a test interface matching the functional interface is generated through the interface generation model.

[0121] In one embodiment, after obtaining a test interface that matches the functional interface, the method further includes:

[0122] Step S510: Receive user feedback information on the test interface;

[0123] Step S520: Based on the feedback information, optimize the test interface to obtain the optimized test interface;

[0124] Step S530: Add the optimized test interface to the knowledge base to update the knowledge base.

[0125] The feedback information is used to characterize whether the test interface is available.

[0126] In this embodiment, when the test interface output by the interface generation model is unavailable, the test interface can be adjusted, optimized, or regenerated to obtain an optimized test interface. Adjusting and optimizing the test interface includes, but is not limited to, correcting the interface parameter names, paths, and interface parameter types.

[0127] Saving the optimized test interface as a new test interface to the knowledge base can expand the number of test interfaces in the knowledge base, making it easier to automatically and quickly match the test interface when generating subsequent test scripts.

[0128] In one embodiment, before retrieving a test interface matching the functional interface from a preset knowledge base based on the functional interface, the method further includes:

[0129] Step S610: Obtain the test interface file, parse the test interface file, and obtain multiple test interfaces.

[0130] The test interface file includes multiple test interfaces.

[0131] In this embodiment of the application, the individual test interfaces in the test interface file are identified by parsing the test interface file.

[0132] Step S620: Obtain the semantic features of each test interface, vectorize the semantic features, and obtain the semantic vector corresponding to each test interface.

[0133] In this embodiment of the application, semantic extraction and vectorization are performed on each test interface to obtain the semantic vector corresponding to each test interface.

[0134] Step S630: Construct a pre-defined knowledge base based on each test interface and its corresponding semantic vector.

[0135] In this embodiment of the application, each test interface and the semantic vector corresponding to each test interface are saved to the knowledge base.

[0136] In one embodiment, after obtaining the test script, the method further includes:

[0137] Step S710: Perform syntax checking on the test script and obtain the syntax checking results;

[0138] Step S720: If the syntax detection result indicates that the test script has syntax errors, the large language model is called to adjust the test script until a test script without syntax errors is obtained.

[0139] The syntax detection includes, but is not limited to, detection of illegal characters, keyword spelling, number formatting, unclosed strings, nested comments, and mismatched brackets.

[0140] In this embodiment of the application, when there is a syntax error in the test script, the syntax error is corrected by using a large language model to obtain a grammatically correct test script.

[0141] In one embodiment, syntax checking is performed on the test script to obtain syntax checking results, including:

[0142] Step S810: Use a syntax detector to check the parentheses, variables, and commands in the test script, and identify and record parenthesis mismatches, variable usage errors, and command errors.

[0143] The syntax detector can be an AST (Abstract Syntax Tree) parser.

[0144] In this embodiment of the application, a syntax detector is used to detect whether the left and right parentheses of the test script are missing, whether the variable name is misspelled, whether the variable is undefined, whether the variable is used in the wrong scope, whether the command parameters are misspelled, and whether the command path is wrong. The detected errors are recorded to obtain the syntax detection results.

[0145] To understand the above method embodiments, such as Figure 3 As shown, the process involves extracting test steps, expected results, and functional interfaces from the uploaded test case file; extracting test interfaces from the uploaded interface file and saving them to the knowledge base; matching the corresponding test interfaces from the knowledge base based on the functional interfaces, and filling the test steps, expected results, and test interfaces into the specified positions of the prompt word template to generate prompt words; and calling the AIGC interface to input the prompt words into the AIGC model to obtain the test script. If a corresponding test interface cannot be matched from the knowledge base, a new test interface is generated using the interface generation model and added to the knowledge base.

[0146] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0147] In one exemplary embodiment, such as Figure 4 As shown, a script generation apparatus is provided, the apparatus comprising:

[0148] The test step acquisition module 410 is used to respond to the script generation request for the target test case and acquire the test steps, expected results and functional interfaces recorded in the target test case.

[0149] The test interface acquisition module 420 is used to acquire a test interface that matches the function interface from a preset knowledge base based on the function interface.

[0150] The prompt word generation module 430 is used to input the test steps, expected results and test interfaces into a pre-built prompt word template to generate prompt words that match the target test case;

[0151] The test script acquisition module 440 is used to input prompt words into the test script generation model to obtain the test script.

[0152] In one embodiment, the knowledge base stores multiple test interfaces and semantic vectors corresponding to each test interface; based on the functional interface, a test interface matching the functional interface is obtained from the preset knowledge base, including:

[0153] Obtain the semantic vector corresponding to the functional interface;

[0154] Obtain the semantic vector corresponding to the functional interface and the similarity between it and the semantic vector corresponding to each test interface. Select the test interface with a similarity greater than or equal to the preset similarity threshold as the test interface that matches the functional interface.

[0155] In one embodiment, after obtaining the similarity between the semantic vector corresponding to the functional interface and the semantic vector corresponding to each candidate test interface, the method further includes obtaining the test interface corresponding to the test step:

[0156] If all similarity levels are less than the preset similarity threshold, the functional interface is input into the interface generation model to obtain a test interface that matches the functional interface.

[0157] In one embodiment, after obtaining a test interface that matches the functional interface, the method further includes:

[0158] Receive user feedback on the test interface;

[0159] Based on the feedback, optimize the test interface and obtain the optimized test interface;

[0160] Add the optimized test interface to the knowledge base to update the knowledge base.

[0161] In one embodiment, before retrieving a test interface matching the functional interface from a preset knowledge base based on the functional interface, the method further includes:

[0162] Obtain the test interface file, parse the test interface file, and obtain multiple test interfaces;

[0163] Obtain the semantic features of each test interface, vectorize the semantic features, and obtain the semantic vector corresponding to each test interface;

[0164] A pre-defined knowledge base is constructed based on each test interface and its corresponding semantic vector.

[0165] In one embodiment, after obtaining the test script, the method further includes:

[0166] Perform syntax checking on the test script and obtain the syntax checking results;

[0167] If the syntax detection results indicate that the test script contains syntax errors, the large language model is invoked to adjust the test script until a test script without syntax errors is obtained.

[0168] In one embodiment, the test script is subjected to syntax checking to obtain syntax checking results, including:

[0169] Using a syntax detector, the test script is checked for parentheses, variables, and commands, and mismatched parentheses, incorrect variable usage, and command errors are identified and recorded.

[0170] The aforementioned script generation device, in response to a script generation request for a target test case, obtains the test steps, expected results, and functional interfaces recorded in the target test case; based on the functional interface, it retrieves a test interface matching the functional interface from a preset knowledge base; it inputs the test steps, expected results, and test interface into a pre-built prompt word template to generate prompt words matching the target test case; and it inputs the prompt words into a test script generation model to obtain the test script. Thus, this application improves test script generation efficiency by automatically generating test scripts based on the test steps, expected results, and test interfaces of the test case, by matching the test interface corresponding to the functional interface from a preset knowledge base and utilizing the test script generation model.

[0171] Each module in the aforementioned script generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0172] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows. Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores script generation data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a script generation method.

[0173] Those skilled in the art will understand that Figure 5The structures shown are merely block diagrams of some structures related to the present application and do not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements. In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of the script generation method described above. The steps of the script generation method described here may be steps from one of the script generation methods in the various embodiments described above.

[0174] In one embodiment, a computer-readable storage medium is provided, storing a computer program that, when executed by a processor, causes the processor to perform the steps of the script generation method described above. The steps of the script generation method described here may be steps from one of the script generation methods in the various embodiments described above.

[0175] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, causes the processor to perform the steps of the script generation method described above. The steps of the script generation method described here may be steps from one of the script generation methods in the various embodiments described above.

[0176] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0177] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0178] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0179] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A script generation method, characterized in that, The method includes: In response to a script generation request for a target test case, obtain the test steps, expected results, and functional interfaces recorded in the target test case; Based on the functional interface, obtain the test interface that matches the functional interface from the preset knowledge base; The test steps, the expected results, and the test interface are input into a pre-built prompt word template to generate prompt words that match the target test case. The prompt words are input into the test script generation model to obtain the test script.

2. The method according to claim 1, characterized in that, The knowledge base stores multiple test interfaces and semantic vectors corresponding to each test interface; the step of retrieving a test interface matching the functional interface from the preset knowledge base includes: Obtain the semantic vector corresponding to the functional interface; Obtain the semantic vector corresponding to the functional interface and the similarity between it and the semantic vector corresponding to each of the test interfaces. Select the test interfaces whose similarity is greater than or equal to a preset similarity threshold as the test interfaces that match the functional interface.

3. The method according to claim 2, characterized in that, After obtaining the similarity between the semantic vector corresponding to the functional interface and the semantic vector corresponding to each of the test interfaces, the method further includes: If all the aforementioned similarities are less than the preset similarity threshold, the functional interface is input into the interface generation model to obtain a test interface that matches the functional interface.

4. The method according to claim 3, characterized in that, After obtaining the test interface that matches the functional interface, the method further includes: Receive user feedback information regarding the test interface; Based on the feedback information, optimize the test interface to obtain the optimized test interface; The optimized test interface is added to the knowledge base to update the knowledge base.

5. The method according to claim 1, characterized in that, Before retrieving a test interface matching the functional interface from a preset knowledge base based on the functional interface, the method further includes: Obtain the test interface file, parse the test interface file, and obtain multiple test interfaces; Obtain the semantic features of each of the test interfaces, and vectorize the semantic features to obtain the semantic vector corresponding to each of the test interfaces; The preset knowledge base is constructed based on each test interface and the semantic vector corresponding to each test interface.

6. The method according to any one of claims 1 to 5, characterized in that, After obtaining the test script, the method further includes: Perform syntax checking on the test script and obtain the syntax checking results; If the grammar detection result indicates that the test script has grammatical errors, the large language model is invoked to adjust the test script until a grammatically correct test script is obtained.

7. The method according to claim 6, characterized in that, The step of performing syntax detection on the test script and obtaining the syntax detection result includes: Using a syntax detector, the test script is inspected for parentheses, variables, and commands, and mismatched parentheses, incorrect variable usage, and command errors are identified and recorded.

8. A script generation device, characterized in that, The device includes: The test step acquisition module is used to respond to a script generation request for a target test case and acquire the test steps, expected results, and functional interfaces recorded in the target test case. The test interface acquisition module is used to acquire a test interface that matches the function interface from a preset knowledge base based on the function interface. The prompt word generation module is used to input the test steps, the expected results, and the test interface into a pre-built prompt word template to generate prompt words that match the target test case; The test script acquisition module is used to input the prompt words into the test script generation model to obtain the test script.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.