A high-efficiency PL / SQL database test case generation method and system

By performing static and dynamic analysis on PL/SQL source code and combining it with machine learning algorithm optimization, efficient PL/SQL database test cases are automatically generated. This solves the problems of low generation efficiency and difficult quality assurance in existing technologies, and achieves efficient and low-error test case generation.

CN120407424BActive Publication Date: 2025-10-10TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510900947.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-01
Publication Date
2025-10-10
Estimated Expiration
2045-07-01

AI Technical Summary

Technical Problem

Writing and maintaining high-quality PL/SQL code test cases is a time-consuming and error-prone task. Existing technologies make it difficult to generate them efficiently and ensure their quality.

Method used

By statically analyzing the PL/SQL source code, generating test case templates, and performing dynamic testing in a simulated or real database environment, the system automatically generates test cases by combining the static and dynamic analysis results, and uses machine learning algorithms to optimize test cases to achieve automated and efficient generation.

Benefits of technology

Significantly improves the efficiency and quality of generating PL/SQL database test cases, reduces manual intervention, lowers error rates, and accelerates development cycles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407424B_ABST
    Figure CN120407424B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of automatic testing in a database management system, and provides a high-efficiency PL / SQL database test case generation method and system, which comprises the following steps: performing static analysis on PL / SQL source code; matching a predefined test case template according to a static analysis result, and dynamically adjusting the test case template according to PL / SQL code characteristics to obtain a test case template; performing dynamic testing according to the test case template, performing path tracking, boundary value detection, and capturing exceptions; automatically generating test cases in combination with static and dynamic analysis results; executing the test cases, performing deep analysis on test results through a machine learning algorithm, adjusting the test cases through a feedback optimization mechanism according to analysis results, and obtaining final test cases. The application significantly improves the generation efficiency and quality of PL / SQL database test cases, reduces manual intervention, reduces error rates, and shortens the development cycle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of automated testing in database management systems, and in particular to a method and system for generating efficient PL / SQL database test cases. Background Art

[0002] PL / SQL, a procedural extension language for databases, is widely used for data processing and business logic implementation. It combines the data manipulation capabilities of SQL with the logical processing capabilities of procedural programming languages, enabling developers to write complex transaction logic, data processing scripts, and stored procedures and functions. However, despite the powerful functionality provided by PL / SQL in complex application scenarios, writing and maintaining high-quality test cases for PL / SQL code can be a time-consuming and error-prone task. Summary of the Invention

[0003] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention provides an efficient PL / SQL database test case generation method and system, which significantly improves the efficiency and quality of PL / SQL database test case generation, reduces manual intervention, lowers error rates, and accelerates the development cycle.

[0004] The present invention provides an efficient PL / SQL database test case generation method, comprising:

[0005] S1: Perform static analysis on the PL / SQL source code to obtain static analysis results;

[0006] S2: Select a matching predefined test case template from the predefined test case template library based on the static analysis results, and dynamically adjust the predefined test case template based on the PL / SQL code characteristics to obtain a test case template;

[0007] S3: Perform dynamic testing based on test case templates in a simulated or real database environment, perform path tracing, boundary value detection, and capture anomalies to obtain dynamic analysis results.

[0008] S4: Combine static analysis results and dynamic analysis results to automatically generate test cases;

[0009] S5: Execute the test cases and conduct in-depth analysis of the test results through machine learning algorithms. Based on the analysis results, adjust the test cases through the feedback optimization mechanism to obtain the final test cases.

[0010] Furthermore, the static analysis includes lexical analysis and grammatical analysis.

[0011] Furthermore, step S1 includes:

[0012] S11: Convert the PL / SQL source code into a token stream, identify all keywords, identifiers, and operators; classify each keyword, identifier, and operator and record its location information;

[0013] S12: Build an abstract syntax tree based on keywords, identifiers, and operators;

[0014] S13: Construct control flow graph and data flow graph based on abstract syntax tree;

[0015] S14: Construct a dependency graph between functions and stored procedures based on the abstract syntax tree, control flow graph, and data flow graph.

[0016] Furthermore, the static analysis results include the location information of each keyword, identifier and operator, the abstract syntax tree, the control flow graph, the data flow graph and the dependency graph between functions and stored procedures;

