A RAG-based test case knowledge enhancement method, device, equipment and medium

By constructing a test case knowledge base based on RAG and utilizing semantic vector representation and structured prompts, the problems of knowledge fragmentation and lack of enterprise-specific knowledge in large language models in traditional test case design are solved, achieving efficient and accurate test case generation and improving coverage and generation quality.

CN122196152APending Publication Date: 2026-06-12FUJIAN ZIXUN INFORMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FUJIAN ZIXUN INFORMATION TECH CO LTD
Filing Date
2026-02-27
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

Traditional test case design relies on personal experience, leading to fragmented knowledge loss, insufficient coverage, and a lack of enterprise-specific knowledge in large language models, resulting in insufficient practicality and relevance of the generated test cases.

Method used

The method adopts RAG-based approach, which constructs a test case knowledge base, transforms multiple test knowledge items into semantic vector representations, and generates enhanced test cases based on semantic similarity retrieval and structured prompts.

🎯Benefits of technology

Significantly improves the comprehensiveness and efficiency of test case design, reduces reliance on individual experience, automatically links historical lessons learned, generates high-quality test cases closely aligned with actual business rules, reduces the probability of missed tests, and improves the return on investment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122196152A_ABST
    Figure CN122196152A_ABST
Patent Text Reader

Abstract

The application provides a RAG-based test case knowledge enhancement method, device, equipment and medium, the method comprises the steps of: constructing a test case knowledge base; receiving a test requirement text input by a user; converting the test requirement text into a query vector, and calculating the similarity between the query vector and the stored semantic vector representation in the vector database; retrieving at least one target knowledge item based on the similarity; constructing structured knowledge enhancement prompt information according to the test requirement text and the attribute information and text content of the retrieved target knowledge item; inputting the knowledge enhancement prompt information into a large language model to generate an enhanced test case, generating a high-quality test case without relying on personal experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of software testing and artificial intelligence technology, and in particular to a method, apparatus, device, and medium for enhancing test case knowledge based on RAG. Background Technology

[0002] In the field of software testing, designing comprehensive, efficient test cases that deeply reveal potential defects is a core and highly challenging task. Traditional test case design heavily relies on the test engineer's personal experience, business acumen, and ability to review historical test results. With the exponential growth in software system complexity and the ever-accelerating pace of business iteration, this reliance on "human memory and experience" has exposed numerous bottlenecks: 1. The problem of fragmentation and loss of knowledge and experience: Excellent testing strategies, previously discovered typical defects ("pitfalls"), a deep understanding of complex business rules, and effective testing models are often scattered across different engineers, test reports, or issue management systems in the form of unstructured documents, emails, or tacit knowledge. When personnel change or projects are updated, these valuable testing assets are easily lost, leading to the recurrence of similar errors in different projects or versions, resulting in wasted testing costs and product quality risks.

[0003] 2. Insufficient test design coverage and depth: When faced with new features or complex business scenarios, test engineers primarily design test cases based on requirements documents and their own divergent thinking, making it difficult to systematically ensure comprehensive coverage of historical experience, peripheral scenarios, and potential risks. Especially in testing across business domains or involving complex interactions, engineers may create testing blind spots due to unfamiliarity with certain domain's "unwritten rules" or risk points.

[0004] 3. Limitations of Large Language Models (LLM) in test case generation: In recent years, AI-assisted testing tools based on large language models have emerged, capable of automatically generating test cases based on natural language descriptions. However, the general models of these tools lack proprietary, structured knowledge specific to particular enterprises, business domains, or systems. The generated test cases often fall into superficial, general patterns, failing to incorporate the details of internal business rules, lessons learned from past failures, and domain-specific testing best practices. This results in insufficient practicality, relevance, and risk insight in the generated results, making them difficult to apply directly to demanding testing scenarios.

[0005] To alleviate these issues, the industry has attempted to build test case libraries or knowledge bases, but existing solutions mostly rely on keyword matching or simple category tags for retrieval. This approach cannot achieve deep semantic association retrieval. For example, when testing the "order cancellation" function, traditional tagging systems may not be able to effectively link to historical defect cases of "inventory not being restored after cancellation" caused by "inventory synchronization delays," because the text descriptions of the two cases do not contain the same keywords.

