Interface test case generation method and device, storage medium and program product

Through the language model, the problem of low efficiency and insufficient coverage of interface test cases in the existing technology is solved, and efficient and comprehensive coverage of test cases is achieved, and the maintenance process is simplified.

CN119149425APending Publication Date: 2024-12-17KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411311110.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

When generating interface test cases, the prior art is inefficient, insufficient coverage and difficult to maintain, and testers need to understand the relevant knowledge of the interface, resulting in low generation efficiency and difficulty in covering various situations in full.

Method used

By obtaining the use case step prompts and interface description, parameter description, interface structure and other information of the interface to be tested, input it into the language model to generate interface test cases, including obtaining required parameters, data query statements, verification formulas and verification results. , use language models to automatically generate test cases, improve efficiency and reduce maintenance costs.

Benefits of technology

It realizes automatic generation of interface test cases, improves testing efficiency, enhances coverage, and can cover normal and abnormal situations more comprehensively, reduces the risk of manual participation, and simplifies the maintenance of interface test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149425A_ABST
    Figure CN119149425A_ABST
Patent Text Reader

Abstract

The invention provides an interface test case generation method and device, a storage medium and a program product. The interface test case generation method disclosed by the invention comprises the following steps: acquiring a case stepwise prompt as well as an interface description, an input parameter description, an interface structure and test data of a to-be-tested interface; inputting the interface description, the input parameter description, the interface structure, the test data and the use case step-by-step prompt into a use case language model to obtain an interface test case; wherein the use case stepwise prompt is used for guiding the use case language model to execute the following steps: acquiring communication parameters and necessarily transmitted parameters from the interface structure and the input parameter description, and generating an interface test case according to the interface description, the communication parameters, the necessarily transmitted parameters and the test data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to an interface test case generation method, device, storage medium and program product. Background Art

[0002] Interface testing is a testing method used to verify the correctness, reliability, performance and security of the interface in the software system. It mainly focuses on whether the interface for data exchange between modules or systems in the system can correctly perform its expected functions. As software systems become more and more complex, the importance of interface testing is increasing. Interface testing includes not only functional testing, but also performance testing, security testing, compatibility testing and other aspects.

[0003] As the core of interface testing, interface test cases determine the comprehensiveness and depth of testing. A good test case can fully cover various situations of the interface, including normal situations, boundary situations and abnormal situations, thus ensuring the stability and reliability of the system.

[0004] However, when generating interface test cases, testers are generally required to understand the interface-related knowledge before generating them, which results in low test efficiency, insufficient coverage and difficulty in maintenance. Summary of the invention

[0005] In order to solve one of the above technical problems, the present disclosure provides an interface test case generation method, device, storage medium and program product.

[0006] According to one aspect of the present disclosure, a method for generating an interface test case is provided, comprising: Get the use case step-by-step prompts and the interface description, input parameter description, interface structure and test data of the interface to be tested; Input the interface description, the input parameter description, the interface structure, the test data and the use case step prompt into a use case language model to obtain an interface test case; Among them, the use case step-by-step prompts are used to guide the use case language model to perform the following steps: obtain communication parameters and required parameters from the interface structure and the input parameter description, and generate an interface test case based on the interface description, the communication parameters, the required parameters and the test data.

[0007] According to at least one embodiment of the present disclosure, a method for generating an interface test case is provided, wherein the step-by-step prompts for obtaining the test case and the interface description, input parameter description, interface structure and test data of the interface to be tested are obtained, including: Get data step-by-step prompts and interface description, input parameter description, interface structure, input parameter data table and data definition language of the interface to be tested; Analyze the required parameters according to the interface description, the input parameter description and the interface structure to obtain the required parameters; Input the interface description, the input parameter description, the interface structure, the input parameter data table, the data definition language, the required parameters and the data step prompt into a data language model to obtain interface test data; Among them, the data step prompt is used to guide the data language model to perform the following steps: when it is determined according to the data definition language that the input parameter data table includes a field corresponding to the parameter to be queried, a data query statement for the parameter to be queried is created and executed according to the interface description, the input parameter description and the interface structure to obtain interface test data.

[0008] According to at least one embodiment of the present disclosure, a method for generating an interface test case is provided, wherein the required parameter analysis is performed according to the interface description, the input parameter description and the interface structure to obtain the required query parameters, including: Get parameter step prompts; Input the interface description, the input parameter description, the interface structure and the parameter step-by-step prompts into a parameter language model to obtain the parameters to be queried; Among them, the parameter step prompt is used to guide the parameter language model to perform the following steps: obtain the required parameters according to the interface structure, obtain the input parameter default values ​​according to the input parameter description, compare the required parameters and the input parameter default values ​​according to the interface description, and obtain the parameters to be checked.

