Database test case generation method and device and storage medium
By automatically generating database test cases using a large language model, the problems of low efficiency, incomplete coverage, and high maintenance costs in traditional methods are solved, achieving efficient and accurate test case generation and lowering the application threshold.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-03
AI Technical Summary
Traditional database testing suffers from problems such as low efficiency in test case writing, incomplete coverage, high maintenance costs, and high barriers to entry.
Test cases are automatically generated using a large language model. This is achieved by dividing the test case guidance file into several test case guidance objects, constructing a knowledge graph and generating test case guidance information, using the large language model to generate test content, and finally forming test cases.
It improves the efficiency and coverage of test case generation, reduces maintenance costs and application threshold, and ensures the accuracy and effectiveness of test cases.
Smart Images

Figure CN121785925A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of database testing, specifically to a database test case generation method, device, and storage medium. Background Technology
[0002] As data volume continues to grow and system complexity increases, relational databases, as an indispensable core component, undertake critical business logic and data persistence functions. To ensure the correctness, stability, and security of the database system, comprehensive testing of the database management system software is necessary.
[0003] Testing relational databases requires writing test case files in a specific format, typically consisting of a set of SQL statements and their expected results. Because modern database management systems are numerous and complex, a large number of high-quality test cases are needed to ensure that testing covers all database functionalities as comprehensively as possible.
[0004] However, traditional methods of writing test cases typically rely on manually reading the user product manual and then writing corresponding test cases based on functional descriptions or industry experience. This approach has the following main problems: 1. Inefficient and costly: When dealing with database systems with numerous functions and constant iterations, manually understanding complex documents and designing a large number of test cases is extremely time-consuming and labor-intensive. 2. Insufficient test coverage: Manual design cannot exhaust all boundary conditions, abnormal scenarios and functional combinations, which can easily lead to the omission of potential defects and incomplete test coverage; 3. Maintenance difficulties: With the updates and optimizations of database functions, existing test cases need to be revised frequently, resulting in high manual maintenance costs and a high risk of errors; 4. High dependence on expert experience: Designing high-quality database test cases requires a deep understanding of database principles and testing expertise, which places extremely high demands on the testers' abilities, meaning the application threshold is relatively high. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this application provides a method for automatically generating test cases, which solves the technical problems of low efficiency, incomplete coverage, high maintenance costs, and high application threshold in traditional database testing.
[0006] To achieve the above objectives, in a first aspect, embodiments of this application provide a database test case generation method, which includes the following steps: The test case guidance file is divided into several test case guidance objects according to the functions. Each test case guidance object includes the function, the function-related functional attributes, and the chapters. Based on the large language model, generate the information required for test cases, and construct the test case guidance information in the test case guidance object; After inputting the test case guidance information into the large language model, the test content is obtained, and test cases are formed based on the test content.
[0007] In conjunction with the first aspect, in one implementation, the process of dividing the test case guidance document into several test case guidance objects according to function includes: The test case guidance file is divided into multiple chunk files according to the splitting nodes; based on the key information of the chunk files, the chunk files are nested and stored as nested chunk objects; the functions and function attributes in each nested chunk object are obtained.
[0008] In conjunction with the first aspect, in one implementation, the process of obtaining the functions and function attributes in each nested block object includes: defining the type of the nested block sub-object without a function title as a chapter; defining the type of the nested block sub-object with a function title as a function; and adding the function title and its corresponding function attribute field to the corresponding nested block sub-object.
[0009] In conjunction with the first aspect, in one implementation, the addition is achieved by migrating the function title and its corresponding function attribute fields.
[0010] In conjunction with the first aspect, in one implementation, the process of constructing test case guidance information in the test case guidance object includes: A knowledge graph is generated based on all nested sub-objects. The knowledge graph includes: Associate the root node of each nested block object; The chapter nodes of the nested sub-objects of the associated chapter type are the lower-level nodes of the root node; Functional nodes of nested sub-objects of associated functional types are functional nodes that are subordinate nodes of chapter nodes; The functional attribute nodes of the nested sub-objects with associated functional attributes are the child nodes of the functional nodes. Edges are constructed based on the hierarchical relationships between root nodes, chapter nodes, function nodes, and function attribute nodes; Traverse each functional node in the knowledge graph, generate the information required for test cases based on the large language model, and combine the functional nodes and their associated functional attribute nodes and chapter nodes to form test case guidance information.
[0011] In conjunction with the first aspect, in one implementation, the process of obtaining test content after inputting test case guidance information into the large language model includes: Based on the functional attribute nodes and chapter nodes associated with the functional nodes, the purpose of the construction is to generate sub-tasks for multiple test points in sequence for each functional node. After the large language model generates test points, subtasks are constructed based on the functions corresponding to each test point, with the aim of generating multiple test items for each test point. After the large language model generates test items, subtasks are constructed based on the functions corresponding to the test items, with the aim of generating test steps corresponding to each test item.
[0012] In conjunction with the first aspect, in one implementation method, the process of generating test cases based on test content includes: After executing the test steps in several different databases, obtain the execution results for each database, and take the execution results with the most common number as the expected results of the test cases for the database under test; if each execution result is unique, then specify one execution result as the expected result; and obtain test cases based on the test content and the expected results.
[0013] In conjunction with the first aspect, in one implementation, the test case guidance object is characterized by the following step before being divided: converting the test case guidance file into a unified format.
[0014] Secondly, embodiments of this application provide a database test case generation device, which includes a processor, a memory, and a database test case generation program stored in the memory and executable by the processor. When the database test case generation program is executed by the processor, it implements the method provided in the first aspect.
[0015] Thirdly, embodiments of this application provide a computer-readable storage medium storing a database test case generation program, which, when executed, implements the method provided in the first aspect.
[0016] Compared with the prior art, the advantages of this application are: This application generates test cases based on the information required by the large language model, and "categorizes" the user manual into several test case guidance information corresponding to each test case, thereby achieving the effect of "simplifying" the user manual (i.e. retaining only the information required by the large language model to generate test cases).
[0017] Therefore, the test case guidance information in this application is equivalent to a condensed version of a part of the user manual (corresponding to a chapter in the test case file). That is, a single test case guidance information fully complies with the effective context window limit of the large language model. In this case, the test cases generated by the large language model have high accuracy.
[0018] In summary, this application realizes the automatic generation of test cases based on a large language model. Compared with manually writing test cases, it improves work efficiency and coverage, and reduces maintenance costs and application threshold. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the framework flow of the database test case generation method in the embodiments of this application; Figure 2 This is a schematic diagram of the overall process of the database test case generation method in the embodiments of this application; Figure 3 This is a schematic diagram of the hardware structure of the database test case generation device involved in the embodiments of this application. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.
[0023] First, a brief description of the research and development process of this application will be given.
[0024] The main problems with existing technologies stem from manually writing test cases. In recent years, large language models based on artificial intelligence have become increasingly intelligent, such as Large Language Models (LLMs). LLMs have demonstrated powerful natural language understanding, text generation, code generation, and logical reasoning capabilities, showing potential to surpass traditional methods in multiple fields. These capabilities offer new approaches to solving the challenge of generating database test cases. For example, LLMs can understand complex text descriptions, including various user manuals and documents written in natural language, extracting key information and understanding the functional information and usage instructions of database management systems. Furthermore, LLMs possess powerful code generation capabilities. Based on these capabilities, LLMs are expected to efficiently and automatically generate comprehensive database test cases from database-related user manuals and documents, thereby overcoming the various challenges faced by manually writing test cases.
[0025] The applicant directly applied a large language model to database test case generation, particularly in generating large-scale, high-quality, and easily maintainable test cases. During this process, the applicant identified the following key technical issues that needed to be addressed: 1. Context window limitations and insufficient information utilization: Database product documentation is usually very long, far exceeding the effective context window limit of current mainstream large language models. This means that even if the entire document is input into the large model, it is impossible to comprehensively utilize all relevant information in the long context, making it difficult to generate a large number of comprehensive test cases. Meanwhile, the inability to comprehensively utilize all relevant information within a long context leads to poor traceability and maintenance difficulties in the generated results: there is a lack of clear and structured association between the directly generated test cases and the functional descriptions in the original documents. When documents or functions change, it is difficult to efficiently locate, understand, and update the relevant test cases, resulting in persistently high maintenance costs.
[0026] 2. The issue of the accuracy of expected results (“illusion”): Large language models may produce “illusions”, generating SQL statements that are syntactically correct but logically flawed or do not conform to actual behavior. More importantly, their judgment of the “expected results” after executing complex SQL statements lacks reliability, and cannot guarantee the validity of test cases and the accuracy of result judgment.
[0027] Based on this, in order to make the objectives, technical solutions and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0028] Firstly, embodiments of this application provide a method for generating database test cases, see [link to relevant documentation]. Figure 1 As shown, the steps of this method include: Step A, Test Case Guidance Document Division Phase: Divide the test case guidance document (user manual) into several test case guidance objects according to the functions. Each test case guidance object includes the function, the function-related functional attributes, and the chapters.
[0029] Step B, Test Content Generation Phase: In the test case guidance object, construct the test case guidance information based on the information required to generate test cases from the large language model.
[0030] This allows the user manual to generate the information needed for test cases based on the large language model, "categorizing" it into several test case guidance information corresponding to each test case. This achieves a "simplification" of the user manual (i.e., retaining only the information needed for the large language model to generate test cases). During implementation, corresponding rules (such as function capture rules, chapter capture rules, and rules for associating functions with chapters) can be set, and then executed by the large language model or the corresponding functional software.
[0031] Step C, Test Case Generation Stage: After inputting the test case guidance information into the large language model (the execution method is to construct prompts for the large language model based on the test case guidance information and then input them into the large language model), the test content is obtained, and test cases are formed based on the test content. As mentioned above, the test case guidance information in this application is equivalent to a condensed version of a portion of the user manual (corresponding to a chapter in the test case file), meaning that a single set of test case guidance information fully conforms to the effective context window constraints of the large language model, thereby improving the accuracy of test cases generated based on the test case guidance information.
[0032] It should be noted that the existing large language models have all been trained by the respective service providers. When performing the test case generation phase, this application can directly use the existing large language models without needing to train or modify the models accordingly.
[0033] Therefore, this application realizes the automatic generation of test cases based on a large language model, which improves work efficiency and coverage, and reduces maintenance costs and application threshold compared with manually writing test cases.
[0034] In one embodiment, the process of dividing the test case guidance document into several test case guidance objects according to function includes: The test case guidance file is divided into multiple chunk files according to the segmentation nodes (usually chapter titles); based on the key information of the chunk files (chapter titles and chapter text), the chunk files are nested and stored as nested chunk objects; in this way, the required content can be quickly traversed later based on the key information.
[0035] Retrieve the functionality and functionality properties of each nested block object.
[0036] In this embodiment, the segmented files are stored in a nested manner as JSON objects, specifically as follows: { "id": "...", "parentId": "...", title: "...", "content": "...", "children": [], } The id field is a randomly generated UUID during the conversion, the parentId field is the id information of the parent chapter, the title field represents the chapter title, the content field represents the segmented main text content, and the children field is a list of child chapters, which contains information in the same format as above.
[0037] For example, if Chapter 1 has sub-chaps 1.1 and 1.2, then the nested block object would be: { "id": "UUID1", "parentId": "...", "title": "chapter 1", "content": "The main text between Chapter 1 and 1.1", "children": [ { "id": "UUID2", "parentId": "UUID1", "title": "chapter 1.1", "content": "The main text between Chapters 1.1 and 1.2", "children": [ ] }, { "id": "UUID3", "parentId": "UUID1", "title": "chapter 1.2", "content": "The main text of Chapter 1.2", "children": [ ] } ]} Furthermore, the process of obtaining the functions and function attributes in each nested block object includes: by traversing the child objects in each nested block object (each object in children corresponds to one child object), defining the type of the nested block sub-objects without function titles as chapters; defining the type of the nested block sub-objects with function titles as functions; and adding the function titles and their corresponding function attribute fields to the nested block sub-objects. The method of adding is to directly migrate the function titles and their corresponding function attribute fields to avoid redundancy between the content and the subsequent attribute content.
[0038] The setting and retrieval of function titles can be performed through corresponding software capture rules (such as "**xxx**", serial number or + bullet point, or other specified prefixes and suffixes, etc.), preferably through a large language model, which has better semantic recognition capabilities.
[0039] In this embodiment, the function titles include "Syntax Format", "Instructions for Use", "Precautions", and "Parameters". In actual use, more functions may be included. For example, adding the function title and its corresponding function attribute field to the corresponding nested sub-object is as follows: { ..., "attribute": [ { "name": "...", "value": "..."} ], "type": "..." } The type field indicates the type of the current JSON object (chapter information type or function type). If the current object is a function type, the attribute field is used to store attributes such as "syntax format", "usage instructions", "notes", and "parameters". The name and value fields correspond to the attribute name and the corresponding text content extracted from the content, respectively.
[0040] At this point, the functions, associated functional attributes, and chapters in the test case guide object (i.e., the nested object with type, function title, and function attribute added above) have all been captured.
[0041] It should be noted that before dividing the test case guidance objects, since the database documents are in different formats, including PDF, HTML, Markdown, etc., in order to provide a more convenient retrieval method and more accurate retrieval results, the test case guidance files need to be converted into a unified format, which is Markdown in this embodiment.
[0042] Furthermore, the process of constructing test case guidance information based on the information required to generate test cases from the large language model, as described above, includes: A knowledge graph is generated based on all nested sub-objects. The knowledge graph includes: (1) Associate the root node of each nested block object. This node is the main node that connects the first-level headings (i.e., the top-level headings of the test case guide objects). It is only used for graph visualization and contains the following attributes: title: User manual title; version: User manual version; (2) Associate chapter nodes of nested sub-objects of chapter type. That is, if the type information in the JSON object is a chapter type, then create a node of that type and store the title and content information of the object as node attributes; the chapter node is a subordinate node of the root node.
[0043] (3) Associate the functional nodes of the nested sub-objects of the functional type. That is, if the type information in the JSON object is a functional type, then create a node of that type and store the title and content information of the object as node attributes; the functional node is the lower-level node of the chapter node.
[0044] (4) Associate the functional attribute nodes of the nested sub-objects of the functional attributes. That is, if the JSON object contains an attribute field, a functional attribute node is created for each attribute in the list and the name and value information are stored. The functional attribute node is the subordinate node of the functional node.
[0045] (5) The edges are constructed based on the hierarchical relationship between the root node, chapter node, function node and function attribute node. Specifically, edges with the type name PARENT_OF are created for all created nodes according to the hierarchical structure in the JSON object.
[0046] Furthermore, since the document contains information such as "Please refer to Chapter XX," it is necessary to extract this semantic information using a large model. During extraction, all nodes in the graph are traversed, prompt words are constructed from the content, and the large model is used to extract semantic information containing reference chapters. Based on this information, the graph is searched to find the corresponding node and an edge named REFERENCE is constructed.
[0047] Traverse each functional node in the knowledge graph, generate the information required for test cases based on the large language model, and combine the functional nodes and their associated functional attribute nodes and chapter nodes to form test case guidance information.
[0048] As can be seen, this application further "simplifies" the relatively information-rich nested objects into a knowledge graph, which can intuitively display only the information required for the test cases. On this basis, it is only necessary to obtain the required information from the knowledge graph to form the input language required for the large language model, which is simple and efficient.
[0049] Meanwhile, according to the above description of the R&D process, the final results directly generated by the large language model have many defects. Therefore, in one embodiment, the above test case guidance information includes three sub-tasks, thereby reducing the semantic difficulty of the large language model in understanding complex targets by using clear output targets of simple sub-tasks, thereby improving the quality and quantity of test content generation.
[0050] Specifically, the process of obtaining test content after inputting test case guidance information into the large language model includes: (1) Based on the functional attribute nodes and chapter nodes associated with the functional nodes, subtasks are constructed with the aim of generating multiple test points sequentially for each functional point; the test points describe the aspects that need to be tested for the functional point, i.e., the test objectives. For example, for the "SIN function" function, "correctness verification for different data types", "correctness verification for boundary values and extreme values", and "correctness verification for illegal values" will be generated.
[0051] (2) After the large language model generates test points, subtasks are constructed based on the functions corresponding to each test point, with the aim of generating multiple test items for each test point. Test items are the test points that are further refined, clarifying the various situations that need to be tested under the test objective. For example, the objective of "correctness verification of the SIN function on different data types" can be expanded to "correctness verification of calculation results for INT type", "correctness verification of calculation results for INT type fields on the data table", etc.
[0052] (3) After the large language model generates test items, it constructs subtasks based on the functions corresponding to each test item, with the aim of generating test steps corresponding to each test item. For specific test items, before being converted into specific SQL statements, they are first converted into operation steps described in natural language. For example, descriptions of SQL statement operations such as creating tables, inserting data, and querying. The purpose of describing them in natural language is to generate query statement information that is independent of specific databases, so that different types of database dialects can be generated subsequently to obtain the expected results.
[0053] To facilitate maintenance, when recording the generated test step descriptions, the version number of the node retrieved from the knowledge graph is also recorded. Since node version numbers may differ, Furthermore, the process of generating test cases based on the test content includes: After executing the above test steps in several different databases (the test steps need to be converted into the execution language of each database, i.e., SQL statements), obtain the execution results for each database. The execution results with the most common number of occurrences are taken as the expected results of the test cases for the database under test. If each execution result is unique, then one execution result is specified as the expected result.
[0054] Test cases are derived by combining the test content and the expected results.
[0055] This solves the problem of the accuracy of expected results ("illusion") mentioned in the above research and development process, and ensures the effectiveness of test cases and the accuracy of result judgment.
[0056] See below. Figure 2 As shown, the above method is illustrated through a specific embodiment.
[0057] S1: Convert the user manual into a functional knowledge graph, specifically including: S101: Convert the user manual to Markdown format; S102: Divide the user manual into chunks and extract key information to store it as a nested JSON object.
[0058] S103: Traverse all JSON objects and check whether they contain a feature topic ("syntax format", "usage instructions", "notes", "parameters") using the large language model. If so, expand the feature title and attribute fields in the JSON object and define the type as a feature. Otherwise, define the type of the JSON object as a chapter.
[0059] S2: Generate test case guidance information based on the functional nodes in the functional knowledge graph.
[0060] S3: The large language model generates multiple test points for each function point based on the test case guidance information.
[0061] S4: The large language model generates multiple test items for each test point.
[0062] S5: The large language model generates corresponding test steps for each test item.
[0063] S6: Based on the test steps description, two types of SQL statements will be generated. The first type consists of different SQL languages for various databases, including Oracle, MySQL, and PostgreSQL, used to obtain the correct expected results. The second type is used to generate SQL statements for the database under test, which are used to synthesize test case files.
[0064] S7: Execute the generated SQL dialects for Oracle, MySQL, and PostgreSQL databases in their respective databases and obtain the results.
[0065] S8: Obtain the desired result by voting on the execution results; specifically: If the results are inconsistent, the result with the most consistent outcome will be taken as the expected result. If all results are inconsistent, the result from the Oracle database will be taken as the expected result.
[0066] S9: Combine the generated SQL for the database under test with the expected voting results, and use a large language model to generate a specific test case file format. At the same time, record the version of the source user manual for maintenance.
[0067] In summary, this application proposes a method for generating relational database test cases based on large language models and knowledge graph retrieval enhancement. By leveraging the natural language understanding and code generation capabilities of large language models, along with database domain expertise, and combining them with knowledge graphs, comprehensive and logically rigorous test cases can be generated quickly. This improves testing efficiency and quality, reduces labor costs, and provides strong support for the stable operation of database systems.
[0068] Secondly, embodiments of this application provide a database test case generation device, which can be a personal computer (PC), laptop computer, server, or other device with data processing capabilities.
[0069] Reference Figure 3 , Figure 3This is a schematic diagram of the hardware structure of the database test case generation device involved in the embodiments of this application. In the embodiments of this application, the database test case generation device may include a processor, a memory, a communication interface, and a communication bus.
[0070] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.
[0071] The communication interface includes input / output (I / O) interfaces, physical interfaces, and logical interfaces used for interconnecting internal components of the database test case generation device, as well as interfaces used for interconnecting the database test case generation device with other devices (such as other computing devices or user equipment). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user equipment can be displays, keyboards, etc.
[0072] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.
[0073] The processor can be a general-purpose processor, which can call the database test case generation program stored in memory and execute the database test case generation method provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). The method executed when the database test case generation program is called can be referred to in various embodiments of the database test case generation method of this application, and will not be repeated here.
[0074] Those skilled in the art will understand that Figure 3 The hardware structure shown does not constitute a limitation of this application and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0075] Thirdly, embodiments of this application also provide a computer-readable storage medium.
[0076] The computer-readable storage medium of this application stores a database test case generation program, wherein when the database test case generation program is executed by a processor, it implements the steps of the database test case generation method described above.
[0077] The method implemented when the database test case generation program is executed can be referred to in various embodiments of the database test case generation method of this application, and will not be repeated here.
[0078] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0079] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.
[0080] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.
[0081] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0082] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.
[0083] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.
[0084] The above are merely specific embodiments of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the scope of the claims.
Claims
1. A method for generating database test cases, characterized in that, The method includes the following steps: The test case guidance file is divided into several test case guidance objects according to the functions. Each test case guidance object includes the function, the function-related functional attributes, and the chapters. Based on the large language model, generate the information required for test cases, and construct the test case guidance information in the test case guidance object; After inputting the test case guidance information into the large language model, the test content is obtained, and test cases are formed based on the test content.
2. The database test case generation method as described in claim 1, characterized in that: The process of dividing the test case guidance file into several test case guidance objects according to function includes: The test case guidance file is divided into multiple chunk files according to the splitting nodes; based on the key information of the chunk files, the chunk files are nested and stored as nested chunk objects; the functions and function attributes in each nested chunk object are obtained.
3. The database test case generation method as described in claim 2, characterized in that: The process of obtaining the functions and function attributes in each nested block object includes: defining the type of the nested block sub-object without a function title as a chapter; defining the type of the nested block sub-object with a function title as a function; and adding the function title and its corresponding function attribute field to the nested block sub-object.
4. The database test case generation method as described in claim 3, characterized in that: The method of adding is to migrate the function title and its corresponding function attribute fields.
5. The database test case generation method as described in claim 2, characterized in that, The process of constructing test case guidance information in the test case guidance object includes: A knowledge graph is generated based on all nested sub-objects. The knowledge graph includes: Associate the root node of each nested block object; The chapter nodes of the nested sub-objects of the associated chapter type are the lower-level nodes of the root node; Functional nodes of nested sub-objects of associated functional types are functional nodes that are subordinate nodes of chapter nodes; The functional attribute nodes of the nested sub-objects with associated functional attributes are the child nodes of the functional nodes. Edges are constructed based on the hierarchical relationships between root nodes, chapter nodes, function nodes, and function attribute nodes; Traverse each functional node in the knowledge graph, generate the information required for test cases based on the large language model, and combine the functional nodes and their associated functional attribute nodes and chapter nodes to form test case guidance information.
6. The database test case generation method as described in claim 1, characterized in that, The process of obtaining test content after inputting test case guidance information into the large language model includes: Based on the functional attribute nodes and chapter nodes associated with the functional nodes, the purpose of the construction is to generate sub-tasks for multiple test points in sequence for each functional node. After the large language model generates test points, subtasks are constructed based on the functions corresponding to each test point, with the aim of generating multiple test items for each test point. After the large language model generates test items, subtasks are constructed based on the functions corresponding to the test items, with the aim of generating test steps corresponding to each test item.
7. The database test case generation method as described in claim 1, characterized in that, The process of generating test cases based on test content includes: After executing the test steps in several different databases, obtain the execution results for each database, and take the execution results with the most common number as the expected results of the test cases for the database under test; if each execution result is unique, then specify one execution result as the expected result; and obtain test cases based on the test content and the expected results.
8. The database test case generation method according to any one of claims 1 to 7, characterized in that, Before the test case guidance object is divided, the following steps are also included: converting the test case guidance file into a unified format.
9. A database test case generation device, characterized in that, The database test case generation device includes a processor, a memory, and a database test case generation program stored in the memory and executable by the processor, wherein when the database test case generation program is executed by the processor, it implements the steps of the database test case generation method as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a database test case generation program, wherein when the database test case generation program is executed, it implements the steps of the database test case generation method as described in any one of claims 1 to 8.