Database test case generation method and device and electronic equipment

By converting natural language testing requirements into an internal instruction language and automatically modifying test cases using a modified template library, the lack of a systematic mechanism in existing technologies is solved, enabling efficient and flexible database test case generation that adapts to complex business logic and diverse testing scenarios.

CN121009010APending Publication Date: 2025-11-25JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511091237.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-05
Publication Date
2025-11-25

AI Technical Summary

Technical Problem

Existing technologies lack a systematic mechanism to convert natural language requirements into standard database test cases, especially in terms of semantic understanding, SQL modeling, and statement dependency management, making it difficult to achieve efficient and flexible test case generation.

Method used

By acquiring natural language test requirements from user input, converting them into an internal instruction language, performing syntax analysis to build test case models, using a template library to determine target templates for modification, and automatically modifying original test cases to generate new test cases.

Benefits of technology

It enables efficient and scalable automatic generation of database test cases, reducing manual intervention, improving the efficiency of automated testing, and adapting to complex business logic and diverse testing scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121009010A_ABST
    Figure CN121009010A_ABST
Patent Text Reader

Abstract

The invention relates to a database test case generation method and device and electronic equipment. The method comprises the following steps: acquiring a natural language test demand input by a user, and converting the natural language test demand into an internal instruction language; performing syntactic analysis on the original test case, and establishing a case model; determining a target transformation template from a transformation template library according to the internal instruction language; and transforming the original test case by utilizing the target transformation template and the case model to generate a new test case. The technical problem that a systematic mechanism for converting natural language requirements into standard test cases does not exist is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database testing technology, and in particular to a method, apparatus, and electronic device for generating database test cases. Background Technology

[0002] In the development and testing of database systems, the construction of test cases is crucial for verifying the correctness of database operations. Traditional test cases often rely on manual writing or simple script generation, which is inefficient, has limited coverage, and struggles to flexibly address complex testing scenarios. As database structures become more complex and business logic more diverse, users increasingly desire to describe test requirements using simple natural language and automatically generate high-quality, structurally complete test cases, reducing human intervention and improving the efficiency of automated testing. However, currently, there is a lack of a systematic mechanism to convert natural language requirements into standard test cases, particularly in areas such as semantic understanding, SQL modeling, statement dependency management, and template modification, where a comprehensive solution is lacking. Summary of the Invention

[0003] This application provides a method, apparatus, and electronic device for generating database test cases to address the technical problem of the lack of a systematic mechanism for converting natural language requirements into standard test cases.

[0004] In a first aspect, this application provides a method for generating database test cases, comprising: obtaining natural language test requirements input by a user and converting the natural language test requirements into an internal instruction language; performing syntactic analysis on the original test cases and establishing a test case model; determining a target modification template from a modification template library based on the internal instruction language; and modifying the original test cases using the target modification template and the test case model to generate new test cases.

[0005] Secondly, this application provides a database test case generation apparatus, comprising: an acquisition module for acquiring natural language test requirements input by a user and converting the natural language test requirements into an internal instruction language; an analysis module for performing syntactic analysis on the original test cases and establishing a test case model; a determination module for determining a target modification template from a modification template library based on the internal instruction language; and a modification module for modifying the original test cases using the target modification template and the test case model to generate new test cases.

[0006] As an optional example, the acquisition module includes: a processing unit for performing word segmentation processing on the natural language testing requirements to obtain word segmentation results; a first analysis unit for performing semantic analysis on the word segmentation results to identify the operation intent; and a generation unit for generating the standardized internal instruction language based on the operation intent.

[0007] As an optional example, the above analysis module includes: a second analysis unit, used to perform syntax analysis on each SQL statement of the original test case to obtain a set of feature information and a set of relation information; a first establishment unit, used to establish a profile of each SQL statement of the original test case based on the set of feature information; a second establishment unit, used to establish a statement dependency graph of the original test case based on the set of relation information; and a third establishment unit, used to establish the test case model by combining the profile and the statement dependency graph.

[0008] As an optional example, the first establishment unit mentioned above includes: a processing subunit, used to take each SQL statement of the original test case as the current SQL statement, and perform the following operations on the current SQL statement: perform syntax analysis on the current SQL statement to generate a syntax tree; based on the syntax tree, extract the object information of the current SQL statement, wherein the object information includes object attribute information and related table information; identify related SQL statements that have a dependency relationship with the current SQL statement; and encapsulate the syntax tree, object information and related SQL statements of the current SQL statement into a structured profile data model to obtain a profile of the current SQL statement.