[0009] According to at least one embodiment of the present disclosure, the method for generating an interface test case further comprises, after obtaining the interface test case: Obtaining initial data and verification formula corresponding to the interface test case: executing the interface test case to obtain output data; Interface verification is performed according to the initial data, the verification formula and the output data to obtain a verification result.

[0010] According to the interface test case generation method provided by at least one embodiment of the present disclosure, the obtaining of initial data and verification formula corresponding to the interface test case includes: Obtain historical step-by-step prompts and interface expectations, coding definitions, output parameter data tables, and data definition languages ​​of the interface to be tested; Input the interface description, interface expectation, coding definition, parameter data table, data definition language and historical step prompt of the interface to be tested into a historical language model to obtain initial data and a verification formula; Among them, the historical step-by-step prompt is used to guide the historical language model to perform the following steps: obtain the query data and data fields before and after the execution of the interface test case according to the interface expectation, the output parameter data table and the data definition language, create an initial query statement and verification formula according to the interface description, coding definition, the query data and data fields before and after the execution of the interface test case, and execute the initial query statement before executing the interface test case to obtain initial data.

[0011] According to at least one embodiment of the present disclosure, the interface test case generation method provided, performing interface verification according to the initial data, the verification formula and the output data to obtain a verification result includes: Obtaining the interface type of the interface to be tested; Assembling the initial data and the output data according to the interface type to obtain assembled data; Interface verification is performed according to the assembly data and the verification formula to obtain a verification result.

[0012] According to at least one embodiment of the present disclosure, the interface test case generation method provided, performing interface verification according to the assembly data and the verification formula to obtain a verification result includes: Obtain verification step prompts and interface expectations of the interface to be tested; Input the interface expectation, the assembly data, the verification formula and the verification step prompt into a verification language model to obtain a verification result; Among them, the verification step prompt is used to guide the verification language model to perform the following steps: determine the expected data according to the interface expectation, the assembly data and the verification formula, compare the output data and the expected data in the assembly data, and obtain the verification result.

[0013] According to another aspect of the present disclosure, there is provided an interface test case generating device, comprising: a memory storing execution instructions; and A processor executes the execution instructions stored in the memory, so that the processor executes the interface test case generation method provided by at least one embodiment of the present disclosure.

[0014] According to another aspect of the present disclosure, a readable storage medium is provided, in which execution instructions are stored. When the execution instructions are executed by a processor, the method for generating an interface test case provided by at least one embodiment of the present disclosure is implemented.

[0015] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the interface test case generating method provided by at least one embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0017] Figure 1 It is a schematic flowchart of the interface test case generation method provided according to an embodiment of the present disclosure.

[0018] Figure 2 This is the process of the interface test case generation method provided in Example 1 of the present disclosure Figure 1 .

[0019] Figure 3 yes Figure 2 The flowchart of the method for obtaining interface test data in the interface test case generation method shown.

[0020] Figure 4 yes Figure 3 The flowchart of the method for obtaining the required parameters in the method for obtaining interface test data is shown.

[0021] Figure 5 This is the process of the interface test case generation method provided in Example 1 of the present disclosure Figure 2 .

[0022] Figure 6 yes Figure 5 The flowchart of the method for obtaining the verification formula in the interface test case generation method shown.

[0023] Figure 7 yes Figure 5 The flowchart of the interface verification method in the interface test case generation method is shown.

[0024] Figure 8 yes Figure 7 The flowchart of the model verification method in the interface verification method is shown.

[0025] Fig. 9 yes Figure 2 The flowchart of the method for obtaining interface parameters in the interface test case generation method shown.

[0026] Fig.10 yes Fig. 9 The flowchart of the method for obtaining interface knowledge base in the method for obtaining interface parameters is shown.

[0027] Fig.11 yes Fig. 9 The flowchart of the method for obtaining test data in the method for obtaining interface parameters is shown.

[0028] Fig.12 This is a schematic diagram of the structure of the interface test case generation device provided in Example 2 of the present disclosure. Figure 1 .

[0029] Fig.13 This is a schematic diagram of the structure of the interface test case generation device provided in Example 2 of the present disclosure. Figure 2 . DETAILED DESCRIPTION

[0030] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.

[0031] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0032] As a core part of the software quality assurance system, interface testing is essentially a rigorous test of the communication protocols between software components to ensure that these components can work together seamlessly to build a stable, efficient and secure software system. In today's highly interconnected and microservice-based IT environment, the role of interface testing is particularly prominent. It not only verifies the correctness of functions, but also ensures the accurate transmission of data, the response speed of the system, the rational use of resources and the ability to resist potential security threats at a deep level. As the basis for the implementation of interface testing, test cases are generally generated manually. However, manually generated test cases have problems such as low efficiency, insufficient coverage and difficulty in maintenance.

