Test case generation method and related equipment

The method automates test case generation by integrating document sources and AI interaction, improving efficiency and completeness in software testing by reducing manual effort and context pollution, and enhancing multi-document integration.

CN120316008APending Publication Date: 2025-07-15创优数字科技(广东)有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510455343.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-11
Publication Date
2025-07-15

AI Technical Summary

Technical Problem

The prior art is inefficient, incomplete coverage, context pollution and multi-file collaboration in the generation of software test cases, making it difficult to effectively integrate the logical relationship between the requirements document and the use case document, resulting in incomplete generation of test cases and coverage vulnerabilities.

Method used

By receiving the requirement documents, use case documents and preset prompt words collections, the content processor is used to perform semantic integration and context association analysis, structured processing data is generated, and the file processor is called for format standardization. It combines the word processor to generate semantic guidance instructions, inputs the AI engine to generate test cases, and performs deduplication and priority sorting, which solves the above problems.

Benefits of technology

It realizes efficient, comprehensive and accurate test case generation, avoids inefficiency and context pollution caused by manual writing, can deeply explore the logical relationship between multiple files, discover test coverage vulnerabilities in uncensored file associations, and improves generation efficiency and comprehensive coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120316008A_ABST
    Figure CN120316008A_ABST
Patent Text Reader

Abstract

The invention discloses a test case generation method and related equipment. The method comprises the following steps: receiving multiple input source data; performing semantic integration and context association analysis on the demand document and the use case document through a content processor to generate structured processing data; calling a file processor to carry out format standardization processing on the input source data, and generating an intermediate file adaptive to AI model input; generating a semantic guidance instruction based on the preset cue word set and a preset multi-type cue word template through a word processor; inputting the structured processing data, the intermediate file and the semantic guidance instruction into an AI engine, and triggering a test case generation model; and receiving an original test case set output by the AI engine, and executing duplicate removal and priority ranking to generate a test case scheme. According to the method, the test case can be efficiently, comprehensively and accurately generated, and various defects existing in the software test case generation process in the prior art are effectively overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing, and more specifically, to a test case generation method and related equipment. Background Art

[0002] In the context of the booming software industry today, the scale of software systems is becoming larger and larger, and their functions are becoming more and more complex. In the software testing process, the generation of test cases is an extremely critical link. However, in the existing technical system, the generation of software test cases still mainly relies on manual writing.

[0003] The process of manually writing test cases is extremely cumbersome, and testers need to conduct meticulous analysis of the requirements documents and use case documents item by item. This process is not only time-consuming and laborious, but also has a particularly prominent efficiency problem when facing large-scale and complex systems. At the same time, the comprehensiveness of manually written test cases is heavily dependent on the personal experience of the testers.

[0004] With the rise of artificial intelligence technology, some AI-assisted tools have begun to be applied in the field of test case generation. In the process of using AI-assisted tools to generate test cases, users need to manually and carefully design prompts to clearly define the task objectives and expected outputs to the AI. For example, when generating a test case for an online education platform, users must accurately describe key information such as the platform's course types, teaching methods, user roles, etc. to the AI to guide the AI to generate adapted test cases. However, the design of prompts is quite difficult, and users need to thoroughly understand the operating mechanism of the AI tool and the characteristics of the test tasks. Any slight deviation will cause the generated test cases to not meet actual needs. Moreover, when using AI tools continuously to handle different test tasks, if new conversations are not manually created to isolate the context, the relevant information of the previous task will interfere with subsequent tasks, causing the AI to output confusing and invalid test cases. This is a serious problem of context pollution.

[0005] In addition, in software project development, requirement documents and use case documents are often scattered across multiple files, with complex logical relationships between different files. Traditional test case generation methods, whether manually written or AI-assisted, are difficult to effectively integrate the logical relationships between these files, cannot accurately detect requirement conflicts between different files, and are difficult to detect test coverage gaps caused by unclear file relationships.

[0006] Based on this, the present application provides a test case generation solution to address a series of defects in the above-mentioned prior art in the software test case generation process, such as low efficiency, incomplete coverage, context pollution, and difficulty in multi-file collaboration. Summary of the invention

[0007] The present application provides a test case generation method and related devices, which can efficiently, comprehensively and accurately generate test cases, and effectively solve various defects existing in the prior art during the software test case generation process.

[0008] A test case generation method, comprising:

[0009] Receiving a plurality of input source data, the input source data including a requirement document, a use case document, and a preset set of prompt words;

[0010] Performing semantic integration and context correlation analysis on the requirement document and the use case document through a content processor to generate structured processing data;

[0011] Invoking a file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the input of the AI model;

[0012] Generating semantic guidance instructions based on the preset set of prompt words and a preset multi-type prompt word template through a word processor;

[0013] Inputting the structured processing data, the intermediate file, and the semantic guidance instructions into an AI engine to trigger a test case generation model;

[0014] Receiving the original test case set output by the AI engine, and performing deduplication and priority sorting to generate a test case solution.

[0015] Optionally, performing semantic integration and context correlation analysis on the requirement document and the use case document to generate structured processing data, including:

[0016] Performing entity recognition and relationship extraction on the requirement document and the use case document, and extracting functional modules, operation steps, and expected results as core semantic units;

[0017] Constructing a logical link between requirements and use cases based on a knowledge graph, mapping the core semantic units into a predefined test scenario framework, and annotating the association strength weights;

[0018] Matching the functional descriptions in the requirement document with the execution conditions in the use case document through a rule engine to identify logical contradictions or coverage omissions, and generating conflict marks;

[0019] Encoding the integrated core semantic units, the association strength weights, and the conflict marks into a tree structure to form structured processing data.

[0020] Optionally, generating semantic guidance instructions based on the preset set of prompt words and a preset multi-type prompt word template, including:

[0021] If it is detected that the preset prompt word set is a non-empty set, a prompt word is selected based on the preset prompt word set, and a semantic guidance instruction is generated;

[0022] If it is detected that the preset prompt word set is an empty set, a prompt word template adapted to the file type included in the input source data is selected from a preset multi-type prompt word template, and a semantic guidance instruction is generated.

[0023] Optionally, selecting a prompt word template adapted to the file type included in the input source data from a preset multi-type prompt word template includes:

[0024] If the input source data only includes the requirement document, a preset basic template including function boundary definition and abnormal scenario guiding words is loaded;

[0025] If the input source data includes a single requirement document and the use case document, a preset combined template including supplementary use cases and requirement mapping relationship description words is loaded;

[0026] If the input source data includes multiple requirement documents and the use case document, a preset multi-file template including cross-document dependency analysis and conflict detection instructions is loaded.

[0027] Optionally, the process of priority sorting includes:

[0028] Extract the function coverage keywords of each test case in the original test case set, and calculate the coverage weight of each test case;

[0029] Match the module defect rate involved in each test case based on the historical defect database to generate a risk level score;

[0030] Calculate the weighted sum of the coverage weight and the risk level score corresponding to each test case, and perform priority sorting on each test case in the original test case set based on the weighted sum.

[0031] Optionally, it further includes:

[0032] When the content processor detects a logical conflict between the requirement document and the use case document, an artificial review mark is triggered, and conflict location information is attached to the structured processed data.

[0033] A test case generation device includes:

[0034] A data receiving unit for receiving a plurality of input source data, the input source data including a requirement document, a use case document, and a preset prompt word set;

[0035] A structure processing unit for semantically integrating and contextually correlating the requirement document and the use case document through a content processor to generate structured processing data;

[0036] An intermediate file unit for calling a file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the input of the AI model;

[0037] A guidance instruction unit for generating semantic guidance instructions through a word processor based on the preset set of prompt words and multiple types of preset prompt word templates;

[0038] An AI call unit for inputting the structured processing data, the intermediate file, and the semantic guidance instructions into an AI engine to trigger a test case generation model;

[0039] A use case generation unit for receiving the original test case set output by the AI engine and performing deduplication and priority sorting to generate a test case solution.

[0040] A test case generation device, including a memory and a processor;

[0041] The memory for storing programs;

[0042] The processor for executing the program to implement each step of the test case generation method as described in any one of the above.

[0043] A readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, each step of the test case generation method as described in any one of the above is implemented.

[0044] A computer program product, including a computer program, characterized in that when the computer program is run by a processor, each step of the test case generation method as described in any one of the above is executed.

[0045] As can be seen from the above technical solutions, a test case generation method and related devices provided by the embodiments of the present application can efficiently, comprehensively, and accurately generate test cases, effectively solving various defects existing in the prior art during the generation of software test cases.

[0046] In terms of improving efficiency, this application receives multi-source data such as requirement documents, use case documents, and a preset set of prompt words. The content processor, file processor, and word processor respectively perform operations such as semantic integration, format standardization processing, and semantic guidance instruction generation on the data, automatically completing complex data processing processes. Users do not need to manually and meticulously design prompt words, nor do they need to conduct cumbersome item-by-item analysis of the documents. They only need to upload the documents, which greatly saves time and effort and solves the problem of low efficiency in manually writing test cases. At the same time, when interacting with AI, the system automatically creates conversations, avoiding the trouble of users manually creating conversations and effectively preventing context pollution, further improving the efficiency of test case generation.

[0047] Regarding improving the comprehensiveness of test case coverage, this application uses the content processor to perform semantic integration and context correlation analysis on requirement documents and use case documents, which can discover potential test scenarios that are easily overlooked during manual writing. At the same time, it uses preset prompt word templates to supplement use cases, avoiding the omission of test cases caused by incomplete manual consideration and solving the problem of incomplete coverage of manually written test cases.

[0048] To address the problem of difficult multi-file collaboration, this application works in coordination with the content processor and the word processor. Especially when the word processor selects different prompt word templates according to the file types included in the input source data, such as loading a preset multi-file template containing cross-document dependency analysis and conflict detection instructions, it can deeply explore the logical relationships between multiple requirement documents and use case files. It can accurately detect requirement conflicts between different files, discover test coverage loopholes caused by unclear file associations, achieve efficient collaboration in a multi-file environment, and effectively solve the problems of traditional test case generation methods in multi-file collaboration. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on the provided drawings.