[0006] Therefore, how to systematically accumulate and organize scattered and unstructured testing experience and knowledge, and how to proactively push and integrate it in a smart and precise manner during test design, thereby significantly improving the comprehensiveness, depth and efficiency of test case design and reducing over-reliance on individual experience, has become a pressing technical problem in this field. Summary of the Invention

[0007] The technical problem to be solved by the present invention is to provide a test case knowledge enhancement method, apparatus, device and medium based on RAG to generate high-quality test cases without relying on personal experience.

[0008] In a first aspect, the present invention provides a test case knowledge enhancement method based on RAG, comprising the following steps: S1. Construct a test case knowledge base, specifically by converting the text content corresponding to multiple test knowledge items into semantic vector representations through a text embedding model, and storing each semantic vector representation in a vector database in association with the attribute information of its corresponding knowledge item; wherein, the attribute information includes at least a category identifier for distinguishing knowledge types; S2, Receive the test requirement text input by the user; S3. Convert the test requirement text into a query vector, and calculate the similarity between the query vector and the stored semantic vector representation in the vector database, and retrieve at least one target knowledge item based on the similarity. S4. Based on the test requirement text and the attribute information and text content of the retrieved target knowledge items, construct structured knowledge enhancement prompt information; S5. Input the knowledge enhancement prompts into the large language model to generate enhanced test cases.

[0009] Secondly, the present invention provides a test case knowledge enhancement device based on RAG, comprising: The vectorized storage module constructs a test case knowledge base, specifically by converting the text content corresponding to multiple test knowledge items into semantic vector representations through a text embedding model, and storing each semantic vector representation in a vector database in association with the attribute information of its corresponding knowledge item; wherein, the attribute information includes at least a category identifier for distinguishing knowledge types; The text receiving module receives the test requirement text input by the user; The retrieval module converts the test requirement text into a query vector, calculates the similarity between the query vector and the stored semantic vector representation in the vector database, and retrieves at least one target knowledge item based on the similarity. The prompting engineering module constructs structured knowledge enhancement prompts based on the test requirement text and the attribute information and text content of the retrieved target knowledge items; The test case generation module inputs the knowledge enhancement prompts into the large language model to generate enhanced test cases.

[0010] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect.

[0011] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.

[0012] One or more technical solutions provided by this invention have at least the following technical effects or advantages: 1. Through vectorized semantic retrieval, it can proactively associate test requirements with implicit knowledge such as historical pitfalls and risk scenarios; even if test engineers are not familiar with a specific domain, it can automatically push relevant historical lessons to ensure that test design covers the boundaries of business rules, abnormal scenarios and defects that have occurred, and significantly reduce the probability of missed tests. 2. Guide large language models to prioritize the generation of test cases for high-risk areas, so that testing resources are focused on the areas most likely to have problems, thereby improving the return on investment in testing; 3. Transform individual tacit knowledge into explicit assets that can be retrieved and reused by the team; avoid the problem of "experience loss when employees leave" and reduce the cost of training new employees; significantly reduce the probability of the same problem recurring in different projects or iterations; 4. By using the Retrieval Enhancement Generation (RAG) mechanism, domain-specific knowledge is dynamically injected into the prompt words of the large language model; this overcomes the limitations of "superficiality and lack of domain depth" when generating test cases from general large models. The generated test cases are closely integrated with the actual business rules and historical context of the enterprise and can be directly used for test execution or as a high-quality design reference. 5. Vector retrieval based on semantic similarity, rather than relying on keyword matching; it can discover knowledge associations that are semantically related but have different text descriptions (such as "order cancellation" being automatically associated with the "inventory synchronization delay" defect). This deep association capability far exceeds that of traditional tagging systems. 6. This invention includes a knowledge base update interface (addKnowledge), which allows new test results to be easily converted into knowledge entries; it has self-evolution capabilities, and as usage time increases, the knowledge base is continuously enriched, and the overall utility and value of the system are continuously improved, forming a virtuous cycle; 7. Even junior test engineers can produce test designs that are close to expert level with the help of the system, reducing the strong dependence of test quality on personal experience and improving the overall capability baseline of the team.

