A software test case intelligent generation method and system

CN122285525APending Publication Date: 2026-06-26SHANGHAI ROBESTEC ENERGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610606493.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-06
Publication Date
2026-06-26

Smart Images

  • Figure CN122285525A_ABST
    Figure CN122285525A_ABST
Patent Text Reader

Abstract

This application provides a method and system for intelligent generation of software test cases. The method includes: the system acquiring each software requirement document, extracting information from each software requirement document using a large language model to obtain all software functional points, and clustering all software functional points using an improved K-means clustering algorithm to obtain multiple functional types with clear business logic; the system using the multiple functional types with clear business logic to retrieve multiple test cases most relevant to each functional type from a pre-built software test case knowledge base; the system generating a software test case set highly matched to the current software function by inputting the multiple test cases most relevant to each functional type, the specific requirement description of the current software function, and a preset prompt word template into the large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of tool invocation technology, and in particular to a method and system for intelligent generation of software test cases. Background Technology

[0002] As modern software systems grow larger and more complex, the number of test cases that need to be designed for system testing also increases significantly.

[0003] However, manually filling in or writing structured test cases according to fixed templates is not only time-consuming and labor-intensive, but also prone to incomplete test coverage or redundant test cases due to human error or misunderstanding. This inefficiency and high cost become even more pronounced when dealing with large-scale, highly complex software systems. Therefore, traditional manual software test case writing relies heavily on human experience, requiring repeated reading of test outlines, requirements documents, design documents, and interface specifications of the tested objects. This approach suffers from inefficiency, incomplete test coverage, insufficient standardization, and an inability to adapt to the rapid iteration requirements of software. Summary of the Invention

[0004] In view of this, embodiments of this application provide a method for intelligently generating software test cases. One or more embodiments of this application also relate to an intelligent software test case generation system, a computing device, a computer-readable storage medium, and a computer program, to address the technical deficiencies existing in the prior art.

[0005] According to a first aspect of the embodiments of this application, a method for intelligently generating software test cases is provided, comprising: The system acquires each software requirement document, extracts information from each software requirement document using a large language model, obtains all software function points, and uses an improved K-means clustering algorithm to cluster all software function points to obtain multiple function types with clear business logic. The system utilizes the multiple functional types with clear business logic to retrieve the most relevant test cases for each functional type from a pre-built software test case knowledge base; The system generates a set of software test cases that are highly matched to the current software function by inputting multiple test cases most relevant to each function type, the specific requirements description of the current software function, and preset prompt word templates into a large language model.

[0006] Preferably, it further includes: By collecting and organizing relevant data from a large number of software projects, a software test case knowledge base containing multiple software test cases is constructed. At the same time, all software test cases in the knowledge base are classified, deduplicated, and updated and maintained to obtain a software test case knowledge base with accuracy, completeness, and timeliness. Each software test case includes a complete test scenario description, input data, and expected output effect.

[0007] Preferably, the system uses an improved K-means clustering algorithm to cluster all the software function points, resulting in multiple function types with clear business logic, including: The system uses a semantic weight adjustment factor determined by training with a large number of software project samples to calculate the quantized feature value of each software function point in each semantic dimension. The system uses the quantized feature values ​​of each software function point in each semantic dimension to construct a quantized feature vector for each software function point, and uses the quantized feature vectors of each software function point to calculate the clustering objective function value for each iteration. When the difference between the clustering objective function values ​​of two consecutive iterations is less than a preset convergence threshold, the system iteration terminates, and the final clustering result is obtained. The clustering result is then used as a functional type with clear business logic.

[0008] Preferably, the system uses a semantic weight adjustment factor determined by training with a large number of software project samples to calculate the quantized feature value of each software function point in each semantic dimension, including: The system calculates the term frequency-inverse document frequency value for each software function point in each semantic dimension, used to quantify the text features of each software function point. The system calculates the semantic similarity between each software function point and each semantic dimension based on the semantic vector of the Qianwen model. The system uses the semantic weight adjustment factor, the word frequency-inverse document frequency value, and the semantic similarity to calculate the quantitative feature value of each software function point in each semantic dimension.

[0009] Preferably, the system uses the semantic weight adjustment factor, the term frequency-inverse document frequency value, and the semantic similarity to calculate the quantized feature value of each software function point in each semantic dimension, including:

