Test case generation method and system based on large model and interface definition

By adopting a test case generation method based on large models and interface definitions, the limitations and high costs of test case generation in existing technologies are solved. It achieves intelligent generation and precise adjustment without the need for a knowledge base, adapts to various needs of software iterative development, and improves the efficiency and reliability of test case generation.

CN120950402APending Publication Date: 2025-11-14TONGDUN NETWORK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511077565.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-01
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Existing test case generation methods have limitations in adapting to multiple adjustments and complex processes, require manual intervention and are costly, making it difficult to meet the diverse adjustments and refined testing needs of software iterative development.

Method used

The test case generation method based on large models and interface definitions extracts and standardizes interface parameters from interface documents, designs intelligent templates, and guides the generation of test cases from the large model through multi-round conversation prompts. Specific types of test prompts are added in each round to supplement and optimize the test cases, ensuring the comprehensiveness and accuracy of the test cases.

Benefits of technology

It enables the generation of test cases covering a wide range of types and scenarios without the need for a pre-built knowledge base, adapting to various adjustment needs in software iterative development, improving the efficiency and reliability of test case generation, and enhancing the applicability and flexibility of the model in different application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120950402A_ABST
    Figure CN120950402A_ABST
Patent Text Reader

Abstract

The invention discloses a test case generation method and system based on a large model and interface definition. The method comprises the following steps: extracting and standardizing various parameters of an interface from an interface document; on the basis of an interface information background, designing a detailed test case, and formulating multiple rounds of session cues to guide a large model generation process; inputting the interface data and the intelligent template into the large model to generate a test case; the test case is supplemented and optimized by adding test cue words of a specific type round by round; the optimized test case is checked and optimized, and a final test case is determined; reviewing the final test case to obtain a formal test case; and filing or sending the formal test cases according to different formats. By implementing the method, the accurate and adjustable process scene test case can be intelligently generated without pre-building a knowledge base, various adjustment and refined test requirements in software iterative development are met, the reliability of the model is improved, and the application range of the model is widened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a test case generation method, and more specifically to a test case generation method and system based on a large model and interface definition. Background Technology

[0002] Test case generation methods utilize automated tools to rapidly create test cases, significantly improving software testing efficiency and reducing labor costs. They enhance test coverage, uncover more potential defects, and ensure improved software quality. Furthermore, this approach supports agile development and continuous integration, helping to accelerate time-to-market and improve user satisfaction.

[0003] CN117349188B proposes a method to automatically generate test cases by inputting interface documentation information and requirement descriptions into a large model and using instructions in a specific format. However, this method has certain limitations; it is difficult to adapt to complex processes that require multiple adjustments and reviews. Furthermore, due to the potential for "illusion" phenomena or differences in understanding within the large model, the generated test cases may require manual verification or minor corrections to ensure their effectiveness. CN118152261A relates to an automatic test case generation technology based on a pre-trained and fine-tuned target large model, combining multiple generation strategies, such as input-output difference-based generation and code template-based generation strategies. While this method improves the efficiency and quality of test case generation to some extent, it also faces high training requirements and high costs, as it relies on a large amount of historical test case and code data for augmented retrieval training. CN119537222A takes a different approach, first building a knowledge base based on the software specification document and then using retrieval-enhanced generation principles to optimize the requirement document. This process is divided into two stages: first, constructing requirement fragments, and then creating instructions for generating test cases. Although this approach aims to improve the understanding of requirements documents and achieve an effective mapping between requirements documents and test cases, it also faces high training thresholds and costs because it requires retrieval-enhanced training.

[0004] In summary, although the three solutions mentioned above offer different approaches to solving the problem of automatic test case generation, they also face their own challenges, including but not limited to process adaptability, the need for manual intervention, and high-cost training requirements.

[0005] Therefore, it is necessary to design a new method to intelligently generate accurate and adjustable process scenario test cases without the need for pre-built knowledge bases, so as to adapt to various adjustments and refined testing needs in software iterative development and improve the reliability and applicability of the model. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method and system for generating test cases based on large models and interface definitions.

[0007] To achieve the above objectives, the present invention adopts the following technical solution: a test case generation method based on a large model and interface definition, comprising: Extract and standardize the various parameters of the interface from the interface document to obtain the interface data; Based on the interface information background, detailed test cases were designed, and multi-round conversation prompts were formulated to guide the large model generation process in order to obtain intelligent templates; Input the interface data and the intelligent template into the large model to generate test cases; By adding specific types of test prompts round by round, the test cases are supplemented and optimized to obtain optimized test cases; The optimized test cases are checked and optimized, and the final test cases are determined. Review the final test cases to obtain the formal test cases; Archive or send the formal test cases in different formats.

[0008] The further technical solution is as follows: the interface data includes interface ID, module, interface description, request method, request path, interface status, Header parameter, Path parameter, Query parameter, Body parameter, Resp return information, and change content.

