Test case generation method and device, electronic equipment and storage medium
By receiving user-uploaded requirement documents, splitting, parsing, and vectorizing them, and using a vector knowledge base and a large language model to generate standardized test cases, the problem of time-consuming and poor maintainability of manual test case writing is solved, achieving efficient and quality-assured test case generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-05
- Publication Date
- 2026-04-07
AI Technical Summary
Current test case development relies on human experience, which is time-consuming, has poor maintainability and reusability, and makes it difficult to guarantee quality.
By receiving user-uploaded requirement documents, we break them down, parse them, and vectorize them. Then, we use a vector knowledge base and a large language model to generate standardized test cases, avoiding the need for manual writing.
This improved the maintainability and reusability of test cases, reduced time costs, and ensured the quality of test case writing.
Smart Images

Figure CN121807723A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a test case generation method, apparatus, electronic device, and storage medium. Background Technology
[0002] Current test case development heavily relies on the personal experience of test engineers, requiring manual analysis of test requirements documents, communication matrices, and electrical parameters, as well as the manual writing of test scripts and verification logic. This process is time-consuming and prone to errors. Furthermore, during manual test case development, test engineers need to repeatedly consult technical documentation, often rewriting similar code for different scenarios of the same function, further wasting significant time on inefficient repetitive work. In addition, the significant differences in structure, style, and coverage dimensions of test cases written by different engineers greatly reduce their maintainability and reusability. More importantly, manually written test cases are easily limited by the test engineer's depth of understanding of the requirements, potentially overlooking new interactive functions or boundary conditions, thus creating potential quality issues. In conclusion, current test case development methods are time-consuming, have poor maintainability and reusability, and struggle to guarantee quality. Summary of the Invention
[0003] In view of this, this application aims to propose a test case generation method, device, electronic device, and storage medium to solve the problems of current test case development methods that require a large amount of time, have poor maintainability and reusability, and are difficult to guarantee quality. The specific technical solution is as follows: According to a first aspect of this application, a test case generation method is provided, the method comprising: Receive user-uploaded requirement documents to be parsed; The requirement document to be parsed is split and parsed to obtain sub-requirement text blocks to generate test cases; The sub-requirement text blocks of the test cases to be generated are vectorized to obtain the sub-requirement text block vectors of the test cases to be generated. The sub-requirement text block vectors of the test cases to be generated are retrieved in a preset vector knowledge base to obtain target similar vectors; Based on the target similarity vector and the sub-requirement text blocks of the test cases to be generated, standard prompt words for the test cases to be generated are generated. Input the standard prompts for the test cases to be generated into a preset large language model, and output standardized test cases.
[0004] Optionally, before retrieving the sub-requirement text block vectors of the test cases to be generated in a preset vector knowledge base to obtain the target similar vectors, the method further includes: The pre-defined test case standard development specification manual and several knowledge materials related to the generated test cases are segmented into text fragments. The text fragment is vectorized to obtain a text fragment vector; A vector knowledge base is generated using the text fragment vectors.
[0005] Optionally, before performing text segmentation on the preset test case standard development specification manual and several knowledge materials related to the generated test cases to obtain text fragments, the method further includes: For any knowledge data related to the generated test cases, the knowledge data is parsed to determine the element information to which the knowledge data belongs in the generated test cases. The element information includes at least one of the test category, test object, test scenario, and test strategy of the generated test cases. The knowledge data is labeled using the element information.
[0006] Optionally, generating a vector knowledge base from the text fragment vectors includes: The aforementioned annotation information is used to divide various knowledge materials into several knowledge databases. For any knowledge base, the text fragment vectors of the knowledge base are aggregated to obtain the vector knowledge base of the knowledge base.
[0007] Optionally, after splitting and parsing the requirement document to be parsed to obtain sub-requirement text blocks for generating test cases, the method further includes: Intent recognition is performed on the sub-requirement text blocks of the test cases to be generated to obtain intent information of the sub-requirement text blocks of the test cases to be generated. The intent information includes at least one of the test category, test object, test scenario and test strategy of the test cases to be generated. The intent information is compared with the annotation information to determine the vector knowledge base corresponding to the sub-requirement text block of the test case to be generated.
[0008] Optionally, before inputting the standard prompt words of the test cases to be generated into a preset large language model and outputting standardized test cases, the method further includes: Obtain the binary format file of the large language model; Deploy the platform framework for the large language model on the server; The large language model is loaded into a binary format file through the platform framework and deployed on a server. A Uniform Resource Locator (URL) is configured for the large language model, the vector knowledge base is deployed on a retrieval-enhanced generation framework, and the retrieval-enhanced generation framework is connected to the large language model through the URL.
[0009] Optionally, the step of retrieving the sub-requirement text block vectors of the test cases to be generated in a preset vector knowledge base to obtain target similar vectors includes: Obtain the similarity between the sub-requirement text block vector of the test case to be generated and the text fragment vector in the preset vector knowledge base; Extract target similarities greater than the similarity threshold from the aforementioned similarities; The target similarity vector is determined from the text fragment vector using the target similarity.
[0010] According to a second aspect of this application, a test case generation apparatus is provided, the apparatus comprising: The receiving module is used to receive user-uploaded requirement documents that need to be parsed. The splitting and parsing module is used to split and parse the requirement document to be parsed to obtain sub-requirement text blocks to generate test cases; The first vectorization processing module is used to vectorize the sub-requirement text blocks of the test cases to be generated, so as to obtain the sub-requirement text block vectors of the test cases to be generated. The retrieval module is used to retrieve the sub-requirement text block vectors of the test cases to be generated from a preset vector knowledge base to obtain target similar vectors. The prompt word generation module is used to generate standard prompt words for the test cases to be generated by using the target similarity vector and the sub-requirement text blocks of the test cases to be generated. The input / output module is used to input the standard prompts of the test cases to be generated into a preset large language model and output standardized test cases.
[0011] According to another aspect of this application, an electronic device is also provided, comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the test case generation method described above.
[0012] According to another aspect of this application, a computer-readable storage medium is also provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to implement any of the test case generation methods of the first aspect described above.
[0013] The test case generation method provided in this application receives a user-uploaded requirement document to be parsed; it then breaks down and parses the requirement document to obtain sub-requirement text blocks for generating test cases. This decomposition of complex requirements avoids omissions, ensuring the comprehensiveness and completeness of the subsequently generated test cases. It also provides appropriately granular input units for subsequent vectorization and retrieval. The sub-requirement text blocks are then vectorized to obtain sub-requirement text block vectors. Vectorization converts the text into numerical features, capturing the semantics of the requirements and avoiding limitations in subsequent matching. Furthermore, it unifies text format differences, improving the robustness of subsequent retrieval. Finally, the sub-requirement text block vectors are stored in a pre-defined vector knowledge base. The system performs a search to obtain target similarity vectors. Using these similarity vectors and the sub-requirement text blocks of the test cases to be generated, standard prompt words for the test cases are generated. By combining user input and vector knowledge base content, the system avoids the illusion problem that may occur when using a large language model, improving the accuracy of the model's output and ensuring the quality of test case writing. The standard prompt words for the test cases to be generated are input into a pre-defined large language model, which outputs standardized test cases. The unified output format through the large language model solves the problem of significant differences in structure, style, and coverage dimensions when test cases are written manually, improving the maintainability and reusability of test cases. Furthermore, it eliminates the need for manual test case writing, saving time and ensuring the quality of test case writing.
[0014] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, specific embodiments of this application are given below. Attached Figure Description
[0015] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 This is a flowchart illustrating the steps of a test case generation method provided in this application; Figure 2 yes Figure 1 The flowchart shown is a step 104 of a test case generation method provided in this application; Figure 3 This is a flowchart of the steps of another test case generation method provided in this application; Figure 4 This is a schematic diagram of the structure of a test case generation device provided in this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0016] To make the objectives, technical solutions, and advantages of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been provided in the various embodiments of this application to facilitate a better understanding of the application. However, the technical solutions claimed in this application can be implemented even without these technical details and with various variations and modifications according to the following embodiments. The division of the various embodiments below is for ease of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.
[0017] In recent years, new energy vehicles have made significant breakthroughs in electrification, intelligentization, and connectivity technologies, leading to increasing functional complexity and shorter project development cycles. To ensure product quality, corresponding testing work also needs to be improved in efficiency and effectiveness. Currently, product quality testing is achieved through test cases developed based on the personal experience of test engineers. However, relying on manual test case development requires consulting numerous documents, resulting in significant time consumption. Furthermore, different scenarios for the same function often require repetitive writing of similar code, further wasting considerable time on inefficient repetitive work. In addition, manual test case development cannot standardize development standards and quality, and may result in incomplete coverage of test points for new functions, thus affecting testing efficiency and quality. Based on these problems, this application proposes a test case generation method. (Refer to...) Figure 1 The diagram illustrates a flowchart of a test case generation method provided in this application, the method including: Step 101: Receive the user-uploaded requirement document to be parsed.
[0018] The requirements document to be parsed in this application contains information about the test cases that the user expects to generate, including the functional points to be tested, all conditions that the test needs to meet, the specific events that trigger the functional action or the execution steps of the function, the expected functional phenomena, the conditions under which the function stops working, and the vehicle or system behavior after the function ends.
[0019] Step 102: Split and parse the requirement document to be parsed to obtain sub-requirement text blocks for generating test cases.
[0020] This application utilizes a requirement document splitting and parsing algorithm to split and parse the requirement document to be parsed. The resulting sub-requirement text blocks include test function point text blocks, prerequisite text blocks, trigger condition text blocks, execution action text blocks, exit condition text blocks, and exit action text blocks. The test function point text block describes the specific functional module to be tested, such as "[Automatic Emergency Braking (AEB) emergency braking when encountering an obstacle ahead]". The prerequisite text block describes all the conditions that need to be met for the test, listed in multiple time-sharing clauses, such as "[1. The vehicle is in the (ignition / charging) ON position and in motion; 2. The vehicle speed is greater than 30 km / h; 3. The AEB system is activated; 4. There is a simulated obstacle within 5-20 meters ahead]". The trigger condition text block describes the specific event that triggers the functional action or the execution steps of the function, such as "[1. Millimeter-wave radar detects an obstacle ahead for 1.5 seconds; 2. The driver does not perform braking operation (brake pedal pressure is less than the threshold); 3. The system predicts the collision time (Time To...)"]. The Collision (TTC) ≤ 2 seconds】, the execution action text block describes the expected functional phenomenon and the specific response that the vehicle or system should make, such as [1. Trigger the audible and visual alarm (buzzer sends an alarm tone + red instrument light flashes); 2. Prefill the brake line pressure to 5 bar; 3. If the driver still does not respond, apply maximum braking force after 0.5 seconds]. The exit condition text block describes the conditions under which the function stops taking effect, such as [1. The vehicle comes to a complete stop (vehicle speed = 0 km / h); 2. The obstacle leaves the sensor detection range; 3. The driver actively takes over braking (pedal pressure is greater than the threshold); 4. System failure (such as sensor signal loss)]. The exit action text block describes the vehicle or system behavior after the function ends, such as [1. Turn off the audible and visual alarm; 2. Store the event log (timestamp, vehicle speed, braking force, etc.); 3. Release automatic braking control and restore full driver control].
[0021] After obtaining the sub-requirement text block, this application utilizes a development intent recognition algorithm tool to identify its intent information. This intent information includes at least one of the following: test category, test object, test scenario, and test strategy for generating test cases. The test category is identified through a classification model or keyword matching and may include functional testing, performance testing, and security testing. The test object is identified through named entity recognition and may be a system module, interface, or component. The test scenario is determined through semantic role annotation and may include normal flow, abnormal flow, and boundary conditions. The test strategy is obtained through rule templates and may include equivalence class partitioning, inversion, and critical value methods. The intent information is matched with the annotation information in a vector knowledge base to determine the vector knowledge base to be used. The annotation information in the vector knowledge base is obtained by parsing the knowledge data in the vector knowledge base. The operational steps include: Intent recognition is performed on the sub-requirement text blocks of the test cases to be generated to obtain intent information of the sub-requirement text blocks of the test cases to be generated. The intent information includes at least one of the test category, test object, test scenario and test strategy of the test cases to be generated. By comparing the intent information with the annotation information, the vector knowledge base corresponding to the sub-requirement text block to be generated as a test case is determined.
[0022] It should be understood that when comparing intent information with annotation information, matching can be done by directly comparing the content of the information or by matching the semantic information of the information; no specific limitation is made here.
[0023] The above steps, by identifying intent information and comparing it with the labeled information in the vector knowledge base, determine the vector knowledge base to be used subsequently, thus narrowing the search scope in the vector knowledge base and improving search matching efficiency.
[0024] Step 103: Vectorize the sub-requirement text blocks of the test cases to be generated to obtain the sub-requirement text block vectors of the test cases to be generated.
[0025] Before vectorization, this application requires preprocessing the sub-requirement text blocks of the test cases to be generated. This includes removing irrelevant characters (such as special symbols and Hyper Text Markup Language (HTML) tags), standardizing capitalization, correcting spelling errors, and removing meaningless generic words. Then, a vectorization model is selected to vectorize the processed data. This model can include a static word vector model, a pre-trained model with fine-tuning, and so on. The static word vector model maps words in the sub-requirement text blocks to fixed-dimensional vectors, generating text vectors through weighted averaging. The context-aware model generates dynamic word vectors using the Transformer model, while sentence-level vectors are obtained through classification labels or pooling. The pre-trained model with fine-tuning fine-tunes the Transformer-based Bidirectional Encoder Representations from Transformers (BERT) on the test case requirement corpus, improving the quality of the vector representations of domain terms.
[0026] By converting the sub-requirement text blocks of the test cases to be generated into sub-requirement text block vectors, unstructured natural language requirements can be transformed into computable mathematical representations, which facilitates subsequent similarity calculations. Moreover, it avoids missing the detection of "synonymous but different words" when calculating similarity in the subsequent process, and also facilitates the reuse of test cases and audit traceability.
[0027] Step 104: Search the sub-requirement text block vectors of the test cases to be generated in the preset vector knowledge base to obtain the target similar vectors.
[0028] The vector knowledge base pre-built in this application is obtained by pre-collecting test case standard development specification manuals and other knowledge materials related to generated test cases, then performing text segmentation and vectorization on this data. The test case standard development specification manual can be the International Software Testing Qualifications Board (ISTQB) standard development specification manual, or it can be a development specification manual developed internally by the enterprise. The knowledge materials related to generated test cases can include historical test case documents, automotive industry knowledge, testing knowledge, and vehicle model project knowledge (including historical requirements documents, communication matrices, and electrical parameters of vehicle model projects). The implementation steps include: The pre-defined test case standard development specification manual and several knowledge materials related to the generated test cases are segmented into text fragments. The text fragment is vectorized to obtain the text fragment vector; Generate a vector knowledge base using text fragment vectors.
[0029] In text segmentation, excessively long paragraphs can be segmented by sentence or paragraph, while preserving complete semantic units. Segmentation can also be done by chapter / clause, extracting tables or code blocks separately, identifying scattered but related fragments through semantic similarity analysis, and merging overly fine fragments with context awareness. An embedding model is used to vectorize text fragments. The resulting vector knowledge base is deployed within the Retrieval-Augmented Generation (RAG) framework.
[0030] Through the above steps, scattered test knowledge can be stored in a computable vector form, enabling semantic-level intelligent retrieval, efficient knowledge reuse (reducing redundant design), and standardized collaboration (team sharing of a unified knowledge base). This significantly improves the consistency, coverage, and automation level of test case design, while reducing reliance on human experience. Furthermore, the establishment of a vector knowledge base allows for the integration of user input with the vector knowledge base when generating test cases using large language models, avoiding the illusion problem inherent in large language models.
[0031] In addition, after collecting a large amount of knowledge related to the generated test cases, it will be cleaned and annotated. During annotation, the knowledge data will be linked to the standardized element system of the test cases. The standardized element information of the test cases includes test category, test object, test scenario, and test strategy. The implementation steps include: For any knowledge data related to the generated test cases, the knowledge data is parsed to determine the element information to which the knowledge data belongs in the generated test cases. The element information includes at least one of the test category, test object, test scenario and test strategy of the generated test cases. Add annotation information to knowledge materials by using element information.
[0032] The above operations, by automatically parsing knowledge data and labeling test element information (such as test category, object, scenario and strategy), realize the structured and regionalized storage of test knowledge, thereby significantly improving the reusability of test cases, design consistency and maintenance efficiency. At the same time, it narrows the search scope and improves the search matching efficiency for subsequent retrieval steps.
[0033] It should be understood that, when generating the vector knowledge base, this application also clusters the knowledge data based on the annotation information, and then obtains the corresponding vector knowledge base based on the clustered knowledge data base. The implementation steps include: Several knowledge resources are divided by labeling information to obtain several knowledge databases; For any knowledge base, aggregate the text fragment vectors of the knowledge base to obtain a vector knowledge base of the knowledge base.
[0034] By following the steps above, we can achieve refined classification and management of test knowledge (such as quick retrieval by test scenario / strategy).
[0035] Furthermore, other methods can be used to generate the vector knowledge base in this application. For example, annotation information is added to the knowledge data, but when the knowledge data is segmented into text to generate text fragment vectors, the text fragment vectors also carry the annotation information of the corresponding knowledge data. Then, when generating the vector knowledge base based on the text fragment vectors, the text fragment vectors are aggregated according to the annotation information (for example, aggregating text fragment vectors containing the same annotation information or semantically similar annotation information) to generate the vector knowledge base.
[0036] In this application, after obtaining the sub-requirement text block vector of the test case to be generated, the similarity of this sub-requirement text block vector of the test case to be generated with each text segment vector in the preset vector knowledge base is calculated. When the similarity is determined to be greater than the similarity threshold, the corresponding text segment vector in the preset vector knowledge base is the target similar vector. Therefore, step 104, as follows... Figure 2 As shown: Step 1041: Obtain the similarity between the sub-requirement text block vector of the test case to be generated and the text fragment vector in the preset vector knowledge base.
[0037] Step 1042: Extract the target similarity greater than the similarity threshold from the similarity.
[0038] Step 1043: Determine the target similarity vector from the text fragment vector using the target similarity.
[0039] It should be understood that if multiple text fragment vectors have a similarity greater than the similarity threshold with the sub-requirement text block vectors of the test cases to be generated, the text fragment vector with the highest similarity will be selected as the target similarity vector.
[0040] The above steps avoid the limitations of mechanical matching through semantic similarity analysis, significantly improving the accuracy and efficiency of subsequent test case generation.
[0041] Step 105: Generate standard prompt words for the test cases to be generated using the target similarity vector and the sub-requirement text blocks of the test cases to be generated.
[0042] This application first converts the target similarity vector into relevant document fragments, and then merges the relevant document fragments with the sub-requirement text blocks of the test cases to be generated to obtain the standard prompt word.
[0043] The format of the standard prompt words is as follows: Please write test cases to test [test function points]. Please use [test strategy] to write them.
[0044] [Prerequisites]: [Triggering Condition]: [Action to be performed]: [Exit Conditions]: [Exit Action]: Please output the results in JSON format, with each item containing four parts: 'Test Point', 'Prerequisites', 'Operation Steps', and 'Expected Result'. } Among the available testing strategies are equivalence class partitioning, reverse partitioning, and critical value testing.
[0045] Step 106: Input the standard prompts for the test cases to be generated into the preset large language model, and output the standardized test cases.
[0046] Before using the large language model in this application, it needs to be deployed on an internal enterprise server. Deployment requires first obtaining the open-source large language model's GPU-based Universal Framework (gguf) format file. Then, to enable private loading, execution, management, and interaction of the large language model, a large language model platform framework will be deployed on the server. The large language model will then be deployed to the server by loading the file through the platform framework. The implementation steps include: Obtain the binary format file of the large language model; Deploy a platform framework on the server for large language models; The large language model is deployed on the server by loading the binary format file of the large language model through the platform framework; Configure a Uniform Resource Locator (URL) for the large language model, deploy a vector knowledge base on the retrieval enhancement and generation framework, and connect the retrieval enhancement and generation framework to the large language model through the URL.
[0047] It should be understood that, since the vector knowledge base is deployed on the Retrieval-Augmented Generation (RAG) framework, after obtaining the target similarity vector through the vector knowledge base and obtaining the standard prompt words for the test cases to be generated based on the target similarity vector and the sub-requirement text blocks of the test cases to be generated, this content needs to be input into the preset large language model. At this time, the Retrieval-Augmented Generation framework needs to be connected with the large language model. Therefore, this application sets a Uniform Resource Locator (URL) for the large language model to achieve the connection between the large language model and the RAG framework.
[0048] The above steps, by efficiently deploying the large language model to the server in binary format (such as GGUF) and configuring the Uniform Resource Locator (URL) to work in conjunction with the Retrieval Augmentation (RAG) framework, can achieve fast model loading, stable service operation, and improve the accuracy of answers by incorporating vector knowledge base content into the output results.
[0049] This application first obtains JavaScript Object Notation (JSON) structured data through a large language model, and then uses a JSON to Excel spreadsheet tool to transform this structured data to obtain standardized test case Excel files.
[0050] For example, the structured data obtained based on the standard prompts for the test cases to be generated is as follows: [ { "testcase": "AEB emergency braking was triggered normally", "pre": [ "The vehicle is in the ON position and in motion". "Car speed 35km / h" "AEB system is activated" "There is an obstacle 10 meters ahead". "Lane lines are clearly visible" ], "action": [ "Millimeter-wave radar continuously detects obstacles for 2 seconds" "Maintain brake pedal pressure 0N", "TTC reduced to 1.8 seconds" ], "res": [ "Triggering audio and visual alarm", "Brake line pressure rises to 5 bar" "Apply braking force of 10 m / s² after 0.5 seconds", Release the brakes after the vehicle has come to a complete stop. ] }, { "testcase": "Driver actively takes over braking", "pre": [ "Vehicle traveling at 45km / h", "AEB system is activated" There is an obstacle 15 meters ahead. ], "action": [ "After the system triggers the audible and visual alarm", "Driver presses the brake pedal (pressure 60N)" ], "res": [ "Immediately disengage automatic braking" "Audible and visual alarm off" "Event log records vehicle speed at the moment of takeover" ] }, … ] In this context, "testcase" corresponds to the "test point" of the output content, "pre" corresponds to the "preconditions" of the output content, "action" corresponds to the "operation steps" of the output content, and "res" corresponds to the "expected result" of the output content.
[0051] In summary, the standardized test case generation process in this application is as follows: Figure 3 As shown, the process begins by acquiring the standard test case development specification manual and related knowledge materials. These are then processed through text segmentation and vectorization to generate a vector knowledge base. Next, the user uploads the requirement document to be parsed, which is then split and parsed using a requirement document splitting and parsing algorithm to obtain sub-requirement text blocks. Intent recognition is performed on these sub-requirement text blocks to obtain their intent information, including the test category, test object, test scenario, and test strategy of the test case to be generated. The corresponding vector knowledge base is then retrieved using this intent information. The sub-requirement text blocks are then vectorized to obtain sub-requirement text block vectors for the test cases to be generated. These vectors are then searched within the aforementioned vector knowledge base. Target similarity vectors with similarity scores higher than a similarity threshold are obtained through vector similarity analysis. These target similarity vectors are converted into relevant document fragments and merged with the sub-requirement text blocks to obtain standard prompt words. These standard prompt words are then input into a large language model to obtain JSON structured data. Finally, a JSON-to-Excel tool is used to convert the JSON structured data into a standardized test case Excel file for output.
[0052] The test case generation method provided in this application receives a user-uploaded requirement document to be parsed; it then breaks down and parses the requirement document to obtain sub-requirement text blocks for generating test cases. This decomposition of complex requirements avoids omissions, ensuring the comprehensiveness and completeness of the subsequently generated test cases. It also provides appropriately granular input units for subsequent vectorization and retrieval. The sub-requirement text blocks are then vectorized to obtain sub-requirement text block vectors. Vectorization converts the text into numerical features, capturing the semantics of the requirements and avoiding limitations in subsequent matching. Furthermore, it unifies text format differences, improving the robustness of subsequent retrieval. The sub-requirement text block vectors are then used in a preset... The system retrieves target similarity vectors from a vector knowledge base. Using these similarity vectors and the sub-requirement text blocks of the test cases to be generated, standard prompts for the test cases are generated. By combining user input and vector knowledge base content, the system avoids the illusion problem that occurs when using a large language model, improving the accuracy of the model's output. The standard prompts for the test cases are then input into a pre-defined large language model, which outputs standardized test cases. This unified output format through the large language model solves the problem of significant differences in structure, style, and coverage dimensions when test cases are manually written, improving the maintainability and reusability of test cases. Furthermore, it eliminates the need for manual test case writing, saving time and ensuring the quality of test case development.
[0053] Reference Figure 4The diagram shows a structural schematic of a test case generation device provided in this application, the device comprising: The receiving module 201 is used to receive the user-uploaded requirement document to be parsed.
[0054] The splitting and parsing module 202 is used to split and parse the requirement document to be parsed, and obtain the sub-requirement text blocks to be generated as test cases.
[0055] The first vectorization processing module 203 is used to vectorize the sub-requirement text blocks of the test cases to be generated, so as to obtain the sub-requirement text block vectors of the test cases to be generated.
[0056] The retrieval module 204 is used to retrieve the sub-requirement text block vectors of the test cases to be generated from a preset vector knowledge base to obtain the target similar vectors.
[0057] The prompt word generation module 205 is used to generate standard prompt words for the test cases to be generated by using the target similarity vector and the sub-requirement text blocks of the test cases to be generated.
[0058] The input / output module 206 is used to input the standard prompt words of the test cases to be generated into the preset large language model and output standardized test cases.
[0059] Optionally, the test case generation device may also include: The text segmentation module is used to segment the text of the preset test case standard development specification manual and other knowledge materials related to the generated test cases, and obtain text fragments.
[0060] The second vectorization processing module is used to vectorize the text fragments to obtain text fragment vectors.
[0061] The generation module is used to generate a vector knowledge base from text fragment vectors.
[0062] The determination module is used to parse any knowledge data related to the generated test cases and determine the element information to which the knowledge data belongs in the generated test cases. The element information includes at least one of the test category, test object, test scenario and test strategy of the generated test cases.
[0063] The annotation module is used to add annotation information to knowledge data based on feature information.
[0064] Optionally, the generation module includes: The partitioning submodule is used to divide several knowledge materials into several knowledge bases based on annotation information.
[0065] The aggregation submodule is used to aggregate the text fragment vectors of any knowledge base to obtain a vector knowledge base.
[0066] Optionally, the test case generation device may also include: The intent recognition module is used to recognize the intent of the sub-requirement text blocks of the test cases to be generated, and to obtain the intent information of the sub-requirement text blocks of the test cases to be generated. The intent information includes at least one of the test category, test object, test scenario and test strategy of the test cases to be generated.
[0067] The comparison module is used to compare the intent information with the annotation information to determine the vector knowledge base corresponding to the sub-requirement text block to be generated as a test case.
[0068] The acquisition module is used to acquire the binary format file of the large language model.
[0069] The platform framework deployment module is used to deploy the platform framework for large language models on the server.
[0070] The model deployment module is used to load the binary format file of the large language model through the platform framework and deploy the large language model on the server.
[0071] The configuration module is used to configure Uniform Resource Locators (URLs) for the large language model. The vector knowledge base is deployed on the retrieval enhancement and generation framework, which is connected to the large language model through the URLs.
[0072] Optionally, the retrieval module 204 includes: The acquisition submodule is used to obtain the similarity between the sub-requirement text block vectors of the test cases to be generated and the text fragment vectors in the preset vector knowledge base.
[0073] The extraction submodule is used to extract target similarity values that are greater than a similarity threshold from the similarity scores.
[0074] The determination submodule is used to determine the target similarity vector from the text fragment vectors based on the target similarity.
[0075] The test case generation method provided in this application receives a user-uploaded requirement document to be parsed; it then breaks down and parses the requirement document to obtain sub-requirement text blocks for generating test cases. This decomposition of complex requirements avoids omissions, ensuring the comprehensiveness and completeness of the subsequently generated test cases. It also provides appropriately granular input units for subsequent vectorization and retrieval. The sub-requirement text blocks are then vectorized to obtain sub-requirement text block vectors. Vectorization converts the text into numerical features, capturing the semantics of the requirements and avoiding limitations in subsequent matching. Furthermore, it unifies text format differences, improving the robustness of subsequent retrieval. The sub-requirement text block vectors are then used in a preset... The system retrieves target similarity vectors from a vector knowledge base. Using these similarity vectors and the sub-requirement text blocks of the test cases to be generated, standard prompts for the test cases are generated. By combining user input and vector knowledge base content, the system avoids the illusion problem that occurs when using a large language model, improving the accuracy of the model's output. The standard prompts for the test cases are then input into a pre-defined large language model, which outputs standardized test cases. This unified output format through the large language model solves the problem of significant differences in structure, style, and coverage dimensions when test cases are manually written, improving the maintainability and reusability of test cases. Furthermore, it eliminates the need for manual test case writing, saving time and ensuring the quality of test case development.
[0076] Reference Figure 5 This application also provides an electronic device, such as Figure 5 As shown, it includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304. Processor 301, memory 303 for storing processor-executable instructions; The processor 301 is configured to execute the instructions to implement the test case generation method described above: Receive user-uploaded requirement documents to be parsed; The requirement document to be parsed is split and parsed to obtain sub-requirement text blocks to generate test cases; The sub-requirement text blocks of the test cases to be generated are vectorized to obtain the sub-requirement text block vectors of the test cases to be generated. The sub-requirement text block vectors of the test cases to be generated are retrieved in a preset vector knowledge base to obtain target similar vectors; Based on the target similarity vector and the sub-requirement text blocks of the test cases to be generated, standard prompt words for the test cases to be generated are generated. Input the standard prompts for the test cases to be generated into a preset large language model, and output standardized test cases.
[0077] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0078] The communication interface is used for communication between the aforementioned terminal and other devices.
[0079] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0080] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be 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, or discrete hardware components.
[0081] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the test case generation methods described in the above embodiments.
[0082] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0083] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0084] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0085] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A test case generation method, characterized in that, The method includes: Receive user-uploaded requirement documents to be parsed; The requirement document to be parsed is split and parsed to obtain sub-requirement text blocks to generate test cases; The sub-requirement text blocks of the test cases to be generated are vectorized to obtain the sub-requirement text block vectors of the test cases to be generated. The sub-requirement text block vectors of the test cases to be generated are retrieved in a preset vector knowledge base to obtain target similar vectors; Based on the target similarity vector and the sub-requirement text blocks of the test cases to be generated, standard prompt words for the test cases to be generated are generated. Input the standard prompts for the test cases to be generated into a preset large language model, and output standardized test cases.
2. The method according to claim 1, characterized in that, Before retrieving the sub-requirement text block vectors of the test cases to be generated from a preset vector knowledge base to obtain the target similar vectors, the method further includes: The pre-defined test case standard development specification manual and several knowledge materials related to the generated test cases are segmented into text fragments. The text fragment is vectorized to obtain a text fragment vector; A vector knowledge base is generated using the text fragment vectors.
3. The method according to claim 2, characterized in that, Before performing text segmentation on the pre-defined test case standard development specification manual and several knowledge materials related to the generated test cases to obtain text fragments, the process also includes: For any knowledge data related to the generated test cases, the knowledge data is parsed to determine the element information to which the knowledge data belongs in the generated test cases. The element information includes at least one of the test category, test object, test scenario, and test strategy of the generated test cases. The knowledge data is labeled using the element information.
4. The method according to claim 3, characterized in that, The process of generating a vector knowledge base using the text fragment vectors includes: The aforementioned annotation information is used to divide various knowledge materials into several knowledge databases. For any knowledge base, the text fragment vectors of the knowledge base are aggregated to obtain the vector knowledge base of the knowledge base.
5. The method according to claim 4, characterized in that, After splitting and parsing the requirement document to be parsed to obtain sub-requirement text blocks for generating test cases, the process further includes: Intent recognition is performed on the sub-requirement text blocks of the test cases to be generated to obtain intent information of the sub-requirement text blocks of the test cases to be generated. The intent information includes at least one of the test category, test object, test scenario and test strategy of the test cases to be generated. The intent information is compared with the annotation information to determine the vector knowledge base corresponding to the sub-requirement text block of the test case to be generated.
6. The method according to claim 1, characterized in that, Before inputting the standard prompt words of the test cases to be generated into the preset large language model and outputting standardized test cases, the process also includes: Obtain the binary format file of the large language model; Deploy the platform framework for the large language model on the server; The large language model is loaded into a binary format file through the platform framework and deployed on a server. A Uniform Resource Locator (URL) is configured for the large language model, the vector knowledge base is deployed on a retrieval-enhanced generation framework, and the retrieval-enhanced generation framework is connected to the large language model through the URL.
7. The method according to claim 2, characterized in that, The step of retrieving the sub-requirement text block vectors of the test cases to be generated from a preset vector knowledge base to obtain target similar vectors includes: Obtain the similarity between the sub-requirement text block vector of the test case to be generated and the text fragment vector in the preset vector knowledge base; Extract target similarities greater than the similarity threshold from the aforementioned similarities; The target similarity vector is determined from the text fragment vector using the target similarity.
8. A test case generation device, characterized in that, The device includes: The receiving module is used to receive user-uploaded requirement documents that need to be parsed. The splitting and parsing module is used to split and parse the requirement document to be parsed to obtain sub-requirement text blocks to generate test cases; The first vectorization processing module is used to vectorize the sub-requirement text blocks of the test cases to be generated, so as to obtain the sub-requirement text block vectors of the test cases to be generated. The retrieval module is used to retrieve the sub-requirement text block vectors of the test cases to be generated from a preset vector knowledge base to obtain target similar vectors. The prompt word generation module is used to generate standard prompt words for the test cases to be generated by using the target similarity vector and the sub-requirement text blocks of the test cases to be generated. The input / output module is used to input the standard prompts of the test cases to be generated into a preset large language model and output standardized test cases.
9. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to execute the instructions to implement the test case generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the test case generation method as described in any one of claims 1 to 7.