Test case generation method, device and equipment and storage medium

By converting natural language test requirements into vectors and selecting reference test cases from the asset library, and then combining these with a language model to generate new test cases, the problem of low test case accuracy in large enterprise software projects is solved, achieving efficient and accurate test case generation.

CN122111848APending Publication Date: 2026-05-29JINAN INSPUR DATA TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JINAN INSPUR DATA TECH CO LTD
Filing Date
2026-02-09
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In large enterprise software development projects, executing all test cases consumes too many resources, and relying on experts to manually select test cases can easily lead to the omission of key test scenarios, resulting in low accuracy of the generated test cases.

Method used

By receiving test requirements described in natural language, converting them into test requirement vectors, filtering reference test case vectors from the test case asset library, generating new test cases that match the test requirements using a language model, and expanding or modifying them by combining prompt words and reference test case vectors.

Benefits of technology

It improves the accuracy of test case generation, reduces resource consumption, ensures that the generated test cases match the requirements, and enhances generation efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111848A_ABST
    Figure CN122111848A_ABST
Patent Text Reader

Abstract

The application discloses a test case generation method, device and equipment and a storage medium, relates to the technical field of software testing, and the test case generation method of the application first receives a test case generation request including a test requirement described by using a natural language; converts the test requirement into a test requirement vector; based on the test requirement vector, at least one reference case vector matched with the test requirement vector is screened out from a test case asset library containing a plurality of test case vectors; and finally, the test requirement vector and the reference case vector are taken as references to generate one or more new test cases matched with the test requirement. According to the method, the natural language test requirement is converted into a vector, the reference case vector in the test case asset library is combined to generate a new test case, manual screening of the test case is not needed, and the efficiency and accuracy of test case generation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software testing technology, and in particular to test case generation methods, apparatus, devices, and storage media. Background Technology

[0002] As enterprise technology projects continue to expand, some large enterprise software development projects need to manage tens of thousands of test cases covering components, functions, performance, and other types of applications. Executing all test cases at once consumes too much resources and is impractical.

[0003] Currently, some technologies rely on experts manually selecting a subset of test cases from a test case library as reference test cases, and then writing new test cases based on these reference test cases. However, due to limitations in the breadth of expert knowledge, key test scenarios are easily overlooked during the test case selection process, resulting in low accuracy of the generated test cases. Summary of the Invention

[0004] This application provides a test case generation method, a test case generation device, an electronic device, a computer-readable storage medium, and a computer program product to at least solve the problem of low accuracy of test cases in related technologies.

[0005] This application provides a test case generation method, including:

[0006] Receive a test case generation request, which includes test requirements described in natural language; Transform test requirements into a test requirement vector; Based on the test requirement vector, reference test case vectors are selected from the test case asset library. The test case asset library includes vectors of multiple test cases, and the reference test case vector refers to at least one vector in the test case asset library that matches the test requirement vector. Using the test requirement vector and reference test case vector as references, generate one or more new test cases that match the test requirements.

[0007] This application also provides a test case generation apparatus, including: The request generation module is used to receive test case generation requests, which include test requirements described in natural language. The requirement vectorization module is used to convert test requirements into test requirement vectors; The reference test case vector filtering module is used to filter reference test case vectors from the test case asset library based on the test requirement vector. The test case asset library includes vectors of multiple test cases, and the reference test case vector refers to at least one vector in the test case asset library that matches the test requirement vector. The test case generation module is used to generate one or more new test cases that match the test requirements, using the test requirement vector and the reference test case vector as references.

[0008] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described test case generation methods when executing the computer program.

[0009] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described test case generation methods.

[0010] In some embodiments of this application, a test case generation request, including natural language testing requirements, is first received and converted into a test requirement vector. Then, a matching reference test case vector is selected from an asset library storing multiple test case vectors. Finally, a new test case is generated based on both vectors. Since vector matching allows for precise location of the reference, the new test cases generated by combining the test requirements and reference vectors match the test requirements, resulting in more accurate test cases. This addresses the problem of low test case accuracy in some technologies. Attached Figure Description

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