[0009] The further technical solution is as follows: the extraction and standardization of various parameters of the interface from the interface document to obtain interface data includes: Extract interface information from the interface documentation; The interface information is split, encoded, and stored according to a unified data standard to form an interface data management library, thereby obtaining the interface data.

[0010] The further technical solution is as follows: the intelligent template includes role background, business requirements, and test case format requirements; the test case format requirements specify the test case number, name, type, priority, module, preconditions, test scope, test steps, and expected results; the test case format requirements change according to the changes in requirements, and fields are added or deleted accordingly.

[0011] The further technical solution is as follows: by adding specific types of test prompts round by round to supplement and optimize the test cases, optimized test cases are obtained, including: Based on the addition of specific types of test prompts in each round, the large model is called in each round to supplement and optimize the test cases, and new prompts are added for specific types of tests in each round.

[0012] The further technical solution is as follows: the different formats include Excel, Markdown, and Xmind.

[0013] This invention also provides a test case generation system based on large models and interface definitions, including: The data acquisition unit is used to extract and standardize the various parameters of the interface from the interface document to obtain the interface data; The template generation unit is used to design detailed test cases based on the interface information background, and to formulate multi-round conversation prompts to guide the large model generation process in order to obtain intelligent templates; The test case generation unit is used to input the interface data and the intelligent template into the large model to generate test cases; The optimization unit is used to supplement and optimize the test cases by adding specific types of test prompts round by round to obtain optimized test cases; The inspection unit is used to inspect and optimize the optimized test cases and determine the final test cases. The review unit is used to review the final test cases to obtain formal test cases; The processing unit is used to archive or send the formal test cases in different formats.

[0014] The further technical solution is as follows: the data acquisition unit includes: The information extraction subunit is used to extract interface information from the interface document; The preprocessing subunit is used to split and encode the interface information according to a unified data standard to form an interface data management library, so as to obtain interface data.

[0015] The further technical solution is as follows: the optimization unit is used to supplement and optimize the test cases by calling the large model in each round according to the addition of specific types of test prompt words in each round, and to add new prompt words for specific types of tests in each round.

[0016] The present invention also provides a computer device, the computer device including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the above-described method.

[0017] The advantages of this invention compared to existing technologies are as follows: This invention extracts and standardizes interface parameters from interface documents to form interface data, and designs intelligent templates containing multi-turn conversation prompts to guide the generation of test cases from large models. Subsequently, by adding specific types of test prompts round by round, the test cases are supplemented and optimized, ensuring the comprehensiveness and accuracy of the test cases. This method does not require pre-built knowledge bases and can intelligently generate test cases covering various types and scenarios based on interface definition information, adapting to various adjustment needs in software iterative development. It also supports manual intervention for further inspection, optimization, and review, thereby quickly responding to changes and achieving refined testing, greatly improving the efficiency and reliability of test case generation, and enhancing the applicability and flexibility of the model in different application scenarios. Finally, formal test cases can be archived or sent in different formats to meet diverse delivery requirements.

[0018] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A schematic diagram illustrating an application scenario of the test case generation method based on large models and interface definitions provided in this embodiment of the invention; Figure 2 A flowchart illustrating the test case generation method based on a large model and interface definition provided in an embodiment of the present invention; Figure 3 A schematic diagram of a sub-process of a test case generation method based on a large model and interface definition provided in an embodiment of the present invention; Figure 4 A schematic block diagram of a test case generation system based on a large model and interface definition provided for embodiments of the present invention; Figure 5 A schematic block diagram of a computer device provided for an embodiment of the present invention. Detailed Implementation

[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

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

[0023] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0024] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0025] Please see Figure 1 and Figure 2 , Figure 1 This is a schematic diagram illustrating an application scenario of the test case generation method based on a large model and interface definition provided in an embodiment of the present invention. Figure 2 This is a schematic flowchart illustrating a test case generation method based on a large model and interface definition, provided in an embodiment of the present invention. This method is applied to a server that interacts with a terminal. It dynamically extracts and standardizes interface parameters directly from the interface documentation to form interface data. Without pre-building a knowledge base, this data, along with intelligent templates designed based on interface information, can guide the generation of test cases from the large model. Subsequently, the test cases are supplemented and optimized by adding specific types of test prompts in successive rounds, ensuring the accuracy and adjustability of the test cases and enabling flexible adaptation to various changes in software iterative development. Finally, the formal test cases are determined through a review, optimization, and evaluation process, and can be archived or sent in different formats. This significantly improves the reliability and applicability of the model in the face of constantly changing requirements, realizing intelligent generation and management of test cases across the entire process.

[0026] Figure 2 This is a flowchart illustrating the test case generation method based on a large model and interface definition provided in an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S110 to S170.

[0027] S110. Extract and standardize the various parameters of the interface from the interface document to obtain the interface data.

[0028] In this embodiment, the interface data includes interface ID, module, interface description, request method, request path, interface status, Header parameter, Path parameter, Query parameter, Body parameter, Resp return information, and change content.

[0029] The main objective of step S110 is to extract the necessary interface information from the interface document and standardize it to form data in a unified format for generating test cases.