[0013] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0014] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0015] Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the device in Embodiment 2 of the present invention. Detailed Implementation

[0016] The overall concept of the technical solution in this application embodiment is as follows: Four-dimensional knowledge classification: Establish a refined classification system for business rules, testing modes, historical pitfalls, and risk scenarios; Vectorized storage: Knowledge items are stored using a vector database, supporting semantic similarity retrieval; Multi-system knowledge isolation: Dynamically create knowledge sets by system name to achieve multi-system knowledge isolation management; Enhanced semantic retrieval: Perform multi-dimensional semantic retrieval based on user needs to obtain highly relevant knowledge; Knowledge Injection Generation: The retrieved knowledge is structured and injected into the AI ​​to generate a Prompt, which in turn generates knowledge-enhanced test cases.

[0017] The complete application process of the method of the present invention in a test scenario of an e-commerce order system is as follows: Step 101: Knowledge Base Initialization and Knowledge Injection The system administrator first initializes the knowledge base for the "e-commerce order system". An instance of the TestCaseKnowledgeBase class is created, and the initCollection() method is called to create a collection named test_knowledge_order_system in the Qdrant vector database. Subsequently, historically accumulated test knowledge entries are added to the knowledge base.

[0018] ```typescript / / Example: Initialize the knowledge base and add a "historical pitfall" knowledge entry. const knowledgeBase = new TestCaseKnowledgeBase('order_system'); await knowledgeBase.initCollection(); const pitfallItem: KnowledgeItem = { id: 'PITFALL_001', category: 'pitfall', / / Category identifier: Historical pitfalls Title: 'Inventory not immediately restored after order cancellation' Content: 'In the order cancellation logic, if the order status is first updated to "cancelled" and then the inventory recovery service is called asynchronously, in high-concurrency scenarios, the cancellation operation may be completed, but the inventory may not be restored due to service delays, leading to overselling.' businessDomain: 'order_management', / / Business domain identifier: order management Tags: ['Concurrency', 'Inventory', 'Transaction Consistency'] }; await knowledgeBase.addKnowledge(pitfallItem); ``` Step 102: Receive test request The test engineer entered the test requirement description into the system: "Test the order cancellation function, considering concurrent scenarios." Step 103: Semantic Retrieval Related Knowledge The system transforms the test requirement text into query vectors and performs multi-dimensional parallel semantic retrieval in the knowledge base. This process calls the `searchByCategory` method.

[0019] ```typescript const searchParams = { Query: 'Testing order cancellation functionality, concurrency scenarios need to be considered' businessDomain: 'order_management', topK: 2, scoreThreshold: 0.7 }; const relevantKnowledge = await knowledgeBase.searchByCategory(searchParams); / / The returned result will contain a knowledge array in four dimensions. ``` Step 104: Construct knowledge-enhancing prompts The system injects the retrieved structured knowledge into the prompts in the large language model. The `buildKnowledgeEnhancedPrompt` function is responsible for this construction.

[0020] ```typescript const enhancedPrompt = buildKnowledgeEnhancedPrompt( When testing the order cancellation function, concurrent scenarios need to be considered. relevant knowledge ); The generated prompt will include sections such as "## Historical Pitfalls and Reminders" and will incorporate specific knowledge content. ``` Step 105: Generate enhanced test cases The enhancedPrompt is then sent to a configured large language model (such as GPT-4), which generates more in-depth and targeted test cases based on context that includes historical experience and expertise.

[0021] Example of generated results: 1. High-concurrency order cancellation inventory test: Steps: Simulate 100 users canceling different orders simultaneously.

[0022] Expected outcome: All order statuses should be correctly updated to "Cancelled", and the total inventory of the corresponding products should increase accurately and immediately without overselling (refer to past pitfalls: it is necessary to verify whether the inventory recovery is a synchronous strong consistency transaction to avoid asynchronous delays that could lead to data inconsistency).

[0023] 2. Test the consistency between the status and resume after cancellation: Steps: Cancel a paid order and check the order status stream, financial transaction history, and user notifications.