[0050] Figure 1 It is a flowchart of a test case generation method disclosed in an embodiment of this application;

[0051] Figure 2 It is a schematic diagram of a test case generation method disclosed in an embodiment of this application;

[0052] Figure 3 It is a schematic diagram of a test case generation device disclosed in an embodiment of this application;

[0053] Figure 4 This is a hardware structure block diagram of a test case generation device disclosed in an embodiment of the present application. Detailed implementation manners

[0054] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0055] The present application can be used in many general-purpose or special-purpose computing device environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor devices, distributed computing environments including any of the above devices or equipment, and so on.

[0056] Next, the solution of the present application will be introduced. The present application proposes the following technical solutions. For details, please refer to the following text.

[0057] Figure 1 This is a flowchart of a test case generation method disclosed in an embodiment of the present application.

[0058] Figure 2 This is a schematic diagram of a test case generation method disclosed in an embodiment of the present application.

[0059] As Figure 1 and Figure 2 shown, the method may include:

[0060] Step S1, receiving a plurality of input source data, where the input source data includes a requirement document, a use case document, and a preset prompt word set.

[0061] Specifically, the requirement document contains detailed functional requirements, performance requirements, and other information of a project or task, and is an important basis for test case generation. For example, the requirement document of an e-commerce project will clarify the specific requirements of functions such as product search, order placement, and payment. The use case document records various operation scenarios, expected results, etc., and provides a reference for the generation of test cases. For example, the use case document of an e-commerce project may record the operation processes under different payment methods and the expected results such as successful payment and failed payment. The preset prompt word set is to more accurately guide the AI to generate test cases and supplement and refine the semantic information required for processing content, such as prompt words like "generate boundary value test cases" and "supplement test cases for abnormal situations". In this step, the system obtains this data from the corresponding storage location or user input port to ensure the integrity and accuracy of the data and provide a reliable data source for subsequent processing.

[0062] Step S2: The content processor performs semantic integration and context correlation analysis on the requirement document and the use case document to generate structured processing data.

[0063] Specifically, the core objective of this step is to deeply mine the information in the requirement document and the use case document. Through semantic integration and context correlation analysis, the originally scattered and unstructured text information is transformed into structured processing data, so as to generate test cases more efficiently in the follow-up. The specific execution process is further divided into the following steps:

[0064] ① Perform entity recognition and relationship extraction on the requirement document and the use case document, and extract functional modules, operation steps, and expected results as core semantic units.

[0065] Specifically, entity recognition uses the named entity recognition (NER) algorithm in natural language processing (NLP) technology, such as the BiLSTM-CRF model based on deep learning. This model can perform word-by-word analysis on the text in the requirement document and the use case document, and identify entities such as "user", "product", "order", etc. In the requirement document of an e-commerce system, in the sentence "The user logs in to the system", "user" and "system" are the identified entities.

[0066] Relationship extraction uses rule-based or machine learning methods to extract the relationships between entities. Rule-based methods can be matched according to predefined grammar rules. For example, in "The user submits an order", through the rules, it can be judged that there is a "submit" relationship between "user" and "order". Machine learning methods can use models such as graph convolutional networks (GCN) to learn the relationship patterns between entities from a large amount of labeled data.

[0067] After identifying the entities and relationships, further extract the functional modules, operation steps, and expected results. For the use case document of an e-commerce system "The user clicks to add the product to the shopping cart on the product details page, and the system should successfully add the product to the shopping cart", "Adding the product to the shopping cart on the product details page" is the functional module, "The user clicks to add the product to the shopping cart" is the operation step, and "The system successfully adds the product to the shopping cart" is the expected result.

[0068] ② Based on the knowledge graph, construct the logical link between the requirements and the use cases, map the core semantic units to the predefined test scenario framework, and annotate the association strength weights.

[0069] Specifically, construct a knowledge graph based on the identified entities and relationships. In an e-commerce system, the nodes can be entities such as "user", "product", "order", etc., and the edges represent the relationships between them, such as "purchase", "browse", etc. A graph database can be used to store and manage the knowledge graph.

[0070] The logical link is established by analyzing the logical connection between requirements and use cases through the knowledge graph. For example, if the requirement document mentions "support users to modify order information", and the use case document has a use case of "users modify the delivery address on the order details page", the logical link between the two can be established through the knowledge graph.

[0071] The predefined test scenario framework includes functional testing, performance testing, security testing, etc. The core semantic units are mapped to the corresponding test scenarios according to their nature. For example, the core semantic unit of "users log in to the system" can be mapped to the functional testing scenario.

[0072] Mark the weights according to the degree of tightness of the association between requirements and use cases. If a use case directly corresponds to a requirement and fully covers the functions of that requirement, a higher weight can be marked; if it is only partially relevant, a lower weight can be marked.

[0073] ③Match the function descriptions in the requirement document with the execution conditions in the use case document through the rule engine, identify logical contradictions or coverage omissions, and generate conflict marks.