[0030] In one embodiment, please refer to Figure 3 The above step S110 may include steps S111 to S112.

[0031] S111. Extract interface information from the interface document.

[0032] In this embodiment, at this stage, the system automatically scans the specified interface documentation (e.g., RESTful API documentation) to extract all necessary information related to the interface. This includes, but is not limited to, the interface ID, the module to which it belongs, the interface description, the request method, the request path, the interface status, the Header parameter, the Path parameter, the Query parameter, the Body parameter, the Response information, and any changes. This process may involve support for different document formats (such as JSON and XML) and the ability to handle complex nested structures and array objects.

[0033] In this step, the system automatically parses interface documents in different formats (such as JSON, XML, etc.) and extracts all relevant information. Specifically, the information to be extracted includes, but is not limited to: Interface ID: Uniquely identifies each interface.

[0034] Belongs to: The business module where the interface is located.

[0035] Interface Description: A brief description of the interface's functionality.

[0036] Request method: such as HTTP methods like GET and POST.

[0037] Request path: The URL path of the API.

[0038] Interface status: Added, modified, deleted, etc.

[0039] Header parameters: Parameters in the request header.

[0040] Path parameter: Path parameter.

[0041] Query parameter: Query string parameter.

[0042] Body parameters: Parameters in the request body.

[0043] Resp response information: Expected response information.

[0044] Change details: Record the specific details of each interface change.

[0045] S112. The interface information is split and encoded according to a unified data standard to form an interface data management library, so as to obtain interface data.

[0046] In this embodiment, the extracted information is then converted into a standard format suitable for machine reading and processing. For example, all parameter types (integers, decimals, strings, booleans, array objects, etc.) are explicitly labeled; and there are clear indications of whether fields are required. Furthermore, by establishing an interface data management library, this information can be easily stored and retrieved, supporting subsequent queries and use. This database not only contains the current version of the interface definition but also records the history of every change, which is crucial for tracking the development and maintenance of the interface.

[0047] The extracted information then needs to be converted into a standard format and stored in a specially designed database for easy retrieval and use. This process includes the following aspects: Standardization processing: The extracted raw data is cleaned and standardized, such as unifying the representation of parameter types (integers, decimals, strings, etc.) and clarifying whether fields are required.

[0048] Decomposition and Encoding: Based on the different components of the interface, it is decomposed into more granular information units and assigned corresponding encoding identifiers to facilitate subsequent calls and management.

[0049] Storing to the API Data Management Repository: The processed API data is saved to a specially built database. This database not only stores the current version of the API definition, but also records the history of every change, which is crucial for tracking the API's evolution.

[0050] Automating the extraction and standardization of API information significantly improves work efficiency. Detailed analysis and standardization of raw data ensures accuracy. It supports multiple API document formats to adapt to diverse project needs. The integrated API change history makes it particularly suitable for rapid iterative updates in agile development models.

[0051] By implementing step S110, a solid foundation can be effectively laid for the subsequent generation of test cases based on interface definitions, significantly improving the quality and efficiency of software testing.

[0052] S120. Based on the interface information background, design detailed test cases and formulate multi-round conversation prompts to guide the large model generation process in order to obtain intelligent templates.

[0053] In this embodiment, the intelligent template not only includes traditional test case elements such as number, name, and type, but also integrates information such as role background and business requirements, making the generated test cases more closely resemble real-world application scenarios. The following are the main components of this intelligent template: Role Background: Specify the role performing the testing task and their background knowledge. For example, "You are a senior test engineer with many years of experience, currently working on testing an e-commerce platform." Business Requirements: This section outlines the specific requirements for the functions or processes that need to be tested. This part is extracted from the requirements document, ensuring the relevance and accuracy of the test cases.

[0054] Test case format requirements: Clearly defines the format standards that the generated test cases should follow, including but not limited to: Test Case Number: Uniquely identifies each test case.

[0055] Use case name: Briefly describe the purpose or focus of the test.

[0056] Use case types: such as functions, processes, exceptions, boundary values, etc.

[0057] Priority: An important indicator for determining the execution order.

[0058] Belonging Module: Specifies the system module corresponding to the test case.

[0059] Prerequisites: The prerequisites that must be met before the test can be performed.

[0060] Test Scope: Clearly specify the specific area to be covered by the test.

[0061] Test steps: List the operation steps and expected results in detail.

[0062] Expected results: The status or output that should be achieved after each test step is completed.

[0063] The intelligent template includes role background, business requirements, and test case format requirements. The test case format requirements specify the test case number, name, type, priority, module, preconditions, test scope, test steps, and expected results. The test case format requirements change according to the requirements, and fields are added or deleted accordingly.