[0033] Figure 1 A schematic flowchart of the interface test case generation method provided by an embodiment of the present disclosure is shown. Figure 1 The detailed description is for a clearer understanding of the technical solution of the present disclosure and should not be considered as a limitation of the protection scope of the present disclosure. In the process of implementing the technical idea of ​​the present disclosure, one or some steps may be omitted, or other alternatives may be adopted.

[0034] Step S110, obtaining data step prompts and interface description, input parameter description, interface structure, input parameter data table and data definition language of the interface to be tested.

[0035] In some embodiments of the present disclosure, the data step-by-step prompt in step S110 is a type of step-by-step prompt. "Step-by-step prompt" is a specific type of input instruction that aims to guide the model to perform tasks or generate responses in a series of ordered steps. This type of prompt usually contains clear sequence instructions, each instruction corresponds to a stage of completing a task, ensuring that the model can understand and follow a specific process to achieve the ultimate goal. The data step-by-step prompt in step S110 is used to guide the data language model to create and execute the data query statement of the parameter to be queried according to the interface description, input parameter description and interface structure when determining that the input parameter data table includes the field corresponding to the parameter to be queried according to the data definition language, and obtain the interface test data.

[0036] In particular, in order to improve the accuracy of data language model processing, the data step prompt can be specifically used to guide the data language model to perform the following steps: determine whether the input parameter table includes the field corresponding to the parameter to be queried according to the data definition language; if included, create and execute the data query statement of the parameter to be queried according to the interface description, input parameter description and interface structure to obtain interface test data; if not included, terminate the generation of interface test cases. In order to optimize the interface test case generation method, if not included, terminating the generation of interface test cases may include: if not included, prompting for additional information and terminating the generation of interface test cases.

[0037] Step S111, obtaining parameter step prompts.

[0038] In some embodiments of the present disclosure, the parameter step prompt in step S111 is also a type of step prompt, which is used to guide the parameter language model to perform the following steps: obtain the required parameters according to the interface structure, obtain the input parameter default values ​​according to the input parameter description, compare the required parameters and the input parameter default values ​​according to the interface description, and obtain the parameters to be checked.

[0039] Step S112, input the interface description, input parameter description, interface structure and parameter step prompts into the parameter language model to obtain the parameters to be checked.

[0040] Step S113, input the interface description, input parameter description, interface structure, input parameter data table, data definition language, required parameters and data step prompts into the data language model to obtain interface test data.

[0041] Step S114, obtaining use case step-by-step prompts.

[0042] In some embodiments of the present disclosure, the parameter step prompt in step S112 and the use case step prompt in step S114 are both a type of step prompt. Among them, the parameter step prompt is used to guide the parameter language model to perform the following steps: obtain the required parameters according to the interface structure, obtain the input parameter default value according to the input parameter description, compare the required parameters and the input parameter default value according to the interface description, and obtain the required parameters. The use case step prompt is used to guide the use case language model to perform the following steps: obtain communication parameters and required parameters from the interface structure and input parameter description, and generate an interface test case according to the interface description, communication parameters, required parameters and test data.

[0043] Step S115, input the interface description, input parameter description, interface structure, test data and use case step prompts into the use case language model to obtain the interface test case.

[0044] Step S116, obtaining historical step-by-step prompts and interface expectations, coding definitions, output parameter data tables, and data definition languages ​​of the interface to be tested.

[0045] In some embodiments of the present disclosure, the historical step-by-step prompt in step S116 is a type of step-by-step prompt, which is used to guide the historical language model to perform the following steps: obtain the query data and data fields before and after the execution of the interface test case according to the interface expectations, output parameter data table and data definition language, create verification query statements and verification formulas according to the interface description, coding definition, and query data and data fields before and after the execution of the interface test case, and execute the verification query statement before executing the interface test case to obtain initial data.

[0046] Step S117, input the interface description, interface expectation, coding definition, parameter data table, data definition language and historical step prompts of the interface to be tested into the historical language model to obtain initial data and verification formula.

[0047] Step S118, execute the interface test case to obtain output data.

[0048] Step S119, obtaining the interface type of the interface to be tested.

[0049] In some implementations of the present disclosure, the interface type acquired in step S119 includes a read interface or a write interface.

[0050] Step S120, assembling the initial data and the output data according to the interface type to obtain assembled data.

[0051] Step S121, obtaining verification step prompts and interface expectations of the interface to be tested.

[0052] In some embodiments of the present disclosure, the verification step prompt in step S121 is a type of step prompt, which is used to guide the verification language model to perform the following steps: determine the expected data according to interface expectations, assemble data, verify query statements and verification formulas, compare the output data and expected data in the assembled data, and obtain the verification result.

[0053] Step S122, input the interface expectation, assembly data, verification formula and verification step prompts into the verification language model to obtain the verification result.