[0074] Specifically, use a rule engine (such as Drools) to define a series of matching rules according to business rules and test requirements. For example, the rule can be "if the requirement document requires that a certain function must support multiple languages, and the use case document does not contain multi-language test cases, it is determined as a coverage omission".

[0075] The rule engine matches the function descriptions in the requirement document and the execution conditions in the use case document sentence by sentence. For an e-commerce system, if the requirement document stipulates that "after the commodity price is modified, the total price of the commodities in the shopping cart should be updated in real time", and there is no test case for updating the total price of the shopping cart in the use case document, the rule engine will identify this as a coverage omission.

[0076] When logical contradictions or coverage omissions are identified, corresponding conflict marks are generated. The conflict marks can include the conflict type (such as logical contradiction, coverage omission), the requirement and use case information involved, etc.

[0077] ④Encode the integrated core semantic units, the association strength weights, and the conflict marks into a tree structure to form structured processing data.

[0078] Specifically, encode the core semantic units, the association strength weights, and the conflict marks obtained from the previous extraction and analysis according to a certain hierarchical structure to form a tree structure. The nodes of the tree can be different core semantic units, and the edges represent the association relationships and weights between them. The conflict marks are attached as special attributes to the corresponding nodes or edges, thus forming structured processing data, which is convenient for subsequent module calls and processing.

[0079] In addition, the execution functions of the content processor may further include:

[0080] When the content processor detects a logical conflict between the requirement document and the use case document, it triggers a manual review mark and attaches conflict location information to the structured processed data.

[0081] Specifically, when the content processor detects a logical conflict between the requirement document and the use case document, for example, in an e-commerce project, the requirement document stipulates that "orders cannot be placed when the product inventory is insufficient", but there is a situation in the use case document where orders can still be placed when the inventory is insufficient. At this time, the content processor will trigger a manual mark to notify the tester for processing. At the same time, conflict location information is attached to the structured processed data, accurately indicating the specific locations of the conflict in the requirement document and the use case document, such as the page number and line number in the requirement document, and under which use case number in the use case document, to facilitate the tester to quickly locate and solve the problem, ensuring the accuracy and effectiveness of the test case generation.

[0082] Step S3: Invoke the file processor to perform format standardization processing on the input source data to generate an intermediate file adapted for the input of the AI model.

[0083] Specifically, since the input source data includes requirement documents, use case documents, and a preset set of prompt words, these data may come from different systems or users, and their formats are diverse. The AI model usually has specific requirements for the format of the input data, so the file processor needs to perform format standardization processing on the input source data. First, the file processor will accurately identify the format of the input data, and judge whether the data belongs to text type, table type, or markup language type, etc., through the file extension or specific identification information in the file header. For text files, if it is a plain text file, the content can be directly read; if it is a Word document, a special library is used to extract the text. For table files, such as Excel files, corresponding tools are used to convert them into CSV format, which is simple and easy for the AI model to process. For markup language files, such as XML files, their structures are parsed and the data is converted into dictionary or list form, and then saved as JSON format according to needs. After these processes, an intermediate file adapted for the input of the AI model is generated to ensure that the data can be effectively processed by the AI model.

[0084] Step S4: Generate semantic guidance instructions through the word processor based on the preset set of prompt words and a preset multi-type prompt word template.

[0085] Specifically, step S4 mainly relies on the word processor to generate semantic guidance instructions by combining the preset set of prompt words and the preset multi-type prompt word template, providing clear guidance for the subsequent generation of test cases.

[0086] First, the system will detect the status of the preset set of prompt words. If the preset set of prompt words is not empty, the word processor will analyze and evaluate the prompt words in the set, comprehensively considering the relevance, importance, etc. of the prompt words to the test scenario and the input source data, select appropriate prompt words, and then combine them into semantic guidance instructions according to certain grammar rules and logical structures to clearly and accurately express the specific requirements and directions for test case generation. For example, when testing an online shopping system with a focus on the shopping cart function, relevant prompt words will be preferentially selected and corresponding instructions will be generated. When the preset set of prompt words is empty, the word processor will identify the file type of the input source data, select an appropriate template from the preset multi-type prompt word templates according to its characteristics and test requirements, and then fill and adjust the template in combination with the content of the input source data, thereby generating semantic guidance instructions. For example, a function integrity verification template may be selected for the requirements document, and a template for supplementing abnormal situation testing may be selected for the test case document. Finally, regardless of which method is used to generate the instructions, they will be optimized and confirmed. The processor will check the grammar, semantics of the instructions and whether they meet the test target requirements, etc. If there are problems, they will be adjusted and modified to ensure that the semantic guidance instructions can provide accurate and effective guidance for the subsequent AI engine, so that the generated test cases meet the actual test requirements.

[0087] Step S5: Input the structured processed data, the intermediate file, and the semantic guidance instructions into the AI engine to trigger the test case generation model.