[0017] The abstract syntax tree includes a plurality of syntax elements, including variable declarations, function definitions, and loop structures, and the abstract syntax tree extracts the name, type, and scope information of each syntax element;

[0018] The control flow graph shows the control flow in the program;

[0019] The data flow diagram shows how data flows in the program;

[0020] The dependency graph between the functions and stored procedures identifies the parameter transfer path, and records global variables, local variables, and the scope of global variables and the scope of local variables.

[0021] Furthermore, in step S2, the test case template library includes boundary value testing, normal process testing, exception handling testing, and performance testing.

[0022] Furthermore, in step S3,

[0023] In a simulated or real database environment, use the debugger API to monitor the execution of each statement in the test case template and its corresponding input and output in real time; and automatically generate execution path reports and boundary value test plans;

[0024] The execution path report includes the function's input and output parameter values, return value, and calling sequence; the boundary value test plan obtains boundary value test cases and boundary value prediction results;

[0025] Capture and record exception information and the location where the exception information occurs based on the execution path report and boundary value prediction results.

[0026] Furthermore, in step S4,

[0027] S41: Obtain static analysis results and dynamic analysis results;

[0028] S42: Divide the input space according to the static analysis results and establish an orthogonal classification dimension for each parameter;

[0029] S43: Based on the orthogonal classification dimensions, the Pairwise algorithm is used to generate pairwise interaction covering sets to obtain the minimum test combination;

[0030] S44: Automatically identify numeric or string boundaries based on dynamic analysis results;

[0031] S45: Traverse all branches of the control flow graph according to the static analysis results and the dynamic analysis results, dynamically iterate and solve the execution path of each branch, and obtain path-sensitive test cases;

[0032] S46: Adopt a cross-stage coordination mechanism to integrate minimum test combinations, numerical or string boundaries, and path-sensitive test cases, dynamically supplement and optimize the minimum test combinations, and generate test cases.

[0033] Furthermore, in step S5,

[0034] S51: Execute the test case and obtain the test result;

[0035] S52: Deeply analyze test results using machine learning algorithms to identify uncovered code paths or potential issues.

[0036] S53: Adjust test cases based on uncovered code paths or potential problems through feedback optimization mechanism;

[0037] S54: Repeat steps S51 to S53 to obtain the final test case.

[0038] Furthermore, in step S53, the adjusted test case is seamlessly integrated with the CI / CD pipeline, automatically triggering the test process.

[0039] The present invention also provides an efficient PL / SQL database test case generation system for executing the above-mentioned efficient PL / SQL database test case generation method, comprising:

[0040] Static analysis module: The static analysis module performs static analysis on the PL / SQL source code to obtain static analysis results;

[0041] A test case template acquisition module, wherein the test case template acquisition module selects a matching predefined test case template from a predefined test case template library according to the static analysis results, and dynamically adjusts the predefined test case template according to PL / SQL code features to obtain a test case template;

[0042] A dynamic analysis module that performs dynamic testing based on test case templates in a simulated or real database environment, performs path tracing, boundary value detection, and captures anomalies;

[0043] A test case generation module, which automatically generates test cases based on static analysis results and dynamic analysis results;

[0044] A feedback optimization module executes test cases, performs in-depth analysis of the test results through a machine learning algorithm, and adjusts the test cases through a feedback optimization mechanism based on the analysis results to obtain the final test cases.

[0045] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:

[0046] The present invention significantly improves the generation efficiency and quality of PL / SQL database test cases, reduces manual intervention, lowers error rates and accelerates the development cycle.

[0047] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0049] Figure 1 The present invention provides a flow chart of an efficient PL / SQL database test case generation method.

[0050] Figure 2 The present invention provides a schematic diagram of the structure of an efficient PL / SQL database test case generation system.

[0051] Reference numerals:

[0052] 101. Static analysis module; 102. Test case template acquisition module; 103. Dynamic analysis module; 104. Test case generation module; 105. Feedback optimization module. DETAILED DESCRIPTION

[0053] To make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below. Obviously, the embodiments described are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.

[0054] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0055] The following combination Figures 1 to 2 The present invention describes an efficient PL / SQL database test case generation method and system.

[0056] like Figure 1 As shown, an efficient PL / SQL database test case generation method includes:

[0057] S1: Perform static analysis on the PL / SQL source code to obtain static analysis results;

[0058] Static analysis includes lexical analysis and grammatical analysis.