[0012] Figure 1 A flowchart illustrating a test case generation method provided for some embodiments of this application; Figure 2 A schematic diagram of a test case generation apparatus provided for some embodiments of this application; Figure 3 A schematic diagram of the modules of an electronic device provided for some embodiments of this application. Detailed Implementation

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

[0014] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0015] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0016] In some technical solutions, generating test cases requires manual selection of reference test cases from a massive test case library based on experience, followed by the generation of new test cases. However, this selection process is prone to errors due to knowledge limitations, potentially overlooking key scenarios and resulting in inaccurate new test cases. Relying entirely on reusing historical test cases to generate new ones consumes significant computing resources to execute irrelevant test cases, leading to a substantial workload. Therefore, generating highly accurate test cases has become a pressing issue.

[0017] In view of this, this application provides a test case generation method that can solve the above problems. The test case generation method can be applied to electronic devices. Electronic devices may include, but are not limited to, tablet computers, laptops, desktop computers, servers, etc. (See also...) Figure 1 This is a flowchart illustrating a test case generation method provided in some embodiments of this application. Figure 1 In this context, the test case generation method includes the following steps: Step S101: Receive a test case generation request. The test case generation request includes test requirements described using natural language.

[0018] Specifically, a test case refers to a standardized set of execution steps used to verify whether the functionality and performance of a software system meet requirements, such as verifying the effectiveness of a data protection strategy. A test case generation request is an instruction initiated by a tester to trigger the automatic test case generation process, adapting to the input requirements of various testing scenarios in large enterprise software projects, including component testing, functional testing, and end-to-end testing.

[0019] Step S102: Convert the test requirements into a test requirement vector.

[0020] Specifically, test requirement vectors refer to the numerical representation of natural language test requirements. They transform natural language test requirements into structured vector data that can be computed by machines, providing a basis for selecting reference test case vectors from the test case asset library and adapting to the needs of large enterprise software projects for rapid retrieval and matching of massive test cases.

[0021] Step S103: Based on the test requirement vector, filter reference test case vectors from the test case asset library. The test case asset library includes vectors of multiple test cases. A reference test case vector refers to at least one vector in the test case asset library that matches the test requirement vector.

[0022] A test case asset repository refers to a data storage space used to store test case vector data and associated information. It can be in the form of a database, structured storage pool, or tables. Its function is to centrally manage tens of thousands of test cases covering component testing, functional testing, and end-to-end testing scenarios in large enterprise software projects, providing a searchable data source for test requirement vectors. The associated information may include, but is not limited to, the version and name of each test case.

[0023] Reference test case vectors refer to at least one test case vector that matches the test requirement vector, obtained through a retrieval process in the test case asset library based on the test requirement vector. These vectors are highly correlated with the test requirement vector in terms of characteristics, and the associated test case content can provide logical reference for the subsequent generation of new test cases.

[0024] Specifically, by inputting a test requirement vector into the system and traversing the test case asset library, vectors that match the test requirement vector can be filtered out as reference test case vectors.

[0025] Step S104: Using the test requirement vector and the reference test case vector as references, generate one or more new test cases that match the test requirements.

[0026] New test cases refer to a set of standardized execution steps generated based on test requirement vectors and reference test case vectors, which are not present in the test case asset library. They are created by intelligent algorithms that transform abstract vector semantics into concrete, executable test case content. One or more generated test cases can meet testing requirements; for example, a single test case can satisfy in-depth verification of core scenarios, while multiple test cases can cover test scenarios of different dimensions, forming a complete test plan.

[0027] In some embodiments, using the test requirement vector and reference use case vector as references, one or more new test cases matching the test requirements are generated, including: Input the prompt words, test requirement vector, and reference test case vector into the language model. The language model then uses the prompt words and test requirement vector as references to expand or modify the test cases corresponding to the reference test case vectors to obtain new test cases, or uses the prompt words, test requirement vector, and reference test case vector as references to generate new test cases.