[0088] Specifically, input the structured processed data, the intermediate file, and the semantic guidance instructions into the AI engine to trigger the test case generation model. First, integrate these three parts of data to ensure that they are presented in a unified format and structure for easy reception and processing by the AI engine. They can be encapsulated into a data object. Then, input the integrated data into the AI engine in a suitable way. The specific input method depends on the interface and usage method of the AI engine. After receiving the input data, the AI engine will trigger the test case generation model. The model will analyze and reason based on the logical relationships in the structured processed data, the detailed information in the intermediate file, and the guidance of the semantic guidance instructions, using relevant technologies such as machine learning and natural language processing, and finally generate test cases that meet the requirements. The generated test cases can be output in a text file, Excel file, or other formats suitable for use by test management tools, and can be preliminarily verified and evaluated to ensure the quality and effectiveness of the test cases.

[0089] Step S6: Receive the original test case set output by the AI engine, and perform deduplication and priority sorting to generate a test case plan.

[0090] Specifically, the AI engine generates test cases based on the input structured processed data, intermediate files, and semantic guidance instructions, and outputs the original test case set. This set may contain multiple test cases, and each test case describes test steps, expected results, and other information for specific functions or scenarios of the system.

[0091] In the original test case set, there may be some duplicate test cases. These duplicate test cases will increase the workload of testing and reduce the testing efficiency. Therefore, it is necessary to remove duplicates from the original test case set. The specific approach is to compare the key information of each test case, such as test steps, expected results, and functional modules involved, find the duplicate test cases and delete them, only retaining a unique test case.

[0092] Priority sorting is to determine the execution order of each test case during the testing process, so as to give priority to testing those test cases that have a greater impact on the system function and higher risks. The specific process is as follows:

[0093] ① Extract the function coverage keywords of each test case in the original test case set, and calculate the coverage weight of each test case.

[0094] Specifically, extract the function coverage keywords from each test case in the original test case set. These keywords can reflect the system function points covered by the test case. For example, for a test case of an e-commerce system, the function coverage keywords may include "product search", "shopping cart addition", "order payment", etc.

[0095] Calculate the coverage weight of each test case. The calculation of the coverage weight can be based on various factors, such as the importance of the function, usage frequency, etc. Generally speaking, the test cases corresponding to functions with high importance and high usage frequency also have higher coverage weights. The coverage weight can be calculated through a pre-set weight table or algorithm.

[0096] ② Match the module defect rate involved in each test case based on the historical defect database to generate a risk level score.

[0097] Specifically, the historical defect database records the defect information found during previous tests or operations of the system, including the module where the defect is located, defect type, occurrence frequency, etc. By matching the module involved in each test case with the historical defect database, the defect rate of this module can be obtained.

[0098] Generate a risk level score based on the module defect rate. The higher the defect rate, the greater the possibility of problems in this module, and the higher the corresponding risk level score. The defect rate can be divided into different intervals, and each interval corresponds to a risk level score.

[0099] ③ Calculate the weighted sum of the coverage weights and the risk level scores corresponding to each of the test cases, and perform priority sorting on each test case in the original test case set based on the weighted sum.

[0100] Specifically, for each test case, calculate the weighted sum of its corresponding coverage weight and risk level score. The weighted sum comprehensively considers the functional coverage of the test case and the potential risk, and can more comprehensively reflect the importance of the test case.

[0101] Perform priority sorting on each test case in the original test case set based on the weighted sum. The test case with a higher weighted sum has a higher priority and should be executed first.

[0102] After deduplication and priority sorting, organize the processed test case set into a test case plan. This plan should include detailed information of each test case, such as test case number, test steps, expected results, priority, etc., so that testers can conduct testing work according to the plan.

[0103] In some embodiments of the present application, the process of step S4, generating a semantic guidance instruction by the word processor based on the preset prompt word set and the preset multi-type prompt word templates, is introduced. Specifically, it may include:

[0104] Step S41: If it is detected that the preset prompt word set is a non-empty set, select a prompt word based on the preset prompt word set and generate a semantic guidance instruction;

[0105] Step S42: If it is detected that the preset prompt word set is an empty set, select a prompt word template adapted to the file type included in the input source data from the preset multi-type prompt word templates and generate a semantic guidance instruction.

[0106] Specifically, step S4 focuses on generating a semantic guidance instruction by means of a word processor using the preset prompt word set and the preset multi-type prompt word templates. This instruction plays a key guiding role in the subsequent generation of test cases that meet the actual requirements by the AI engine. The whole process is divided into two different processing paths according to whether the preset prompt word set is empty.

[0107] When it is detected that the preset prompt word set is a non-empty set, it indicates that the user or the system has preset some key prompt information. The word processor will select appropriate prompt words from this set. During the selection process, factors such as the relevance and importance of the prompt words to the current test scenario will be comprehensively considered. For example, when testing a financial trading system, the preset prompt word set may include prompt words such as "transaction amount limit" and "account security verification". If the current test focus is on the security of transactions, the processor will preferentially select the prompt words related to account security verification. Then, according to certain grammar rules and logical structures, these selected prompt words will be combined into semantic guidance instructions. For example, after selecting the prompt words "transaction amount upper limit" and "transaction exception handling", the generated semantic guidance instruction may be "Generate test cases for the transaction amount upper limit and transaction exception handling".