[0059] Use tools such as ANTLR (Another Tool for Language Recognition) or Jison (a parser generator written in JavaScript) to perform lexical and syntactic analysis on PL / SQL source code.

[0060] S11: Convert the PL / SQL source code into a token stream, identify all keywords, identifiers, and operators; classify each keyword, identifier, and operator and record its location information;

[0061] Keywords include SELECT, INSERT, UPDATE, etc.; identifiers include variable names and function names, etc.; operators include = and +, etc.

[0062] In some specific embodiments of the present invention, for each keyword, identifier and operator, the system records their line number and column number in the source code and stores them in a structured data, which may be in JSON format, for subsequent error location.

[0063] S12: Build an abstract syntax tree (AST) based on keywords, identifiers, and operators;

[0064] The abstract syntax tree includes multiple syntax elements, including variable declarations, function definitions, and loop structures. The abstract syntax tree extracts the name, type, scope, and other information of each syntax element and records it in a data structure. For a variable declaration, the system not only records the variable's name, but also its data type, initial value, and scope.

[0065] The abstract syntax tree includes multiple nodes, each of which includes a syntax structure and attributes of the syntax structure.

[0066] In some specific embodiments of the present invention, for example, an assignment statement node records the assigned variable and its value source.

[0067] S13: Construct control flow graph (CFG) and data flow graph (DFG) based on abstract syntax tree;

[0068] CFG shows the control flow in a program; DFG shows how data flows in a program;

[0069] CFG and DFG record the conditional expression and branch paths of each control structure (such as IF statements and CASE statements) in detail, ensuring comprehensive coverage of all possible execution paths. For example, for an IF-ELSE structure, the specific content of the conditional expression is recorded and the corresponding path is generated for each branch.

[0070] Automatically generate detailed documentation to explain how these logical structures work, helping developers understand the workflow of the code.

[0071] S14: Construct a dependency graph between functions and stored procedures based on the abstract syntax tree, control flow graph, and data flow graph.

[0072] Dependency graphs between functions and stored procedures include direct and indirect calls, identifying parameter passing paths, and understanding the interactions between different parts.

[0073] Analyzing the use of global variables and ensuring that all dependencies are captured correctly helps in understanding the overall structure of the program and how its parts affect each other.

[0074] Records global and local variables used in functions and stored procedures, as well as their scopes, to help developers understand the scope and lifecycle of variables. For example, a variable scope map is generated to clearly show how each variable is used within its scope.

[0075] Automatically extract all input parameters, output parameters and their data types from the function or stored procedure signature, taking into account default values, optional parameters, etc., to ensure comprehensive coverage of all possible input and output combinations.

[0076] Extract all input and output parameters of a function or stored procedure, including their data types, constraints (such as NOT NULL), and default values, to form a detailed parameter list. For example, for a stored procedure with multiple input parameters, record each parameter's data type, whether it allows NULL values, and whether it has a default value.

[0077] Static analysis results include the location information of each keyword, identifier and operator, abstract syntax tree, control flow graph, data flow graph and dependency graph between functions and stored procedures;

[0078] The abstract syntax tree includes multiple syntax elements, including variable declarations, function definitions, and loop structures. The name, type, and scope information of each syntax element are extracted;

[0079] The dependency graph between functions and stored procedures identifies the parameter transfer path and records global variables, local variables, and the scope of global variables and local variables.

[0080] S2: Selecting a matching test case template from a predefined test case template library based on the static analysis results, and dynamically adjusting the test case template based on PL / SQL code features to obtain a test case template;

[0081] The predefined test case template library contains various types of predefined test case templates, including boundary value testing, normal process testing, exception handling testing, performance testing, etc. Each test case template has a detailed description, explaining the applicable scenarios and expected results.

[0082] Test case templates are designed with common programming patterns and best practices in mind, ensuring they meet the needs of most scenarios. For example, they include length limit tests for string operations and overflow tests for numeric calculations.

[0083] Each test case template comes with a detailed guide to help users adapt the template to their specific needs. For example, the boundary value test template provides specific advice on how to choose appropriate boundary values.

[0084] Dynamically adjust template content based on specific PL / SQL code characteristics (such as specific functions used, data types involved, etc.). For example, add a dedicated date format test case for date operation code.

