Software configuration item test case automatic generation method based on large language model

Through the automatic generating method based on software configuration items based on large language models, the problem of the flexibility and transplantability of software testing systems in existing technologies has been solved. The level of automation.

CN119336609AActive Publication Date: 2025-01-21XIAN ZHONGLANG AL TECH CO LTD

Patent Information

Application Number
CN202411884199.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-01-21
Estimated Expiration
2044-12-20

AI Technical Summary

Technical Problem

The prior art relies on FPGA modules and signal conversion modules in software testing, resulting in limited flexibility and portability of the system, difficult to adapt to changes in software requirements and design, and requires manual intervention to generate and parse test sequences.

Method used

Automatically generate the test case of software configuration items based on large language models, through intelligent text segmentation, prompt constructing and testing cases, improve the production efficiency and accuracy of test cases, and ensure the targeted and coverage of test cases.

Benefits of technology

It significantly reduces the workload of manually writing test cases, improves the quality of test cases and the automation level of software testing, and enhances the flexibility and portability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336609A_ABST
    Figure CN119336609A_ABST
Patent Text Reader

Abstract

The invention discloses a software configuration item test case automatic generation method based on a large language model, and relates to the technical field of software testing. In order to solve the problems that in the prior art, the flexibility and transportability of a system are limited, the system is difficult to adapt to constantly changing software requirements and designs, and manual intervention is still needed to generate and analyze a test sequence. According to the automatic generation method for the software configuration item test case based on the large language model, through intelligent text segmentation, prompt word construction and test case generation, the efficiency and accuracy of test case generation are improved, the pertinence and coverage of the test case are ensured, and the workload of manually compiling the test case is remarkably reduced; a knowledge graph of software configuration items is constructed, so that the understanding of the model on correlation and similarity among texts is enhanced, and the quality of test case generation is improved; and through a real-time feedback and optimization mechanism, the automation level and the test efficiency of software testing are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular to a method for automatically generating test cases for software configuration items based on a large language model. Background Art

[0002] With the continuous increase in software scale and complexity, the traditional manual test case writing method has been unable to meet the needs of efficient and comprehensive testing. For example, the Chinese patent with publication number: CN104866423B discloses a test method and system for software configuration items, and the system includes a network interface module, a CPU processing module, an FPGA module, a signal conversion module, an interface conversion module and a storage module; the network interface module is used to receive the test sequence sent by the test control terminal; the CPU processing module is used to receive the test sequence, parse and schedule the test sequence, generate corresponding test instructions, and configure the test interface parameters of the corresponding test instructions; the FPGA module generates the configuration interface timing relationship and test data according to the test interface parameters; the signal conversion module is used to convert the interface timing relationship and test data into test stimulus information matching the test device; the interface conversion module is used to feed back the response information made by the device under test according to the test stimulus information to the FPGA module; the storage module is used to store the response information.

[0003] Although the above patents have improved the level of test automation to a certain extent, they rely on FPGA modules, signal conversion modules, etc., which limits the flexibility and portability of the system and makes it difficult to adapt to changing software requirements and designs. Manual intervention is still required to generate and parse test sequences. Summary of the invention

[0004] The purpose of the present invention is to provide a method for automatically generating test cases for software configuration items based on a large language model. Through intelligent text segmentation, prompt word construction and test case generation, not only the efficiency and accuracy of test case generation are improved, but also the pertinence and coverage of test cases are ensured, and the workload of manually writing test cases is significantly reduced, so as to solve the problems raised in the above-mentioned background technology.

[0005] To achieve the above object, the present invention provides the following technical solutions: The method for automatically generating test cases for software configuration items based on a large language model comprises the following steps: Step 1: Build the environment: Select the corresponding large language model according to the characteristics of the software configuration items and test requirements, install and configure the framework for building applications based on the large language model, and install and configure related components; Step 2: Construct prompt words: Based on the framework and related components, a software project document library is established, which includes requirement documents and design documents related to software configuration items, and the requirement documents and design documents obtained from the software project document library are divided into multiple small text fragments to generate a small text list; At the same time, it stores and memorizes the context information of the small text fragments, parses the content of the small text list, and constructs prompt words; Step 3: Test case generation: passing the constructed prompt words to the large language model to generate test cases for the software configuration items, and feeding back the generated test cases to the testers in real time through the framework; Step 4: Test case evaluation and optimization: Save the generated test cases in a predetermined format. At the same time, establish a test case library to classify, annotate and optimize the test cases.

[0006] Furthermore, the construction environment is specifically: Analyze software configuration items: Analyze software configuration items to determine key information on software functional characteristics, performance indicators, and interface design; Select the big prediction model: Determine the required natural language processing capabilities based on the software functional characteristics, performance indicators, and key information of interface design, and select the corresponding big language model based on the needs of generating test cases; Install and configure the framework: Create a Python virtual environment, install the application development library that supports the large language model in the environment, and configure the large language model parameters; Configure related components: Install and configure related components, including text segmenter, file format parser, requirement document analysis tool, and design document visualization tool. After the configuration is complete, test each related component.

[0007] Furthermore, the building environment also includes training the selected large language model, and the specific steps include: Data processing: collect text data of software configuration items, identify the text data, and filter out target text data that meets the test requirements; Feature extraction: extract text features from the filtered target text data, and generate a text feature dataset for training based on the extraction results; Model training: Train the large language model based on the text feature dataset to optimize the large language model's ability to understand and generate text related to software configuration items; Model output: Verify the trained large language model, determine whether the performance of the trained large language model meets the predetermined standards based on the verification results, and output the large language model that meets the predetermined standards.