[0108] If it is detected that the preset prompt word set is an empty set, the word processor will select an appropriate template from the preset multi-type prompt word templates according to the file type included in the input source data to generate semantic guidance instructions. There are specifically the following three adaptation methods:

[0109] First, if the input source data only contains the requirement document, load the preset basic template containing function boundary definitions and exception scenario prompt words.

[0110] Specifically, when the input source data only contains the requirement document, the system will load the preset basic template containing function boundary definitions and exception scenario prompt words. The requirement document usually describes the functions that the system should have, but may not detail the boundary conditions of the functions and exception scenarios. The function boundary definition prompt words in the preset basic template can help determine the situation at the boundary of the normal usage range of the system functions. For example, in the requirement document of an e-commerce system, for the description of product inventory, the function boundary definition prompt words can guide the generation of test cases such as "Product purchase test when the inventory is 0" and "Product addition test when the inventory reaches the upper limit". The exception scenario prompt words can guide the consideration of the system's performance in abnormal situations, such as test cases for the system's function performance in scenarios like network interruption and server failure.

[0111] Second, if the input source data contains a single requirement document and the use case document, load the preset combined template containing supplementary use cases and requirement mapping relationship description words.

[0112] Specifically, if the input source data includes a single requirement document and a use case document, the system will load a preset combined template that includes supplementary use cases and requirement mapping relationship descriptors. The single requirement document specifies the functional requirements of the system, while the use case document records some existing test cases. The supplementary use case descriptors in the preset combined template can help identify functional points or scenarios not covered in the existing use cases, thereby generating supplementary test cases. For example, if the requirement document mentions various promotional activities for products, but only some of the promotional activities are tested in the use case document, the supplementary use case descriptors can guide the generation of test cases for other promotional activities. The requirement mapping relationship descriptors help clarify the correspondence between use cases and requirements, ensuring that each requirement is covered by corresponding test cases and improving the integrity and effectiveness of testing.

[0113] Thirdly, if the input source data includes multiple said requirement documents and said use case documents, a preset multi-file template containing cross-document dependency analysis and conflict detection instructions is loaded.

[0114] Specifically, when the input source data includes multiple requirement documents and use case documents, the system will load a preset multi-file template containing cross-document dependency analysis and conflict detection instructions. There may be complex dependency relationships and potential conflicts between multiple requirement documents and use case documents. The cross-document dependency analysis instructions can guide the analysis of functional dependencies, data dependencies, etc. between different documents. For example, a certain function defined in one requirement document may depend on the data format defined in another document. Through cross-document dependency analysis, test cases can be generated to verify whether this dependency relationship is correct. The conflict detection instructions are used to discover possible contradictions or inconsistencies between different documents, such as inconsistent descriptions of the same function in different requirement documents, or conflicts between the test steps in the use case document and the requirements in the requirement document. Thus, test cases for these conflict situations are generated to ensure the consistency and correctness of the system's functions in a multi-document environment.

[0115] Next, a test case generation device provided by an embodiment of the present application is described. The test case generation device described below can be correspondingly referred to with the test case generation method described above.

[0116] See Figure 3 , Figure 3 which is a schematic diagram of a test case generation device disclosed in an embodiment of the present application.

[0117] As Figure 3 shown, the said test case generation device may include:

[0118] A data receiving unit 110, configured to receive multiple input source data, where the input source data includes a requirement document, a use case document, and a preset prompt word set;

[0119] The structure processing unit 120 is used to perform semantic integration and context association analysis on the requirement document and the use case document through a content processor to generate structured processing data;

[0120] The intermediate file unit 130 is used to call the file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the AI model input;

[0121] A guidance instruction unit 140, configured to generate a semantic guidance instruction based on the preset prompt word set and preset multi-type prompt word templates through a word processor;

[0122] The AI calling unit 150 is used to input the structured processing data, the intermediate file and the semantic guidance instruction into the AI engine to trigger the test case generation model;

[0123] The use case generation unit 160 is used to receive the original test case set output by the AI engine, perform deduplication and priority sorting, and generate a test case solution.

[0124] It can be seen from the above technical solutions that a test case generation method and related equipment provided in the embodiment of the present application can realize efficient, comprehensive and accurate generation of test cases, and effectively solve the various defects existing in the prior art in the software test case generation process.

[0125] In terms of improving efficiency, this application automatically completes complex data processing processes by receiving multi-source data such as requirement documents, use case documents, and preset prompt word sets, and the content processor, file processor, and word processor respectively perform operations such as semantic integration, format standardization, and semantic guidance instruction generation on the data. Users do not need to manually carefully design prompt words, nor do they need to perform tedious item-by-item analysis of documents. They only need to upload documents, which greatly saves time and energy and solves the problem of inefficiency in manually writing test cases. At the same time, when interacting with AI, the system automatically creates dialogues, avoiding the trouble of users manually creating dialogues, and effectively preventing context pollution, further improving the efficiency of test case generation.