[0054] In some embodiments of the present disclosure, the use case language model, data language model, parameter language model, historical language model and verification language model are all a type of language model. The language model can be a traditional language model, such as a statistical language model (N-gram model, maximum entropy model, hidden Markov model, etc.), a language model based on a neural network, etc.; it can also be a pre-trained model with a large number of parameters, such as the GPT series models (such as GPT-1, GPT-2, etc.), the BERT series models (such as BERT, RoBERTa, ALBERT, etc.), the M6 ​​model, the Tongyi Qianwen model, etc. The above-mentioned use case language model, data language model, parameter language model, historical language model and verification language model can be the same language model or different language models.

[0055] Combine the following Figures 2 to 11 The interface test case generation method disclosed in the present invention is described in detail.

[0056] Embodiment 1: Figure 2 The present invention is a flowchart of a method for generating interface test cases according to an embodiment of the present invention.

[0057] refer to Figure 2 The interface test case generation method M200 of this embodiment includes: Step S210, obtaining the use case step prompts and the interface description, input parameter description, interface structure and test data of the interface to be tested.

[0058] Step S220, input the interface description, input parameter description, interface structure, test data and use case step prompts into the use case language model to obtain the interface test case.

[0059] The use case step prompt is used to guide the use case language model to perform the following steps: obtain communication parameters and required parameters from the interface structure and input parameter description, and generate an interface test case according to the interface description, communication parameters, required parameters and test data.

[0060] The interface test case generation method provided by the present disclosure inputs the data of the interface to be tested and the use case step prompt into the use case language model, guides the use case language model to execute the use case generation step through the use case step prompt, and obtains the interface test case. The interface test case generation method does not require human participation, can improve the efficiency of interface test case generation and reduce costs, and when the interface to be tested is adjusted, only the data of the interface to be tested needs to be adjusted, which is convenient for maintenance, and solves the problem that in the prior art, when generating interface test cases, the tester generally needs to understand the interface-related knowledge before generating, and the test efficiency is low and difficult to maintain. In addition, since the language model is usually trained with massive text data, a variety of interface test cases can be generated through the language model, which helps to cover different scenarios and edge cases, and can solve the problem that manual testing may not cover all possible test scenarios, insufficient coverage, thereby increasing the risk of missing potential problems.