[0028] Prompts refer to predefined natural language content. They can be predefined standardized instructions, such as generating test cases that include test steps, test results, and trial versions; or they can be natural language expressions, such as referring to these test cases to help me expand test cases to be applicable to new test scenarios.

[0029] A language model is an artificial intelligence model with text generation capabilities. After being trained on data, it can understand the structure and logic of test cases and can expand, modify, or generate new test cases based on the input vector information and prompt words.

[0030] Generating new test cases refers to the process where, when reference test cases cannot cover entirely new scenarios requiring testing, the language model integrates prompt words, test requirement vectors, and reference test case vectors to directly create entirely new test cases, filling the scenario gaps in the test case asset library.

[0031] Specifically, the prompt words, test requirement vector, and reference use case vector are first input into the language model. Guided by the prompt words, the language model parses the requirements in the test requirement vector and then extracts the test cases associated with the reference use case vector. Subsequently, processing is performed based on the prompt words and test requirement vector. If the reference use case vector partially matches the requirement scenario, the model will expand or modify the reference use cases; if a completely new scenario needs to be covered, the model will directly generate new test cases based on the prompt words, reference use case vector, and test requirement vector.

[0032] In the above embodiments, prompt words ensure that the model understands the generated requirements, test requirement vectors ensure the consistency between new test cases and original requirements, reference test case vectors provide basic test logic, language models realize the transformation from vector information to usable test cases, and the newly generated test cases can accurately match the current test scenario, which can effectively improve generation efficiency and accuracy.

[0033] In summary, in the technical solutions of some embodiments of this application, a test case generation request including natural language testing requirements is first received, and the requirements are converted into test requirement vectors. Then, matching reference test case vectors are selected from an asset library storing multiple test case vectors. Finally, new test cases are generated based on both. Since the reference basis can be accurately located through vector matching, the new test cases generated by combining the test requirements and reference vectors can match the test requirements, that is, the obtained test cases are relatively accurate, thereby solving the problem of low test case accuracy in some technologies.

[0034] In some embodiments, the method of this application may further include, before filtering reference use case vectors from the test case asset library: Obtain the basic data used to build test cases; Based on the basic data, a reference document is generated, which includes the dataset of test cases and the metadata of the test cases. The dataset in the reference document is converted into semantic vectors, and the semantic vectors and metadata in the reference document are stored in a pre-built storage structure to form a test case asset library.

[0035] Specifically, the basic data for test cases refers to the set of original information that supports the generation of test cases, including but not limited to test cases and their descriptions extracted from the database, such as the step definitions and associated component identifiers of the test cases. At the same time, related documents can be supplemented, such as knowledge base articles, user guides, and troubleshooting solution documents. When test cases and their descriptions are insufficient, related documents can serve as a supplement to ensure data integrity. This data forms the basis for building a test case asset library.

[0036] Reference Documents (RDs) are structured documents that integrate and process basic data. They are generated by integrating three types of inputs through machine learning models: first, the original content of the test cases, such as the verification steps; second, the test case descriptions, such as detailed explanations; and third, supplementary related documents, such as storage component technical manuals. This integration transforms scattered basic data into standardized reference documents.

[0037] The dataset in the reference document refers to the core execution elements of the test cases, including test steps, execution sequences, associated hardware / software identifiers, and other specific content. Associated hardware / software identifiers are symbols or codes that uniquely identify the hardware devices or software modules associated with the test case. The metadata in the reference document refers to auxiliary information describing the attributes of the test cases, including minimum application version requirements and test priorities, providing a basis for filtering reference cases based on attribute dimensions.

[0038] Semantic vectors, also known as embedding vectors (EVs), are numerical representations obtained by vectorizing a dataset in a reference document using a text embedding transformation model. For example, they can be represented as floating-point vectors of 768 to 1024 dimensions, with each dimension corresponding to a different dimension of the semantic features of the dataset. This vector form enables a precise mathematical representation of the semantics of the reference document.