[0064] To enable large-scale models to dynamically adjust their output based on different contexts and needs, a series of multi-turn conversational prompts need to be pre-defined. These prompts not only guide the large-scale model to gradually refine and improve test cases, but also continuously optimize results based on feedback. Below are some example prompt settings: Round 1: "Based on the provided interface definition information, please generate basic functional test cases." Round Two: "Based on this, please supplement the test cases for security and performance." Third round: "For all the use cases generated above, please check and add the necessary exception handling scenarios." Round 4: "Please provide specific instance data for all test steps to facilitate practical operation." Each round of prompts aims to expand or deepen the content of the test cases, thereby ensuring that the final generated test case set is both comprehensive and detailed, effectively covering all possible scenarios.

[0065] Specifically, firstly, the system automatically parses the parameters in the interface documentation to form structured interface data. Based on the interface information and business requirements, a preliminary intelligent template framework is built, including role background, business requirements, and test case format requirements. According to different stages of the testing objectives, multi-round conversation prompts are carefully designed to guide the large model in gradually improving test cases. The intelligent template and the prompts for the current round are input into the large model to start the generation process, and the returned test cases are received. The generated test cases are reviewed, and if necessary, the large model is called again with new prompts for optimization or supplementation until satisfactory results are achieved.

[0066] Through this series of steps, the transformation from interface definition to high-quality test cases is automated, greatly improving testing efficiency and quality.

[0067] S130. Input the interface data and the smart template into the large model to generate test cases.

[0068] In this embodiment, the test cases are a series of basic test cases automatically generated by calling a Large Language Model (LLM) based on parsed interface definition information (including but not limited to interface ID, request method, path parameters, query parameters, etc.) and preset smart templates. These test cases cover the basic functional verification requirements of the interface, but may not yet include all details or special cases. Specifically: First, the system automatically extracts relevant fields from the interface documentation and converts them into a standard format to ensure that the information in each interface is complete and easy to understand.

[0069] Then, a pre-designed smart template is used, which not only includes general background information, role settings, and business requirement descriptions, but also includes format requirements and rule descriptions for specific types of test cases.

[0070] Finally, the prepared interface data and the smart template are input into the large model, and its powerful text processing capabilities are used to generate a test case set covering the basic functional points.

[0071] S140. By adding specific types of test prompts round by round, the test cases are supplemented and optimized to obtain optimized test cases.

[0072] In this embodiment, the test cases are supplemented and optimized by calling the large model round by round based on the addition of specific types of test prompts. New prompts can be added for specific types of tests in each round.

[0073] The optimized test cases are a more comprehensive and accurate set of test cases formed through multiple rounds of iterative improvements based on the original test cases. Each round of improvement involves adding specific types of test prompts to the larger model, guiding further refinement and improvement of existing test cases. The specific process is as follows: The first round of optimization: For example, for security testing, provide the large model with prompts such as "Please add test cases on SQL injection attack protection", prompting the large model to generate corresponding security test cases based on the existing test case framework.

[0074] Subsequent rounds of optimization: Based on project requirements or review feedback, continue to add prompts such as performance testing, exception handling, boundary value analysis, etc., to gradually enrich and improve the test case library.

[0075] Context inheritance: Each round of large model calls inherits the results of the previous rounds as context, ensuring that newly added test cases can be seamlessly integrated into the overall test plan, while avoiding duplication of work.

[0076] This approach not only allows for rapid response to changing requirements but also significantly improves the quality and coverage of test cases, ultimately resulting in a testing solution that is both compliant with standards and highly flexible. This greatly reduces the workload of manually writing test cases, improves work efficiency, and also reduces the risk of overlooking important scenarios due to human error.

[0077] S150. Check and optimize the optimized test cases, and determine the final test cases.

[0078] In this embodiment, the optimized test cases generated from the large model are first reviewed by automated tools or junior engineers. This step mainly focuses on whether the basic structure of the test cases is complete (such as including test case number, name, type, priority, etc.) and whether the test steps and expected results are clear and logically reasonable.

[0079] Next, senior engineers or testing experts will conduct a more in-depth inspection, focusing on assessing whether the test coverage is comprehensive and covers all key functionalities and abnormal situations; at the same time, they must ensure that the test cases conform to the project's business context and technical requirements to avoid mistesting due to misunderstandings.

[0080] Based on the results of the above checks, if any deficiencies are found in certain test cases, further optimization is required. For example, for test cases with insufficient boundary value analysis, more boundary conditions can be added; for cases where the process test scenarios are not detailed enough, additional steps can be added to simulate real-world usage scenarios. Furthermore, specific types of test prompts can be added according to actual needs, and the large model can be called again for targeted optimization.

[0081] Finally, after multiple iterations and optimizations, when all test cases meet the predetermined quality standards, the final version can be determined. These test cases not only effectively verify the system's functionality but also provide a solid foundation for subsequent reviews.

[0082] S160. Review the final test cases to obtain formal test cases.

[0083] In this embodiment, formal test cases refer to the final version of test cases that have been fully checked, optimized, and reviewed by multiple parties, and have been confirmed to meet the project requirements and have sufficient authority and reliability. They can be directly used in the system verification and quality assurance process.