[0061] In some embodiments of the present disclosure, the interface description of the interface to be tested in step S210 is a detailed description of the function, input and output, behavior and limitation of a certain interface in the software system; the interface description generally includes: interface name (used to concisely and clearly describe the function or purpose of the interface for easy identification and reference), interface type (such as RESTful API, SOAP Web service, RPC call, etc.), interface URL / URI (the complete path or endpoint of the interface, including HTTP method (such as GET, POST, PUT, DELETE, etc.) and URL), HTTP method (if applicable) (describing the HTTP request type supported by the interface, such as GET for retrieving data, POST for sending data, PUT for updating data, and DELETE for deleting data), request header (required HTTP header information, such as authentication token, content type, etc.), request parameters (such as path parameters (parameters that must be included in the URL, usually used to uniquely identify resources), query parameters (parameters appended to the URL for filtering, sorting or paging, etc.), request body parameters (if it is a POST or PUT request, the format of the request body needs to be detailed (JSON, XML, etc.) and the specific fields and data types it contains, etc.; it should include the name, type, whether it is required, description, default value, etc. of each parameter), request example (used to provide sample code or data for the request, including the complete format of the request and the expected response data, which is helpful for understanding and testing the interface), response header (used for returning HTTP header information, such as Content-Type, Set-Cookie, etc.), response body (describes what data a successful response should contain, as well as the structure and format of the data), response code (used to indicate the HTTP status code and its meaning in different situations, such as 200 (success), 400 (request error), 40 4 (not found), 500 (server error), etc.), response examples (used to provide sample response data to help users understand the output of the interface), error handling (define the error codes and messages returned in various error situations to facilitate debugging and troubleshooting), security considerations (describe the authentication and authorization mechanisms of the interface, such as authentication, authorization, encryption requirements, etc.), version information (used to provide the version number of the interface, as well as the change records between versions to help users understand the compatibility and changes of the interface) and notes (any other information that needs to be explained to help developers better understand the usage scenarios and details of the interface, such as interface limitations, performance considerations, usage scenarios, etc.). Interface descriptions help to understand and use the interface.

[0062] The input parameter description of the interface to be tested in step S210 refers to a detailed description of the input parameters required when calling the API or interface. These descriptions help understand how to construct effective test cases and ensure that all necessary scenarios are covered. The input parameter description usually includes the following: parameter name (each parameter has a clear name for identification and reference), parameter type (defines the data type of the parameter, such as string, integer, floating point number, Boolean, array, object, etc.), parameter description (explains the purpose, meaning and possible value range of the parameter, and explains its role in the interface logic), required / optional (specifies whether the parameter is required, that is, whether this parameter must be included when the interface is called), default value (if applicable) (if the parameter is optional, a default value can be provided when the parameter is not provided , the default value will be used), value range (valid value range of the parameter, such as the maximum and minimum value of a numeric parameter, or the length limit of a string parameter, etc.), parameter position (specify the position of the parameter in the request, such as path parameter (path), query parameter (query), request body parameter (body), header parameter (header), etc.), example value (give one or more example values ​​of the parameter to help build test cases), special rules (any special rules that may exist, such as regular expression matching, enumeration types, etc.) and associated parameters (if there is a dependency relationship between parameters, this relationship needs to be described, such as the presence or absence of a parameter affects the validity of another parameter). Detailed description of input parameters can help you better understand the requirements of the interface, create comprehensive test cases, and verify the behavior and response of the interface under various input conditions.

[0063] The interface structure of the interface to be tested in step S210 refers to the composition and design of the API (application programming interface) or interface, which describes how to communicate with the service over the network. Understanding the interface structure is crucial to writing effective test cases and ensuring that the interface works as expected. Usually an interface structure includes the following parts: base URL (specifies the URL or URI for accessing the interface), HTTP method (defines the request type, such as GET (retrieve information), POST (create resources), PUT (update resources), DELETE (delete resources), etc.), request header (HTTP header information required by the interface, such as authentication information (Authorization), content type (Content-Type), accepted data type (Accept), etc.), request body (depending on the HTTP method, it may carry request data; for POST and PUT requests, the request body usually contains the data to be sent, which can be in JSON, XML or other formats), query parameters (attached to the URL to filter, sort or modify the results of the request), path parameters (Path Parameters) (parameters embedded in the URL, usually used to identify specific resources, such as {userId} in / users / {userId}), response status code (HTTP status code and its description in different situations, indicating the result of the request, such as 200 (success), 400 (wrong request), 404 (resource not found), 500 (internal server error), etc.), response body (data returned by the server, usually also in JSON, XML or other formats), error handling (describes how the interface should respond when encountering an error, including error codes, error messages and possible solutions as well as documentation and comments). In interface testing, test cases need to be generated based on the interface structure to ensure that all functions and boundary conditions of the interface are fully verified.

[0064] In some embodiments of the present disclosure, the use case language model is guided to perform tasks in a series of orderly steps through use case step-by-step prompts, ensuring that the use case language model can understand and follow a specific process to generate interface test cases, thereby significantly improving the ability of the use case language model to understand and generate interface test cases.

[0065] In some embodiments of the present disclosure, in order to improve the comprehensiveness of test cases (i.e., not only covering normal or expected processes, but also being able to respond correctly to non-standard or unexpected inputs) and security, the interface test cases obtained through step S220 include not only normal test cases, but also abnormal test cases. At this time, the use case step prompt is used to guide the use case language model to perform the following steps: when generating an interface test case according to the interface description, communication parameters, required parameters and test data, it is specifically used to generate a normal test case according to the interface description, input parameter description, communication parameters and test data, and generate an abnormal test case according to the interface description, input parameter description, communication parameters and required parameters.

[0066] In some embodiments of the present disclosure, Figure 3 As shown, step S210 may include: step S211, obtaining data step prompts and interface description, input parameter description, interface structure, input parameter data table and data definition language of the interface to be tested; step S212, performing mandatory parameter analysis according to the interface description, input parameter description and interface structure to obtain parameters to be checked; step S213, inputting the interface description, input parameter description, interface structure, input parameter data table, data definition language, parameters to be checked and data step prompts into a data language model to obtain interface test data; wherein the data step prompts are used to guide the data language model to create and execute data query statements for the parameters to be checked according to the interface description, input parameter description and interface structure when determining that the input parameter data table includes fields corresponding to the parameters to be checked according to the data definition language, so as to obtain interface test data.

[0067] In particular, in order to improve the processing capability of the data language model, the data step prompt can also be specifically used to guide the data language model to perform the following steps: determine whether the input parameter data table includes the field corresponding to the parameter to be queried according to the data definition language; if included, create and execute the data query statement of the parameter to be queried according to the interface description, input parameter description and interface structure to obtain the interface test data; if not included, terminate the generation of interface test data. Among them, in order to optimize the interface test case generation method, "if not included, terminate the generation of interface test cases" can include: if not included, prompt for additional information and terminate the generation of interface test cases.

[0068] In some embodiments of the present disclosure, the input parameter data table of the interface to be tested is a document used for interface test design, which records and manages in detail the input parameters and their properties required when the interface is called. This table usually contains all the key information required for interface testing, ensuring comprehensive test coverage, and also facilitates testers to quickly understand the input requirements of the interface. The following are the columns that may be included in the input parameter data table: parameter name (unique identifier of the parameter, used to reference the parameter in the interface call), parameter type (data type of the parameter, such as string, integer, floating point number, Boolean value, array, object, etc.), required / optional (marks whether the parameter is required. Required parameters must be provided when the interface is called, while optional parameters can be selectively provided according to business logic), default value (the default value used by the interface when the optional parameter is not explicitly provided), description (a brief description of the meaning and function of the parameter, as well as its position and importance in the interface logic), value range (the valid value range of the parameter, such as the maximum and minimum values ​​of numeric parameters, the length limit or format requirement of string parameters), example value (provides one or two example values ​​of the parameter to help testers build test cases), notes (any additional instructions or precautions, such as dependencies between parameters, special character processing rules, etc.), test case ID (associated test case number for easy tracking and maintenance), and expected results (for each parameter, the expected behavior or response of the interface under different input values ​​may be listed). Through such a structured approach, it can be ensured that all input parameters of the interface are fully considered, and test cases covering various boundary conditions and abnormal situations can be designed, thereby improving the completeness and effectiveness of the test.

[0069] In some embodiments of the present disclosure, the data definition language (DDL) of the interface to be tested is a set of SQL statements used to define the structure of a database table. It describes the structure of a table, fields and their attributes, constraints, etc. DDL generally includes CREATE TABLE (used to create a new database table, which defines the table name and columns in the table, including the data type and constraints of each column), ALTER TABLE (used to modify the structure of an existing table; such as adding, modifying or deleting columns, changing primary keys, adding foreign keys, etc.) and DROP TABLE (used to delete a table; in a test environment, this may be used to clean up data or reset the test status), etc. These DDLs help define and manage the structure and constraints of database tables to ensure the integrity and consistency of data.

[0070] In some embodiments of the present disclosure, data step-by-step prompts are used to guide the data language model to perform tasks in a series of ordered steps, ensuring that the data language model can understand and follow a specific process to generate interface test data, thereby significantly improving the data language model's ability to understand and generate interface test data.

[0071] In some embodiments of the present disclosure, Figure 4 As shown, step S212 may include: step S2121, obtaining parameter step prompts; step S2122, inputting the interface description, input parameter description, interface structure and parameter step prompts into the parameter language model to obtain the parameters to be checked; wherein the parameter step prompts are used to guide the parameter language model to perform the following steps: obtaining the required parameters according to the interface structure, obtaining the input parameter default values ​​according to the input parameter description, comparing the required parameters with the input parameter default values ​​according to the interface description, and obtaining the parameters to be checked.

[0072] In some embodiments of the present disclosure, parameter step-by-step prompts are used to guide the parameter language model to perform tasks in a series of orderly steps, ensuring that the parameter language model can understand and follow a specific process to generate the required parameters, thereby significantly improving the parameter language model's ability to understand and generate the required parameters.

[0073] Furthermore, if Figure 5 As shown, the interface test case generation method provided by the present disclosure may also include: Step S230, obtaining initial data and verification formula corresponding to the interface test case.

[0074] In some embodiments of the present disclosure, the initial data in step S230 is the data before the execution of the interface test case related to the test case in the database; the verification formula in step S230 is used to verify whether the system output conforms to the logical expression or algorithm of the expected result; the verification formula can be a simple comparison operation or a complex logical operation, or even involve statistical analysis of data. Figure 6 As shown, step S230 may include: step S231, obtaining historical step-by-step prompts and interface expectations, coding definitions, parameter data tables, and data definition languages ​​of the interface to be tested; step S232, inputting the interface description, interface expectations, coding definitions, parameter data tables, data definition languages, and historical step-by-step prompts of the interface to be tested into a historical language model to obtain initial data and verification formulas; wherein the historical step-by-step prompts are used to guide the historical language model to perform the following steps: obtaining query data and data fields before and after the execution of the interface test case according to the interface expectations, parameter data tables, and data definition languages, creating an initial query statement and verification formula according to the interface description, coding definitions, query data, and data fields before and after the execution of the interface test case, and executing the initial query statement before executing the interface test case to obtain initial data.

[0075] In some embodiments of the present disclosure, the interface expectations of the interface to be tested refer to the pre-set requirements and standards for the functions, performance and behavior of a specific interface. These expectations cover the reactions of the interface under normal and abnormal conditions and are the basis for interface design, implementation and testing. Interface expectations include: functional expectations, performance expectations, error handling expectations, data format expectations, state change expectations, security expectations, compatibility expectations, documentation and annotation expectations, testability expectations, and scalability and maintainability expectations.

[0076] In some embodiments of the present disclosure, the coding definition of the interface to be tested is the interface code definition, which represents a predefined code for a specific function or state. These codes are usually predefined and consistent throughout the system so that the various components of the system can understand and exchange information with each other.

[0077] In some embodiments of the present disclosure, the output parameter data table (or response data table) of the interface to be tested is a document used to describe the data structure and format returned to the client after the interface call is successful. The output parameter data table is very important for testers and developers because it clarifies the response structure of the interface, including data types, fields, status codes, and other possible response information. The output parameter data table may include: status code, response header, response body, error information, paging information, links, etc.

[0078] In some embodiments of the present disclosure, historical step-by-step prompts are used to guide the historical language model to perform tasks in a series of orderly steps, ensuring that the historical language model can understand and follow a specific process to generate initial data and verification formulas, thereby significantly improving the ability of the historical language model to understand and generate initial data and verification formulas.

[0079] Step S240, execute the interface test case to obtain output data.

[0080] Step S250, performing interface verification according to the initial data, the verification formula and the output data to obtain a verification result.

[0081] In some embodiments of the present disclosure, Figure 7 As shown, step S250 may include: step S251, obtaining the interface type of the interface to be tested; step S252, assembling the initial data and the output data according to the interface type to obtain the assembled data; step S253, performing interface verification according to the assembled data and the verification formula to obtain the verification result. Among them, the interface type in step S251 includes a read interface or a write interface. When the interface type is a read interface, the assembled data obtained by step S252 can be output data & initial data; when the interface type is a write interface, the assembled data obtained by step S252 can be initial data & output data, and the assembled data can also be in other formats.

[0082] like Figure 8 As shown, step S253 may include: step S2531, obtaining verification step prompts and interface expectations of the interface to be tested; step S2532, inputting the interface expectations, assembly data, verification formulas and verification step prompts into a verification language model to obtain verification results; wherein the verification step prompts are used to guide the verification language model to perform the following steps: determining expected data based on interface expectations, assembly data and verification formulas, comparing output data in the assembly data with expected data, and obtaining verification results.

[0083] In some embodiments of the present disclosure, verification step prompts are used to guide the verification language model to perform tasks in a series of orderly steps, ensuring that the verification language model can understand and follow a specific process to perform interface verification, thereby significantly improving the verification language model's ability to understand and perform interface verification.

[0084] In some embodiments of the present disclosure, Fig. 9 As shown, step S210 may also include: step S214, obtaining an interface knowledge base of the interface to be tested; step S215, obtaining an interface description, an input parameter description and an interface structure from the interface knowledge base. Fig.10 As shown, step S214 may include: step S2141, obtaining the test target of the interface to be tested; step S2142, obtaining the interface knowledge base according to the test target. Fig.11 As shown, step S215 may include: step S2151, obtaining multiple sub-libraries from the interface knowledge base according to the input required for different step-by-step prompts; step S2152, obtaining the use case sub-library corresponding to the use case step-by-step prompts from the multiple sub-libraries; step S2153, obtaining the interface description, input parameter description and interface structure from the use case sub-library.

[0085] The interface knowledge base may be pre-set, or may be obtained from a preset knowledge base in advance through steps S2141 and S2142.

[0086] The use case language model, data language model, parameter language model, history language model and verification language model can be the same language model or different language models. The use case step prompt, data step prompt, parameter step prompt, history step prompt and verification step prompt are all a type of step prompt, realizing different guidance functions.

[0087] Figure 12 to Figure 13 The interface test case generation device of the present invention can be implemented based on a hardware implementation method using a processor.

[0088] Embodiment 2: An embodiment of the present disclosure provides an interface test case generating device.

[0089] The system may include corresponding modules for executing each or several steps in the above flowchart. Therefore, each step or several steps in the above flowchart may be executed by the corresponding module, and the system may include one or more modules in these modules. The module may be one or more hardware modules specially configured to execute the corresponding steps, or implemented by a processor configured to execute the corresponding steps, or stored in a computer-readable medium for implementation by a processor, or implemented by some combination.

[0090] Fig.12 1 is an interface test case generation device 1000 that uses a hardware implementation of a processing system. The hardware can be implemented using a bus architecture. The bus architecture can include any number of interconnecting buses and bridges, depending on the specific application and overall generation constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc., which are conventional techniques in the art and will not be described again.

[0091] like Fig.12 As shown, the interface test case generating device according to the present disclosure may include: The data acquisition module 1010 is used to obtain the use case step prompts and the interface description, input parameter description, interface structure and test data of the interface to be tested.

[0092] A use case input module 1020 is used to input the interface description, input parameter description, interface structure, test data and use case step prompt into the use case language model to obtain an interface test case; The use case step prompt is used to guide the use case language model to perform the following steps: obtain communication parameters and required parameters from the interface structure and input parameter description, and generate an interface test case according to the interface description, communication parameters, required parameters and test data.

[0093] Furthermore, if Fig.13 As shown, the interface test case generation device provided by the present disclosure may also include: The verification acquisition module 1030 is used to obtain initial data and verification formulas corresponding to the interface test case.

[0094] The use case execution module 1040 is used to execute the interface test case and obtain output data.

[0095] The interface verification module 1050 is used to perform interface verification according to the initial data, the verification formula and the output data to obtain a verification result.

[0096] The interface test case generation device provided in the present disclosure implements the interface test case generation process through the above modules, and the process of the above modules implementing their respective functions is similar to that provided in Example 1 of the present disclosure, and will not be repeated here.

[0097] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0098] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.