[0009] As an optional example, the determination module includes: a search unit, used to search for a preliminary set of modification templates corresponding to the keywords in the modification template library using the internal instruction language as keywords; and a filtering unit, used to create filtering conditions and filter the preliminary set of modification templates according to the filtering conditions to obtain the target modification template with the highest matching degree to the internal instruction language.

[0010] As an optional example, the above-mentioned modification module includes: an extraction unit for extracting the transformation rules of the target modification template; a determination unit for determining the target SQL statement that needs to be modified from the original test case based on the internal instruction language and the test case model; and a modification unit for modifying the target SQL statement based on the transformation rules and the internal instruction statement to generate the new test case.

[0011] As an optional example, the above apparatus further includes: an update module, used to update the test case model according to the new test cases after modifying the original test cases using the target modification template and the test case model to generate new test cases.

[0012] Thirdly, this application provides a storage medium storing a computer program, wherein the computer program is executed by a processor to perform the above-described method for generating database test cases.

[0013] Fourthly, this application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-described method for generating database test cases through the computer program.

[0014] The technical solutions provided in this application have the following advantages compared with the prior art:

[0015] This application employs a method that obtains user input in natural language to test requirements and converts these requirements into an internal instruction language; performs syntactic analysis on the original test cases to establish test case models; determines target modification templates from a modification template library based on the internal instruction language; and modifies the original test cases using the target modification templates and the test case models to generate new test cases. This method establishes an efficient and scalable automatic database test case generation mechanism through natural language parsing, test case modeling, modification template matching, and automatic modification techniques. This maximizes the use of existing test cases, rapidly generates new test cases, and effectively meets specific testing requirements, thereby solving the technical problem of lacking a systematic mechanism to convert natural language requirements into standard test cases. Attached Figure Description

[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0019] Figure 1 This is a flowchart of an optional method for generating database test cases according to an embodiment of this application;

[0020] Figure 2 This is a flowchart illustrating the specific implementation of an optional method for generating database test cases according to an embodiment of this application.

[0021] Figure 3This is a schematic diagram of the SQL profile structure of an optional database test case generation method according to an embodiment of this application;

[0022] Figure 4 This is a schematic diagram of an optional database test case generation device according to an embodiment of this application;

[0023] Figure 5 This is a schematic diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0024] 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.

[0025] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0026] According to a first aspect of the embodiments of this application, a method for generating database test cases is provided, optionally, as follows: Figure 1 As shown, the above method includes:

[0027] S102, Obtain the natural language testing requirements input by the user and convert the natural language testing requirements into an internal instruction language;

[0028] S104, Perform syntax analysis on the original test cases and establish test case models;

[0029] S106, determine the target modification template from the modification template library according to the internal instruction language;

[0030] S108 uses the target modification template and test case model to modify the original test cases and generate new test cases.

[0031] Optionally, in this embodiment, as Figure 2The flowchart shown illustrates the specific implementation process. Users express their desired operations on the database test cases in natural language, i.e., natural language test requirements, such as "add an integer field to table A," "add an insert statement," or "add transaction control." The system receives these natural language test requirements and processes them through preprocessing (e.g., word segmentation, stop word removal), semantic analysis, and operation intent recognition. This transforms the natural language into a structured internal command language that the system can recognize. For example, the natural language test requirement "add column" is converted into the internal command language "ADD COL INT user_table," and the natural language test requirement "add commit operation" is converted into the internal command language "ADD COMMIT." The original test cases contain multiple SQL statements, potentially involving table creation, data insertion, record updates, and queries. Each SQL statement needs to be analyzed to establish a reusable and adaptable test case model. The internal instruction language is a standard expression of user intent. Based on these internal instruction languages, a matching target modification template is searched from a pre-built modification template library. Finally, based on the selected target modification template and combined with the statement structure and dependencies in the use case model, the original test cases are precisely modified or expanded, and the SQL sequence with correct statement order and reasonable logic is output as the new test cases.

[0032] Optionally, in this embodiment, an efficient and scalable automatic database test case generation mechanism is established through natural language parsing, test case modeling, template matching, and automatic modification. Users only need to describe the test intent, and the system can automatically generate complex statements. The process from requirements to test cases is fully automatic and requires no manual intervention. Relying on structured test case models and templates, the system can be modified to have context adaptability, support continuous expansion and modification of the template library, adapt to various business scenarios, significantly improve test generation speed, and enhance SQL scenario coverage.