[0008] Furthermore, the data processing also includes constructing a knowledge graph of software configuration items, specifically: Define the specific instance of the software configuration item as the key node in the software configuration item knowledge graph, match the specific instance with the existing software library, and input the detailed data of the software configuration item into the software library based on the matching result; Draw a knowledge graph of software configuration items based on the detailed data of the software library, and align entities between the knowledge graphs of software configuration items; Perform large language model training based on information in the software configuration item knowledge graph.

[0009] Furthermore, constructing the prompt words in the step 2 also includes: classifying the requirement documents and design documents collected in the software project document library according to document type and relevance, and preprocessing the classified requirement documents and design documents.

[0010] Furthermore, in step 2, the requirement document and design document obtained from the software project document library are segmented into multiple small text segments, specifically including: Load the requirement document and design document into the file format parser to parse the document content and determine the document structure of the requirement document and design document; Identify key information in requirement documents and design documents based on document structure and set a maximum text fragment length; Taking the natural paragraphs in the requirement document and the design document as the preliminary segmentation unit, obtaining the content length of each paragraph, and if it exceeds the set maximum text segment length, segmenting the natural paragraph into sentences that meet the maximum text segment length and maintaining the integrity of the sentence; A context window is set at each segmentation point, including related sentences and words before and after, wherein the segmentation point is avoided to be located in the middle of the key information; A plurality of small text segments are generated based on the segmentation result, and a unique number is assigned to each small text segment. Each small text segment is arranged according to the unique number to generate a small text list.

[0011] Furthermore, the maximum text segment length is set, including: Extract key information from requirement documents and design documents; Extract key words contained in each key information from each key information; Extract the number of characters corresponding to each keyword and the frequency of each keyword appearing in the requirements document and design document; Retrieving key words in the requirement document and the design document whose frequencies are lower than a preset first frequency threshold as first keyword data; Obtaining a first setting coefficient using the number of characters of the key words included in the first keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The first setting coefficient is obtained by the following formula: Among them, J 01 represents the first setting coefficient; n represents the total number of key words contained in the first keyword data; L 01i represents the number of characters of the i-th keyword in the first keyword data; L 01b represents the standard deviation of the number of characters of the n key words in the first key word data; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; f 01i represents the frequency of the i-th keyword in the first keyword data appearing in the requirement document and the design document; f 01c represents the first frequency threshold; f 01b represents the frequency standard deviation of n key words in the first keyword data in the requirement document and the design document; Retrieving key words in the requirement document and the design document whose frequencies exceed a preset second frequency threshold as second keyword data; Obtaining a second setting coefficient using the number of characters of the key words included in the second keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The second setting coefficient is obtained by the following formula: Among them, J 02 represents the second setting coefficient; m represents the total number of key words contained in the second keyword data; L 02i represents the number of characters of the i-th keyword in the second keyword data; L 02b represents the standard deviation of the number of characters of the m key words in the second key word data; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; R 02 represents a preset second reference coefficient, and the value range of the second reference coefficient is 1.24-1.53; f 02i represents the frequency of the i-th keyword in the second keyword data appearing in the requirement document and the design document; f 02c represents the second frequency threshold; f 02b represents the frequency standard deviation of the m key words in the second key word data in the requirement document and the design document; The maximum text segment length is set using the first setting coefficient and the second setting coefficient.

[0012] Further, using the first setting coefficient and the second setting coefficient to set the maximum text segment length includes: extracting a first setting coefficient and a second setting coefficient; Comparing the first setting coefficient with a preset first coefficient threshold; comparing the second setting coefficient with a preset second coefficient threshold; When the first setting coefficient exceeds a preset first coefficient threshold, and the second setting coefficient exceeds a preset second coefficient threshold, the first setting coefficient and the second setting coefficient are used to set the maximum text segment length; The maximum text segment length is obtained by the following formula: Among them, H max represents the maximum text segment length, and H max Indicated as rounded up; J 02 Indicates the second setting coefficient; J 01 Indicates the first setting coefficient; J 02c represents the second coefficient threshold; J 01c represents the first coefficient threshold; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; R 02 represents a preset second reference coefficient, and the value range of the second reference coefficient is 1.24-1.53; H c Indicates the preset initial text segment length; When the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and when the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, the maximum text fragment length is set using keywords whose frequency of appearance in the requirement document and the design document is not lower than the preset first frequency threshold, but lower than the preset second frequency threshold.

[0013] Further, when the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, the maximum text segment length is set using keywords whose frequencies in the requirement document and the design document are not lower than the preset first frequency threshold, but lower than the preset second frequency threshold, including: When the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, then retrieve the key words in the requirement document and the design document whose frequency is not lower than the preset first frequency threshold, but lower than the preset second frequency threshold as the third keyword data; Obtaining a third setting coefficient using the number of characters of the key words included in the third keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The third setting coefficient is obtained by the following formula: Among them, J 03 represents the third setting coefficient; k represents the total number of key words contained in the third keyword data; L 03i represents the number of characters of the i-th keyword in the third keyword data; L 03b represents the standard deviation of the number of characters of k key words in the third key word data; R 03 represents a preset third reference coefficient, and the value range of the third reference coefficient is 1.19-1.42; f 03i represents the frequency of the i-th keyword in the third keyword data appearing in the requirement document and the design document; f 01c represents the first frequency threshold; f 02c represents the second frequency threshold; f 03b represents the frequency standard deviation of k key words in the third keyword data in the requirement document and the design document; The third setting coefficient is used to set the maximum text segment length, wherein the maximum text segment length is obtained by the following formula: Among them, H max represents the maximum text segment length, and H max Indicates rounding up; H c Indicates the preset initial text segment length; J 03 Indicates the third setting coefficient; R 03 represents a preset third reference coefficient, and the value range of the third reference coefficient is 1.19-1.42; J 02 Indicates the second setting coefficient; J 01 Indicates the first setting coefficient.