[0010] in, Let be the quantized feature value of the i-th functional point on the j-th semantic dimension; It is a semantic weight adjustment factor; The term frequency-inverse document frequency value of the i-th functional point on the j-th semantic dimension; Let be the semantic similarity between the i-th functional point and the j-th semantic dimension; The frequency of occurrence of the keyword corresponding to the j-th semantic dimension in the ith functional sub-point; It is the inverse document frequency value of the i-th functional point in the j-th semantic dimension.

[0011] Preferably, the system calculates the clustering objective function value for each iteration using the quantized feature vector of each software function point, including: The system calculates the squared first Euclidean distance between each software function point and each category center based on the quantized feature vector of each software function point. The system calculates the squared second Euclidean distance between each category and the center of each category; The system uses inter-class distance weighting factors, the first squared Euclidean distance, and the second squared Euclidean distance to calculate the clustering objective function value for each iteration.

[0012] Preferably, the system calculates the clustering objective function value for each iteration using inter-class distance weighting factors to enhance class discriminative power, the squared first Euclidean distance, and the squared second Euclidean distance, including:

[0013] in, Let be the clustering objective function value for the t-th iteration; This represents the number of cluster categories; This represents the k-th cluster category; Let i be the quantized feature vector of the i-th software function point, which is composed of the quantized feature values ​​of the software function point across all semantic dimensions. constitute; Let the center vector of the k-th cluster category be denoted as 'k'. The square of the first Euclidean distance between the i-th functional point and the k-th category center; This is the inter-class distance weighting factor; For the k-th category and the th The squared second Euclidean distance between the centers of each category; For the first The center vector of each cluster category.

[0014] According to a second aspect of the embodiments of this application, a software test case intelligent generation system is provided, comprising: The acquisition module is configured to acquire each software requirement document, extract information from each software requirement document using a large language model, acquire all software function points, and use an improved K-means clustering algorithm to cluster all software function points to obtain multiple function types with clear business logic. The retrieval module is configured to use the multiple functional types with clear business logic to retrieve multiple test cases most relevant to each functional type from a pre-built software test case knowledge base; The generation module is configured to generate a set of software test cases that are highly matched with the current software function by inputting multiple test cases most relevant to each function type, the specific requirement description of the current software function, and the preset prompt word template into the large language model.

[0015] According to a third aspect of the embodiments of this application, a computing device is provided, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement any of the steps of the intelligent generation method for software test cases.

[0016] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of any one of the software test case intelligent generation methods.

[0017] According to a fifth aspect of the embodiments of this application, a computer program is provided, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described intelligent generation method for software test cases.

[0018] The intelligent software test case generation scheme provided in this application has the following beneficial effects: 1) Significantly improved efficiency: Relying on large language models and knowledge base retrieval technology, it can process massive amounts of software requirement documents in a short time, quickly generate batch test cases, significantly shorten the test case writing cycle, reduce repetitive work for testers, accelerate the software testing process, and effectively adapt to the delivery requirements of rapid software iteration.

[0019] 2) Comprehensive test coverage: Based on a pre-built test case knowledge base and clustered functional types, the retrieved test cases can accurately match various functions of the software, comprehensively cover functional scenarios, boundary conditions and potential risk points, effectively reduce test scenario omissions, reduce the risk of undetected defects after software launch, and improve software operation stability and user experience.

[0020] 3) High level of standardization: Test cases are generated based on a unified large language model and knowledge base retrieval logic. With the same software requirements input, a set of test cases with consistent standards and uniform quality can be obtained. This solves the problem of inconsistent test case quality in the traditional manual writing method, helps to build a stable and reliable software testing quality system, ensures the consistency of test results executed by different testers at different stages, and improves the accuracy of software quality assessment.

[0021] 4) Highly practical: This solution combines the efficiency of intelligent generation with the targeted nature of manual optimization. While reducing the workload of manual operations, it further improves the quality of test cases through manual adjustments and supplements. It is suitable for various software projects, especially large software projects with complex requirements and fast iteration speeds, and has a wide range of application scenarios and practical value. Attached Figure Description

[0022] Figure 1 This is a flowchart of a software test case intelligent generation method provided in one embodiment of this application; Figure 2 This is a schematic diagram of a Markdown table provided in one embodiment of this application; Figure 3 This is a schematic diagram of a software test case intelligent generation system provided in one embodiment of this application; Figure 4 This is a structural block diagram of a computing device provided in one embodiment of this application. Detailed Implementation