[0033] As an alternative example, translating natural language testing requirements into an internal instruction language includes:

[0034] The natural language testing requirements are processed by word segmentation to obtain the segmentation results;

[0035] Perform semantic analysis on the word segmentation results to identify the operational intent;

[0036] Based on the operational intent, a standardized internal instruction language is generated.

[0037] Optionally, in this embodiment, upon receiving a natural language testing request from a user, such as "Please add a varchar field to the user table," the text content is first segmented using natural language processing technology. This process aims to decompose the original continuous statement into basic words or phrases with semantic boundaries. The segmentation tools used may include rule-based segmenters, statistical models, or deep learning language models. Based on the obtained segmentation results, semantic understanding and intent recognition are further performed to extract the user's operation target. In the example above, by recognizing keywords such as "add," "field," "varchar," and "user table," the user's intent is determined to be: operation type "add field (AddColumn)," data type "varchar," and target object "user table." According to the identified operation intent, it is mapped to a structured internal instruction language, such as "ADD_COL varchar user." The internal instruction language serves as an intermediate expression form, with a clear structure and explicit semantics. It can be directly matched with subsequent template libraries, is extensible, supports unified encoding for multiple operation types, is easy for computer processing, unambiguous, and facilitates program recognition and logical branch judgment.

[0038] Optionally, in this embodiment, the natural language test requirements input by the user are converted into an internal instruction language, enabling non-technical users to express test requirements in natural language form, providing high-precision input for subsequent template matching and modification, and supporting the recognition of various complex intents, thereby improving the system's intelligence level. Through a semantic mapping mechanism, an automatic transition from "language" to "structure" is achieved.

[0039] As an optional example, performing syntax analysis on the original test cases and building a test case model includes:

[0040] Perform syntax analysis on each SQL statement in the original test cases to obtain a set of feature information and a set of relation information;

[0041] Based on the feature information set, a profile of each SQL statement in the original test case is created;

[0042] Based on the set of relational information, construct the statement dependency graph of the original test cases;

[0043] By combining user profiles and statement dependency graphs, a use case model is established.

[0044] Optionally, in this embodiment, the original test cases often consist of several SQL statements. A built-in SQL parser performs syntax tree parsing on each SQL statement to identify its structure and the objects it operates on. The feature information set includes, but is not limited to, statement type, table name, field name, data type, operation attributes, related tables, and related SQL statements. The relationship information set includes the dependencies between this SQL statement and other SQL statements, such as a SQL statement depending on a previously defined SQL statement, or a SQL statement referencing previously inserted data. The structural features, object information, syntax tree, and semantic tags of each SQL statement are uniformly encapsulated into a statement profile to represent the static attributes and functional roles of the SQL statement. Figure 3 The diagram illustrates the SQL profile structure. The SQL profile data structure can include various attributes such as syntax trees, SQL types, operation objects, operation behaviors, parameter or literal information, involved transaction statements or logical branch information, related tables, and related SQL statements. This SQL profile can be stored as structured JSON, database tables, or in-memory objects for easy matching and modification. Based on the execution order and dependencies between SQL statements, a directed graph is constructed to represent the contextual relationships between each SQL statement. This statement dependency graph helps understand the execution logic order and object reference relationships between statements, ensuring that the contextual consistency between statements is not broken during modification. Finally, all the generated SQL statement profiles are merged with the overall statement dependency graph to form a unified use case model. This model can abstractly represent the overall structure and semantic features of the original test cases for subsequent modification operations.

[0045] Optionally, in this embodiment, the test case model established through the above steps fully expresses the test case structure and semantic features, which facilitates automatic analysis and understanding by the program, clearly represents statement dependencies, ensures the correctness of test data and execution order, provides precise anchor points for modification, can locate the modification target and its context, improves the automation and intelligence level of test case generation, greatly reduces manual intervention, supports the analysis and reconstruction of complex business logic, and enhances the adaptability and reusability of test cases.

[0046] As an optional example, based on the feature information set, the profile of each SQL statement in the original test case includes:

[0047] Treat each SQL statement from the original test cases as the current SQL statement, and perform the following operations on the current SQL statement:

[0048] Perform syntax analysis on the current SQL statement and generate a syntax tree;

[0049] Based on the syntax tree, extract the object information of the current SQL statement, which includes object attribute information and related table information;

[0050] Identify related SQL statements that have a dependency relationship with the current SQL statement;

[0051] The syntax tree, object information, and related SQL statements of the current SQL statement are uniformly encapsulated into a structured profile data model to obtain a profile of the current SQL statement.