[0085] Automatically selects the appropriate template based on static analysis results and allows users to manually adjust the template to better suit specific needs. A visual editor is provided, allowing users to easily modify test case templates. For example, users can quickly adjust test steps in a template by dragging and dropping components.

[0086] Automatically generate preliminary test case templates and provide intelligent prompts to help users improve the template content. For example, when a variable is detected as potentially sensitive data, the user is prompted to add corresponding security testing steps.

[0087] According to the static analysis result, a matching predefined test case template is selected from the predefined test case template library, and the test case template is dynamically adjusted according to the PL / SQL code characteristics to obtain a test case template.

[0088] S3: Perform dynamic testing based on test case templates in a simulated or real database environment, perform path tracing, boundary value detection, and capture anomalies to obtain dynamic analysis results.

[0089] In a simulated or real database environment, use the debugger API to monitor the execution of each statement in the test case template and its corresponding input and output in real time;

[0090] The collected information includes but is not limited to the current value of variables, control flow jump status, etc.

[0091] Support for multi-version database environments ensures consistency and reliability of test results. For example, before each execution, the target database version is automatically detected and the test strategy is adjusted accordingly.

[0092] Record the input and output parameter values ​​of each function call to help understand program behavior. The system will also generate detailed log files to record all important events and status changes;

[0093] Automatically generate an execution path report that includes the function's input and output parameter values, return value, and calling sequence; this helps developers gain a deeper understanding of the program's actual execution.

[0094] Automatically generate boundary value test plans to obtain boundary value test cases and boundary value prediction results; automatically generate a series of boundary value test cases to ensure that each variable is fully tested within its legal range. For example, for integer types, generate test cases such as minimum value -1, minimum value, minimum value +1, maximum value -1, maximum value, and maximum value +1.

[0095] Pay special attention to the boundary conditions of variable values ​​to ensure that all possible input ranges are covered. For example, for numeric variables, in addition to considering the maximum and minimum values, also consider the conditions close to these two limits.

[0096] Automatically generate a detailed boundary value test plan that lists the boundary value test cases and expected results for each variable. For example, for a form with an age field, the system will generate test cases for age = 0, age = 1, age = maximum value, age = maximum value + 1, etc.

[0097] Capture and record exception information and their locations based on execution path reports and boundary value predictions. Capturing and recording all thrown exceptions and their locations helps generate more targeted test cases and provides potential fixes for uncaught exceptions.

[0098] Exception information is recorded in detail, including stack traces and error messages, allowing developers to quickly identify the problem. Furthermore, the cause of the exception is automatically analyzed and improvement suggestions are made. For example, if an exception is detected to be caused by a null pointer reference, it is recommended to add a null value check.

[0099] Automatically generate detailed exception reports that list the location of each exception, the stack trace, and recommended fixes. This helps developers quickly fix problems in their code.

[0100] S4: Combine static analysis results and dynamic analysis results to automatically generate test cases;

[0101] S41: Obtain static analysis results and dynamic analysis results;

[0102] Upload PL / SQL script files through an intuitive and easy-to-use graphical user interface (GUI), configure test requirements (such as expected code coverage and whether to enable advanced analysis options), and obtain static and dynamic analysis results.

[0103] The GUI interface supports users to view and edit the generated test cases.

[0104] The GUI features a user-friendly design, making it easy for even non-technical users to get started. It provides extensive documentation and examples to help users understand how to use the tool. The GUI supports drag-and-drop file uploads, simplifying operations. The GUI offers detailed configuration options, allowing users to flexibly set test parameters based on project requirements. For example, users can select different test coverage standards (such as 80% and 90%) or choose whether to enable advanced options such as performance testing and security testing.

[0105] S42: Divide the input space according to the static analysis results and establish an orthogonal classification dimension for each parameter;

[0106] In some specific embodiments of the present invention, a classification tree method (CTM) is used to partition the input space and establish an orthogonal classification dimension for each parameter.

[0107] S43: Based on the orthogonal classification dimensions, a pairwise comparison / operation algorithm is used to generate pairwise interaction covering sets to obtain the minimum test combination;

[0108] In some specific embodiments of the present invention, Pairwise Independent Combinatorial Testing (PICT) is used to generate minimum test combinations, and combinations with constraint conflicts are automatically filtered.

[0109] S44: Automatically identify numeric or string boundaries based on dynamic analysis results;