[0039] Specifically, test cases and their descriptions can be extracted from the database first. If the information is insufficient, related documents can be automatically added. Then, the three types of inputs are integrated through the analyzer's machine learning model to generate a structured reference document containing the dataset and metadata. Next, the dataset is converted into a semantic vector and stored in a preset storage structure along with the metadata. Finally, a test case asset library that can be used for subsequent retrieval is formed.

[0040] In the above embodiments, basic data including test cases, descriptive information, and supplementary related documents are first acquired. Then, a machine learning model integrates this data to generate a structured reference document containing datasets and metadata. Finally, the dataset is converted into semantic vectors and stored in a preset storage structure along with the metadata to construct a test case asset library. This approach not only addresses the issue of insufficient test case information by supplementing it with related documents, ensuring the completeness of the basic data, but also transforms scattered data into standardized reference documents and vector representations. This provides a structured and quantifiable retrieval basis for subsequent reference case vector selection, improving the completeness of the test case asset library and the accuracy of subsequent retrievals, and laying a data foundation for generating test cases that meet the requirements.

[0041] In some embodiments, step S102, converting test requirements into a test requirement vector, includes: Check whether the length of the test requirement exceeds the preset length threshold; If the length of the test requirement exceeds the preset length threshold, a requirement summary is extracted from the test requirement, and a test requirement vector is generated based on the request summary. If the length of the test requirement does not exceed the preset length threshold, a test requirement vector will be generated directly based on the test requirement.

[0042] The preset length threshold refers to the maximum input length limit that the test case recommendation model can handle, usually measured in tokens, such as 512 tokens. Its purpose is to prevent model failure due to excessively long test requirements, ensuring the stability and accuracy of the vector transformation process.

[0043] A requirement summary is a text containing key information obtained after compressing excessively long test requirements. It must retain the core semantics of the original requirements while removing redundant expressions. For example, the input test requirement "Recommended test cases for CPU (Central Processing Unit) overheating caused by fan failure, covering hardware diagnostics and thermal system verification" can be compressed into "Fan failure causes CPU overheating, requiring hardware diagnostics + thermal testing," which retains the original information while meeting the model's input length requirements.

[0044] The process of extracting requirement summaries is completed by a summarizer model, such as a dedicated text compression model like T5-Summarizer (Text-to-TextTransfer Transformer). This model can accurately identify the core elements and redundant information in the test requirements and maintain semantic integrity while shortening the text length through compression technology.

[0045] Specifically, the system first performs a length check on the received natural language test requirements. If the number of tokens does not exceed a preset threshold, the system directly calls the text embedding model to convert the complete requirements into a test requirement vector. If the threshold is exceeded, the system first starts the digester model to generate a requirement digest, and then uses the digest as input to call the text embedding model to generate a vector.

[0046] In the above embodiments, by first detecting whether the length of the test requirement exceeds a preset threshold, for excessively long requirements, a requirement summary retaining the core semantics is extracted using a digester model before generating a vector; otherwise, a vector is generated directly. This approach avoids model processing failures due to excessively long requirements by using the preset threshold, ensuring the stability of vector conversion. Furthermore, the digester model retains key information and eliminates redundant expressions when compressing requirements, ensuring the accuracy of the generated test requirement vectors. This improves the accuracy of test requirement vector conversion and lays the foundation for accurate matching of subsequent reference use case vectors.

[0047] In some embodiments, step S103, which involves filtering reference test case vectors from the test case asset library based on test requirement vectors, includes: The similarity between the test requirement vector and each vector in the test case asset library is calculated to obtain the similarity between the test requirement vector and each vector. In the test case asset library, at least some vectors whose similarity to the test requirement vector exceeds a similarity threshold will be used as reference test case vectors.

[0048] Similarity calculation refers to using vector similarity algorithms, such as cosine similarity, to perform mathematical operations on the test requirement vector and each semantic vector in the test case asset library, deriving a numerical result that represents the degree of semantic association between the two. For example, when the test requirement vector represents "diagnostic test of CPU overheating caused by fan failure," vectors related to "heat dissipation system anomaly detection" in the test case asset library will show high similarity, while vectors related to "network latency test" will have low similarity.