[0014] Furthermore, the step 2 of parsing the small text list content and constructing prompt words specifically includes: Traverse the small text list, read each small text segment, and analyze the key information in each small text segment; Matching the key information with a preset prompt word template, and inputting the key information into the corresponding prompt word template based on the matching result to generate a complete prompt word; At the same time, test case feedback data generated by the large language model is obtained, and the prompt words are optimized based on the test case feedback data.

[0015] Furthermore, the test case generated in step 3 specifically includes: Test case ID: Assign a unique identifier to each test case; Test purpose: The purpose and goal of the test case; Preconditions: The conditions that must be met before executing the test case; Test steps: The steps to execute the test; Input data: The data entered during the test; Expected results: The expected results after executing the test steps; Actual results: The actual results after executing the test steps; Test conclusion: Whether the test result is successful.

[0016] Compared with the prior art, the present invention has the following beneficial effects: Through intelligent text segmentation, prompt word construction and test case generation, not only the efficiency and accuracy of test case generation are improved, but also the pertinence and coverage of test cases are ensured, significantly reducing the workload of manual test case writing; by building a knowledge graph of software configuration items, the model's understanding of the correlation and similarity between texts is enhanced, thereby improving the quality of test case generation; at the same time, through real-time feedback and optimization mechanisms, test cases are continuously adjusted and improved, making the generated test cases more in line with actual needs, effectively improving the automation level and testing efficiency of software testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 The invention discloses a method step diagram for automatically generating software configuration item test cases based on a large language model. DETAILED DESCRIPTION

[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0019] In order to solve the technical problems that the existing technology relies on FPGA modules, signal conversion modules, etc., resulting in limited flexibility and portability of the system, making it difficult to adapt to changing software requirements and designs, and still requiring manual intervention to generate and parse test sequences, please refer to Figure 1, this embodiment provides the following technical solutions: The method for automatically generating test cases for software configuration items based on a large language model comprises the following steps: Step 1: Build the environment: Select the corresponding large language model according to the characteristics of the software configuration items and test requirements. For example, select the GPT series model with powerful natural language processing and generation capabilities, install and configure the framework for building large language model-based applications, such as Langchain, Hugging Face's Transformers, etc.; at the same time, install and configure related components, including text segmenters, file format parsers, etc.; Step 2: Build prompt words: Establish a software project document library, including the requirements documents and design documents related to the software configuration items, collect the corresponding requirements documents and design documents from the software project document library, and classify them according to document type and relevance. Preprocess the classified requirements documents and design documents, such as removing irrelevant format information, unifying terminology and naming conventions, to ensure that the information received by the model is of higher quality; Based on the framework and related components (such as csv, json, html, pdf, etc.), the requirement document (PRD) and design document (TDD) are divided into multiple small text fragments to generate a small text list, where PRD and TDD contain key information such as functional requirements, performance requirements, interface design, etc. of the software configuration items; At the same time, use the Memory module (such as ConversationBufferMemory and ConversationSummaryBufferMemory) to store and memorize the context information of small text fragments, reduce the number of interactions with the large language model, parse the content of the small text list, and build prompt words to ensure that the prompt words can guide the large language model to generate test cases that meet the requirements; Step 3: Test case generation: The constructed prompt words are passed to the large language model to generate test cases for the software configuration items. The test cases include: various functional scenarios, boundary conditions and exception handling of the software configuration items. The generated test cases are fed back to the testers in real time through the framework for further review and execution, including: Test case ID: a unique identifier is assigned to each test case; Test purpose: the purpose and goal of the test case; Preconditions: the conditions that must be met before executing the test case; Test steps: the steps to execute the test; Input data: the data entered during the test; Expected results: the expected results after executing the test steps; Actual results: the actual results after executing the test steps; Test conclusion: whether the test result is successful; Step 4: Test case evaluation and optimization: Save the generated test cases in a predetermined format, such as Markdown, Excel, etc., for easy subsequent use and management. At the same time, establish a test case library to classify, annotate and optimize the test cases to improve the efficiency and accuracy of subsequent use.

[0020] In this embodiment, in order to prevent the large model from responding late or exceeding the token limit due to too much content being passed in at one time, the framework's text segmenter is used to segment the file into multiple small text lists. The test engineer evaluates the effectiveness and coverage of the generated test cases, and based on the evaluation results, provides feedback to the large language model for further optimization to improve the generation of test cases.

[0021] In this embodiment, through intelligent text segmentation, prompt word construction and test case generation, not only the efficiency and accuracy of test case generation are improved, but also the pertinence and coverage of test cases are ensured, and the workload of manual test case writing is significantly reduced; by building a knowledge graph of software configuration items, the model's understanding of the correlation and similarity between texts is enhanced, thereby improving the quality of test case generation; at the same time, through real-time feedback and optimization mechanisms, test cases are continuously adjusted and improved, so that the generated test cases are more in line with actual needs, effectively improving the automation level and testing efficiency of software testing.