[0110] S45: Traverse all branches of the control flow graph according to the static analysis results and the dynamic analysis results, dynamically iterate and solve the execution path of each branch, and obtain path-sensitive test cases;

[0111] In some specific embodiments of the present invention, all branch nodes of the control flow graph are traversed, the IF / WHILE conditions are converted into logical expressions, the path constraints are recorded in SMT-LIB format, Z3 is used to dynamically solve the values ​​that satisfy the constraints, unreachable paths are skipped, and finally an input set that satisfies different branch conditions is generated. This process is repeated to obtain path-sensitive test cases.

[0112] S46: Adopt a cross-stage coordination mechanism to integrate minimum test combinations, numerical or string boundaries, and path-sensitive test cases, dynamically supplement and optimize the minimum test combinations, and generate test cases.

[0113] In some specific embodiments of the present invention, a cross-stage coordination mechanism is adopted, input constraints are passed to path condition solution, covered paths are dynamically counted, and supplementary use cases are generated. The coverage matrix is ​​used to optimize the combination to generate test cases. After the generated test cases are automatically executed, it is verified whether the actual output matches the expectation, and the failed use cases are traced back to the corresponding stage to adjust the generation strategy.

[0114] Combine static and dynamic analysis results to automatically generate test cases through the GUI. The entire process from uploading code to generating test cases is fully automated, allowing users to complete complex tasks with simple operations. A series of predefined tasks, such as static analysis and dynamic analysis, run in the background, notifying the user upon completion. A real-time progress bar displays the completion percentage of the current task, and a detailed test progress report is automatically generated, listing the completion time for each stage, the number of issues found, and the recommended solutions. This helps teams stay informed of test progress and take necessary actions, while also providing detailed error reports when errors occur.

[0115] S5: Execute test cases, conduct in-depth analysis of test results using machine learning algorithms, and adjust test cases based on the analysis results through feedback optimization mechanisms.

[0116] S51: Execute the test case and obtain the test result;

[0117] S52: Deeply analyze test results using machine learning algorithms to identify uncovered code paths or potential issues.

[0118] By comparing actual output with expected results, we identify discrepancies and assess the impact of these issues. Result analysis goes beyond simple pass / fail judgments and includes assessments of performance metrics and resource consumption. For example, this includes analysis of memory usage and CPU utilization. A detailed test result analysis report is automatically generated, listing the comparison of actual and expected output for each test case, as well as any identified issues. For example, for a performance test case, the system analyzes execution time and resource consumption, and provides optimization recommendations.

[0119] Machine learning algorithms include decision trees and K-Means. Decision trees quickly classify test results through rule matching, such as distinguishing SQL injection risks and data type conversion errors. K-Means clusters similar failed test cases, such as all stored procedure crashes caused by "null value passing."

[0120] S53: Adjust test cases based on uncovered code paths or potential issues through a feedback optimization mechanism; the adjusted test cases are seamlessly integrated with the CI / CD pipeline to automatically trigger the testing process.

[0121] Based on the analysis results, the system continuously optimizes the testing strategy, for example, increasing the testing intensity of certain key points or adjusting the priority of test cases. At the same time, the system also predicts possible future problems based on historical data and takes preventive measures in advance.

[0122] The system will automatically adjust the test plan according to the test results, automatically generate an optimized test plan, list the new priority and execution order of each test case, and improve test efficiency and accuracy. For example, for frequently problematic code segments, increase the test frequency and coverage to allocate resources more effectively and improve test efficiency.

[0123] The adjusted test cases are seamlessly integrated with existing CI / CD pipelines, ensuring that a new round of testing is automatically triggered after each code change. This ensures that code quality is always at a high level.

[0124] Support for integration with mainstream version control systems such as Git enables automated code synchronization and test triggering. When code is committed, the test process is automatically started, and a detailed CI / CD integration report is automatically generated, listing the test results for each code commit, problems found, and suggested fixes, and the results are fed back to the development team.

[0125] S54: Repeat steps S51 to S53 to obtain the final test cases.

[0126] The efficiency and quality differences between the present application and traditional manual test case writing are verified through experiments. For 10 real PL / SQL stored procedures, three groups of developers use the present application method and traditional manual test case writing to store for two hours, evaluate code coverage, defect discovery rate, and test case generation time. The experimental data is shown in Table 1,