[0052] Optionally, in this embodiment, to accurately characterize the structure and semantic features of each SQL statement, a profile is further created for each SQL statement in the original test case. Specifically, each SQL statement in the original test case is sequentially treated as the current processing object for subsequent profile generation operations. By processing each statement one by one, it can be ensured that each statement can be structurally modeled. The current SQL statement is analyzed using an SQL syntax parsing tool to generate an abstract syntax tree, which describes the basic structure, key nodes, and syntax hierarchy of the SQL statement. Object information is the collection of database objects involved in the statement: object attribute information: field name, field type, primary key, NOT NULL, default value, index, etc.; related table information: table names, aliases, and join relationships referenced or operated on in the statement, etc. This information is extracted from the syntax tree and expressed in a structured manner to form the object feature set of the current SQL statement. By analyzing the execution order and shared object names between SQL statements, other SQL statements that have dependencies on the current SQL statement are identified. The above-mentioned syntax structure, object information, dependency information, and other elements are encapsulated into a unified data structure, i.e., the SQL statement profile. Each SQL statement generates such a profile data model for subsequent use case modeling and modification operations.

[0053] As an optional example, determining the target modification template from the modification template library based on the internal instruction language includes:

[0054] Using the internal instruction language as keywords, search the template library for a set of preliminary modification templates that correspond to the keywords;

[0055] Create filtering criteria and filter the initial set of modified templates according to the filtering criteria to obtain the target modified template with the highest matching degree with the internal instruction language.

[0056] Optionally, in this embodiment, to achieve automated and controllable modification of the original test cases, it is necessary to determine the target modification template that best matches the instruction language from the modification template library. Specifically, the converted standardized internal instruction language is used as a keyword and input into the modification template library for preliminary matching and retrieval. Through precise keyword matching or fuzzy matching, several candidate templates associated with the current internal instruction language can be quickly retrieved, forming a preliminary modification template set. To further improve the modification accuracy and adaptability, multi-dimensional filtering conditions are set for the preliminary modification template set, such as: statement type consistency, target object adaptability, execution context matching degree, user intent feature matching, etc. For multiple modification templates that pass the filtering, a matching score is calculated based on factors such as keyword matching degree, context adaptability, and template rule complexity, and finally, the template with the highest score is selected as the target modification template. Through the above process, the most suitable modification template is dynamically matched from the modification template library, improving the accuracy of the modification. Combining semantic understanding and context analysis, it avoids the misselection of inapplicable templates; it adapts to diverse modification needs and supports automatic positioning of templates of different granularities based on complex semantic intent.

[0057] As an optional example, by utilizing the target modification template and use case model, the original test cases can be modified to generate new test cases, including:

[0058] Extract the transformation rules of the target template;

[0059] Based on the internal instruction language and test case model, determine the target SQL statements that need to be modified from the original test cases;

[0060] Based on the transformation rules and internal instruction statements, the target SQL statement is modified to generate new test cases.

[0061] Optionally, in this embodiment, after obtaining the target modification template, combined with the existing use case model, the structural modification of the original test cases can be automatically completed to generate new test cases that meet the testing requirements. Specifically, each target modification template contains a set of structured transformation rules, typically consisting of template statements, placeholder identifiers, applicable conditions, optional parameters, execution order, etc. First, these transformation rules are parsed from the selected target template to guide subsequent statement insertion, replacement, or modification operations. These transformation rules clarify the statement structure to be inserted, the dependent data objects, and the context conditions for modification. Based on the operational intent expressed in the internal instruction language and the statement profile recorded in the use case model, the target SQL statement or target insertion position that needs to be modified in the original test case can be automatically identified. For example, if the instruction is "add field," the CREATE TABLE statement is searched. This step ensures accurate positioning of the transformation operation and avoids accidental modification of irrelevant statements. According to the aforementioned transformation rules and the extracted target SQL statement, one of the following modification operations is performed: statement insertion, statement modification, statement replacement, statement reorganization, etc. During the generation of new SQL statements, placeholders in the transformation rules are automatically populated, based on multi-dimensional information such as the current use case model, field library, and semantic context. Finally, the modified SQL statements are reassembled to form new test cases that are logically complete and semantically consistent.

[0062] Optionally, in this embodiment, the original test cases are structurally modified based on the modification template rules, thereby realizing automated modification of test cases, significantly improving the efficiency of test scenario construction, template-driven and logically unified, ensuring that the modification results meet the expected semantics, adapting to complex testing requirements, supporting multiple types of semantic modification, ensuring the consistency of dependency relationships, and guaranteeing that the new test cases have a closed-loop structure and semantic coherence during execution.