[0022] In this embodiment, the construction environment is specifically: Analyze software configuration items: Analyze software configuration items to determine key information on software functional characteristics, performance indicators, and interface design; Select a large prediction model: Determine the required natural language processing capabilities based on the software functional characteristics, performance indicators, and key information of the interface design. Combined with the needs of generating test cases, select the corresponding large language model, such as GPT-3 or GPT-4, to ensure that the model has sufficient natural language processing and generation capabilities; Installation and configuration framework: Create a Python virtual environment, install the application development library that supports the large language model in the environment, and configure the large language model parameters to provide support for subsequent test case generation; Configure related components: Install and configure related components, including text segmenters, file format parsers, requirement document analysis tools, and design document visualization tools, to facilitate the processing of requirement documents and design documents. After the configuration is completed, test each related component to ensure that they can correctly process actual requirement documents and design documents.

[0023] In this embodiment, the software configuration items are analyzed, including clarifying all functional points of the software, including user interface, business logic and data processing, etc., identifying which functions are core functions according to functional characteristics, and prioritizing them, understanding the interaction methods between different functions and the interaction methods in response to user input; determining performance indicators such as the software's response time, number of concurrent users, and data processing capabilities, and understanding hardware resource limitations such as CPU, memory, storage, etc.; listing all external and internal interfaces, including APIs, database connections, service calls, etc., analyzing the data formats used by the interfaces, such as JSON, XML, etc., and checking the completeness and accuracy of the interface documents.

[0024] In this embodiment, the building environment further includes training the selected large language model, and the specific steps include: Data processing: Collect text data of software configuration items, including requirement documents, design documents, design specifications, historical test cases, user feedback, etc., identify the text data, and filter out target text data that meets the test requirements, for example: For functional testing, filter out texts describing function points, user stories, and business processes; For performance testing, identify text containing performance metrics and hardware resource limits; For interface testing, find the documentation section that describes the API interface and database connection; Feature extraction: extract text features from the filtered target text data, and generate a text feature dataset for training based on the extraction results; Model training: Train the large language model based on the text feature dataset to optimize the large language model's ability to understand and generate text related to software configuration items; Model output: Verify the trained large language model, determine whether the performance of the trained large language model meets the predetermined standards based on the verification results, and output the large language model that meets the predetermined standards.

[0025] In this embodiment, the data processing further includes constructing a knowledge graph of software configuration items, specifically: Define specific instances of software configuration items as key nodes in the software configuration item knowledge graph, such as specific functional modules, business logic units, etc., and match specific instances with existing software libraries. Based on the matching results, input detailed data of software configuration items into the software library, including functional descriptions, interface definitions, performance parameters, etc.; Draw a knowledge graph of software configuration items based on the detailed data of the software library, where nodes represent functional points, business processes, etc., and edges represent the relationship between them; and align entities between software configuration item knowledge graphs to ensure that the same or similar functional points can be matched in different graphs; A large language model is trained based on the information in the software configuration item knowledge graph, so that it can understand the correlation and similarity between texts related to software configuration items.

[0026] In this embodiment, by combining large language model training and the construction of a software configuration item knowledge graph, the efficiency and quality of test case generation are improved. Developers and testers can obtain test cases faster and reduce the workload of manually writing test cases. At the same time, the generated test cases are more targeted and comprehensive, and can better meet the needs of software testing.

[0027] In this embodiment, in step 2, the requirement document and design document obtained from the software project document library are divided into multiple small text segments, specifically including: Load the requirement document and design document into the file format parser to parse the document content and determine the document structure of the requirement document and design document, such as chapters, paragraphs, lists, etc., to determine the appropriate segmentation points; Identify key information in requirement documents and design documents based on document structure, such as functional descriptions, performance indicators, interface definitions, etc., and set the maximum text segment length; Taking the natural paragraphs in the requirement document and the design document as the preliminary segmentation unit, obtaining the content length of each paragraph, and if it exceeds the set maximum text segment length, segmenting the natural paragraph into sentences that meet the maximum text segment length and maintaining the integrity of the sentence; A context window is set at each segmentation point, including related sentences and words before and after, so as to provide sufficient context information; wherein the segmentation point is not located in the middle of the key information, such as not in the middle of the function point description or performance index, to ensure that each small text segment contains complete key information, such as a single function point or performance index; Generate multiple small text segments based on the segmentation results, assign a unique number to each small text segment, arrange each small text segment according to the unique number, and generate a small text list to facilitate subsequent tracking and context reconstruction; Specifically, the maximum text segment length is set, including: Extract key information from requirement documents and design documents; Extract key words contained in each key information from each key information; Extract the number of characters corresponding to each keyword and the frequency of each keyword appearing in the requirements document and design document; Retrieving key words in the requirement document and the design document whose frequencies are lower than a preset first frequency threshold as first keyword data; Obtaining a first setting coefficient using the number of characters of the key words included in the first keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The first setting coefficient is obtained by the following formula: Among them, J 01 represents the first setting coefficient; n represents the total number of key words contained in the first keyword data; L 01i represents the number of characters of the i-th keyword in the first keyword data; L 01b represents the standard deviation of the number of characters of the n key words in the first key word data; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; f 01i represents the frequency of the i-th keyword in the first keyword data appearing in the requirement document and the design document; f 01c represents the first frequency threshold; f 01b represents the frequency standard deviation of n key words in the first keyword data in the requirement document and the design document; Retrieving key words in the requirement document and the design document whose frequencies exceed a preset second frequency threshold as second keyword data; Obtaining a second setting coefficient using the number of characters of the key words included in the second keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The second setting coefficient is obtained by the following formula: Among them, J 02 represents the second setting coefficient; m represents the total number of key words contained in the second keyword data; L 02i represents the number of characters of the i-th keyword in the second keyword data; L 02b represents the standard deviation of the number of characters of the m key words in the second key word data; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; R 02 represents a preset second reference coefficient, and the value range of the second reference coefficient is 1.24-1.53; f 02i represents the frequency of the i-th keyword in the second keyword data appearing in the requirement document and the design document; f 02c represents the second frequency threshold; f 02b represents the frequency standard deviation of the m key words in the second key word data in the requirement document and the design document; The maximum text segment length is set using the first setting coefficient and the second setting coefficient.