[0127] Table 1 Experimental data

[0128]

[0129] As shown in Table 1, the test case generation speed of the present application is 4.4 times that of manual writing. The present application significantly shortens the test case generation time, greatly improves the efficiency, discovers 41% more logical errors through branch coverage, and increases the boundary-related defect discovery rate by 100%. The present application method automatically generates 27 abnormal test cases that are not considered by manual writing. Compared with the traditional manual writing method, the completeness and maintainability of the test cases are significantly improved.

[0130] As shown in Figure 2 , a high-efficiency PL / SQL database test case generation system is used to execute a high-efficiency PL / SQL database test case generation method, which includes:

[0131] The static analysis module 101 performs static analysis on the PL / SQL source code to obtain a static analysis result;

[0132] The test case template acquisition module 102 selects a matching predefined test case template from a predefined test case template library according to the static analysis result, and dynamically adjusts the predefined test case template according to the PL / SQL code characteristics to obtain a test case template;

[0133] The dynamic analysis module 103 performs dynamic testing according to the test case template in a simulated or real database environment, executes path tracking, boundary value detection, and captures exceptions;

[0134] The test case generation module 104 automatically generates test cases in combination with the static analysis result and the dynamic analysis result;

[0135] The feedback optimization module 105 executes the test case, performs in-depth analysis on the test result through a machine learning algorithm, adjusts the test case through a feedback optimization mechanism according to the analysis result, and obtains a final test case.

[0136] Through the cooperative work of the above modules, through the use of ANTLR or Jison tools for lexical and syntax analysis, and the construction of abstract syntax tree, control flow graph and data flow graph, the logical structure, control flow and data flow in the code can be automatically identified, reducing the workload of manual analysis and improving the accuracy and efficiency of analysis.

[0137] Based on the static analysis result, the most suitable template is selected from the predefined test case template library, and the user can adjust it according to the specific requirements. This intelligent matching and adaptive customization mechanism greatly simplifies the test case design process, while ensuring the effectiveness and pertinence of the test case.

[0138] By paying special attention to the boundary conditions of variable values and generating a series of boundary value test cases, it is ensured that each variable is fully tested within its legal range. In addition, the dynamic analysis module can capture and record all exceptions thrown and their occurrence positions, helping developers quickly locate potential problems and improve the quality and stability of the code. The call relationship graph between functions and stored procedures is constructed, the parameter passing path is clear, and the interaction between different parts is understood, which helps to better understand the overall structure of the program and the mutual influence between its parts, so as to better design test cases and ensure comprehensive coverage of the entire system. A intuitive and easy-to-use graphical user interface (GUI) is provided, allowing users to easily upload PL / SQL script files, configure test requirements, and view and edit generated test cases. The GUI greatly reduces the user's threshold, even non-technical personnel can quickly get started. The entire process from code upload to test case generation is fully automated, and users can complete complex tasks with simple operations. Progress tracking, error recovery and other functions ensure that the test task can be successfully completed even when problems are encountered, improving work efficiency.

[0139] Using machine learning algorithms to deeply analyze the results of each test, identify potential problem areas, and continuously optimize testing strategies based on the analysis results, not only helps to immediately fix existing problems, but also predicts possible problems in the future, allowing preventive measures to be taken in advance and further improve product quality.

[0140] Seamlessly integrate with CI / CD pipelines to automate code synchronization and test triggering. When code is submitted, the test process is automatically started and the results are fed back to the development team, ensuring that code quality is always at a high level.