[0126] In order to improve the comprehensiveness of test case coverage, this application uses a content processor to perform semantic integration and contextual association analysis on requirement documents and use case documents, which can discover potential test scenarios that are easily missed during manual writing. At the same time, it uses preset prompt word templates to supplement use cases, avoiding the omission of test cases due to incomplete manual consideration, and solving the problem of incomplete coverage of manually written test cases.

[0127] To address the problem of difficult multi-file collaboration, this application enables the collaborative work of a content processor and a word processor. Especially when the word processor selects different prompt templates according to the file types included in the input source data, such as loading a preset multi-file template containing cross-document dependency analysis and conflict detection instructions, it can deeply explore the logical relationships between multiple requirement documents and use case files. It can accurately detect requirement conflicts between different files, discover test coverage vulnerabilities caused by unclear file associations, achieve efficient collaboration in a multi-file environment, and effectively solve the problems of traditional test case generation methods in multi-file collaboration.

[0128] Optionally, perform semantic integration and context correlation analysis on the requirement document and the use case document to generate structured processing data, including:

[0129] Perform entity recognition and relationship extraction on the requirement document and the use case document, and extract functional modules, operation steps, and expected results as core semantic units;

[0130] Based on a knowledge graph, construct a logical link between requirements and use cases, map the core semantic units to a predefined test scenario framework, and mark the association strength weights;

[0131] Match the functional descriptions in the requirement document with the execution conditions in the use case document through a rule engine, identify logical contradictions or coverage omissions, and generate conflict marks;

[0132] Encode the integrated core semantic units, the association strength weights, and the conflict marks into a tree structure to form structured processing data.

[0133] Optionally, generate semantic guidance instructions based on the preset prompt word set and preset multi-type prompt templates, including:

[0134] If it is detected that the preset prompt word set is a non-empty set, select prompt words based on the preset prompt word set and generate semantic guidance instructions;

[0135] If it is detected that the preset prompt word set is an empty set, select a prompt template adapted to the file type included in the input source data from the preset multi-type prompt templates and generate semantic guidance instructions.

[0136] Optionally, select a prompt template adapted to the file type included in the input source data from the preset multi-type prompt templates, including:

[0137] If the input source data only includes the requirement document, load a preset basic template containing function boundary definition and abnormal scenario guiding words;

[0138] If the input source data includes a single such requirement document and use case document, load a preset combined template including supplementary use cases and requirement mapping descriptors;

[0139] If the input source data includes multiple such requirement documents and use case documents, load a preset multi-file template including cross-document dependency analysis and conflict detection instructions.

[0140] Optionally, the process of priority ranking includes:

[0141] Extract the function coverage keywords of each test case in the original test case set, and calculate the coverage weight of each test case;

[0142] Match the module defect rate involved in each test case based on the historical defect database to generate a risk level score;

[0143] Calculate the weighted sum of the coverage weight and the risk level score corresponding to each test case, and perform priority ranking on each test case in the original test case set based on the weighted sum.

[0144] Optionally, it further includes:

[0145] When the content processor detects a logical conflict between the requirement document and the use case document, trigger a manual review mark and attach conflict location information to the structured processed data.

[0146] The test case generation device provided by the embodiments of the present application can be applied to a test case generation device. Figure 4 The hardware structure block diagram of the test case generation device is shown. Refer to Figure 4 , the hardware structure of the test case generation device may include: at least one processor 1, at least one communication interface 2, at least one memory 3, and at least one communication bus 4;

[0147] In the embodiments of the present application, the number of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 is at least one, and the processor 1, the communication interface 2, and the memory 3 complete mutual communication through the communication bus 4;

[0148] The processor 1 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention, etc.;

[0149] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;

[0150] Among them, the memory stores a program, and the processor can call the program stored in the memory. The program is used for:

[0151] Receiving multiple input source data, where the input source data includes a requirements document, a use case document, and a preset set of prompt words;

[0152] Performing semantic integration and context correlation analysis on the requirements document and the use case document through a content processor to generate structured processed data;

[0153] Calling a file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the input of the AI model;

[0154] Generating semantic guidance instructions through a word processor based on the preset set of prompt words and a preset multi-type prompt word template;

[0155] Inputting the structured processed data, the intermediate file, and the semantic guidance instructions into an AI engine to trigger a test case generation model;

[0156] Receiving the original test case set output by the AI engine and performing deduplication and priority sorting to generate a test case plan.

[0157] Optionally, the refined functions and extended functions of the program can be referred to the above description.

[0158] An embodiment of the present application further provides a readable storage medium, which can store a program suitable for execution by a processor. The program is used for:

[0159] Receiving multiple input source data, where the input source data includes a requirements document, a use case document, and a preset set of prompt words;

[0160] Performing semantic integration and context correlation analysis on the requirements document and the use case document through a content processor to generate structured processed data;

[0161] Calling a file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the input of the AI model;

[0162] Generating semantic guidance instructions through a word processor based on the preset set of prompt words and a preset multi-type prompt word template;

[0163] Inputting the structured processed data, the intermediate file, and the semantic guidance instructions into an AI engine to trigger a test case generation model;

[0164] Receiving the original test case set output by the AI engine and performing deduplication and priority sorting to generate a test case plan.