[0028] The technical effect of the above technical solution is: by extracting key information and keywords from the requirement documents and design documents, the technical solution can more accurately identify the core content of the requirement documents and design documents. This helps to more accurately analyze and utilize this information in subsequent processing. By calculating the first setting coefficient and the second setting coefficient, the technical solution can comprehensively consider factors such as the number of characters, frequency of occurrence, and standard deviation of these data of the keywords, so as to set a more reasonable maximum text segment length. This helps to ensure that the extracted text segment contains sufficient information without being too lengthy. The technical solution filters keywords through a preset frequency threshold, reduces the amount of data to be processed, and thus improves processing efficiency. At the same time, by introducing statistics such as standard deviation to optimize the setting coefficient calculation, the efficiency and accuracy of the calculation are further improved. The setting coefficient calculation formula in the technical solution includes an adjustable reference coefficient (R 01 and R 02 ), which enables the system to be flexibly adjusted according to specific application scenarios and needs. This adaptive ability helps to improve the flexibility and versatility of the system. Since this technical solution can handle complex documents containing a large amount of key information and keywords, it is applicable to various types of text data. This makes this technical solution have broad application prospects in text mining, information retrieval, natural language processing and other fields.

[0029] In summary, the technical effects of this technical solution in terms of performance indicators are mainly reflected in improving the accuracy of information extraction, enhancing the rationality of text segment length, optimizing processing efficiency, improving the system's adaptive ability, and supporting complex document processing. These effects together constitute the unique advantage of this technical solution in setting the maximum text segment length.

[0030] Specifically, using the first setting coefficient and the second setting coefficient to set the maximum text segment length includes: extracting a first setting coefficient and a second setting coefficient; Comparing the first setting coefficient with a preset first coefficient threshold; comparing the second setting coefficient with a preset second coefficient threshold; When the first setting coefficient exceeds a preset first coefficient threshold, and the second setting coefficient exceeds a preset second coefficient threshold, the first setting coefficient and the second setting coefficient are used to set the maximum text segment length; The maximum text segment length is obtained by the following formula: Among them, Hmax represents the maximum text segment length, and H max Indicated as rounded up; J 02 Indicates the second setting coefficient; J 01 Indicates the first setting coefficient; J 02c represents the second coefficient threshold; J 01c represents the first coefficient threshold; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; R 02 represents a preset second reference coefficient, and the value range of the second reference coefficient is 1.24-1.53; H c Indicates the preset initial text segment length; When the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and when the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, the maximum text fragment length is set using keywords whose frequency of appearance in the document is not lower than the preset first frequency threshold, but lower than the preset second frequency threshold.

[0031] The technical effect of the above technical solution is: by comparing the first setting coefficient with the preset first coefficient threshold value, and the second setting coefficient with the preset second coefficient threshold value, the technical solution can ensure that when setting the maximum text segment length, the number of characters, the frequency of occurrence, and the standard deviation of these data of the key words are fully considered. This helps to improve the accuracy of the text segment length and make it closer to the actual content of the document. The technical solution provides a variety of ways to set the maximum text segment length. When the first setting coefficient and the second setting coefficient both exceed the preset threshold value, a specific formula is used to calculate the maximum text segment length; when this condition is not met, the key words with a frequency of occurrence in the document within a specific range are used to set it. This design enhances the flexibility of the system and enables it to adapt to different types of documents and application scenarios. Through the preset coefficient threshold value and frequency threshold value, the technical solution can reduce the amount of data to be processed, thereby improving processing efficiency. At the same time, using the setting coefficient for calculation also avoids a complex iterative process, further improving the calculation efficiency. When the first setting coefficient and the second setting coefficient do not exceed the preset threshold value, the technical solution uses the key words with a frequency of occurrence in the document within a specific range to set the maximum text segment length. This helps to ensure that the extracted text segment contains enough information to avoid missing important content. Since this technical solution can process complex documents containing a large amount of key information and key words, and reasonably set the maximum text segment length according to the document content, it is applicable to various types of text data. This makes this technical solution have broad application prospects in the fields of text mining, information retrieval, natural language processing, etc. Parameters such as coefficient threshold, frequency threshold and reference coefficient in this technical solution can be adjusted according to specific needs, which helps to improve the adaptability and scalability of the system. At the same time, this technical solution can also serve as the basis or component of other more complex algorithms to further expand its scope of application.