[0024] Expected outcome: The status changes to "Cancelled", a refund transaction is generated, and the user receives a cancellation confirmation notification.

[0025] Step 106: Closed-loop update of the knowledge base If a new defect is discovered during the new testing cycle, such as "the use of unverified coupon redemption logic when canceling orders leads to data errors," this can be added as a new knowledge entry to the knowledge base to achieve knowledge accumulation.

[0026] ```typescript const newPitfall: KnowledgeItem = { id: 'PITFALL_NEW_001', category: 'pitfall', Title: 'Coupon redemption logic error when order is cancelled' Content: 'When canceling an order, if a "one-time coupon" was used, the system incorrectly attempted to roll back the coupon's status to "unused," violating the coupon's business rules and resulting in the same coupon being used repeatedly.' businessDomain: 'order_management', tags: ['coupons', 'business rules'] }; await knowledgeBase.addKnowledge(newPitfall); ``` 1. Text embedding and vectorization This system supports configuring different text embedding models. The following example demonstrates the core implementation of the `generateOpenAIEmbedding` method using the OpenAI compatible API.

[0027] ```typescript private async generateOpenAIEmbedding(text: string): Promise<number[]> { / / Models configured using environment variables, such as 'text-embedding-3-small' const model = process.env.EMBEDDING_MODEL || 'text-embedding-3-small'; / / Generate embedding vectors using OpenAI-compatible APIs const response = await this.openai.embeddings.create({ model: model, input: text, encoding_format: 'float' }); / / The returned embedding vector is a high-dimensional floating-point array (e.g., 1536 dimensions). return response.data[0].embedding; } ``` Explanation: This method maps the input text string into a high-dimensional distributed vector representation that can characterize its semantic information through a pre-trained neural network embedding model. Texts with similar semantics (such as "order cancellation" and "transaction reversal") have high cosine similarity in the vector space.

[0028] 2. Attribute-based retrieval filtering During the search process, the system allows filtering based on attributes such as businessDomain. This is achieved through the filter parameter in the Qdrant client call.

[0029] ```typescript / / Build filter conditions inside the searchKnowledge method const filter: any = { must: []}; if (businessDomain) { / / Precisely match business domain identifiers filter.must.push({ key: 'businessDomain', match: { value:businessDomain}}); } if (category) { / / Exact match category identifier filter.must.push({ key: 'category', match: { value: category}}); } / / Perform vector similarity search with filtering conditions const searchResult = await this.qdrant.search(this.collectionName, { vector: queryVector, limit: topK, filter: filter.must.length > 0 ? filter : undefined, / / Apply the filter score_threshold: scoreThreshold, with_payload: true }); ``` Note: This implementation ensures that search results are not only based on semantic similarity, but also precisely limited to specific business domains and knowledge categories, improving the accuracy and relevance of the search.

[0030] 3. Construction of structured prompt information The `buildKnowledgeEnhancedPrompt` function is responsible for structuring the retrieved knowledge by category and injecting it into the prompt template in a formatted way.