[0084] Organize cross-departmental teams (including but not limited to developers, testers, product managers, etc.) to participate in review meetings. Each role conducts a comprehensive review of test cases from their respective professional perspectives. Developers focus on technical implementation details to ensure the accuracy of test points; testers focus on the effectiveness and feasibility of test methods; and product managers are responsible for ensuring the consistency of the overall business logic.

[0085] All comments and suggestions collected during the review process will be recorded and used as an important basis for further optimization. If any problems or areas for improvement are found during the review, the relevant personnel should be notified promptly for correction. If necessary, the large model should be called again to generate new test cases for specific problems or to supplement and improve existing test cases.

[0086] Once all modifications are complete and all parties have reached a consensus, the test cases can be officially approved as "official test cases." This means that they have undergone rigorous quality checks, possess sufficient authority and reliability, and can be directly applied to subsequent testing work.

[0087] S170. Archive or send the formal test cases in different formats.

[0088] In this embodiment, the different formats include Excel, Markdown, and Xmind.

[0089] To meet the needs of different application scenarios, formal test cases need to be converted into various common formats, such as Excel spreadsheets, Markdown documents, and XMind mind maps. This facilitates information sharing and communication between different departments, and also makes archiving and management easier.

[0090] Establish a robust version control system to ensure that every update is traceable. Each revised test case should be assigned a unique version number, and its change history should be meticulously recorded for future reference and retrieval.

[0091] Distribute the compiled test cases to relevant stakeholders through internal networks or other secure channels. For example, provide the development team with detailed interface test cases to help them better understand the system architecture; deliver a complete functional test plan to the quality assurance team to support them in carrying out comprehensive functional verification; and submit customized acceptance reports to clients to demonstrate project progress.

[0092] Given that software products may undergo multiple iterations and upgrades during their lifecycle, it is also necessary to regularly review and update archived test cases to ensure that they are always up-to-date and match the actual situation of the current system.

[0093] In this embodiment, interface documents are obtained through environment parameter configuration, parsed, split, encoded, and stored according to a unified data standard to form an interface data management library. Interface definition information includes interface ID, module, interface description, request method, request path, interface status, Header parameters, Path parameters, Query parameters, Body parameters, Response information, and changes. Interface status is categorized as added, unchanged, deleted, and modified, and all changes are appended and recorded chronologically.

[0094] The intelligent template consists of template content and multi-turn conversation content. The template content includes generated test case role information, business background information, test case rule requirements, requirement definition placeholders, and the format information of the test cases returned after generation. For example, the template content could be: "You are an XX engineer with many years of XX experience, currently engaged in testing work in XX business background. Please output test cases in XX format based on the provided interface definition information; the test cases include test case number, test case name, test case type, priority, module, preconditions, test scope, test steps, expected results, and whether automation is supported; test case types include function, process, exception, scenario, data, boundary, etc.; the test case number consists of English letters, underscores, and numbers, such as module_function_001; the test case name consists of module name, test case type, and test point, such as module name_function_test point; priority is divided into high, medium, and low; test steps require one test step to correspond to one expected result. If it is a process, scenario, etc. test case, it can contain multiple steps and multiple results..." The {requirement definition} is a placeholder, which is replaced according to the interface definition information or requirement description information.

[0095] Multi-round conversations can contain supplementary, optimization, and correction instructions, directly inheriting the context. For example: Round 1: Help supplement security-type test cases; Round 2: Help supplement performance-type test cases; Round 3: Anything else to supplement? Round 4: For the test cases generated above, supplement the test steps with specific instance test data; Round N: XXXX.

[0096] The interface definition information is combined with the prompts from the smart template, and multiple rounds of session appending are used to sequentially call the large model in each round, obtain the returned test cases, and store them in the database for management. For example, the interface definition assembly format could be: Interface ID: get_ / customFunction / getAvailableList, Module: Custom Function, Interface Description: Query the list of available custom functions, Request Method: get, Request Path: / customFunction / getAvailableList, Interface Status: New, Header Parameter: null, Path Parameter: / customFunction / getAvailableList, Query Parameter: null, Body Parameter: null, Resp Parameter: [{"name":"code","valueType":"integer","isMust":"yes","egValue":"","desc":"Identifier"},{"name":"data","valueType":"object","isMust":"","egValue":"","desc":"Name"},{"name":"message","valueType":"string","isMust":"no","egValue":"","desc":""},{"name":"success","valueType":"boolean","isMust":"","egValue":"","desc":""}]; Changes: None... The information of the interface will change according to the definition information of the interface.]

[0097] For the test cases returned by the large model, you can select test cases that need optimization or correction and call the large model again to handle special cases or supplement the large model with information to optimize or correct the test cases. You can also extend the current test cases with new test cases. Test cases that have been manually verified are used to make them official test cases.

[0098] Test cases adopted as official documents undergo multi-party review. If corrections or additions are required, the large model can be invoked again to refine individual or batch test cases based on the description of the correction or addition suggestions. This enables multiple interactions between humans and the large model, fully leveraging the high-speed generation capabilities of the large model and the human supplementation capabilities in extreme scenarios. This ensures the comprehensiveness and breadth of test cases, freeing humans from the tedious work of generating common test cases and uniformly modifying batch test cases, allowing humans to focus more on judgment, selection, and minor additions.