[0023] It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. In the following description, suffixes such as "module," "part," or "unit" used to denote elements are used solely for illustrative purposes and have no inherent meaning. Therefore, "module," "part," or "unit" may be used interchangeably.

[0024] This application provides a method for intelligently generating software test cases. It also relates to a system for intelligently generating software test cases, a computing device, a computer-readable storage medium, and a computer program, which will be described in detail in the following embodiments.

[0025] The core objective of this application is to address the technical pain points of traditional manual software test case writing, including low efficiency, incomplete test coverage, insufficient standardization, and inability to adapt to the rapid iteration needs of software. The specific objectives are as follows: 1. Improve the efficiency of test case writing, reduce the time and effort that testers need to spend on reading requirements documents, analyzing business logic, designing test scenarios and data, break through the efficiency limitations of manual writing, and meet the delivery requirements of rapid software iteration.

[0026] 2. To address the issue of incomplete test coverage caused by subjective differences and insufficient experience among testers during the manual writing of test cases, ensure that test cases can fully cover all functions, boundary scenarios, and potential risk points of the software, and reduce the probability of undetected defects appearing after the software goes live.

[0027] 3. Standardize the generation of test cases to avoid differences in style, coverage, and detail caused by varying experience and knowledge background of testers. This will help build a stable and reliable software testing quality system and ensure the accuracy and consistency of test results.

[0028] Figure 1 A flowchart of a software test case intelligent generation method according to an embodiment of this application is shown, which specifically includes the following steps.

[0029] Step S101: The system obtains each software requirement document, extracts information from each software requirement document using a large language model, obtains all software function points, and uses an improved K-means clustering algorithm to cluster all software function points to obtain multiple function types with clear business logic. Step S102: The system uses the multiple functional types with clear business logic to retrieve multiple test cases most relevant to each functional type from a pre-built software test case knowledge base; This application embodiment also includes: by collecting and organizing relevant data from a large number of software projects, constructing a software test case knowledge base containing multiple software test cases, and simultaneously classifying, deduplicating, and updating and maintaining all software test cases in the software test case knowledge base to obtain a software test case knowledge base with accuracy, completeness, and timeliness; wherein, each software test case includes a complete test scenario description, input data, and expected output effect.

[0030] Step S103: The system generates a set of software test cases that are highly matched with the current software function by inputting multiple test cases most relevant to each function type, the specific requirement description of the current software function, and the preset prompt word template into the large language model.

[0031] In one specific embodiment of this application, the system uses an improved K-means clustering algorithm to cluster all the software function points, resulting in multiple function types with clear business logic, including: The system uses a semantic weight adjustment factor determined by training with a large number of software project samples to calculate the quantized feature value of each software function point in each semantic dimension. The system uses the quantized feature values ​​of each software function point in each semantic dimension to construct a quantized feature vector for each software function point, and uses the quantized feature vectors of each software function point to calculate the clustering objective function value for each iteration. When the difference between the clustering objective function values ​​of two consecutive iterations is less than a preset convergence threshold, the system iteration terminates, and the final clustering result is obtained. The clustering result is then used as a functional type with clear business logic.

[0032] In one specific embodiment of this application, the system utilizes a semantic weight adjustment factor determined through training on a large number of software project samples to calculate the quantized feature value of each software function point in each semantic dimension, including: The system calculates the term frequency-inverse document frequency value for each software function point in each semantic dimension, used to quantify the text features of each software function point. The system calculates the semantic similarity between each software function point and each semantic dimension based on the semantic vector of the Qianwen model. The system uses the semantic weight adjustment factor, the word frequency-inverse document frequency value, and the semantic similarity to calculate the quantitative feature value of each software function point in each semantic dimension.

[0033] In one specific embodiment of this application, the system uses the semantic weight adjustment factor, the term frequency-inverse document frequency value, and the semantic similarity to calculate the quantized feature value of each software function point on each semantic dimension, including:

[0034] in, Let be the quantized feature value of the i-th functional point on the j-th semantic dimension; It is a semantic weight adjustment factor; The term frequency-inverse document frequency value of the i-th functional point on the j-th semantic dimension; Let be the semantic similarity between the i-th functional point and the j-th semantic dimension; The frequency of occurrence of the keyword corresponding to the j-th semantic dimension in the ith functional sub-point; It is the inverse document frequency value of the i-th functional point in the j-th semantic dimension.