[0049] In practice, to improve the computational efficiency of massive vectors, the Approximate Nearest Neighbor (ANN) search method is adopted. The test requirement vector is used as the anchor point to quickly locate semantically similar vectors, avoiding the inefficiency caused by traversing all vectors in the test case asset library, and ensuring that the computation can still be completed efficiently in massive data scenarios.

[0050] The similarity threshold is a pre-set critical value used to determine whether the semantic relevance of vectors meets the standard. Its function is to filter vectors with low semantic relevance, ensuring that the selected reference use case vectors are highly matched with the test requirements. This threshold can be adjusted according to the test scenario. If it is necessary to improve the accuracy of the filtering, the similarity threshold can be appropriately increased; if it is necessary to expand the filtering scope to cover more test cases, the similarity threshold can be appropriately decreased.

[0051] Specifically, the system first uses an approximate nearest neighbor search to quickly calculate the similarity between the test requirement vector and all vectors in the test case asset library, using the test requirement vector as the anchor point. Then, based on a preset similarity threshold, it filters out vectors that meet the similarity standard. The upper limit of the number of vectors to be filtered can be set according to actual needs, such as filtering out the top five most similar vectors, and simultaneously extracting the test case metadata associated with these vectors.

[0052] In the above embodiments, a vector similarity algorithm is used to calculate the similarity between the test requirement vector and the vectors in the asset library. Approximate nearest neighbor search is then used to quickly locate the most similar vector. Simultaneously, an adjustable similarity threshold and an optional upper limit on the number of similar vectors are used to filter reference test case vectors. This approach avoids the inefficiency of fully traversing a massive number of vectors through approximate nearest neighbor search, ensuring efficient computation even in large-scale projects. Furthermore, the similarity threshold filters vectors with low semantic relevance, and the threshold and upper limit can be adjusted according to requirements to achieve precise matching of test requirements, laying the foundation for efficiently generating test cases that meet those requirements.

[0053] In some embodiments, the method of this application further includes: If no reference test case vector is found from the test case asset library, a test case gap alert is generated. The alert is used to prompt the addition of test cases that match the test requirements.

[0054] Test case gap alerts are automatically generated by the system when no reference test case vectors are found. Their core function is to inform testers of insufficient scenario coverage in the test case asset library, preventing new test case generation failures. The alert content includes two parts: first, it informs the gap status, such as "No relevant test cases found"; second, it provides targeted suggestions, such as "Check if the query semantics are clear" and "Expand the test library to cover fan redundancy design scenarios," guiding testers to take remedial measures.

[0055] Specifically, if a matching reference test case vector is found during the screening process, the subsequent generation steps continue. If the similarity between all vectors in the test case asset library and the test requirement vector does not reach the preset threshold, or if there are no matching results due to a lack of test case vectors for relevant scenarios in the test case asset library, resulting in no reference test case vectors being selected, an alert generation mechanism is immediately triggered. After receiving the alert, testers can optimize the query description or add new test cases based on the suggestions.

[0056] In the above embodiments, when no reference test case vector is found from the test case asset library, a test case gap alert is automatically generated, which includes gap status information and targeted suggestions. This not only provides timely feedback to testers regarding insufficient scenario coverage in the asset library or query semantic issues, but also guides testers to take remedial measures through specific suggestions. The supplementary test cases can also improve the scenario coverage of the test case asset library, providing support for subsequent similar testing needs and enhancing the overall reliability of the test case generation system.

[0057] In some embodiments, the test case asset library also includes metadata information for each test case, and the method further includes: If no new test cases matching the test requirements are generated using the test requirement vector and reference test case vector as references, then the test case asset library is used to determine whether there are test cases matching the test requirements based on the metadata information of each test case.