[0032] In summary, the technical effects of this technical solution in terms of performance indicators are mainly reflected in improving the accuracy of text segment length, enhancing system flexibility, optimizing processing efficiency, improving the integrity of information extraction, supporting the processing of complex documents, and facilitating adjustment and expansion. These effects together constitute the unique advantage of this technical solution in setting the maximum text segment length.

[0033] Specifically, when the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, the maximum text segment length is set using keywords whose frequency of appearance in the document is not lower than the preset first frequency threshold but lower than the preset second frequency threshold, including: When the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, then retrieve the key words in the requirement document and the design document whose frequency is not lower than the preset first frequency threshold, but lower than the preset second frequency threshold as the third keyword data; Obtaining a third setting coefficient using the number of characters of the key words included in the third keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The third setting coefficient is obtained by the following formula: Among them, J 03 represents the third setting coefficient; k represents the total number of key words contained in the third keyword data; L 03i represents the number of characters of the i-th keyword in the third keyword data; L 03b represents the standard deviation of the number of characters of k key words in the third key word data; R 03 represents a preset third reference coefficient, and the value range of the third reference coefficient is 1.19-1.42; f 03i represents the frequency of the i-th keyword in the third keyword data appearing in the requirement document and the design document; f 01c represents the first frequency threshold; f 02c represents the second frequency threshold; f 03b represents the frequency standard deviation of k key words in the third keyword data in the requirement document and the design document; The third setting coefficient is used to set the maximum text segment length, wherein the maximum text segment length is obtained by the following formula: Among them, H max represents the maximum text segment length, and H max Indicates rounding up; H c Indicates the preset initial text segment length; J 03 Indicates the third setting coefficient; R 03 represents a preset third reference coefficient, and the value range of the third reference coefficient is 1.19-1.42; J 02 Indicates the second setting coefficient; J 01 Indicates the first setting coefficient.

[0034] The technical effect of the above technical solution is: when the first setting coefficient and the second setting coefficient do not exceed the preset threshold, the technical solution can automatically retrieve the keywords with a frequency between the first frequency threshold and the second frequency threshold in the demand document and the design document as the third keyword data, and use these data to calculate the third setting coefficient. In this way, the maximum text segment length finally set can better adapt to the actual content of the document, avoiding information omission or redundancy caused by overly strict or loose settings. By introducing the third setting coefficient and the corresponding calculation formula, the technical solution can provide a reasonable maximum text segment length setting in different situations. This design enhances the robustness of the system, enabling it to maintain stable performance in various complex scenarios. Using the number of keyword characters and the frequency of occurrence in the third keyword data to calculate the third setting coefficient helps to ensure that the extracted text segment contains enough information. At the same time, by reasonably setting the maximum text segment length, it can be avoided that the segment is too long and difficult to process, or that important information is omitted because the segment is too short. The technical solution directly calculates the maximum text segment length through a preset reference coefficient and a calculation formula, avoiding complex iterative processes or manual adjustments. This helps to improve processing efficiency and reduce computing time and resource consumption. Parameters such as the reference coefficient and the initial text segment length in this technical solution can be adjusted according to specific needs. This design makes the system more flexible and can adapt to different application scenarios and needs. At the same time, this technical solution can also serve as the basis or component of other more complex algorithms, further expanding its scope of application. Since this technical solution can handle complex documents containing a large amount of key information and keywords, and reasonably set the maximum text segment length according to the content of the document, it is suitable for various types of text data. This makes this technical solution have broad application prospects in the fields of text mining, information retrieval, natural language processing, etc.

[0035] In summary, the technical effects of this technical solution in terms of performance indicators are mainly reflected in improving the adaptability of text segment length, enhancing the robustness of the system, optimizing the integrity of information extraction, improving processing efficiency, facilitating adjustment and expansion, and supporting the processing of complex documents. These effects together constitute the unique advantage of this technical solution in setting the maximum text segment length.

[0036] In this embodiment, by setting the context window and ensuring that the segmentation point is not in the middle of the key information, the text segmenter can intelligently identify and retain the context information of the text segment, avoiding the destruction of the continuity and integrity of the key information during segmentation. The segmentation strategy can also be adjusted according to the model feedback to optimize the context window size and segmentation point selection; In this embodiment, the step 2 of parsing the small text list content and constructing prompt words specifically includes: Traverse the small text list, read each small text fragment, and analyze the key information in each small text fragment, such as function points, performance indicators, interface definitions, user stories, business rules, etc.; Matching the key information with a preset prompt word template, and inputting the key information into the corresponding prompt word template based on the matching result to generate a complete prompt word; Among them, the prompt word template includes: Test purpose: According to the functional description in the text fragment, explain the purpose of the test case, such as "verify the user login function". Test steps: guide the model to generate specific operation steps, and write the guiding language of the test steps according to the functional points, such as "enter a valid user name and password, and click the login button". Expected results: According to the functional expectations, describe the expected results after executing the test steps, such as "the user has successfully logged in and jumped to the homepage". Test conditions: According to the functional requirements, point out the prerequisites for executing the test, such as "the user has registered and the account is valid"; At the same time, test case feedback data generated by the large language model is obtained, and the prompt words are optimized based on the test case feedback data.

[0037] In this embodiment, by constructing small text fragments containing sufficient contextual information and combining them with prompt word templates, the large language model is guided to generate more accurate and targeted test cases, thereby improving the quality of test cases. By traversing the small text list and analyzing key information, combined with the use of prompt words, the large language model's ability to understand text related to software configuration items is enhanced, enabling it to more effectively generate test cases that meet the requirements, providing accurate input for the large language model, thereby significantly improving the overall performance and practicality of automatic generation of test cases for software configuration items.