[0099] Due to the unique nature of B2B systems, related R&D deliverables need to be submitted to the client for unified archiving or delivered to different roles for review. This necessitates delivering test cases in various formats, such as Excel, Markdown, and Xmind. By unifying the management of these different delivery formats, test engineers' manpower is freed up, while ensuring the standardization and completeness of test case data.

[0100] The interface definitions in this embodiment may not be named in a standardized way. They need to be reviewed more carefully to ensure that the interface paths and parameter definitions are named in full match with their corresponding English names. Arbitrary naming should be avoided, otherwise it will lead to errors or ambiguities in the original information when generating large models, which in turn will result in errors in the generated results.

[0101] Training intelligent template content and multi-turn conversation prompts requires experienced senior engineers or experts to design, and the quality of the template prompts directly determines the quality of the generated test cases.

[0102] The number of rounds in a multi-turn session is limited by the context support capabilities of the large model.

[0103] Based on existing interface definitions, the system selects the interface information of a single module or all modules and outputs it to the LLM (Large Model) in a specified format. This allows the Large Model to obtain contextual information, and the necessary background information is set in the prompt word smart template. The generated information undergoes context inheritance, enabling the generation of multiple types of test cases through multi-round sessions. The system also optimizes and improves the generated test cases, even setting the test case review criteria within the smart template as needed. This minimizes manual intervention and generates comprehensive, complete, and precise test cases.

[0104] By using a large-scale LLM model to set up multi-turn sessions, we can cover as many different types of test cases as possible, making the test cases more diverse and comprehensive. This reduces problems such as incomplete test case design and non-standard test case formats caused by a lack of testing experience or business context. At the same time, by controlling the generation of test case templates, we can ensure the comprehensiveness of the test case designs for functional modules generated using those templates, reducing the workload of test case design, review, and standardization of test case formats, thereby significantly improving testing efficiency.

[0105] For existing manually written use cases or use cases generated from large models, further optimization, correction, supplementation, and adjustment can be performed to achieve multi-round interaction with the large model.

[0106] Furthermore, the method in this embodiment, based on single-module or full-scale interface definitions, can directly obtain contextual information, prompting the large model to arrange interfaces according to dependent steps, generating process scenario test cases, and generating precise test cases based on the variable states of the interfaces. This method can not only parse the requirement document description language but also perform structured parsing of interface definitions. Through structured interface document information, test cases can be generated with a single click, and the descriptive information of the interface documents and the meaning of interface naming definitions can be used to infer business-related principles and process-related combinations. Even without building a knowledge base, the massive data capabilities of the large model can be leveraged to infer and generate the required test cases.

[0107] In this embodiment, interface documents are obtained through environment parameter configuration and automatically parsed. The parsed data is split, encoded, and saved according to a unified data standard, forming an interface data management library. Technical personnel can select the required interfaces by module or all interfaces through a visual interface management list. After pre-setting intelligent prompt templates to generate test cases based on interface definitions, different large models can be called to generate the required test cases. Multiple prompts can be set in the intelligent templates as needed, inheriting context information to directly optimize existing test cases or supplement them with more scenario test cases. For generated test cases, manual intervention with optimization commands can be used to call the large model again for optimization. Finally, the generated or final test cases can be exported in different formats to support review, archiving, or delivery. For test cases with suggested corrections during the review process, the large model can be called again for batch optimization or generation, or manual corrections can be made according to the actual situation.

[0108] The core advantage of this embodiment lies in its ability to initiate multiple rounds of large-scale model calls without manual intervention, based on interface definition information and through multi-round trained intelligent templates and multi-round trained prompt words. During the call process, context information is inherited, and rich test cases are generated according to instructions, including various types of test cases such as functional, process, exception, boundary value, internationalization, security, UI, UX, and large data volume test cases. Simultaneously, this embodiment also supports manual intervention, allowing for the initiation of optimization, correction, and improvement instructions on existing test cases, and the regeneration of single or batch test cases. This significantly reduces the manual intervention process required when calling large models, which necessitates the assembly of requirement descriptions, interface information, and background business information. Using existing information, the preparatory work for large-scale model calls can be completed quickly, thereby more efficiently completing the generation, optimization, review, and correction of test cases. With minimal manual confirmation, the entire lifecycle management of test cases can be achieved. Furthermore, for interfaces in different states (such as added, modified, or deleted), this embodiment's method can provide corresponding prompt words to the large model, requiring it to generate targeted test cases. Among them, the test cases generated for interfaces that have been modified or deleted fall within the scope of precise testing, which greatly reduces the scope of test cases, enables precise testing, and thus significantly improves testing efficiency.