[0035] In one specific embodiment of this application, the system calculates the clustering objective function value for each iteration using the quantized feature vector of each software function point, including: The system calculates the squared first Euclidean distance between each software function point and each category center based on the quantized feature vector of each software function point. The system calculates the squared second Euclidean distance between each category and the center of each category; The system uses inter-class distance weighting factors, the first squared Euclidean distance, and the second squared Euclidean distance to calculate the clustering objective function value for each iteration.

[0036] In one specific embodiment of this application, the system calculates the clustering objective function value for each iteration using inter-class distance weighting factors for enhancing class discriminative power, the squared first Euclidean distance, and the squared second Euclidean distance, including:

[0037] in, Let be the clustering objective function value for the t-th iteration; This represents the number of cluster categories; This represents the k-th cluster category; Let i be the quantized feature vector of the i-th software function point, which is composed of the quantized feature values ​​of the software function point across all semantic dimensions. constitute; Let the center vector of the k-th cluster category be denoted as 'k'. The square of the first Euclidean distance between the i-th functional point and the k-th category center; This is the inter-class distance weighting factor; For the k-th category and the th The squared second Euclidean distance between the centers of each category; For the first The center vector of each cluster category.

[0038] This application combines large language models, clustering algorithms, and manual optimization techniques to automate the generation of software test cases. The specific technical solution consists of four core components, detailed below: (a) Collecting and organizing the test case knowledge base A large amount of software project-related data is collected and organized in advance to build a test case knowledge base. Each test case includes a complete test scenario description, input data, and expected output results (e.g., the test scenario is "user login normally," the input data is "valid username and password," and the expected output result is "login successful and redirected to the user's homepage"). Simultaneously, the test cases in the knowledge base are categorized, deduplicated, and updated to ensure the accuracy, completeness, and timeliness of the data, providing reliable support for subsequent test case retrieval and generation.

[0039] (II) Requirements Document Analysis and Information Extraction Functional Information Extraction: Using existing large language model technology and leveraging the domestic Qianwen model, we comprehensively extract information from the software requirements document, accurately refine all the software functional points contained in the document, and ensure that no core or detailed functions are missed, providing complete and accurate basic data for subsequent cluster analysis.

[0040] Functional Clustering Classification: An improved K-means clustering algorithm (combined with functional semantic similarity optimization) is used to cluster all extracted software functional points. The core idea is to quantify the scattered functional points through semantic features and calculate similarity, ultimately aggregating them into several test scenario categories with clear business logic. This achieves accurate transformation from functional points to test scenario categories. Its uniqueness lies in introducing a functional semantic weight factor, avoiding the category bias caused by traditional clustering relying solely on textual surface features. The specific formula and derivation are as follows: 1. Formula for quantifying semantic features of functional sub-points:

[0041] The calculation methods for each parameter are specified as follows: - : The quantized feature value of the i-th functional point on the j-th semantic dimension (core quantization indicator, taking into account both text frequency and semantic relevance), calculated based on and Substituting into the above formula, we can directly calculate the result.

[0042] - Semantic weight adjustment factor (value range 0.6~0.8, determined by training with a large number of software project samples, prioritizing semantic relevance weight).

[0043] - The term frequency-inverse document frequency value of the i-th functional point on the j-th semantic dimension is used to quantify the textual features of the functional point. The calculation formula is as follows: ,in: (Term Frequency): The frequency of occurrence of the keyword corresponding to the j-th semantic dimension in the i-th functional sub-point, calculated using the following formula: In the formula, Let j be the number of times the keyword of the j-th semantic dimension appears in the i-th functional sub-point. Let M be the total number of occurrences of all semantic dimension keywords in the i-th functional point, and M be the total number of semantic dimensions. It is the inverse document frequency value of the i-th functional point in the j-th semantic dimension, and the number of functional points containing the keyword of the j-th semantic dimension. The calculation formula is:

[0044] In the formula, For indicator functions, when (That is, when the i-th functional point contains the j-th semantic dimension keyword), ;otherwise N represents the total number of functional points.

[0045] - The semantic similarity between the i-th functional point and the j-th semantic dimension is calculated based on the semantic vector of the domestic Qianwen model, using the following formula:

[0046] in, and The calculation method is as follows: - The semantic vector of the i-th functional point is generated by encoding the text description of the i-th functional point using the domestic Thousand Questions model. The specific calculation formula (based on the model's encoding logic) is as follows:

[0047] In the formula, The text description for the i-th functional point (e.g., "Enter a valid username when registering"). This is the semantic encoding function for the domestically developed "Thousand Questions" model; The vector space dimension is represented by dim=d, where d is the semantic vector dimension (default is 768 dimensions, which can be adjusted according to software complexity). The output is a d-dimensional real vector. In the formula, These are the real vectors of the i-th functional point in the semantic dimensions from the 1st to the dth. - The semantic vector of the j-th semantic dimension, calculated using the same method as... Consistent.

[0048] Additional notes: The dot product of two vectors is calculated using the following formula: ; and Let be the magnitudes of the two vectors, calculated using the formula: , .

[0049] 2. Clustering objective function (optimization objective: minimize intra-cluster semantic distance, maximize inter-cluster semantic distance)

[0050] The calculation methods for each parameter are specified as follows: - : The clustering objective function value of the t-th iteration. The smaller the value, the better the clustering effect. It can be obtained by substituting the parameters.

[0051] - The number of clusters (i.e., the number of test scenario categories) is determined adaptively by the elbow method combined with software functional complexity. ).

[0052] - : The kth cluster category (corresponding to a test scenario category).

[0053] - The quantized feature vector of the i-th functional point is composed of the quantized feature values ​​of that functional point across all semantic dimensions, and is calculated using the following formula:

[0054] In the formula, These are the quantized feature values ​​of the i-th functional point in the 1st to Mth semantic dimensions (i.e., through the first step) (All results calculated by the formula), M is the total number of semantic dimensions, and the final result is... It is an M-dimensional real vector.

[0055] - The center vector of the k-th cluster is calculated using the following formula:

[0056] In the formula, The number of functional points contained in the k-th category. The sum of the quantized feature vectors of all functional points within the k-th category (adding the corresponding dimensions of the vectors), ultimately It is an M-dimensional real vector.

[0057] - The inter-class distance weight factor (value 0.3~0.5) is used to enhance class differentiation and is a unique design of this clustering approach to avoid class overlap.

[0058] - The squared Euclidean distance between the i-th functional point and the k-th category center measures the intra-class cohesion. The formula is as follows:

[0059] In the formula, The center vector of the kth class The component in the j-th semantic dimension.

[0060] - The squared second Euclidean distance between the centers of the k-th and l-th classes measures the inter-class separation. The formula is:

[0061] In the formula, For the first Cluster category center vectors The component in the j-th semantic dimension, For the first The center vector of each cluster category.

[0062] 3. Termination condition for clustering iteration

[0063] in: - : The value of the clustering objective function in the t-th iteration can be obtained by substituting it into the clustering objective function formula; - The clustering objective function value for the (t-1)th iteration, calculated using the same method as... Consistent; - Convergence threshold (value) When the difference between the clustering objective function of two consecutive iterations is less than the threshold, the iteration terminates and the final clustering result is obtained.

[0064] Through the above formula and iterative process, scattered functional points can be accurately integrated and categorized into several clear test scenario categories based on their semantic features and business relevance. This makes the software functional system more organized, and also leverages semantic weighting factors. and inter-class distance weight factor Its unique design improves clustering accuracy and provides reliable support for the subsequent generation of targeted test cases.

[0065] (III) Test Case Generation Test case retrieval and generation: Based on a large amount of pre-collected and organized software project-related data knowledge base, the knowledge base retrieval function of the large language model is used to retrieve and generate n test cases that are most relevant to each function type based on the function types obtained by clustering. This ensures that the generated test cases are highly matched with the software functions, thereby improving the relevance and effectiveness of testing.

[0066] During the retrieval phase, the system leverages the semantic understanding capabilities of the Large Language Model (LLM) to represent the function types segmented by clustering algorithms in the preprocessing phase using feature vectors. Based on this representation, the system performs high-dimensional vector similarity retrieval in the knowledge base (e.g., using cosine similarity or Euclidean distance metrics) to filter out functions with the highest semantic relevance to the current function type. A number of historical test cases.

[0067] A. Relevant test cases retrieved from the knowledge base based on category tags: The input to the knowledge base is "coupon stacking", which is then retrieved from the knowledge base using a large language model.