[0031] ```typescript function buildKnowledgeEnhancedPrompt(testPurpose: string,knowledgeResults): string { let knowledgeContext = ''; / / Inject business rules if (knowledgeResults.businessRules.length > 0) { knowledgeContext += '\n## Related Business Rules\n'; knowledgeResults.businessRules.forEach((r, i) => { knowledgeContext += `${i + 1}. ${r.knowledge.title}: ${r.knowledge.content}\n`; }); } / / Inject test mode if (knowledgeResults.testPatterns.length > 0) { knowledgeContext += '\n## Recommended Test Mode\n'; knowledgeResults.testPatterns.forEach((r, i) => { knowledgeContext += `${i + 1}. ${r.knowledge.title}: ${r.knowledge.content}\n`; }); } / / Injecting historical pitfalls if (knowledgeResults.pitfalls.length > 0) { knowledgeContext += '\n## Historical Pitfalls Reminders\n'; / / Format the title knowledgeResults.pitfalls.forEach((r, i) => { / / Inject the title and content of each knowledge item in a fixed format. knowledgeContext += `${i + 1}. ${r.knowledge.title}: ${r.knowledge.content}\n`; }); } / / Injecting risk scenarios if (knowledgeResults.riskScenarios.length > 0) { knowledgeContext += '\n## Risk Scenarios to Watch\n'; knowledgeResults.riskScenarios.forEach((r, i) => { knowledgeContext += `${i + 1}. ${r.knowledge.title}: ${r.knowledge.content}\n`; }); } You are a test case generation expert. Please generate detailed test points based on the following test objectives and knowledge base information. Note: This implementation clearly distinguishes different categories of knowledge by adding specific chapter titles (such as historical pitfall reminders) and symbols, guiding the large language model to better understand and utilize this structured information. Example 1

[0032] like Figure 1 As shown, this embodiment provides a test case knowledge enhancement method based on RAG, including the following steps: S1. Construct a test case knowledge base, specifically by converting the text content corresponding to multiple test knowledge items into semantic vector representations through a text embedding model, and storing each semantic vector representation in a vector database in association with the attribute information of its corresponding knowledge item; wherein, the attribute information includes at least a category identifier for distinguishing knowledge types; S2, Receive the test requirement text input by the user; S3. Convert the test requirement text into a query vector, and calculate the similarity between the query vector and the stored semantic vector representation in the vector database, and retrieve at least one target knowledge item based on the similarity. S4. Based on the test requirement text and the attribute information and text content of the retrieved target knowledge items, construct structured knowledge enhancement prompt information; S5. Input the knowledge enhancement prompts into the large language model to generate enhanced test cases.

[0033] In this embodiment, preferably, the category identifier includes at least one of the following: business rules, test modes, historical pitfalls, and risk scenarios.

[0034] In this embodiment, preferably, the attribute information further includes a business domain identifier; in step S3, the search results are filtered based on the business domain identifier.

[0035] In this embodiment, preferably, the business domain identifier is used to identify software functions or business scenarios.

[0036] In this embodiment, preferably, in step S3, multiple retrieval processes are executed in parallel. Each retrieval process filters knowledge items based on a preset category identifier and calculates similarity for each item.

[0037] In this embodiment, preferably, the construction of structured knowledge enhancement prompt information in step S4 includes: classifying the retrieved target knowledge items according to their category identifiers, organizing their text content with formatted titles corresponding to the categories, and injecting them into a prompt template containing the test requirement text.

[0038] In this embodiment, preferably, it also includes: Obtain defect records or experience summary texts generated during test execution; The defect record or experience summary text is transformed into a new knowledge entry, which includes text content, a semantic vector representation generated by the text embedding model, and attribute information determined based on its content. The new knowledge entries are stored in the vector database.

[0039] Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2. Example 2

[0040] like Figure 2 As shown, this embodiment provides a test case knowledge enhancement device based on RAG, including: The vectorized storage module constructs a test case knowledge base, specifically by converting the text content corresponding to multiple test knowledge items into semantic vector representations through a text embedding model, and storing each semantic vector representation in a vector database in association with the attribute information of its corresponding knowledge item; wherein, the attribute information includes at least a category identifier for distinguishing knowledge types; The text receiving module receives the test requirement text input by the user; The retrieval module converts the test requirement text into a query vector, calculates the similarity between the query vector and the stored semantic vector representation in the vector database, and retrieves at least one target knowledge item based on the similarity. The prompting engineering module constructs structured knowledge enhancement prompts based on the test requirement text and the attribute information and text content of the retrieved target knowledge items; The test case generation module inputs the knowledge enhancement prompts into the large language model to generate enhanced test cases.

[0041] In this embodiment, preferably, the category identifier includes at least one of the following: business rules, test modes, historical pitfalls, and risk scenarios.

[0042] In this embodiment, preferably, the attribute information further includes a business domain identifier; in the retrieval module, the retrieval results are filtered based on the business domain identifier.

[0043] In this embodiment, preferably, the business domain identifier is used to identify software functions or business scenarios.

[0044] In this embodiment, preferably, the retrieval module executes multiple retrieval processes in parallel. Each retrieval process filters knowledge items based on a preset category identifier and calculates similarity for each.

[0045] In this embodiment, preferably, the construction of structured knowledge enhancement prompts in the prompting engineering module includes: classifying the retrieved target knowledge items according to their category identifiers, organizing their text content with formatted titles corresponding to the categories, and injecting them into a prompt template containing the test requirement text.

[0046] In this embodiment, preferably, an update module is also included: Obtain defect records or experience summary texts generated during test execution; The defect record or experience summary text is transformed into a new knowledge entry, which includes text content, a semantic vector representation generated by the text embedding model, and attribute information determined based on its content. The new knowledge entries are stored in the vector database.

[0047] Since the apparatus described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention.

[0048] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1, as detailed in Embodiment 3. Example 3

[0049] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it can implement any of the implementation methods in Embodiment 1.

[0050] Since the electronic device described in this embodiment is the device used to implement the method in Embodiment 1 of this application, those skilled in the art can understand the specific implementation method and various variations of the electronic device in this embodiment based on the method described in Embodiment 1 of this application. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection of this application.

[0051] Based on the same inventive concept, this application provides a storage medium corresponding to Embodiment 1, as detailed in Embodiment 4. Example 4

[0052] This embodiment provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it can implement any of the implementation methods in Embodiment 1.

[0053] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0054] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0055] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0056] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0057] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A test case knowledge enhancement method based on RAG, characterized in that, Includes the following steps: S1. Construct a test case knowledge base, specifically by converting the text content corresponding to multiple test knowledge items into semantic vector representations through a text embedding model, and storing each semantic vector representation in a vector database in association with the attribute information of its corresponding knowledge item; wherein, the attribute information includes at least a category identifier for distinguishing knowledge types; S2, Receive the test requirement text input by the user; S3. Convert the test requirement text into a query vector, and calculate the similarity between the query vector and the stored semantic vector representation in the vector database, and retrieve at least one target knowledge item based on the similarity. S4. Based on the test requirement text and the attribute information and text content of the retrieved target knowledge items, construct structured knowledge enhancement prompt information; S5. Input the knowledge enhancement prompts into the large language model to generate enhanced test cases.

2. The method according to claim 1, characterized in that, The category identifiers include at least one of the following: business rules, test modes, historical pitfalls, and risk scenarios.

3. The method according to claim 1, characterized in that, The attribute information also includes a business domain identifier; in step S3, the search results are filtered based on the business domain identifier.

4. The method according to claim 3, characterized in that, The business domain identifier is used to identify software functions or business scenarios.

5. The method according to claim 1, characterized in that, In S3, multiple retrieval processes are executed in parallel. Each retrieval process filters knowledge items based on a preset category identifier and calculates similarity for each item.

6. The method according to claim 1, characterized in that, The structured knowledge enhancement prompt information in S4 includes: classifying the retrieved target knowledge items according to their category identifiers, organizing their text content with formatted titles corresponding to the categories, and injecting them into a prompt template containing the test requirement text.

7. The method according to claim 1, characterized in that, Also includes: Obtain defect records or experience summary texts generated during test execution; The defect record or experience summary text is transformed into a new knowledge entry, which includes text content, a semantic vector representation generated by the text embedding model, and attribute information determined based on its content. The new knowledge entries are stored in the vector database.

8. A test case knowledge enhancement device based on RAG, characterized in that, include: The vectorized storage module constructs a test case knowledge base, specifically by converting the text content corresponding to multiple test knowledge items into semantic vector representations through a text embedding model, and storing each semantic vector representation in a vector database in association with the attribute information of its corresponding knowledge item; wherein, the attribute information includes at least a category identifier for distinguishing knowledge types; The text receiving module receives the test requirement text input by the user; The retrieval module converts the test requirement text into a query vector, calculates the similarity between the query vector and the stored semantic vector representation in the vector database, and retrieves at least one target knowledge item based on the similarity. The prompting engineering module constructs structured knowledge enhancement prompts based on the test requirement text and the attribute information and text content of the retrieved target knowledge items; The test case generation module inputs the knowledge enhancement prompts into the large language model to generate enhanced test cases.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the 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 method as described in any one of claims 1 to 7.