[0063] As an optional example, after modifying the original test cases using the target modification template and test case model to generate new test cases, the above method also includes:

[0064] Update the test case model based on the new test cases.

[0065] Optionally, in this embodiment, to maintain the consistency and timeliness of the test case model, after generating new test cases, the test case model is further updated synchronously to ensure that subsequent modification operations can still be accurately executed based on the latest semantic context. Specifically, all SQL statements in the new test cases are re-analyzed to extract new feature and relational information, and the SQL statement profile and statement dependency graph are reconstructed. The updated profile and statement dependency graph are then synchronized to the current test case model, replacing the original content, to ensure that the model reflects the latest test case structure and semantic relationships.

[0066] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0067] According to another aspect of the embodiments of this application, a database test case generation apparatus is also provided, such as... Figure 4 As shown, it includes:

[0068] The acquisition module 402 is used to acquire the natural language test requirements input by the user and convert the natural language test requirements into an internal instruction language;

[0069] Analysis module 404 is used to perform syntax analysis on the original test cases and build test case models;

[0070] The determination module 406 is used to determine the target modification template from the modification template library according to the internal instruction language;

[0071] Modification module 408 is used to modify the original test cases and generate new test cases by utilizing the target modification template and test case model.

[0072] It should be noted that the acquisition module 402 in this embodiment can be used to execute step S102 in this application embodiment, the analysis module 404 in this embodiment can be used to execute step S104 in this application embodiment, the determination module 406 in this embodiment can be used to execute step S106 in this application embodiment, and the modification module 408 in this embodiment can be used to execute step S108 in this application embodiment.

[0073] As an optional example, the modules to be acquired include:

[0074] The processing unit is used to perform word segmentation on natural language testing requirements and obtain the word segmentation results.

[0075] The first analysis unit is used to perform semantic analysis on the word segmentation results and identify the operation intent;

[0076] The generation unit is used to generate a standardized internal instruction language based on the operational intent.

[0077] As an optional example, the analysis module includes:

[0078] The second analysis unit is used to perform syntax analysis on each SQL statement in the original test cases to obtain a set of feature information and a set of relation information.

[0079] The first establishment unit is used to create a profile of each SQL statement in the original test case based on the feature information set;

[0080] The second building unit is used to build the statement dependency graph of the original test cases based on the set of relational information.

[0081] The third building unit is used to combine user profiles and statement dependency graphs to build use case models.

[0082] As an optional example, the first building unit includes:

[0083] The processing subunit is used to treat each SQL statement from the original test case as the current SQL statement and perform the following operations on the current SQL statement:

[0084] Perform syntax analysis on the current SQL statement and generate a syntax tree;

[0085] Based on the syntax tree, extract the object information of the current SQL statement, which includes object attribute information and related table information;

[0086] Identify related SQL statements that have a dependency relationship with the current SQL statement;

[0087] The syntax tree, object information, and related SQL statements of the current SQL statement are uniformly encapsulated into a structured profile data model to obtain a profile of the current SQL statement.

[0088] As an optional example, the identified modules include:

[0089] The search unit is used to search for a set of preliminary modification templates that correspond to the keywords in the modification template library using the internal instruction language as keywords.

[0090] The filtering unit is used to create filtering conditions and filter the preliminary set of modification templates according to the filtering conditions to obtain the target modification template with the highest matching degree with the internal instruction language.

[0091] As an optional example, the modification module includes:

[0092] The extraction unit is used to extract the transformation rules of the target modification template;

[0093] The determination unit is used to determine the target SQL statements that need to be modified from the original test cases based on the internal instruction language and test case model;

[0094] The transformation unit is used to transform the target SQL statement according to the transformation rules and internal instruction statements to generate new test cases.

[0095] As an optional example, the above-described apparatus further includes:

[0096] The update module is used to modify the original test cases by utilizing the target modification template and test case model, generate new test cases, and then update the test case model based on the new test cases.

[0097] For other examples of this embodiment, please refer to the examples above, which will not be repeated here.

[0098] Figure 5 This is a schematic diagram of an optional electronic device according to an embodiment of this application, such as... Figure 5 As shown, it includes a processor 502, a communication interface 504, a memory 506, and a communication bus 508. The processor 502, communication interface 504, and memory 506 communicate with each other via the communication bus 508.