[0068] The system retrieved the "similar cases" (Top-3): Case ID_101 (from last year's Double 11 project): Test the use of a single coupon to verify whether the amount deduction is correct.

[0069] Case ID_205 (from a financial project): Testing multiple discounts to verify whether negative amounts occur.

[0070] Case ID_309 (from an e-commerce project): Testing boundary values ​​to verify whether the system forcibly sets the discount amount to 0.01 yuan when the discount amount exceeds the total price of the product.

[0071] The system inputs relevant test cases, a detailed description of the current functional requirements, and preset prompt templates into the large language model. Through the model's reasoning and generation capabilities, combined with specific output format constraints (such as Markdown format), it ultimately generates a set of highly relevant and targeted test cases that closely match the current software functionality. This process effectively utilizes testing experience from historical data, significantly improving the accuracy and effectiveness of test case generation.

[0072] B. Specific requirements description for the current function The system inputs: "Please write test cases for the following function: Function name: Double 11 settlement page coupon stacking. Rule 1: Supports stacking 'store coupon' + 'platform coupon'. Rule 2: The actual payment amount after stacking is ≥ the original price of the product × 10% (i.e., the minimum discount limit). Rule 3: If the calculated amount is less than 10%, it will be automatically adjusted to 10% of the original price." C. Preset prompt template system instruction: "You are a senior test engineer. Please refer to the historical test logic in [Part A] and generate multiple core test cases for the new requirements in [Part B]. Output format requirements: Please use a Markdown table with columns: [Test Case Number, Test Case Title, Preconditions, Steps, Expected Result], such as..." Figure 2 As shown.

[0073] (iv) Test case optimization Based on the results retrieved from the knowledge base using the large language model, an initial test case set is generated. This initial test case set undergoes multi-dimensional optimization to ensure its quality and effectiveness. First, duplicate test cases are removed to avoid wasting testing resources. Second, based on the software's risk assessment results and functional importance levels, test cases are prioritized, with higher priority given to test cases involving core business functions and security-critical components. Finally, based on the experience and feedback of testers, the test cases are manually adjusted and supplemented to further improve the test case set and enhance the comprehensiveness of test coverage.

[0074] Figure 3 This illustration shows a structural diagram of an intelligent software test case generation system according to an embodiment of this application, as shown below. Figure 3 As shown, the system includes: an acquisition module, configured to acquire each software requirement document, extract information from each software requirement document using a large language model, acquire all software function points, and cluster all software function points using an improved K-means clustering algorithm to obtain multiple function types with clear business logic; The retrieval module is configured to use the multiple functional types with clear business logic to retrieve multiple test cases most relevant to each functional type from a pre-built software test case knowledge base; The generation module is configured to generate a set of software test cases that are highly matched with the current software function by inputting multiple test cases most relevant to each function type, the specific requirement description of the current software function, and the preset prompt word template into the large language model.

[0075] The above is an illustrative scheme of a software test case intelligent generation system according to this embodiment. It should be noted that the technical solution of this software test case intelligent generation system and the technical solution of the software test case intelligent generation method described above belong to the same concept. Details not described in detail in the technical solution of the software test case intelligent generation system can be found in the description of the technical solution of the software test case intelligent generation method described above.

[0076] Figure 4 A structural block diagram of a computing device 400 according to an embodiment of this application is shown. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and a database 450 is used to store data.

[0077] The computing device 400 also includes an access device 440, which enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.

[0078] In one embodiment of this application, the aforementioned components of the computing device 400 and Figure 4 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 4 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.

[0079] The computing device 400 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 400 can also be a mobile or stationary server.

[0080] The processor 420 is used to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-described intelligent generation method for software test cases.

[0081] An embodiment of this application also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the above-described intelligent software test case generation method.

[0082] An embodiment of this application also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described intelligent software test case generation method.

[0083] The above are illustrative schemes of a computing device, a computer-readable storage medium, and a computer program according to this embodiment. It should be noted that each technical solution belongs to the same concept as the above-described intelligent software test case generation method, and details not described in detail for each technical solution can be found in the description of the above-described intelligent software test case generation method.

[0084] The preferred embodiments of this application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and spirit of this application shall be within the scope of the claims.

Claims

1. A method for intelligently generating software test cases, characterized in that, include: The system acquires each software requirement document, extracts information from each software requirement document using a large language model, obtains all software function points, and uses an improved K-means clustering algorithm to cluster all software function points to obtain multiple function types with clear business logic. The system utilizes the multiple functional types with clear business logic to retrieve the most relevant test cases for each functional type from a pre-built software test case knowledge base; The system generates a set of software test cases that are highly matched to the current software function by inputting multiple test cases most relevant to each function type, the specific requirements description of the current software function, and preset prompt word templates into a large language model.

2. The method according to claim 1, characterized in that, Also includes: By collecting and organizing relevant data from a large number of software projects, a software test case knowledge base containing multiple software test cases is constructed. At the same time, all software test cases in the knowledge base are classified, deduplicated, and updated and maintained to obtain a software test case knowledge base with accuracy, completeness, and timeliness. Each software test case includes a complete test scenario description, input data, and expected output effect.

3. The method according to claim 1, characterized in that, The system uses an improved K-means clustering algorithm to cluster all the software function points, resulting in several function types with clear business logic, including: The system uses a semantic weight adjustment factor determined by training with a large number of software project samples to calculate the quantized feature value of each software function point in each semantic dimension. The system uses the quantized feature values ​​of each software function point in each semantic dimension to construct a quantized feature vector for each software function point, and uses the quantized feature vectors of each software function point to calculate the clustering objective function value for each iteration. When the difference between the clustering objective function values ​​of two consecutive iterations is less than a preset convergence threshold, the system iteration terminates, and the final clustering result is obtained. The clustering result is then used as a functional type with clear business logic.

4. The method according to claim 3, characterized in that, The system utilizes semantic weight adjustment factors determined through training on a large number of software project samples to calculate the quantized feature values ​​of each software function point in each semantic dimension, including: The system calculates the term frequency-inverse document frequency value for each software function point in each semantic dimension, used to quantify the text features of each software function point. The system calculates the semantic similarity between each software function point and each semantic dimension based on the semantic vector of the Qianwen model. The system uses the semantic weight adjustment factor, the word frequency-inverse document frequency value, and the semantic similarity to calculate the quantitative feature value of each software function point in each semantic dimension.

5. The method according to claim 4, characterized in that, The system utilizes the semantic weight adjustment factor, the term frequency-inverse document frequency value, and the semantic similarity to calculate the quantified feature value of each software function point in each semantic dimension, including: in, Let be the quantized feature value of the i-th functional point on the j-th semantic dimension; It is a semantic weight adjustment factor; The term frequency-inverse document frequency value of the i-th functional point on the j-th semantic dimension; Let be the semantic similarity between the i-th functional point and the j-th semantic dimension; The frequency of occurrence of the keyword corresponding to the j-th semantic dimension in the ith functional sub-point; It is the inverse document frequency value of the i-th functional point in the j-th semantic dimension.

6. The method according to claim 5, characterized in that, The system uses the quantized feature vector of each software function point to calculate the clustering objective function value for each iteration, including: The system calculates the squared first Euclidean distance between each software function point and each category center based on the quantized feature vector of each software function point. The system calculates the squared second Euclidean distance between each category and the center of each category; The system uses inter-class distance weighting factors, the first squared Euclidean distance, and the second squared Euclidean distance to calculate the clustering objective function value for each iteration.

7. The method according to claim 6, characterized in that, The system utilizes inter-class distance weighting factors to enhance class discriminative power, the squared first Euclidean distance, and the squared second Euclidean distance to calculate the clustering objective function value for each iteration, including: in, Let be the clustering objective function value for the t-th iteration; This represents the number of cluster categories; This represents the k-th cluster category; Let i be the quantized feature vector of the i-th software function point, which is composed of the quantized feature values ​​of the software function point across all semantic dimensions. constitute; Let the center vector of the k-th cluster category be denoted as 'k'. The square of the first Euclidean distance between the i-th functional point and the k-th category center; This is the inter-class distance weighting factor; For the k-th category and the th The squared second Euclidean distance between the centers of each category; For the first The center vector of each cluster category.

8. A software test case intelligent generation system, characterized in that, include: The acquisition module is configured to acquire each software requirement document, extract information from each software requirement document using a large language model, acquire all software function points, and use an improved K-means clustering algorithm to cluster all software function points to obtain multiple function types with clear business logic. The retrieval module is configured to use the multiple functional types with clear business logic to retrieve multiple test cases most relevant to each functional type from a pre-built software test case knowledge base; The generation module is configured to generate a set of software test cases that are highly matched with the current software function by inputting multiple test cases most relevant to each function type, the specific requirement description of the current software function, and the preset prompt word template into the large language model.

9. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, they implement the steps of the intelligent generation method for software test cases according to any one of claims 1 to 7.

10. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the intelligent generation method for software test cases according to any one of claims 1 to 7.