[0109] The aforementioned test case generation method based on a large model and interface definition extracts and standardizes interface parameters from interface documents to form interface data. It then designs intelligent templates containing multi-turn conversation prompts to guide the generation of test cases from the large model. Subsequently, specific types of test prompts are added round by round to supplement and optimize the test cases, ensuring their comprehensiveness and accuracy. This method does not require a pre-built knowledge base; it can intelligently generate test cases covering various types and scenarios based on interface definition information, adapting to various adjustment needs in software iterative development. It also supports manual intervention for further inspection, optimization, and review, thereby quickly responding to changes and achieving refined testing. This significantly improves the efficiency and reliability of test case generation and enhances the applicability and flexibility of the model in different application scenarios. Finally, formal test cases can be archived or sent in different formats to meet diverse delivery requirements.

[0110] Figure 4 This is a schematic block diagram of a test case generation system 300 based on a large model and interface definition, provided in an embodiment of the present invention. Figure 4As shown, corresponding to the above-described test case generation method based on large models and interface definitions, the present invention also provides a test case generation system 300 based on large models and interface definitions. This test case generation system 300 includes a unit for executing the above-described test case generation method based on large models and interface definitions, and the system can be configured in a server. Specifically, please refer to... Figure 4 The test case generation system 300 based on large models and interface definitions includes a data acquisition unit 301, a template generation unit 302, a test case generation unit 303, an optimization unit 304, an inspection unit 305, a review unit 306, and a processing unit 307.

[0111] The data acquisition unit 301 is used to extract and standardize various parameters of the interface from the interface document to obtain interface data; the template generation unit 302 is used to design detailed test cases based on the interface information background and formulate multi-round conversation prompts to guide the large model generation process to obtain intelligent templates; the test case generation unit 303 is used to input the interface data and the intelligent template into the large model to generate test cases; the optimization unit 304 is used to supplement and optimize the test cases by adding specific types of test prompts round by round to obtain optimized test cases; the inspection unit 305 is used to inspect and optimize the optimized test cases and determine the final test cases; the review unit 306 is used to review the final test cases to obtain formal test cases; and the processing unit 307 is used to archive or send the formal test cases in different formats.

[0112] In one embodiment, the data acquisition unit 301 includes: The information extraction subunit is used to extract interface information from the interface document; the preprocessing subunit is used to split and encode the interface information according to a unified data standard and save it to form an interface data management library to obtain interface data.

[0113] In one embodiment, the optimization unit 304 is used to call the large model to supplement and optimize the test cases in each round by adding specific types of test prompt words, and to add new prompt words for specific types of tests in each round.

[0114] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the test case generation system 300 based on the large model and interface definition and each unit can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.

[0115] The aforementioned test case generation system 300 based on large models and interface definitions can be implemented as a computer program, which can be used in various ways, such as... Figure 5 It runs on the computer device shown.

[0116] Please see Figure 5 , Figure 5 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 can be a server, wherein the server can be a standalone server or a server cluster composed of multiple servers.

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

[0118] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions that, when executed, cause the processor 502 to execute a test case generation method based on a large model and interface definition.

[0119] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.

[0120] The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a test case generation method based on a large model and interface definition.

[0121] This network interface 505 is used for network communication with other devices. Those skilled in the art will understand that... Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0122] The processor 502 is used to run a computer program 5032 stored in the memory to perform the following steps: The interface parameters are extracted and standardized from the interface documentation to obtain interface data. Based on the interface information background, detailed test cases are designed, and multi-round conversation prompts are formulated to guide the large model generation process to obtain intelligent templates. The interface data and intelligent templates are input into the large model to generate test cases. The test cases are supplemented and optimized by adding specific types of test prompts round by round to obtain optimized test cases. The optimized test cases are checked and optimized, and the final test cases are determined. The final test cases are reviewed to obtain formal test cases. The formal test cases are archived or sent in different formats.

[0123] The interface data includes interface ID, module, interface description, request method, request path, interface status, Header parameter, Path parameter, Query parameter, Body parameter, Resp return information, and change content.

[0124] The intelligent template includes role background, business requirements, and test case format requirements. The test case format requirements specify the test case number, name, type, priority, module, preconditions, test scope, test steps, and expected results. The test case format requirements change according to the requirements, and fields are added or deleted accordingly.

[0125] The different formats include Excel, Markdown, and Xmind.

[0126] In one embodiment, when the processor 502 extracts and standardizes the parameters of the interface from the interface document to obtain interface data, it specifically implements the following steps: Extract interface information from the interface document; split and encode the interface information according to a unified data standard to form an interface data management library, thereby obtaining interface data.

[0127] In one embodiment, when the processor 502 implements the step of supplementing and optimizing the test cases by adding specific types of test prompts round by round to obtain optimized test cases, the specific steps are as follows: Based on the addition of specific types of test prompts in each round, the large model is called in each round to supplement and optimize the test cases, and new prompts are added for specific types of tests in each round.

[0128] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU) 307. The processor 502 may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0129] It will be understood by those skilled in the art 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 includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.