[0058] Specifically, although reference test case vectors have been obtained through the screening process, there may still be discrepancies between the semantic features of the reference test case vectors and the core requirements of the test requirement vectors. For example, if the requirement is "to recommend test cases for CPU overheating caused by fan failure, covering hardware diagnostics and cooling system verification", the reference test case vectors only cover "cooling system verification", resulting in the final output of no new test cases that meet the requirements. In this case, introducing metadata judgment can serve as a supplementary means of semantic vector matching.

[0059] The system extracts key attributes that correspond to metadata from the test requirements, and then compares them with the metadata of all test cases in the test case asset library. If the metadata of a test case completely matches the extracted requirement attributes, the test case is determined to match the test requirements; if the metadata of all test cases fails to meet the attribute matching conditions, it is determined that there are no matching test cases in the asset library.

[0060] In the above embodiments, when no matching new test cases are generated using the test requirement vector and reference test case vector, metadata information from the test case asset library is introduced. Key attribute information of the requirements is extracted and compared with the metadata to determine if a matching test case exists. This avoids missing existing test cases in the test case asset library due to the limitations of semantic vector matching, and uses attribute comparison of metadata as a supplementary means to semantic vector matching, thereby improving the comprehensiveness of test case retrieval and providing a more reliable solution.

[0061] Corresponding to the test case generation method, this application also provides a test case generation apparatus. (See also...) Figure 2 This is a schematic diagram of a test case generation device provided in some embodiments of this application. Figure 2 In this context, the test case generation device includes: The request generation receiving module 201 is used to receive test case generation requests, which include test requirements described in natural language. The requirement vectorization module 202 is used to convert test requirements into test requirement vectors. The reference test case vector filtering module 203 is used to filter reference test case vectors from the test case asset library based on the test requirement vector. The test case asset library includes vectors of multiple test cases. A reference test case vector refers to at least one vector in the test case asset library that matches the test requirement vector. The test case generation module 204 is used to generate one or more new test cases that match the test requirements, using the test requirement vector and the reference test case vector as references.

[0062] In some embodiments, the reference use case vector filtering module 203 is specifically used for: The basic data acquisition unit is used to acquire the basic data used to build test cases. The reference document generation unit is used to generate reference documents based on the basic data. The reference documents include the dataset of test cases and the metadata of the test cases. The test case asset library building unit is used to convert the dataset in the reference document into semantic vectors, and store the semantic vectors and metadata in the reference document into a pre-built storage structure to form the test case asset library.

[0063] In some embodiments, the demand vectorization module 202 is specifically used for: The requirement length detection unit is used to detect whether the length of the test requirement exceeds a preset length threshold. The requirement summary generation and vector conversion unit is used to extract a requirement summary from the test requirement if the length of the test requirement exceeds a preset length threshold, and generate a test requirement vector based on the request summary. The direct vector conversion unit is used to generate a test requirement vector directly based on the test requirement if the length of the test requirement does not exceed a preset length threshold.

[0064] In some embodiments, the reference use case vector filtering module 203 is specifically used for: The vector similarity calculation unit is used to calculate the similarity between the test requirement vector and each vector in the test case asset library, and obtain the similarity between the test requirement vector and each vector. The reference use case vector filtering unit is used to select at least a portion of the vectors in the test use case asset library that have a similarity to the test requirement vector exceeding a similarity threshold as reference use case vectors.

[0065] In some embodiments, the test case generation module 204 is specifically used for: The test case generation execution unit is used to input prompt words, test requirement vectors, and reference test case vectors into the language model. The language model uses the prompt words and test requirement vectors as references to expand or modify the test cases corresponding to the reference test case vectors to obtain new test cases, or uses the prompt words, test requirement vectors, and reference test case vectors as references to generate new test cases.

[0066] In some embodiments, the test case generation module 204 is specifically used for: The test case gap alert generation unit is used to generate a test case gap alert if no reference test case vector is found from the test case asset library. The alert is used to prompt the addition of test cases that match the test requirements.

[0067] In some embodiments, the reference use case vector filtering module 203 is specifically used for: The metadata matching judgment unit is used to determine whether there are test cases in the test case asset library that match the test requirements if no new test cases matching the test requirements are generated using the test requirement vector and the reference test case vector as references.