[0038] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A method for automatically generating test cases for software configuration items based on a large language model, characterized in that: The following steps are involved: Step 1: Build the environment: Select the corresponding large language model according to the characteristics of the software configuration items and test requirements, install and configure the framework for building applications based on the large language model, and install and configure related components; Step 2: Construct prompt words: Based on the framework and related components, a software project document library is established, which includes requirement documents and design documents related to software configuration items, and the requirement documents and design documents obtained from the software project document library are divided into multiple small text fragments to generate a small text list; At the same time, it stores and memorizes the context information of the small text fragments, parses the content of the small text list, and constructs prompt words; Step 3: Test case generation: passing the constructed prompt words to the large language model to generate test cases for the software configuration items, and feeding back the generated test cases to the testers in real time through the framework; Step 4: Test case evaluation and optimization: Save the generated test cases in a predetermined format. At the same time, establish a test case library to classify, annotate and optimize the test cases.

2. The method for automatically generating software configuration item test cases based on a large language model according to claim 1, characterized in that: The construction environment is specifically: Analyze software configuration items: Analyze software configuration items to determine key information on software functional characteristics, performance indicators, and interface design; Select the big prediction model: Determine the required natural language processing capabilities based on the software functional characteristics, performance indicators, and key information of interface design, and select the corresponding big language model based on the needs of generating test cases; Install and configure the framework: Create a Python virtual environment, install application development libraries that support large language models, and configure large language model parameters; Configure related components: Install and configure related components, including text segmenter, file format parser, requirement document analysis tool, and design document visualization tool. After the configuration is complete, test each related component.

3. The method for automatically generating software configuration item test cases based on a large language model as claimed in claim 2, characterized in that: The building environment also includes training the selected large language model, and the specific steps include: Data processing: collect text data of software configuration items, identify the text data, and filter out target text data that meets the test requirements; Feature extraction: extract text features from the filtered target text data, and generate a text feature dataset for training based on the extraction results; Model training: Train the large language model based on the text feature dataset to optimize the large language model's ability to understand and generate text related to software configuration items; Model output: Verify the trained large language model, determine whether the performance of the trained large language model meets the predetermined standards based on the verification results, and output the large language model that meets the predetermined standards.

4. The method for automatically generating software configuration item test cases based on a large language model as claimed in claim 3, characterized in that: The data processing also includes constructing a knowledge graph of software configuration items, specifically: Define the specific instance of the software configuration item as the key node in the software configuration item knowledge graph, match the specific instance with the existing software library, and input the detailed data of the software configuration item into the software library based on the matching result; Draw a knowledge graph of software configuration items based on the detailed data of the software library, and align entities between the knowledge graphs of software configuration items; Train a large language model based on the information in the software configuration item knowledge graph.

5. The method for automatically generating software configuration item test cases based on a large language model as claimed in claim 4, characterized in that: The step 2 of constructing prompt words also includes: classifying the demand documents and design documents collected in the software project document library according to document type and relevance, and preprocessing the classified demand documents and design documents.

6. The method for automatically generating software configuration item test cases based on a large language model as claimed in claim 5, characterized in that: In the step 2, the requirement document and design document obtained from the software project document library are divided into multiple small text fragments, specifically including: Load the requirement document and design document into the file format parser to parse the document content and determine the document structure of the requirement document and design document; Identify key information in requirement documents and design documents based on document structure and set a maximum text fragment length; The natural paragraphs in the requirement document and the design document are used as preliminary segmentation units, and the content length of each paragraph is obtained. If the content length of each paragraph exceeds the set maximum text segment length, the natural paragraph is segmented into sentences that meet the maximum text segment length; A context window is set at each segmentation point, including related sentences and words before and after, wherein the segmentation point is avoided to be located in the middle of the key information to maintain the integrity of the key information; A plurality of small text segments are generated based on the segmentation result, and a unique number is assigned to each small text segment. Each small text segment is arranged according to the unique number to generate a small text list.

7. The method for automatically generating software configuration item test cases based on a large language model as claimed in claim 6, characterized in that: Set the maximum text segment length, including: Extract key information from requirement documents and design documents; Extract key words contained in each key information from each key information; Extract the number of characters corresponding to each keyword and the frequency of each keyword appearing in the requirements document and design document; Retrieving key words in the requirement document and the design document whose frequencies are lower than a preset first frequency threshold as first keyword data; Obtaining a first setting coefficient using the number of characters of the key words included in the first keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The first setting coefficient is obtained by the following formula: Among them, J 01 represents the first setting coefficient; n represents the total number of key words contained in the first keyword data; L 01i represents the number of characters of the i-th keyword in the first keyword data; L 01b represents the standard deviation of the number of characters of the n key words in the first key word data; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; f 01i represents the frequency of the i-th keyword in the first keyword data appearing in the requirement document and the design document; f 01c represents the first frequency threshold; f 01b represents the frequency standard deviation of n key words in the first keyword data in the requirement document and the design document; Retrieving key words in the requirement document and the design document whose frequencies exceed a preset second frequency threshold as second keyword data; Obtaining a second setting coefficient using the number of characters of the key words included in the second keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The second setting coefficient is obtained by the following formula: Among them, J 02 represents the second setting coefficient; m represents the total number of key words contained in the second keyword data; L 02i represents the number of characters of the i-th keyword in the second keyword data; L 02b represents the standard deviation of the number of characters of the m key words in the second key word data; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; R 02 represents a preset second reference coefficient, and the value range of the second reference coefficient is 1.24-1.53; f 02i represents the frequency of the i-th keyword in the second keyword data appearing in the requirement document and the design document; f 02c represents the second frequency threshold; f 02b represents the frequency standard deviation of the m key words in the second key word data in the requirement document and the design document; The maximum text segment length is set using the first setting coefficient and the second setting coefficient.