[0130] Therefore, the present invention also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein when executed by a processor, the computer program causes the processor to perform the following steps: The interface parameters are extracted and standardized from the interface documentation to obtain interface data. Based on the interface information background, detailed test cases are designed, and multi-round conversation prompts are formulated to guide the large model generation process to obtain intelligent templates. The interface data and intelligent templates are input into the large model to generate test cases. The test cases are supplemented and optimized by adding specific types of test prompts round by round to obtain optimized test cases. The optimized test cases are checked and optimized, and the final test cases are determined. The final test cases are reviewed to obtain formal test cases. The formal test cases are archived or sent in different formats.

[0131] The interface data includes interface ID, module, interface description, request method, request path, interface status, Header parameter, Path parameter, Query parameter, Body parameter, Resp return information, and change content.

[0132] The intelligent template includes role background, business requirements, and test case format requirements. The test case format requirements specify the test case number, name, type, priority, module, preconditions, test scope, test steps, and expected results. The test case format requirements change according to the requirements, and fields are added or deleted accordingly.

[0133] The different formats include Excel, Markdown, and Xmind.

[0134] In one embodiment, when the processor executes the computer program to extract and standardize the parameters of the interface from the interface document to obtain interface data, it specifically implements the following steps: Extract interface information from the interface document; split and encode the interface information according to a unified data standard to form an interface data management library, thereby obtaining interface data.

[0135] In one embodiment, when the processor executes the computer program to implement the step of supplementing and optimizing the test cases by adding specific types of test prompts round by round to obtain optimized test cases, the processor specifically implements the following steps: Based on the addition of specific types of test prompts in each round, the large model is called in each round to supplement and optimize the test cases, and new prompts are added for specific types of tests in each round.

[0136] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.

[0137] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0138] In the embodiments provided by this invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of each unit is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0139] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the system of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit 307, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0140] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0141] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A test case generation method based on large models and interface definitions, characterized in that: include: Extract and standardize the various parameters of the interface from the interface document to obtain the interface data; Based on the interface information background, detailed test cases were designed, and multi-round conversation prompts were formulated to guide the large model generation process in order to obtain intelligent templates; Input the interface data and the intelligent template into the large model to generate test cases; By adding specific types of test prompts round by round, the test cases are supplemented and optimized to obtain optimized test cases; The optimized test cases are checked and optimized, and the final test cases are determined. Review the final test cases to obtain the formal test cases; Archive or send the formal test cases in different formats.

2. The test case generation method based on large model and interface definition according to claim 1, characterized in that, The interface data includes interface ID, module, interface description, request method, request path, interface status, Header parameter, Path parameter, Query parameter, Body parameter, Resp return information, and change content.

3. The test case generation method based on large model and interface definition according to claim 1, characterized in that, The process of extracting and standardizing various parameters of the interface from the interface document to obtain interface data includes: Extract interface information from the interface documentation; The interface information is split, encoded, and stored according to a unified data standard to form an interface data management library, thereby obtaining the interface data.

4. The test case generation method based on large model and interface definition according to claim 1, characterized in that, The intelligent template includes role background, business requirements, and use case format requirements; The test case format requirements specify the test case number, name, type, priority, module, preconditions, test scope, test steps, and expected results. The test case format requirements may change as needed, with fields added or deleted as required.

5. The test case generation method based on large model and interface definition according to claim 1, characterized in that, The process of supplementing and optimizing test cases by adding specific types of test prompts round by round to obtain optimized test cases includes: Based on the addition of specific types of test prompts in each round, the large model is called in each round to supplement and optimize the test cases, and new prompts are added for specific types of tests in each round.

6. The test case generation method based on large model and interface definition according to claim 1, characterized in that, The different formats include Excel, Markdown, and Xmind.

7. A test case generation system based on large models and interface definitions, characterized in that: include: The data acquisition unit is used to extract and standardize the various parameters of the interface from the interface document to obtain the interface data; The template generation unit is used to design detailed test cases based on the interface information background, and to formulate multi-round conversation prompts to guide the large model generation process in order to obtain intelligent templates; The test case generation unit is used to input the interface data and the intelligent template into the large model to generate test cases; The optimization unit is used to supplement and optimize the test cases by adding specific types of test prompts round by round to obtain optimized test cases; The inspection unit is used to inspect and optimize the optimized test cases and determine the final test cases. The review unit is used to review the final test cases to obtain formal test cases; The processing unit is used to archive or send the formal test cases in different formats.

8. The test case generation system based on large model and interface definition according to claim 7, characterized in that, The data acquisition unit includes: The information extraction subunit is used to extract interface information from the interface document; The preprocessing subunit is used to split and encode the interface information according to a unified data standard to form an interface data management library, so as to obtain interface data.

9. The test case generation system based on large model and interface definition according to claim 7, characterized in that, The optimization unit is used to supplement and optimize the test cases by calling the large model round by round based on the addition of specific types of test prompt words in each round, and to add new prompt words for specific types of tests in each round.

10. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • A test case generation method and device based on large model

    CN117349188B

  • Test case generation method and device based on large model, equipment and storage medium

    CN118152261A

  • Test case generation method and system based on large model and retrieval enhancement generation

    CN119537222A