[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. An efficient PL / SQL database test case generation method, characterized in that: include: S1: Perform static analysis on the PL / SQL source code to obtain static analysis results; S2: Select a matching predefined test case template from the predefined test case template library based on the static analysis results, and dynamically adjust the predefined test case template based on the PL / SQL code characteristics to obtain a test case template; S3: Perform dynamic testing based on test case templates in a simulated or real database environment, perform path tracing, boundary value detection, and capture anomalies to obtain dynamic analysis results. S4: Combine static analysis results and dynamic analysis results to automatically generate test cases; S41: Obtain static analysis results and dynamic analysis results; S42: Divide the input space according to the static analysis results and establish an orthogonal classification dimension for each parameter; S43: Based on the orthogonal classification dimensions, the Pairwise algorithm is used to generate pairwise interaction covering sets to obtain the minimum test combination; S44: Automatically identify numeric or string boundaries based on dynamic analysis results; S45: Traverse all branches of the control flow graph according to the static analysis results and the dynamic analysis results, dynamically iterate and solve the execution path of each branch, and obtain path-sensitive test cases; S46: Adopts a cross-stage coordination mechanism to integrate minimum test combinations, numerical or string boundaries, and path-sensitive test cases, dynamically supplements and optimizes minimum test combinations, and generates test cases; S5: Execute the test cases and conduct in-depth analysis of the test results through machine learning algorithms. Based on the analysis results, adjust the test cases through the feedback optimization mechanism to obtain the final test cases.

2. An efficient PL / SQL database test case generation method according to claim 1, characterized in that: The static analysis includes lexical analysis and grammatical analysis.

3. The method for generating an efficient PL / SQL database test case according to claim 1, wherein: Step S1 includes: S11: Convert the PL / SQL source code into a token stream, identify all keywords, identifiers, and operators; classify each keyword, identifier, and operator and record its location information; S12: Build an abstract syntax tree based on keywords, identifiers, and operators; S13: Construct control flow graph and data flow graph based on abstract syntax tree; S14: Construct a dependency graph between functions and stored procedures based on the abstract syntax tree, control flow graph, and data flow graph.

4. The method for generating an efficient PL / SQL database test case according to claim 3, wherein: The static analysis results include the location information of each keyword, identifier and operator, the abstract syntax tree, the control flow graph, the data flow graph and the dependency graph between functions and stored procedures; The abstract syntax tree includes a plurality of syntax elements, including variable declarations, function definitions, and loop structures, and the abstract syntax tree extracts the name, type, and scope information of each syntax element; The control flow graph shows the control flow in the program; The data flow diagram shows how data flows in the program; The dependency graph between the functions and stored procedures identifies the parameter transfer path, and records global variables, local variables, and the scope of global variables and the scope of local variables.

5. The method for generating an efficient PL / SQL database test case according to claim 1, wherein: In step S2, the test case template library includes boundary value testing, normal process testing, exception handling testing, and performance testing.

6. The method for generating an efficient PL / SQL database test case according to claim 1, wherein: In step S3, In a simulated or real database environment, use the debugger API to monitor the execution of each statement in the test case template and its corresponding input and output in real time; And automatically generate execution path reports and boundary value test plans; The execution path report includes the function's input and output parameter values, return value, and calling sequence; the boundary value test plan obtains boundary value test cases and boundary value prediction results; Capture and record exception information and the location where the exception information occurs based on the execution path report and boundary value prediction results.

7. The method for generating an efficient PL / SQL database test case according to claim 1, wherein in step S5, S51: Execute the test case and obtain the test result; S52: Deeply analyze test results using machine learning algorithms to identify uncovered code paths or potential issues. S53: Adjust test cases based on uncovered code paths or potential problems through feedback optimization mechanism; S54: Repeat steps S51 to S53 to obtain the final test case.

8. According to the efficient PL / SQL database test case generation method of claim 7, in step S53, the adjusted test case is seamlessly integrated with the CI / CD pipeline to automatically trigger the test process.

9. An efficient PL / SQL database test case generation system, characterized by: The method for generating an efficient PL / SQL database test case according to any one of claims 1 to 8 comprises: Static analysis module: The static analysis module performs static analysis on the PL / SQL source code to obtain static analysis results; A test case template acquisition module, wherein the test case template acquisition module selects a matching predefined test case template from a predefined test case template library according to the static analysis results, and dynamically adjusts the predefined test case template according to PL / SQL code features to obtain a test case template; A dynamic analysis module that performs dynamic testing based on test case templates in a simulated or real database environment, performs path tracing, boundary value detection, and captures anomalies; A test case generation module, which automatically generates test cases based on static analysis results and dynamic analysis results; A feedback optimization module executes test cases, performs in-depth analysis of the test results through a machine learning algorithm, and adjusts the test cases through a feedback optimization mechanism based on the analysis results to obtain the final test cases.

Citation Information

Patent Citations

  • Automatic test case generation platform

    CN117112400A

  • Code analysis optimization method and device, computer equipment and storage medium

    CN118132424A

  • Automatic test case generation method based on large model and particle swarm optimization

    CN119271565A

  • Method and apparatus for performing test by using test case

    US20200019494A1