Test case generation method, electronic equipment, storage medium and program product
By fine-grained decomposition of the test case generation process and using artificial intelligence models for structured processing and quality assessment, the problems of unclear logic and omissions in test case generation directly using artificial intelligence models are solved, and efficient, accurate and maintainable generation of test cases is achieved.
Patent Information
- Application Number
- CN202510741874.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-09-09
AI Technical Summary
In the existing technology, the process of directly generating test cases by artificial intelligence models is implicit, resulting in the output test cases often having unclear logic or omitting important test scenarios, and having poor quality.
The test case generation process is fine-grained and decomposed into requirement documents, sub-requirement fragments and context fragments, splitting results, test scenarios and test case steps, and structured processing is performed using artificial intelligence models, including splitting, analysis and design, combined with quality assessment and deduplication.
It significantly improves the accuracy, completeness and maintainability of test cases, improves test efficiency and accuracy, reduces resource overhead, ensures efficient and controllable testing process and comprehensive coverage, and improves the delivery quality and stability of software products.
Smart Images

Figure CN120610896A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to a test case generation method, electronic equipment, storage medium and program product. Background Art
[0002] In the field of software testing, the design and generation of test cases is critical for ensuring system quality and functional correctness. Traditional test case generation relies primarily on test engineers manually understanding the semantics of requirement documents, extracting test scenarios, and writing test cases. This process, which relies heavily on manual experience, is inefficient, costly, and prone to omissions and misunderstandings. This problem is particularly acute in scenarios with complex requirements and extensive documentation.
[0003] In recent years, the rapid development of various artificial intelligence (AI) models, such as Large Language Models (LLMs), has demonstrated significant advantages in semantic understanding, logical reasoning, and text generation, gradually demonstrating broad application prospects in software engineering tasks. Generating test cases based on LLMs effectively addresses the shortcomings of traditional manual methods in semantic understanding and use case design, becoming an emerging research and application hotspot. Existing AI models often rely on the principle of "inputting requirements documents into the AI model and directly outputting test cases."
[0004] However, the artificial intelligence model directly outputs test cases, and its internal processing process is implicit, resulting in the output test cases often having unclear logic or missing important test scenarios, resulting in poor test case quality. Summary of the Invention
[0005] The present disclosure provides a test case generation method, electronic device, storage medium and program product.
[0006] According to one aspect of the present disclosure, a test case generation method is provided, comprising: obtaining a requirement document; obtaining sub-requirement fragments and context fragments of each sub-requirement fragment included in the requirement document; for each sub-requirement fragment, splitting it according to its context fragment to obtain a split result of each sub-requirement fragment; for each split result of the sub-requirement fragment, performing a test requirement analysis on it according to the sub-requirement fragment and its context fragment to obtain a test scenario for each sub-requirement fragment; for each test scenario of the sub-requirement fragment, designing a test case for it according to the sub-requirement fragment and its context fragment to obtain multiple test cases for the requirement document.
[0007] According to one aspect of the technical solution, by decomposing the test case generation process into requirement documents, sub-requirement fragments and context fragments, split results, test scenarios and test case steps, the test case generation process is fine-grainedly expanded, which can greatly reduce the logical ambiguity and omissions of the test cases and significantly improve the accuracy, completeness and maintainability of the test cases.
[0008] According to the test case generation method of at least one embodiment of the present disclosure, after obtaining the multiple test cases of the requirement document, the method further includes: performing quality assessment on the multiple test cases based on each sub-requirement fragment and its context fragment, splitting results, and test scenarios to obtain the use case quality of the multiple test cases; in response to the use case quality meeting the quality requirements, using the multiple test cases as executable test cases.
[0009] According to the test case generation method of at least one embodiment of the present disclosure, in response to the use case quality not meeting the quality requirements, the method further includes: re-executing the splitting of the sub-requirement fragment according to its context fragment until the use case quality meets the quality requirements or reaches the cutoff condition.
[0010] The technical solutions of this embodiment improve testing efficiency and accuracy, enhance maintainability and automation capabilities, ensure efficient, controllable, and comprehensive testing activities, and ultimately enhance the delivery quality and stability of software products. They also effectively improve the quality stability of multiple test cases, reduce the risk of omissions, and balance the resource overhead of test case generation, ultimately significantly improving the reliability of test assets and the overall delivery quality of the system.
[0011] According to the test case generation method of at least one embodiment of the present disclosure, taking the multiple test cases as executable test cases includes: determining whether the multiple test cases include repeated test cases; in response to the test cases not including repeated test cases, taking the multiple test cases as executable test cases.
[0012] According to the test case generation method of at least one embodiment of the present disclosure, in response to the multiple test cases including duplicate cases, the method of using the multiple test cases as executable test cases also includes: deduplicating the multiple test cases to obtain deduplicated test cases; and using the deduplicated test cases as executable test cases.
[0013] The technical solutions implemented in this implementation effectively improve test efficiency, accuracy, and maintainability, ensuring an efficient and controllable testing process and ultimately enhancing product quality and delivery speed. They also significantly enhance test execution efficiency, use case maintainability, and defect location accuracy, while ensuring complete coverage and maximizing resource utilization, supporting an efficient, accurate, and sustainable testing system.
[0014] According to the test case generation method of at least one embodiment of the present disclosure, obtaining the sub-requirement fragments and the context fragments of each sub-requirement fragment included in the requirement document includes: dividing the requirement document into at least one sub-requirement fragment; and retrieving the context fragment of each sub-requirement fragment from the requirement document.
[0015] According to the test case generation method of at least one embodiment of the present disclosure, dividing the requirement document into at least one sub-requirement segment includes: parsing the requirement document to obtain a parsing result; and dividing the requirement document into at least one sub-requirement segment according to the parsing result.
[0016] According to the technical solution of this embodiment, the completeness and accuracy of test case generation can be improved, maintenance costs can be reduced, and the automatic tracking and intelligent processing capabilities from requirements to tests can be enhanced.
[0017] According to the test case generation method of at least one embodiment of the present disclosure, the retrieving the context fragment of each sub-requirement fragment from the requirement document includes: summarizing the requirements of each sub-requirement fragment respectively to obtain a sub-requirement summary of each sub-requirement fragment; and retrieving the context fragment of each sub-requirement fragment from the requirement document according to the sub-requirement summary.
[0018] According to the test case generation method of at least one embodiment of the present disclosure, the retrieving the context fragment of each sub-requirement fragment from the requirement document according to the sub-requirement summary includes: taking each sub-requirement fragment and its sub-requirement summary as input, and using the RAG method to obtain the context fragment of each sub-requirement fragment from the requirement document.
[0019] According to the technical solution of this embodiment, it is possible to improve the consistency of requirement understanding, the accuracy of context fragment extraction and the integrity of subsequent test design, and promote the automation and intelligence of the test design process. Using the RAG method to retrieve context fragments can significantly improve the accuracy, relevance and efficiency of context fragment extraction, while supporting dynamic generation, reducing manual intervention, and improving the system's ability to handle long requirement documents or diversified requirements. In addition, by integrating retrieval and generation through the RAG method, the practicality and reliability of test case generation software are significantly improved, especially in scenarios where external knowledge is required.
[0020] According to the test case generation method of at least one embodiment of the present disclosure, the dividing of the requirement document into at least one sub-requirement segment includes: obtaining the semantics of the requirement document; segmenting the requirement document according to the semantics to obtain semantic blocks; obtaining a semantic vector for each semantic block; clustering the semantic vectors to obtain clusters; and forming sub-requirement segments from semantic blocks related to the semantic vectors included in each cluster.
[0021] According to the technical solution of this embodiment, relevant requirements in a requirement document can be effectively organized into segments with clear themes and interrelationships, thereby improving the organizational efficiency of sub-requirement segments.
[0022] According to the test case generation method of at least one embodiment of the present disclosure, before splitting the sub-requirement fragment according to its context fragment, the method further includes: obtaining auxiliary information for generating a test case; splitting the sub-requirement fragment according to its context fragment includes: splitting the sub-requirement fragment according to the auxiliary information and the context fragment of the sub-requirement fragment; performing a test requirement analysis on the sub-requirement fragment and its context fragment includes: performing a test requirement analysis on the sub-requirement fragment according to the auxiliary information, the sub-requirement fragment and its context fragment; designing a test case for the sub-requirement fragment and its context fragment includes: designing a test case for the sub-requirement fragment according to the auxiliary information, the sub-requirement fragment and its context fragment.
[0023] According to the test case generation method of at least one embodiment of the present disclosure, the auxiliary information includes one or more of: a sub-requirement summary of each sub-requirement fragment, UI component information related to the requirement document, and business knowledge related to the requirement document.
[0024] The technical solution of this embodiment can greatly improve the comprehensiveness, accuracy, efficiency and maintainability of the test, better cover the system functions, reduce redundancy and omissions, and ensure the correctness and stability of the system in various scenarios.
[0025] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the test case generation method of any embodiment of the present disclosure.
[0026] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the test case generation method of any embodiment of the present disclosure is used to implement.
[0027] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the test case generating method according to any embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.
[0029] Figure 1 This is a schematic flow chart of a test case generation method according to an embodiment of the present disclosure. Figure 1 .
[0030] Figure 2 This is a schematic flow chart of a test case generation method according to an embodiment of the present disclosure. Figure 2 .
[0031] Figure 3 This is a schematic flow chart of a test case generation method according to an embodiment of the present disclosure. Figure 3 .
[0032] Figure 4 yes Figure 2 Schematic flow of the test case execution preparation method in the test case generation method shown Figure 1 .
[0033] Figure 5 yes Figure 2 Schematic flow of the test case execution preparation method in the test case generation method shown Figure 2 .
[0034] Figure 6 yes Figure 1 The schematic flowchart of the fragment acquisition method in the test case generation method shown in FIG.
[0035] Figure 7 yes Figure 6 The schematic flow of the context acquisition method in the fragment acquisition method shown Figure 1 .
[0036] Figure 8 yes Figure 6 The schematic flow of the context acquisition method in the fragment acquisition method shown Figure 2 .
[0037] Figure 9 yes Figure 6 The schematic flow of the required fragment acquisition method in the fragment acquisition method shown in FIG Figure 1 .
[0038] Figure 10 yes Figure 6 The schematic flow of the required fragment acquisition method in the fragment acquisition method shown in FIG Figure 2 .
[0039] Figure 11 This is a schematic flow chart of a test case generation method according to an embodiment of the present disclosure. Figure 4 .
[0040] Figure 12 It is a schematic flowchart of a test case generation method according to an embodiment of the present disclosure.
[0041] Figure 13 It is a schematic structural block diagram of a test case generation device according to an embodiment of the present disclosure.
[0042] Figure 14 The present invention is a schematic structural block diagram of an electronic device equipped with a test case generating device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The present disclosure is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are intended only to illustrate the relevant content and are not intended to limit the present disclosure. It should also be noted that, for ease of description, only the portions relevant to the present disclosure are shown in the accompanying drawings.
[0044] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0045] Taking an e-commerce system as an example, the core content of the requirements document includes: "Multiple payment methods are supported when users pay for orders; the order status changes to "paid" after a successful payment, and remains "unpaid" if it fails; the order is automatically canceled and inventory is released if the payment timeout expires; the payment amount must be rounded to two decimal places and cannot exceed the user's account balance." This content is fed into the large language model and prompted to output test cases. The large language model outputs the following test cases: Because test case TC04 doesn't specify the timeout period, nor does it clarify whether inventory release is successful and how to verify it, and test case TC07 doesn't explain how to prevent duplicate submissions, the test cases generated by the large language model suffer from unclear logic. Furthermore, because the test cases generated by the large language model don't include test scenarios such as whether the account balance equals the order amount, whether the order status correctly transitions from "paying" to "paid or unpaid," and whether inventory release is successful, direct test case generation based on the large language model has omissions. In summary, the quality of test cases generated directly from the requirements document by the large language model is poor.
[0046] To this end, the present disclosure proposes the following technical solution, which solves the problem that a large language model directly outputs test cases, and its internal processing process is implicit, resulting in the output test cases often having unclear logic or omitting important test scenarios, and the quality of the test cases is poor.
[0047] For the convenience of description and to make the technical solution of the present disclosure easier to understand, the terms of the present disclosure are first explained before describing the technical solution of the present disclosure.
[0048] A requirements document is a document written by business analysts, product managers, or requirements analysts in the early stages of system or product development to describe the system or product's functions, performance, user scenarios, and other requirements.
[0049] The splitting result is the specific functional points or non-functional points split from the requirement document.
[0050] A test scenario is a specific test item or checkpoint designed to verify the functions, features, or requirements of a system or product.
[0051] A test case is a specific test execution step, including detailed information such as input data, operation steps, and expected results.
[0052] The test case generation method provided by the present disclosure can be implemented by test case generation software installed on electronic devices such as servers.
[0053] Figure 1 The figure shows the overall process diagram of the test case generation method according to one embodiment of the present disclosure. Figure 1 The test case generation method shown includes steps S110 to S150, wherein the method can be executed by an electronic device such as a server.
[0054] In step S110 , a requirement document is obtained.
[0055] In some embodiments of the present disclosure, the requirement document obtained in step S110 may be manually uploaded or filled out by a user (such as a tester, product manager, etc.), or may be automatically captured from a project management system, etc.
[0056] The requirements document obtained through step S110 may include basic information (used to indicate who wrote the document, for whom it is written, the version number, and what has been changed), an introduction (used to explain what the project does, what terminology and references are used), an overall description (used to describe the system's structure, roles, technical constraints, etc. as a whole), functional requirements (used to clarify each function that the system needs to implement), non-functional requirements (used to explain the standard for "whether the system is "well done"), external interface requirements (used to describe how to connect with other systems), data requirements (used to define the fields, data structures and processing rules used by the system), etc.
[0057] In step S120 , sub-requirement fragments included in the requirement document and context fragments of each sub-requirement fragment are obtained.
[0058] In some embodiments of the present disclosure, the sub-requirement fragment obtained in step S120 is a small-grained paragraph or sentence extracted from the requirement document. The context fragment of a sub-requirement fragment is a document content fragment associated with the sub-requirement fragment, providing its meaning supplement, constraint explanation or background information.
[0059] Clear context fragments can ensure that test cases do not deviate from the sub-requirement fragments, avoiding logical loopholes or implementation deviations caused by missing information.
[0060] In step S130 , each sub-demand segment is split according to its context segment to obtain a split result of each sub-demand segment.
[0061] In some embodiments of the present disclosure, step S130 may be implemented by an artificial intelligence model, which is used to generate structured splitting results based on the sub-demand fragments and their context fragments.
[0062] Step S130 generates splitting results in a structured manner, which can ensure that the requirements are executable and unambiguous.
[0063] In step S140 , for the splitting result of each sub-requirement fragment, a test requirement analysis is performed on the sub-requirement fragment and its context fragment to obtain a test scenario for each sub-requirement fragment.
[0064] In some embodiments of the present disclosure, step S140 may be implemented by an artificial intelligence model, which is used to generate a structured test scenario based on each sub-requirement fragment and its context fragment and splitting results.
[0065] Step S140 generates test scenarios in a structured manner, which can improve the consistency and traceability of the test scenarios and facilitate subsequent test case generation.
[0066] In step S150 , for the test scenario of each sub-requirement fragment, a test case is designed based on the sub-requirement fragment and its context fragment to obtain multiple test cases of the requirement document.
[0067] In some embodiments of the present disclosure, step S150 may be implemented by an artificial intelligence model, which is used to generate a test case based on each sub-requirement fragment and its context fragment and test scenario.
[0068] Step S150 generates test cases in a structured manner, which can improve the standardization and consistency of test cases, reduce manual writing errors, and enhance automated processing capabilities.
[0069] The test case generation method disclosed herein decomposes the test case generation process into a requirements document, sub-requirement fragments and context fragments, split results, test scenarios, and test case steps, expanding the test case generation process into a fine-grained manner. This significantly reduces test case logic ambiguity and omissions, and significantly improves the accuracy, completeness, and maintainability of test cases. This test case generation method addresses the prior art problem of large language models directly outputting test cases, whose internal processing is implicit, resulting in test cases with often unclear logic or omission of important test scenarios, resulting in poor test case quality.
[0070] In some embodiments of the present disclosure, the artificial intelligence model used in step S130, step S140, and step S150 may be the same model, such as a large language model; the artificial intelligence models used in step S130, step S140, and step S150 may also be different models, such as step S130 using the BERT (Bidirectional Encoder Representations from Transformers model, step S140 using the T5 (Text-To-Text Transfer Transformer) model, step S150 using the GPT model, etc. Specifically, the artificial intelligence models used in step S130, step S140, and step S150 may be different intelligent entities of an artificial intelligence model.
[0071] Furthermore, the test case generation method provided by the present disclosure may further include the following steps after step S150: Figure 2 Steps S160 to S170 are shown.
[0072] In step S160 , quality assessment is performed on multiple test cases based on each sub-requirement fragment and its context fragment, splitting result, and test scenario to obtain the use case quality of the multiple test cases.
[0073] In some embodiments of the present disclosure, the quality of a test case is the overall quality level of the test case during its design, writing, and execution. The quality of a test case can be assessed using one or more of the following metrics: correctness, completeness, clarity, enforceability, and consistency.
[0074] Correctness metrics are used to check whether multiple test cases accurately reflect the true intent of the requirements or test scenarios; whether the test steps are logically correct and free of obvious operational errors or skipped steps. Completeness metrics are used to check whether multiple test cases contain necessary elements (such as case titles, preconditions, test steps, expected results, etc.) and whether multiple test cases omit necessary links. Clarity metrics are used to check whether the language of multiple test cases is concise and clear, without ambiguity; whether each step in multiple test cases can be consistently understood and executed by different testers; and whether the terminology and action descriptions are consistent across multiple test cases. Executability metrics are used to check whether testers can follow the steps of multiple test cases, whether they can actually perform them, and whether there are any unexecutable steps. The required data, environment, and interfaces for multiple test cases are clearly described or can be reasonably inferred. Consistency metrics are used to check whether multiple test cases are consistent with existing requirements documents and test scenarios, whether any functional logic is arbitrarily added or deleted, and whether the style of multiple test cases is consistent.
[0075] Quality requirements can be pre-set. When the test case quality meets the quality requirements, it indicates that the multiple test cases have reached the standard for formal execution or inclusion in the test suite, and step S170 is executed. If the test case quality of multiple test cases does not meet the quality requirements, it indicates that the multiple test cases have defects or problems and cannot be directly executed. They need to be supplemented, modified, or redesigned. Failure to do so may result in invalid testing, missed tests, or erroneous conclusions.
[0076] In step S170, the multiple test cases are used as executable test cases.
[0077] By using steps S160 to S170 to treat multiple test cases that meet the quality requirements as executable test cases, the test efficiency and accuracy can be improved, the maintainability and automation capabilities can be enhanced, and the test activities can be ensured to be efficient, controllable and comprehensive, thereby ultimately improving the delivery quality and stability of the software product.
[0078] Furthermore, the test case generation method provided by the present disclosure, in response to the use case quality obtained in step S160 not meeting the quality requirements, re-executes step S130 until the use case quality meets the quality requirements or reaches the cut-off condition, such as Figure 3 shown.
[0079] In some embodiments of the present disclosure, the cutoff condition can be, for example, reaching the maximum number of attempts or a generation timeout. This cutoff condition mechanism can effectively improve the quality stability of multiple test cases, reduce the risk of omissions, and balance the resource overhead of test case generation, ultimately significantly improving the reliability of test assets and the overall delivery quality of the system.
[0080] Regarding step S170, in some embodiments of the present disclosure, it may include the following: Figure 4 Steps S171 to S172 are shown.
[0081] In step S171 , it is determined whether the multiple test cases include repeated test cases.
[0082] In some embodiments of the present disclosure, step S171 determines whether multiple test cases include repeated use cases, mainly based on the following criteria: consistent test objectives (i.e., the functional points and business scenarios verified by the test cases are the same or extremely similar), the preconditions are the same or there is no obvious difference (i.e., the test environment, initial data, and system status requirements are consistent or very close), the execution steps are highly similar (i.e., the operating procedures are basically the same, with only differences in expression or minor operational adjustments), the expected results are consistent (i.e., there is no essential difference in the system response or result status after the test is completed), and the coverage overlaps (i.e., the functional modules and business processes covered by the test cases are repeated, and there is no new verification value), etc.
[0083] If it is determined in step S171 that the multiple test cases include duplicate cases, this indicates that the multiple test cases may lead to redundant verification, affecting test efficiency and resource utilization. If it is determined in step S171 that the multiple test cases do not include duplicate cases, this indicates that the multiple test cases are each used to independently verify a unique scenario or functional module, ensuring test coverage, and step S172 is executed.
[0084] In step S172, multiple test cases are used as executable test cases.
[0085] By ensuring that multiple test cases are non-repetitive and serve as executable test cases through steps S171 to S172, test efficiency, accuracy and maintainability can be effectively improved, ensuring that the test process is efficient and controllable, and ultimately improving product quality and delivery speed.
[0086] When it is determined in step S171 that multiple test cases include repeated test cases, step S170, in some embodiments of the present disclosure, may further include: Figure 5 Steps S173 to S174 are shown.
[0087] In step S173, multiple test cases are deduplicated to obtain deduplicated test cases.
[0088] In some embodiments of the present disclosure, step S173 may deduplicate multiple test cases by using a text similarity algorithm, a structured data comparison method, or the like.
[0089] In step S174, the deduplicated use cases are used as executable test cases.
[0090] By using steps S173 to S174 to treat the deduplicated test cases as executable test cases, the test execution efficiency, case maintainability and defect location accuracy can be significantly improved, while ensuring coverage integrity and maximum resource utilization, supporting an efficient, accurate and sustainable testing system.
[0091] Regarding step S120, in some embodiments of the present disclosure, it may include the following: Figure 6 Steps S121 to S122 are shown.
[0092] In step S121 , the requirement document is divided into at least one sub-requirement segment.
[0093] In some embodiments of the present disclosure, step S121 may divide the requirement document according to functional modules, behaviors or time, trigger conditions or expected results, etc.
[0094] In step S122 , the context fragment of each sub-requirement fragment is retrieved from the requirement document.
[0095] In some embodiments of the present disclosure, step S122 may detect the context segment of each sub-requirement segment from the requirement document based on the structural hierarchy, adjacent semantics, keyword matching, and other methods of the requirement document.
[0096] By dividing the sub-requirement segments and extracting the context segments through steps S121 to S122, the completeness and accuracy of test case generation can be improved, maintenance costs can be reduced, and the automatic tracking and intelligent processing capabilities from requirements to tests can be enhanced.
[0097] Regarding step S122, in some embodiments of the present disclosure, it may include the following: Figure 7 Steps S1221 to S1222 are shown.
[0098] In step S1221, the requirements of each sub-requirement fragment are summarized to obtain a sub-requirement summary of each sub-requirement fragment.
[0099] In some embodiments of the present disclosure, step S1221 can summarize the sub-requirement fragments through an artificial intelligence model, such as information compression and abstract extraction (i.e., automatically identifying key information from lengthy and trivial sub-requirement fragments, eliminating irrelevant details, and extracting the core intentions and main conditions), unified expression and standardized processing (i.e., sub-requirement fragments of different styles and different expression habits are uniformly re-expressed in a standardized and standardized language to improve the standardization and consistency of subsequent processing), supplementary implicit information reasoning (i.e., through reasoning and association completion, reasonable premises, restrictions or background information are automatically supplemented when generating a summary to make the sub-requirement summary more complete), etc.
[0100] In step S1222 , a context segment of each sub-requirement segment is retrieved from the requirement document according to the sub-requirement summary.
[0101] In some embodiments of the present disclosure, step S1222 may retrieve context fragments from the requirement document by combining semantic matching, logical dependency, and other means.
[0102] Steps S1221 to S1222 determine context fragments based on the sub-requirement profile, which can improve the consistency of requirement understanding, the accuracy of context fragment extraction and the integrity of subsequent test design, and promote the automation and intelligence of the test design process.
[0103] Regarding step S122, in some embodiments of the present disclosure, it may also include the following Figure 8 Steps 1223 to S1224 are shown.
[0104] In step S1223, each sub-requirement fragment is input into the fifth artificial intelligence model respectively to obtain a sub-requirement summary of each sub-requirement fragment.
[0105] In some embodiments of the present disclosure, the process of obtaining the sub-demand summary in step S1223 is similar to the following. Figure 7 The step S1221 shown is the same.
[0106] In step S1224, each sub-requirement fragment and its sub-requirement summary are taken as input, and the context fragment of each sub-requirement fragment is obtained from the requirement document using the RAG method.
[0107] Steps S1223 and S1224 utilize the RAG method to retrieve context snippets, significantly improving the accuracy, relevance, and efficiency of context snippet extraction. This method also supports dynamic generation, reduces manual intervention, and enhances the system's ability to handle long requirements documents or diverse requirements. Furthermore, the integration of retrieval and generation through the RAG method significantly enhances the practicality and reliability of test case generation software, particularly in scenarios requiring external knowledge.
[0108] Regarding step S121, in some embodiments of the present disclosure, it may include the following: Figure 9 Steps S1211 to S1215 are shown.
[0109] In step S1211, the semantics of the requirement document is obtained.
[0110] In some embodiments of the present disclosure, step S1211 may adopt a process such as rule-based grammatical analysis, natural language processing, or syntax analysis to obtain the semantics of the requirement document.
[0111] In step S1212, the requirement document is segmented according to semantics to obtain semantic blocks.
[0112] In step S1213 , the semantic vector of each semantic block is obtained.
[0113] In some embodiments of the present disclosure, step S1213 may convert the semantic block into a semantic vector through methods such as Bag of Words (BoW), Term Frequency-Inverse Document Frequency (TF-IDF), and Word2Vec.
[0114] In step S1214 , the semantic vectors are clustered to obtain clusters.
[0115] In step S1215 , semantic blocks related to the semantic vectors included in each cluster constitute a sub-demand segment.
[0116] By extracting sub-requirement fragments through steps S1211 to S1215, relevant requirements in the requirement document can be effectively organized into fragments with clear themes and mutual relevance, thereby improving the organizational efficiency of the sub-requirement fragments.
[0117] Regarding step S121, in some embodiments of the present disclosure, it may include the following: Figure 10 Steps S1216 to S1217 are shown.
[0118] In step S1216, the requirement document is parsed to obtain a parsing result.
[0119] In some embodiments of the present disclosure, step S1216 may use a file parser, a deep learning model, etc. to parse the requirements document and extract the content included in the requirements document (i.e., the parsing result).
[0120] In step S1217, the requirement document is divided into at least one sub-requirement segment according to the parsing result.
[0121] In some embodiments of the present disclosure, step S1217 may specifically divide the requirement document using the process of steps S1211 to S1215.
[0122] By parsing and dividing the requirement document through steps S1216 to S1217, the comprehensibility, accuracy and structure of the requirements can be improved, thereby reducing the occurrence of duplication, omissions and conflicts.
[0123] Furthermore, the test case generation method provided by the present disclosure may further include the following steps before step S130: Figure 11 Step S180 is shown.
[0124] In step S180 , auxiliary information for generating a test case is obtained.
[0125] In some embodiments of the present disclosure, the auxiliary information in step S180 may include one or more of a sub-requirement summary of each sub-requirement fragment, UI component information related to the requirement document, and business knowledge related to the requirement document. The UI component information related to the requirement document is a detailed description of the components and elements related to the user interface in the requirement document; common UI components include buttons, text boxes, menus, labels, etc. The business knowledge related to the requirement document is a description of business logic, rules, and processes, focusing on how the system performs tasks and operations according to business requirements and how it adapts to business rules.
[0126] At this time, step S130 specifically involves splitting each sub-demand segment according to the auxiliary information and the context segment of the sub-demand segment to obtain a split result of each sub-demand segment.
[0127] Step S140 is specifically to perform a test requirement analysis on the split result of each sub-requirement fragment according to the auxiliary information, the sub-requirement fragment and its context fragment to obtain a test scenario for each sub-requirement fragment.
[0128] Step S150 specifically involves designing a test case for the test scenario of each sub-requirement fragment according to the auxiliary information, the sub-requirement fragment and its context fragment, to obtain multiple test cases for the requirement document.
[0129] Step S180 uses auxiliary information to provide more context and details for test case generation, significantly improving the comprehensiveness, accuracy, efficiency, and maintainability of the test. By combining auxiliary information such as requirements documents, UI component information, and business knowledge, test cases can better cover system functionality, reduce redundancy and omissions, and ensure the correctness and stability of the system in various scenarios.
[0130] The test case generation method disclosed herein divides the test case generation process into multiple steps, making the steps more detailed, allowing the model to understand information in a refined manner, and generating more detailed test cases. This method can be used to assist test engineers in analyzing requirement documents, designing test cases, and supplementing test cases. Furthermore, this method uses sub-requirement fragments, their contextual fragments, and auxiliary information as model input, enriching the model tokens and resolving the issue of insufficient model tokens and the model ignoring detailed information when the requirement document is long.
[0131] Figure 12 An exemplary flowchart of the test case generation method according to the present disclosure is shown.
[0132] Figure 12 In the flowchart shown, the test case generation process may include: In step S210, a requirement document is obtained.
[0133] In step S220, the requirement document is parsed using a file parser to extract the content in the requirement document and obtain a parsing result.
[0134] In step S230 , the requirement document is divided into at least one sub-requirement segment according to the parsing result by using semantic segmentation and vector clustering methods.
[0135] In some embodiments of the present disclosure, step S230 may first segment the requirement document using a semantic segmentation method; then perform vector clustering on the segmentation results using a vector clustering method to obtain at least one sub-requirement segment. Each sub-requirement segment includes all segmentation results included in each cluster, that is, each sub-requirement segment may include one or more segmentation results.
[0136] In step S240 , an artificial intelligence model is used to extract a sub-demand summary of each sub-demand segment.
[0137] In step S250, each sub-requirement fragment and its sub-requirement summary are taken as input, and the context fragment related to each sub-requirement fragment is retrieved using the RAG method.
[0138] In step S260, UI component information and business knowledge related to the requirement document are obtained.
[0139] In step S270, each sub-requirement fragment and its sub-requirement summary, context fragment, UI component information and business knowledge are input into the demand analysis agent to obtain the splitting result of each sub-requirement fragment.
[0140] In step S280, each sub-requirement fragment and its sub-requirement summary, context fragment, UI component information, business knowledge and splitting result are input into the test design agent to obtain the test scenario of each sub-requirement fragment.
[0141] In step S290, each sub-requirement fragment and its sub-requirement summary, context fragment, UI component information, business knowledge and test scenario are input into the use case generation agent to obtain multiple test cases of the requirement document.
[0142] In step S300, the reflective review agent combines the splitting results of each sub-requirement fragment, the test scenario, and multiple test cases to analyze the use case quality of multiple test cases.
[0143] In some embodiments of the present disclosure, the use case quality obtained in step S300 may indicate whether the multiple test cases are complete or correct. If the use case quality obtained in step S300 indicates that the multiple test cases are incomplete or incorrect, step S270 is re-executed until the use case quality is complete and correct or a cutoff condition is met. If the use case quality obtained in step S300 indicates that the multiple test cases are complete and correct, step S310 is executed.
[0144] In step S310, the reflective agent analyzes whether there are repeated test cases in the multiple test cases.
[0145] In some embodiments of the present disclosure, when it is determined in step S310 that there are duplicate test cases in the multiple test cases, step S320 is executed; when it is determined in step S310 that there are no duplicate test cases in the multiple test cases, step S340 is executed.
[0146] In step S320, multiple test cases are deduplicated to obtain deduplicated test cases.
[0147] In step S330, the deduplicated use cases are used as executable test cases.
[0148] In step S340, the multiple test cases are used as executable test cases.
[0149] In some embodiments of the present disclosure, the demand analysis agent in step S270, the test design agent in step S280, the use case generation agent in step S290, and the reflection and review agent in step S300 are entities that can autonomously perceive, make decisions, and perform specific tasks based on the capabilities of the artificial intelligence model by configuring specific instructions, built-in workflows, memory, tool calls, and other mechanisms. The above-mentioned agents can be built based on existing artificial intelligence models (such as Chatgpt, etc.). The above-mentioned agents can be different parts of the same artificial intelligence model, such as a large language model. Different prompts can be used to control different agents or artificial intelligence models to achieve corresponding functions.
[0150] This disclosure provides a test case generation method that automatically generates test cases based on requirement documents, significantly reducing the workload of manually writing test cases. The test case generation method provided by this disclosure can be used in areas such as web application testing, mobile app testing, interface testing, and back-end system testing. After test cases are generated using this method, processes such as case optimization, case implementation and instantiation, test execution, defect management, test summary, and case reuse can be performed.
[0151] During the use case optimization process, boundary conditions and abnormal situations can be added, and invalid use cases can be removed. During the use case implementation and instantiation process, test cases can be supplemented into a form that can be actually executed, or test cases can be converted into test scripts, etc. During the test execution process, tests can be executed manually or automatically according to the test cases, and the execution results can be recorded and compared with the expected results. In defect management, if the test fails, a bug request is submitted to the developer to fix it, and the failed test case is regressed to confirm that the problem has been resolved. In the test summary and use case reuse process, the use case execution pass rate and the key bugs found are summarized, and high-value use cases are retained as future regression test cases.
[0152] The present disclosure also provides a test case generation device (corresponding to a test case generation method). Figure 13 A schematic diagram showing a hardware implementation using a processing system is shown.
[0153] like Figure 14As shown, the hardware structure of an electronic device / apparatus can be implemented using a bus architecture. The bus architecture can include any number of interconnecting buses and bridges, depending on the specific application and overall design constraints of the hardware. Bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules. Bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc. Bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component Architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of illustration, the figure shows only one connecting line, but this does not mean that there is only one bus or one type of bus.
[0154] For ease of explanation, some steps of the above method are described as corresponding to modules. It should be understood that the corresponding modules for performing one or more steps of the above method can be one or more hardware modules specifically configured to perform the corresponding steps, or implemented by a processor configured to perform the corresponding steps, or stored in a computer-readable medium for implementation by a processor, or implemented by some combination thereof.
[0155] like Figure 13 As shown, the test case generation device includes a document acquisition module 1010 , a fragment acquisition module 1020 , a requirement analysis module 1030 , a test design module 1040 and a use case generation module 1050 .
[0156] The document acquisition module 1010 is used to acquire the requirement document.
[0157] The fragment acquisition module 1020 is used to acquire the sub-requirement fragments included in the requirement document and the context fragments of each sub-requirement fragment.
[0158] The demand analysis module 1030 is configured to split each sub-demand segment according to its context segment to obtain a split result of each sub-demand segment.
[0159] The test design module 1040 is used to analyze the test requirements of each sub-requirement fragment based on the split result of the sub-requirement fragment and its context fragment, and obtain a test scenario for each sub-requirement fragment.
[0160] The use case generation module 1050 is used to design a test case for the test scenario of each sub-requirement fragment according to the sub-requirement fragment and its context fragment, and obtain multiple test cases of the requirement document.
[0161] The specific implementation of each module in the above-mentioned device can refer to the implementation process of the corresponding steps in the above-mentioned method implementation of the present disclosure, and will not be repeated here.
[0162] The present disclosure also provides a readable storage medium having a computer program stored therein, which is used to implement the above-mentioned method when the computer program is executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.
[0163] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part using software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the process or function of the present disclosure is performed in whole or in part.
[0164] A computer program or instruction can be stored in a readable storage medium or transferred from one readable storage medium to another. For example, the computer program or instruction can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The readable storage medium can be any accessible medium or a data storage device such as a server or data center that integrates one or more accessible media. The accessible medium can be a magnetic medium such as a floppy disk, hard disk, or magnetic tape; an optical medium such as a digital video disk; or a semiconductor medium such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.
[0165] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0166] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0167] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0168] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0169] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in a suitable manner in any one or more embodiments / methods or examples. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and the features of different embodiments / methods or examples, unless they are contradictory.
[0170] Those skilled in the art will appreciate that the above embodiments are merely intended to clearly illustrate the present disclosure and are not intended to limit the scope of the present disclosure. Other changes or modifications may be made based on the above disclosure, and such changes or modifications are still within the scope of the present disclosure.
Claims
1. A test case generation method, characterized in that: include: Obtain requirements documents; Obtaining sub-requirement fragments included in the requirement document and context fragments of each sub-requirement fragment; For each sub-demand fragment, split it according to its context fragment to obtain a split result of each sub-demand fragment; For each sub-requirement fragment split result, perform test requirement analysis on the sub-requirement fragment and its context fragment to obtain the test scenario for each sub-requirement fragment; as well as For the test scenario of each sub-requirement fragment, a test case is designed according to the sub-requirement fragment and its context fragment to obtain multiple test cases of the requirement document.
2. The test case generation method according to claim 1, wherein: After obtaining the plurality of test cases of the requirement document, the method further includes: Performing a quality assessment on the multiple test cases based on each sub-requirement fragment and its context fragment, the splitting result, and the test scenario to obtain the test case quality of the multiple test cases; and In response to the quality of the test cases meeting the quality requirements, the multiple test cases are used as executable test cases.
3. The test case generation method according to claim 2, wherein: The step of using the multiple test cases as executable test cases includes: Determining whether the multiple test cases include repeated test cases; and In response to the test cases not including duplicate test cases, the plurality of test cases are used as executable test cases.
4. The test case generation method according to any one of claims 1 to 3, wherein: The obtaining of the sub-requirement fragments and the context fragment of each sub-requirement fragment included in the requirement document includes: Dividing the requirement document into at least one sub-requirement segment; and A context fragment for each child requirement fragment is retrieved from the requirement document.
5. The test case generation method according to claim 4, wherein: The retrieving a context fragment of each sub-requirement fragment from the requirement document includes: Summarize the requirements of each sub-requirement fragment to obtain a sub-requirement summary of each sub-requirement fragment; and A context fragment for each sub-requirement fragment is retrieved from the requirement document according to the sub-requirement summary.
6. The test case generation method according to claim 4, wherein: The step of dividing the requirement document into at least one sub-requirement segment comprises: Obtaining semantics of the requirements document; Segmenting the requirement document according to the semantics to obtain semantic blocks; Get the semantic vector of each semantic block; Clustering the semantic vectors to obtain clusters; and The semantic blocks related to the semantic vectors included in each cluster constitute the sub-demand fragment.
7. The test case generation method according to any one of claims 1 to 3, characterized in that: Before splitting the sub-requirement fragment according to its context fragment, the method further comprises: acquiring auxiliary information for generating a test case; The splitting of the sub-demand fragment according to its context fragment includes: splitting the sub-demand fragment according to the auxiliary information and the context fragment of the sub-demand fragment; The performing of a test requirement analysis on the sub-requirement fragment and its context fragment, comprising: performing a test requirement analysis on the sub-requirement fragment and its context fragment according to the auxiliary information; The designing of a test case based on the sub-requirement fragment and its context fragment includes: designing a test case based on the auxiliary information, the sub-requirement fragment and its context fragment.
8. An electronic device, characterized in that: include: a memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the test case generation method according to any one of claims 1 to 7.
9. A readable storage medium, characterized in that The readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the test case generation method according to any one of claims 1 to 7.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the test case generating method according to any one of claims 1 to 7 is implemented.