[0165] Optionally, the refinement function and expansion function of the program may refer to the above description.

[0166] The embodiment of the present application also provides a computer program product, including a computer program, and the method executed when the computer program is run by a processor is as follows:

[0167] Receive multiple input source data, where the input source data includes a requirement document, a use case document, and a preset set of prompt words;

[0168] Perform semantic integration and context correlation analysis on the requirement document and the use case document through a content processor to generate structured processed data;

[0169] Call a file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the input of the AI model;

[0170] Generate semantic guidance instructions through a word processor based on the preset set of prompt words and a preset multi-type prompt word template;

[0171] Input the structured processed data, the intermediate file, and the semantic guidance instructions into an AI engine to trigger a test case generation model;

[0172] Receive the original test case set output by the AI engine, and perform deduplication and priority sorting to generate a test case plan.

[0173] Optionally, the refinement function and expansion function of the program may refer to the above description.

[0174] Finally, it should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.

[0175] The various embodiments in this specification are described in a progressive manner, and the key points of each embodiment are the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other.

[0176] The foregoing description of the disclosed embodiments enables those skilled in the art to practice or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A test case generation method, characterized in that Including: Receiving multiple input source data, where the input source data includes a requirements document, a use case document, and a preset set of prompt words; Performing semantic integration and context correlation analysis on the requirements document and the use case document through a content processor to generate structured processed data; Invoking a file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the input of the AI model; Generating semantic guidance instructions through a word processor based on the preset set of prompt words and a preset multi-type prompt word template; Inputting the structured processed data, the intermediate file, and the semantic guidance instructions into an AI engine to trigger a test case generation model; Receiving the original test case set output by the AI engine and performing deduplication and priority sorting to generate a test case solution.

2. The method according to claim 1, wherein Performing semantic integration and context correlation analysis on the requirements document and the use case document to generate structured processed data, including: Performing entity recognition and relationship extraction on the requirements document and the use case document, and extracting functional modules, operation steps, and expected results as core semantic units; Constructing a logical link between requirements and use cases based on a knowledge graph, mapping the core semantic units into a predefined test scenario framework, and marking the associated strength weights; Matching the function description in the requirements document with the execution conditions in the use case document through a rule engine to identify logical contradictions or coverage omissions, and generating conflict markers; Encoding the integrated core semantic units, the associated strength weights, and the conflict markers into a tree structure to form structured processed data.

3. The method according to claim 1, characterized in that, Generating semantic guidance instructions based on the preset set of prompt words and a preset multi-type prompt word template, including: If it is detected that the preset set of prompt words is a non-empty set, select prompt words based on the preset set of prompt words and generate semantic guidance instructions; If it is detected that the preset set of prompt words is an empty set, select a prompt word template adapted to the file type included in the input source data from the preset multi-type prompt word templates, and generate semantic guidance instructions.

4. The method according to claim 3, wherein Selecting a prompt word template adapted to the file type included in the input source data from the preset multi-type prompt word templates, including: If the input source data only includes the requirements document, load a preset basic template including function boundary definition and abnormal scenario guiding words; If the input source data includes a single requirements document and a use case document, load a preset combined template including supplementary use cases and requirement mapping relationship description words; If the input source data includes multiple requirements documents and use case documents, load a preset multi-file template including cross-document dependency analysis and conflict detection instructions.

5. The method according to claim 1, characterized in that, The process of the priority sorting includes: Extracting the function coverage keywords of each test case in the original test case set and calculating the coverage weight of each test case; Matching the module defect rate involved in each test case based on the historical defect database to generate a risk level score; Calculate the weighted sum of the coverage weights and the risk level scores corresponding to each of the test cases, and perform priority sorting on each test case in the original test case set based on the weighted sum.

6. The method according to claim 1, wherein It further includes: When the content processor detects a logical conflict between the requirement document and the use case document, trigger a manual review mark and attach conflict location information to the structured processing data.

7. A test case generation device, characterized in that, It includes: A data receiving unit for receiving multiple input source data, where the input source data includes a requirement document, a use case document, and a preset set of prompt words; A structure processing unit for performing semantic integration and context correlation analysis on the requirement document and the use case document through a content processor to generate structured processing data; An intermediate file unit for calling a file processor to perform format standardization processing on the input source data to generate an intermediate file adapted to the input of the AI model; A guidance instruction unit for generating semantic guidance instructions through a word processor based on the preset set of prompt words and a preset multi-type prompt word template; An AI calling unit for inputting the structured processing data, the intermediate file, and the semantic guidance instructions into an AI engine to trigger a test case generation model; A use case generation unit for receiving the original test case set output by the AI engine and performing deduplication and priority sorting to generate a test case solution.

8. A test case generation device, characterized in that, It includes a memory and a processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the test case generation method described in any one of claims 1-6.

9. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements each step of the test case generation method described in any one of claims 1-6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is run by the processor, it executes each step of the test case generation method described in any one of claims 1-6.

Citation Information

Cited By

  • Intelligent test case mining system and method based on knowledge graph

    CN121326753A