[0099] The computer program or instructions may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, the computer program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0100] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0101] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0102] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0104] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.

[0105] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0106] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

Claims

1. A method for generating an interface test case, characterized in that: include: Get the use case step-by-step prompts and the interface description, input parameter description, interface structure and test data of the interface to be tested; as well as Input the interface description, the input parameter description, the interface structure, the test data and the use case step prompt into a use case language model to obtain an interface test case; Among them, the use case step-by-step prompts are used to guide the use case language model to perform the following steps: obtain communication parameters and required parameters from the interface structure and the input parameter description, and generate an interface test case based on the interface description, the communication parameters, the required parameters and the test data.

2. The interface test case generation method according to claim 1, characterized in that: The step-by-step prompts for obtaining the use case and the interface description, input parameter description, interface structure and test data of the interface to be tested include: Get data step-by-step prompts and interface description, input parameter description, interface structure, input parameter data table and data definition language of the interface to be tested; Analyze the required parameters according to the interface description, the input parameter description and the interface structure to obtain the required parameters; and Input the interface description, the input parameter description, the interface structure, the input parameter data table, the data definition language, the required parameters and the data step prompt into a data language model to obtain interface test data; Among them, the data step prompt is used to guide the data language model to perform the following steps: when it is determined according to the data definition language that the input parameter data table includes a field corresponding to the parameter to be queried, a data query statement for the parameter to be queried is created and executed according to the interface description, the input parameter description and the interface structure to obtain interface test data.