8. The method for automatically generating software configuration item test cases based on a large language model according to claim 7, characterized in that: Setting the maximum text segment length using the first setting coefficient and the second setting coefficient includes: extracting a first setting coefficient and a second setting coefficient; Comparing the first setting coefficient with a preset first coefficient threshold; comparing the second setting coefficient with a preset second coefficient threshold; When the first setting coefficient exceeds a preset first coefficient threshold, and the second setting coefficient exceeds a preset second coefficient threshold, the first setting coefficient and the second setting coefficient are used to set the maximum text segment length; The maximum text segment length is obtained by the following formula: Among them, H max represents the maximum text segment length, and H max Indicated as rounded up; J 02 Indicates the second setting coefficient; J 01 Indicates the first setting coefficient; J 02c represents the second coefficient threshold; J 01c represents the first coefficient threshold; R 01 represents a preset first reference coefficient, and the value range of the first reference coefficient is 1.37-1.48; R 02 represents a preset second reference coefficient, and the value range of the second reference coefficient is 1.24-1.53; H c Indicates the preset initial text segment length; When the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and when the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, the maximum text fragment length is set using keywords whose frequency of appearance in the requirement document and the design document is not lower than the preset first frequency threshold, but lower than the preset second frequency threshold.

9. The method for automatically generating software configuration item test cases based on a large language model as claimed in claim 8, characterized in that: When the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, the maximum text segment length is set using keywords whose frequencies in the requirement document and the design document are not lower than the preset first frequency threshold, but lower than the preset second frequency threshold, including: When the first setting coefficient does not exceed the preset first coefficient threshold or the second setting coefficient does not exceed the preset second coefficient threshold, and the first setting coefficient does not exceed the preset first coefficient threshold and the second setting coefficient does not exceed the preset second coefficient threshold, then retrieve the key words in the requirement document and the design document whose frequency is not lower than the preset first frequency threshold, but lower than the preset second frequency threshold as the third keyword data; Obtaining a third setting coefficient using the number of characters of the key words included in the third keyword data and the corresponding frequencies of occurrence in the requirement document and the design document; The third setting coefficient is obtained by the following formula: Among them, J 03 represents the third setting coefficient; k represents the total number of key words contained in the third keyword data; L 03i represents the number of characters of the i-th keyword in the third keyword data; L 03b represents the standard deviation of the number of characters of k key words in the third key word data; R 03 represents a preset third reference coefficient, and the value range of the third reference coefficient is 1.19-1.42; f 03i represents the frequency of the i-th keyword in the third keyword data appearing in the requirement document and the design document; f 01c represents the first frequency threshold; f 02c represents the second frequency threshold; f 03b represents the frequency standard deviation of k key words in the third keyword data in the requirement document and the design document; The third setting coefficient is used to set the maximum text segment length, wherein the maximum text segment length is obtained by the following formula: Among them, H max represents the maximum text segment length, and H max Indicates rounding up; H c Indicates the preset initial text segment length; J 03 Indicates the third setting coefficient; R 03 represents a preset third reference coefficient, and the value range of the third reference coefficient is 1.19-1.42; J 02 Indicates the second setting coefficient; J 01 Indicates the first setting coefficient.

10. The method for automatically generating software configuration item test cases based on a large language model according to claim 6, characterized in that: The second step of parsing the small text list content and constructing prompt words specifically includes: Traverse the small text list, read each small text segment, and analyze the key information in each small text segment; Matching the key information with a preset prompt word template, and inputting the key information into the corresponding prompt word template based on the matching result to generate a complete prompt word; At the same time, the test case feedback data generated by the large language model is obtained, and the prompt words are optimized based on the test case feedback data; The test cases generated in step 3 specifically include: Test case ID: Assign a unique identifier to each test case; Test purpose: The purpose and goal of the test case; Preconditions: The conditions that must be met before executing the test case; Test steps: The steps to execute the test; Input data: The data entered during the test; Expected results: The expected results after executing the test steps; Actual results: The actual results after executing the test steps; Test conclusion: Whether the test result is successful.

Citation Information

Patent Citations

  • Method and system for testing software configuration items

    CN104866423B

  • NLP-based system test case automatic generation method

    CN107832229A

  • Test case generation method and device, storage medium and computer equipment

    CN116974943A

  • Knowledge graph construction method, electronic equipment and storage medium

    CN117252261A

  • Test case code generation method and related equipment

    CN117707983A

Cited By

  • Software configuration item test case data processing analysis method based on large language model

    CN119883940A

  • Software Configuration Item Test Case Data Processing and Analysis Method Based on Large Language Model

    CN119883940B

  • Message interaction method and device, equipment and medium

    CN120416208A

  • An AI large model-based message interaction method, device, equipment and medium

    CN120416208B

  • Test case generation method based on multi-modal knowledge base and self-adaptive cue words

    CN121187962A