[0099] Memory 506 is used to store computer programs;

[0100] When processor 502 executes a computer program stored in memory 506, it performs the following steps:

[0101] Obtain the user's input in natural language to specify the testing requirements, and then translate the natural language testing requirements into an internal instruction language;

[0102] Perform syntax analysis on the original test cases and build a test case model;

[0103] Based on the internal instruction language, determine the target modification template from the modification template library;

[0104] By using target modification templates and test case models, the original test cases are modified to generate new test cases.

[0105] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The symbol is represented by a single thick line, but this does not indicate that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0106] The memory may include RAM, or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0107] As an example, the memory 506 described above may include, but is not limited to, the acquisition module 402, analysis module 404, determination module 406, and modification module 408 from the database test case generation device described above. Furthermore, it may include, but is not limited to, other module units from the database test case generation device described above, which will not be elaborated upon in this example.

[0108] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0109] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.

[0110] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only. The device that implements the above database test case generation method can be a terminal device, such as a smartphone (e.g., Android phone, iOS phone), tablet computer, PDA, mobile Internet Devices (MID), PAD, etc. Figure 5 This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 5 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 5 The different configurations shown.

[0111] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, ROM, RAM, disk or optical disk, etc.

[0112] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, which, when executed by a processor, performs the steps in the above-described method for generating database test cases.

[0113] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0114] 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.

[0115] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0116] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0117] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.

[0118] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0119] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0120] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for generating database test cases, characterized in that, include: Obtain the user's input of natural language testing requirements and convert the natural language testing requirements into an internal instruction language; Perform syntax analysis on the original test cases and build a test case model; Based on the internal instruction language, the target modification template is determined from the modification template library; Using the target modification template and the use case model, the original test cases are modified to generate new test cases.

2. The method according to claim 1, characterized in that, The process of converting the natural language testing requirements into an internal instruction language includes: The natural language testing requirements are processed by word segmentation to obtain the word segmentation results; Perform semantic analysis on the word segmentation results to identify the operation intent; Based on the stated operational intent, a standardized internal instruction language is generated.

3. The method according to claim 1, characterized in that, Syntax analysis was performed on the original test cases, and a test case model was established, including: Syntax analysis is performed on each SQL statement in the original test cases to obtain a set of feature information and a set of relation information; Based on the set of feature information, a profile of each SQL statement in the original test case is established; Based on the set of relational information, establish the statement dependency graph of the original test cases; The use case model is established by combining the profile and the statement dependency graph.

4. The method according to claim 3, characterized in that, Based on the set of feature information, the profile of each SQL statement in the original test case is established, including: Take each SQL statement from the original test case as the current SQL statement, and perform the following operation on the current SQL statement: Perform syntax analysis on the current SQL statement to generate a syntax tree; Based on the syntax tree, the object information of the current SQL statement is extracted, wherein the object information includes object attribute information and related table information; Identify related SQL statements that have a dependency relationship with the current SQL statement; The syntax tree, object information, and related SQL statements of the current SQL statement are uniformly encapsulated into a structured profile data model to obtain a profile of the current SQL statement.

5. The method according to claim 1, characterized in that, Based on the internal instruction language, the target modification template is determined from the modification template library, including: Using the internal instruction language as keywords, search for a set of preliminary modification templates corresponding to the keywords in the modification template library; Create filtering criteria and filter the preliminary set of modified templates according to the filtering criteria to obtain the target modified template with the highest matching degree with the internal instruction language.

6. The method according to claim 1, characterized in that, Using the target modification template and the use case model, the original test cases are modified to generate new test cases, including: Extract the transformation rules of the target modification template; Based on the internal instruction language and the use case model, determine the target SQL statement that needs to be modified for the original test case; Based on the transformation rules and the internal instruction statements, the target SQL statement is modified to generate the new test cases.

7. The method according to claim 1, characterized in that, After modifying the original test cases using the target modification template and the test case model to generate new test cases, the method further includes: Update the test case model based on the new test cases.

8. A database test case generation device, characterized in that, include: The acquisition module is used to acquire the natural language test requirements input by the user and convert the natural language test requirements into an internal instruction language; The analysis module is used to perform syntax analysis on the original test cases and build test case models; The determination module is used to determine the target modification template from the modification template library according to the internal instruction language; The modification module is used to modify the original test cases using the target modification template and the test case model to generate new test cases.

9. A computer-readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to perform the method described in any one of claims 1 to 7.

10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7 through the computer program.