3. The interface test case generation method according to claim 2, characterized in that: The step of performing mandatory parameter analysis according to the interface description, the input parameter description and the interface structure to obtain the required parameters includes: Get parameter step-by-step prompts; and Input the interface description, the input parameter description, the interface structure and the parameter step-by-step prompts into a parameter language model to obtain the parameters to be queried; Among them, the parameter step prompt is used to guide the parameter language model to perform the following steps: obtain the required parameters according to the interface structure, obtain the input parameter default values ​​according to the input parameter description, compare the required parameters and the input parameter default values ​​according to the interface description, and obtain the parameters to be checked.

4. The method for generating interface test cases according to any one of claims 1 to 3, characterized in that: After obtaining the interface test case, it also includes: Obtaining initial data and verification formulas corresponding to the interface test case: executing the interface test case to obtain output data; and Interface verification is performed according to the initial data, the verification formula and the output data to obtain a verification result.

5. The interface test case generation method according to claim 4, characterized in that: The obtaining of initial data and verification formula corresponding to the interface test case includes: Obtaining historical step-by-step prompts and interface expectations, coding definitions, output parameter data tables, and data definition languages ​​of the interface to be tested; and Input the interface description, interface expectation, coding definition, parameter data table, data definition language and historical step prompt of the interface to be tested into a historical language model to obtain initial data and a verification formula; Among them, the historical step-by-step prompt is used to guide the historical language model to perform the following steps: obtain the query data and data fields before and after the execution of the interface test case according to the interface expectation, the output parameter data table and the data definition language, create an initial query statement and verification formula according to the interface description, coding definition, the query data and data fields before and after the execution of the interface test case, and execute the initial query statement before executing the interface test case to obtain initial data.

6. The interface test case generation method according to claim 4, characterized in that: The performing interface verification according to the initial data, the verification formula and the output data to obtain a verification result includes: Obtaining the interface type of the interface to be tested; Assembling the initial data and the output data according to the interface type to obtain assembled data; and Interface verification is performed according to the assembly data and the verification formula to obtain a verification result.

7. The interface test case generation method according to claim 6, characterized in that: The performing interface verification according to the assembly data and the verification formula to obtain a verification result includes: Obtaining verification step prompts and interface expectations of the interface to be tested; and Input the interface expectation, the assembly data, the verification formula and the verification step prompt into a verification language model to obtain a verification result; Among them, the verification step prompt is used to guide the verification language model to perform the following steps: determine the expected data according to the interface expectation, the assembly data and the verification formula, compare the output data and the expected data in the assembly data, and obtain the verification result.

8. An interface test case generation device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instructions stored in the memory, so that the processor executes the interface test case generation method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the interface test case generation method described in any one of claims 1 to 7.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the interface test case generation method described in any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Method, device and equipment for generating test case based on large language model

    CN120803950A