[0068] For a description of the features in the embodiment corresponding to the test case generation device, please refer to the relevant description in the embodiment corresponding to the sample data processing method, which will not be repeated here.

[0069] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0070] See also Figure 3 Embodiments of this application also provide an electronic device, including a memory 10 and a processor 20, wherein the memory 10 stores a computer program and the processor 20 is configured to run the computer program to perform the steps in any of the above-described test case generation method embodiments.

[0071] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described test case generation method embodiments at runtime.

[0072] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0073] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described test case generation method embodiments.

[0074] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described test case generation method embodiments.

[0075] Those skilled in the art will further 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 implementation should not be considered beyond the scope of this application.

[0076] The foregoing has provided a detailed description of a test case generation method, apparatus, device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to aid in understanding the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A test case generation method, characterized in that, The method includes: Receive a test case generation request, the test case generation request including test requirements described using natural language; Convert the test requirements into a test requirement vector; Based on the test requirement vector, reference test case vectors are selected from the test case asset library, which includes vectors of multiple test cases. The reference test case vector refers to at least one vector in the test case asset library that matches the test requirement vector. Using the test requirement vector and the reference test case vector as references, generate one or more new test cases that match the test requirements.

2. The method according to claim 1, characterized in that, Before filtering the reference test case vector from the test case asset library, the method further includes: Obtain the basic data used to build test cases; Based on the aforementioned basic data, a reference document is generated, which includes the dataset of test cases and the metadata of the test cases. The dataset in the reference document is converted into a semantic vector, and the semantic vector and the metadata in the reference document are stored in a pre-built storage structure to form the test case asset library.

3. The method according to claim 1, characterized in that, The step of converting the test requirements into a test requirement vector includes: Detect whether the length of the test requirement exceeds a preset length threshold; If the length of the test requirement exceeds the preset length threshold, then a requirement summary is extracted from the test requirement, and the test requirement vector is generated based on the request summary. If the length of the test requirement does not exceed the preset length threshold, the test requirement vector is generated directly based on the test requirement.

4. The method according to claim 1, characterized in that, The step of selecting reference test case vectors from the test case asset library based on the test requirement vector includes: The similarity between the test requirement vector and each vector in the test case asset library is calculated to obtain the similarity between the test requirement vector and each vector. In the test case asset library, at least some vectors whose similarity to the test requirement vector exceeds a similarity threshold are used as the reference test case vectors.

5. The method according to claim 1, characterized in that, The step of generating one or more new test cases that match the test requirements, using the test requirement vector and the reference test case vector as references, includes: The prompt words, the test requirement vector, and the reference test case vector are input into the language model. The language model uses the prompt words and the test requirement vector as references to expand or modify the test cases corresponding to the reference test case vector to obtain the new test cases, or uses the prompt words, the test requirement vector, and the reference test case vector as references to generate the new test cases.

6. The method according to claim 1, characterized in that, The method further includes: If the reference test case vector is not found from the test case asset library, a test case gap alert is generated, which prompts the addition of test cases that match the test requirements.

7. The method according to claim 1, characterized in that, The test case asset library also includes metadata information for each test case, and the method further includes: If no new test case matching the test requirement is generated using the test requirement vector and the reference test case vector as references, then based on the metadata information of each test case, it is determined whether there is a test case matching the test requirement in the test case asset library.

8. A test case generation device, characterized in that, The device includes: A request generation receiving module is used to receive test case generation requests, which include test requirements described in natural language. The requirement vectorization module is used to convert the test requirements into test requirement vectors; The reference test case vector filtering module is used to filter reference test case vectors from the test case asset library based on the test requirement vector. The test case asset library includes vectors of multiple test cases, and the reference test case vector refers to at least one vector in the test case asset library that matches the test requirement vector. The test case generation module is used to generate one or more new test cases that match the test requirements, using the test requirement vector and the reference test case vector as references.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the test case generation method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the test case generation method as described in any one of claims 1 to 7.