Test parameter generation method and device, storage medium and electronic equipment
By automatically generating test data and test classes, the problems of weak correlation between test data and low code matching in traditional integration testing are solved, thus achieving efficient and accurate integration testing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 中国邮政储蓄银行股份有限公司
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-21
AI Technical Summary
Traditional integration testing suffers from weak correlation between manually created test data and low matching degree between manually written test method code, resulting in low testing efficiency and poor accuracy.
By acquiring user identification information, raw database information, and mapped database information, test data and test classes, including test source code files, are automatically generated. Regular expressions and structured query statements are used to achieve automated generation of test parameters.
It significantly improved the relevance of test data and the matching degree of code, reduced coding time, and improved the success rate and coverage of integration tests.
Smart Images

Figure CN121901103A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software testing technology, and more specifically, to a method for generating test parameters, a device for generating test parameters, a computer-readable storage medium, and an electronic device. Background Technology
[0002] Traditional integration testing suffers from problems such as weak correlation between manually created test data and low code matching in manually written test methods. In other words, traditional integration testing has two core issues: 1. Test data level: Manually written data has weak logical correlation, often leading to repeated modifications due to insufficient coverage of business scenarios, consuming significant time and resources. 2. Test code level: Manually coded test classes are prone to being disconnected from actual functional logic, resulting in low code matching and frequent rework and adjustments during later testing. These problems directly impact testing efficiency and accuracy. Summary of the Invention
[0003] The main objective of this application is to provide a method, apparatus, computer-readable storage medium, and electronic device for generating test parameters, so as to at least solve the problems of weak correlation of manually fabricated test data and low matching degree of manually written test method code in traditional integration testing.
[0004] To achieve the above objectives, according to one aspect of this application, a method for generating test parameters is provided, comprising: acquiring first generated data, wherein the first generated data is data required to generate test data, the first generated data including user identification information, original database information, mapping database information, and original data, wherein the original data is data in the original database corresponding to the test data; automatically generating the test data based on the first generated data, and determining second generated data based on the test data, wherein the second generated data is data required to generate a test class, the second generated data including a test source code file and the test data; and automatically generating the test class based on the second generated data to generate test parameters, wherein the test parameters include the test data and the test class.
[0005] Optionally, the first generated data automatically generates the test data, including: receiving input user identification information; determining the original database based on the original database information and determining the mapping database based on the mapping database information, wherein the original database information includes the database name of the original database and the mapping database information includes the database name of the mapping database; determining whether there is an exported table name and data filtering conditions, wherein the exported table name is the target table for exporting the original data from the original database and the data filtering conditions are used to filter the original data from the original database; if the exported table name and the data filtering conditions exist, filtering the original data from the original database based on the user identification information, the exported table name, and the data filtering conditions, and exporting a structured query statement to the mapping database based on the original data to obtain the test data.
[0006] Optionally, the process of obtaining the original data from the original database using the user identification information, the exported table name, and the data filtering conditions includes: determining the target table based on the exported table name and determining a regular expression based on the data filtering conditions; and using the regular expression to obtain the original data from the target table based on the user identification information and the data filtering conditions, wherein the original data is data that corresponds to the user identification information and satisfies the data filtering conditions.
[0007] Optionally, there may be multiple exported table names. After determining whether an exported table name and data filtering conditions exist, the method further includes: if an exported table name exists but the data filtering conditions do not exist, determining all data in the target tables corresponding to all exported table names that correspond to the user identification information as the original data; if the data filtering conditions exist but the exported table name does not exist, using regular expressions to filter from all tables in the original database to obtain the original data that corresponds to the user identification information and satisfies the data filtering conditions; if the data filtering conditions do not exist and the exported table name does not exist, determining all data in all tables in the database that correspond to the user identification information as the original data.
[0008] Optionally, the second generated data further includes a test class name, dependency configuration, and test mode. The test class name is a unique identifier for the generated test class. The dependency configuration includes runtime data for the test class. The test mode includes the test category of the test class. Automatically generating the test class based on the second generated data includes: determining a generation directory, which is the storage location of the test class; and automatically generating a standardized test code class in the generation directory based on the test class name, dependency configuration, test mode, test source code file, and test data to obtain the test class.
[0009] Optionally, the test class name, the dependency configuration, the test mode, the test source code file, and the test data are used to automatically generate a standardized test code class in the generation directory to obtain the test class. This includes: determining the path of the structured query statement corresponding to the test data to obtain the test data path; and receiving a preset operation applied to a preset icon to automatically generate the standardized test code class in the generation directory based on the test class name, the dependency configuration, the test mode, the test source code file, and the test data path to obtain the test class.
[0010] Optionally, the method further includes: establishing a visual display interface; and using a JAVA SWING GUI component to visually display the test data and the test class on the display interface.
[0011] According to another aspect of this application, a test parameter generation apparatus is provided, comprising: an acquisition unit, configured to acquire first generation data, the first generation data being data required to generate test data, the first generation data including user identification information, original database information, mapping database information, and original data, wherein the original data is data in the original database corresponding to the test data; a first generation unit, configured to automatically generate the test data based on the first generation data, and determine second generation data based on the test data, the second generation data being data required to generate a test class, the second generation data including a test source code file and the test data; and a second generation unit, configured to automatically generate the test class based on the second generation data to generate test parameters, the test parameters including the test data and the test class.
[0012] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to perform any of the methods for generating test parameters described above.
[0013] According to another aspect of this application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including a method for performing any of the aforementioned test parameters.
[0014] Applying the technical solution of this application, the method for generating the above-mentioned test parameters first obtains first generated data, which is the data required to generate test data. The first generated data includes user identification information, original database information, mapping database information, and original data, which is the data in the original database corresponding to the test data. Test data is automatically generated based on the first generated data, and second generated data is determined based on the test data. The second generated data is the data required to generate test classes, including test source code files and test data. Test classes are automatically generated based on the second generated data to generate test parameters, which include test data and test classes. This method can quickly generate the underlying data and test classes required for integration testing through parameter configuration, reducing coding and manual data generation time, improving the success rate and coverage of integration tests, and solving the problems of weak correlation in manually generated test data and low matching degree in manually written test method class code in traditional integration testing. Attached Figure Description
[0015] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0016] Figure 1 A hardware structure block diagram of a mobile terminal for performing a method for generating test parameters according to an embodiment of this application is shown.
[0017] Figure 2 A flowchart illustrating a method for generating test parameters according to an embodiment of this application is shown.
[0018] Figure 3 An architectural design diagram of a method for generating test parameters according to an embodiment of this application is shown;
[0019] Figure 4 A flowchart illustrating a test data generation method for a test parameter generation method according to an embodiment of this application is shown.
[0020] Figure 5 A flowchart illustrating a test class generation method for a test parameter generation method according to an embodiment of this application is shown.
[0021] Figure 6 A structural block diagram of a test parameter generation apparatus provided according to an embodiment of this application is shown.
[0022] The above figures include the following reference numerals:
[0023] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. Detailed Implementation
[0024] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] For ease of description, the following explains some of the nouns or terms used in the embodiments of this application:
[0028] Integration testing: Also known as assembly testing, joint testing, or subsystem testing, integration testing aims to verify that different modules or components can work together correctly in the integrated system, ensuring the system's correctness, consistency, and reliability.
[0029] The raw database refers to the foundational database used for data export. As the core source of integration test data, it stores and retrieves the system's original data. Through standardized data structures and export mechanisms, it provides a real and complete data source for integration testing, ensuring the accuracy and reliability of data interaction and business logic verification during the testing process. It is a key underlying resource connecting the data production end and the test application end.
[0030] Mapping library: refers to a dedicated database used for importing test data. As a data support platform for integration testing, it accurately matches the requirements of test scenarios by pre-configuring and managing standardized test data, providing a complete and reliable data source for system integration testing and helping to verify the accuracy of data interaction and business logic between systems.
[0031] As described in the background section, existing technologies often suffer from fragmented test data logic due to manual coding, requiring repeated modifications, resulting in high time consumption and inefficiency. Furthermore, manually coded test classes are prone to deviating from the actual functional logic, leading to rework and modifications later. In other words, traditional integration testing suffers from two core problems: 1. Test data level: Manually written data logic has weak coherence, often requiring repeated modifications due to insufficient coverage of business scenarios, consuming significant time. 2. Test code level: Manually coded test classes are prone to disconnect from the actual functional logic, resulting in low code matching and frequent rework and adjustments during later testing. These problems directly impact testing efficiency and accuracy.
[0032] To address the issues of weak correlation in manually generated test data and low matching degree in manually written test method code in traditional integration testing, embodiments of this application provide a method for generating test parameters, a device for generating test parameters, a computer-readable storage medium, and an electronic device.
[0033] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0034] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of generating test parameters according to an embodiment of the present invention. For example... Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0035] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to method Z in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0036] This embodiment provides a method for generating test parameters that runs on a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0037] Figure 2 This is a flowchart of a method for generating test parameters according to an embodiment of this application. For example... Figure 2 As shown, the method includes the following steps:
[0038] Step S201: Obtain first generated data. The first generated data is the data required to generate test data. The first generated data includes user identification information, original database information, mapping database information, and original data. The original data is the data in the original database corresponding to the test data.
[0039] Specifically, audio data is acquired, which refers to the speech data of the target object during its speech. When the target object is conducting integration testing of the credit card system, the operator needs to input user identification information, such as the customer number, through the parameter configuration interface. This can be understood as the customer's unique identifier in the credit card system. The raw database information refers to the selected original database, i.e., the database that carries the real business data; the mapping database information points to the mapping database into which the test data will be imported, used to store test-related data. The raw data mentioned above refers to the customer-related business data in the original database, which will serve as the basic source for generating test data. By accurately acquiring user identification information and raw data closely related to the test scenario, the generated test data is ensured to have a high degree of business relevance and authenticity.
[0040] By extracting data with real business processes directly from the actual runtime library, rather than relying entirely on manually constructed test data, the relevance and scenario coverage of the test data are significantly enhanced, reducing the risk of test failures due to inaccurate data or logical disconnect.
[0041] Step S202: Automatically generate the test data based on the first generated data, and determine the second generated data based on the test data. The second generated data is the data required to generate the test class, and the second generated data includes the test source code file and the test data.
[0042] Specifically, the system automatically generates the aforementioned test data based on the first generated data, and determines the second generated data based on the test data. The second generated data is the data required to generate the test class, and includes the test source code file and the aforementioned test data. Specifically, based on user identification information, the original database, and the mapping database information, the system automatically exports relevant data from the original database using a custom SQL script or data processing algorithm to generate test data highly matching the test scenario. Subsequently, the system automatically generates a second set of data—the data required for the test class—based on the generated test data and the selected test source code file. This process includes, but is not limited to, regular expression matching, data type conversion, and logical association construction. Through parameter configuration, the system can intelligently process data, providing accurate data support for subsequent test class generation.
[0043] Parametric intelligent generation of test data effectively solves the problem of low efficiency in manual data generation, while ensuring a high degree of consistency between the data and the test scenario, thereby improving the efficiency and success rate of integration testing.
[0044] Step S203: Automatically generate the test class based on the second generated data to generate test parameters, which include test data and test class.
[0045] Specifically, the test class is automatically generated based on the second generated data to generate test parameters, including test data and the test class itself. After data generation, the operator fills in relevant test class parameters, such as class name and dependency configuration, specifying the functional code file to be tested and the test data storage path. The system will then automatically generate the test class based on this information. This process involves logical parsing of the functional code, test case design, and referencing of test data. The final generated test class will ensure a high degree of matching with the target code, providing a standardized testing method for integration testing.
[0046] The automated generation of test classes that precisely match the functional code logic greatly reduces the time spent on manual coding, lowers the risk of rework due to insufficient code matching, and further improves the efficiency and accuracy of testing.
[0047] The method for generating the test parameters described in this application first obtains first generated data, which is the data required to generate test data. This first generated data includes user identification information, original database information, mapping database information, and original data, which is the data in the original database corresponding to the test data. Test data is automatically generated based on the first generated data, and second generated data is determined based on the test data. This second generated data is the data required to generate test classes and includes test source code files and test data. Test classes are automatically generated based on the second generated data to generate test parameters, which include test data and test classes. This method can quickly generate the underlying data and test classes required for integration testing through parameter configuration, reducing coding and manual data generation time, and improving the success rate and coverage of integration tests. It solves the problems of weak correlation in manually generated test data and low matching degree in manually written test method class code in traditional integration testing.
[0048] In this embodiment, the test parameter generation method significantly improves testing efficiency and accuracy through the automated generation of integration test data and test classes. First, it acquires specific identifier information input by the user, namely the customer number parameter, along with related original and mapping database information. This process ensures that the generated test data has a clear target and source. Then, based on this first generated data, the system automatically generates test data with strong business relevance, solving the problems of time-consuming manual data generation and weak data relevance in traditional methods. Next, based on the generated test data, the system further determines the second generated data, including the source code file to be tested and the already generated test data. This step provides the necessary input for the automatic generation of test classes. Finally, based on the second generated data, the system automatically generates test classes that highly match the actual functional code, effectively improving the quality of the test code and solving the problem of low matching degree in manually coded test classes. In summary, this technical solution, through two-step automated generation, achieves effective preparation of test parameters, greatly reducing data preparation time and coding workload before integration testing, while also improving test coverage and success rate, providing strong support for efficient integration testing.
[0049] The system architecture design of the test parameter generation method is as follows: Figure 3 As shown, the system comprises a presentation layer, a business logic layer, and a data storage layer. The presentation layer uses Java Swing GUI components for the front end. Java Swing components can present various data in an intuitive and easy-to-understand way, whether it's simple text information or complex tabular data. When displaying SQL scripts, the JTable component clearly displays the values and inserted fields in the SQL script. Each row represents the column name and value to be inserted in a script, allowing users to view and analyze the data at a glance. The business logic layer adds event listeners to the Swing components, enabling the association between user operations and business logic. When a user clicks the "Export" button or the "Generate Test Class" button, the corresponding event listener is triggered, executing the corresponding business logic. The data storage layer uses SQLite, a lightweight, embedded relational database that runs directly within the software without requiring a separate server process. This simplifies software deployment and maintenance, reducing system complexity and cost. As the data layer, SQLite can independently complete data storage and management tasks without additional database server support. SQLite provides software with data persistence capabilities, enabling the storage of various types of data generated during software operation, such as test case data and test database configuration information, on disk in a structured manner. Even if the software is shut down or the system crashes, the data will not be lost and can be reused the next time the software is started.
[0050] In some embodiments, the first generated data is automatically used to generate the test data, including the following steps:
[0051] Step S301: Receive the input user identification information;
[0052] Step S302: Determine the original database based on the original database information and determine the mapping database based on the mapping database information. The original database information includes the database name of the original database and the mapping database information includes the database name of the mapping database.
[0053] Step S303: Determine whether there is an exported table name and data filtering conditions. The exported table name is the target table from the original database to export the original data. The data filtering conditions are used to filter the original data from the original database.
[0054] Step S304: Given the existence of the aforementioned exported table name and the aforementioned data filtering conditions, the aforementioned original data is obtained from the aforementioned original database based on the aforementioned user identification information, the aforementioned exported table name, and the aforementioned data filtering conditions. The structured query statement is then exported to the aforementioned mapping database based on the aforementioned original data to obtain the aforementioned test data.
[0055] In this embodiment, when the system receives the identification information input by the user, it automatically filters the original data from the original database according to the specified original database and mapping database information, based on the set export table names and data filtering conditions. This process ensures the accuracy and relevance of the test data because the original data comes directly from the database in the actual operating environment, thus truly reflecting the actual operating status and data relationships of the system. Subsequently, the system generates structured query statements (SQL) based on this original data and imports them into the mapping database to form the test data. This parameter-configured data generation method not only simplifies the data preparation process before integration testing but also avoids errors and inconsistencies caused by manual data generation, improving the quality of the test data. By intelligently matching data and business rules in real-world scenarios, the generation of test data can more accurately cover various test scenarios, improving the coverage and success rate of integration testing, thereby shortening the overall testing cycle, optimizing the testing process, and ensuring the efficiency and accuracy of system integration testing.
[0056] In some embodiments, the original data is obtained by filtering from the original database based on the user identification information, the exported table name, and the data filtering conditions, including the following steps:
[0057] Step S401: Determine the target table based on the exported table name and determine the regular expression based on the data filtering conditions.
[0058] Step S402: Based on the user identification information and the data filtering conditions, the original data is obtained from the target table using the regular expression. The original data is data that corresponds to the user identification information and meets the data filtering conditions.
[0059] The test data generation process includes the following steps: Parameter Configuration: Enter the required customer parameters in the input boxes, including: ID, customer number, ID card number, card number, specific business data, and customer-based parameters (multi-line batch input is supported); Database Selection: Specify the original database (data source database name) and the mapping database (target database for test data). Enter the data source database name (data is different in each database); Table Name and Filter Settings: Enter the table names for which data needs to be generated (tables under this customer), and add regular expressions to filter data as needed. Export: Click the "Export SQL" button, and the system will automatically generate related test data that meets the integration test requirements. Flexible data adaptation capabilities: Through parameterized configuration, the required test data can be accurately filtered according to different test scenarios, achieving efficient matching between test data and scenario requirements.
[0060] In this embodiment, the process of filtering raw data from the original database based on user identification information, exported table names, and data filtering conditions is refined. Specifically, firstly, the target data storage table is determined based on the exported table name, and a regular expression is set as the standard for data filtering based on the data filtering conditions. Subsequently, using user identification information combined with the data filtering conditions, the set regular expression is executed to accurately filter out the raw data from the target table that matches the user identification and meets the filtering conditions. This design ensures the accuracy and applicability of the test data, avoids interference from non-target data, and improves the efficiency and accuracy of integration testing. Through parameterized configuration, intelligent data filtering is achieved, reducing errors that may be caused by manual intervention, and also providing a high-quality data foundation for subsequent test class generation, ensuring the consistency and reliability of the entire testing process.
[0061] In some embodiments, there are multiple exported table names. After determining whether an exported table name and data filtering conditions exist, the method further includes the following steps:
[0062] Step S501: If the above-mentioned exported table name exists and the above-mentioned data filtering conditions do not exist, all data in the above-mentioned target table corresponding to the above-mentioned exported table name that corresponds to the above-mentioned user identification information shall be determined as the above-mentioned original data.
[0063] Step S502: If the above data filtering conditions exist and the above exported table name does not exist, use regular expressions to filter from all tables in the above original database to obtain the above original data that corresponds to the above user identification information and meets the above data filtering conditions.
[0064] Step S503: If the above data filtering conditions do not exist and the above exported table name does not exist, all data corresponding to the above user identification information in all tables of the above database shall be determined as the above original data.
[0065] The business logic layer includes several functionalities. The business logic layer uses event listeners added to Swing components to link user actions with business logic. When a user clicks the "Export" or "Generate Test Class" button, the corresponding event listener is triggered, executing the relevant business logic. The data storage layer uses SQLite, a lightweight, embedded relational database that runs directly within the software without requiring a separate server process. This simplifies software deployment and maintenance, reducing system complexity and cost. As the data layer, SQLite can independently handle data storage and management without additional database server support. SQLite provides data persistence capabilities, storing various types of data generated during software operation, such as test case data and test database configuration information, on disk in a structured manner. Even if the software is shut down or the system crashes, the data is not lost and can be reused upon the next software startup.
[0066] In this embodiment, to ensure the flexibility and comprehensiveness of integrated test data generation, this solution further details the raw data determination strategy under different parameter configurations. When there are multiple export table names without specific data filtering conditions, the system will automatically identify user identification information and extract relevant data from all specified tables as raw data, ensuring broad coverage of test scenarios. Conversely, if data filtering conditions exist but no export table name is specified, regular expressions will be used to intelligently filter data in the raw database that matches the user identification information and meets the filtering conditions, achieving precise data positioning and improving test targeting. In the most comprehensive case, when there are neither table names nor data filtering conditions, the system will traverse the entire database and extract all data associated with user identification information as test raw data, ensuring the integrity of the basic test data and laying a solid data foundation. The implementation of these strategies significantly enhances the adaptability and efficiency of this solution, enabling the rapid generation of high-quality test data regardless of diverse testing needs or complex data environments, assisting testers in efficiently conducting integration testing.
[0067] In some embodiments, the second generated data further includes a test class name, dependency configuration, and test mode. The test class name is a unique identifier for the generated test class. The dependency configuration includes runtime data for the test class. The test mode includes the test category of the test class. Automatically generating the test class based on the second generated data includes the following steps:
[0068] Step S601: Determine the generation directory, which is the storage location of the test class.
[0069] Step S602: Based on the above test class name, the above dependency configuration, the above test mode, the above test source code file and the above test data, automatically generate a standardized test code class in the above generation directory to obtain the above test class.
[0070] The test class generation process includes the following steps: Parameter input: Enter relevant parameters for the test class (such as class name, dependency configuration, etc.). Code and data path selection: Specify the functional code file to be tested and the test data storage path. Execution generation: Click the "Generate Test Class" button, and the system automatically matches the code logic and test data to generate standardized integration test code classes. Automated test class generation: Based on the selected test mode according to the parameter configuration, the system automatically generates integration test method classes that match the functional code logic, reducing manual coding errors and improving code consistency and testing efficiency.
[0071] In this embodiment, when the second generated data includes the test class name, dependency configuration, and test mode, the system first determines the generation directory of the test class, which is the exact location where the test class is stored. Subsequently, based on the test class name, dependency configuration, test mode, test source code files, and test data generated through the previous configuration, the system can automatically generate a standardized set of test code classes in the generation directory, thus obtaining the final test class. This design achieves precise matching between test data and test methods. Through parameterized configuration, it ensures that the generation of test classes is not only fast but also highly adaptable to specific test scenarios. The introduction of dependency configuration automates and reliably sets up the test environment, while the selection of test modes enhances the flexibility and coverage of test methods. The entire process significantly improves the efficiency of integration test preparation, reduces human error, ensures the accuracy and consistency of test results, and thus promotes the smooth progress of the integration test phase and improves test quality.
[0072] In some embodiments, based on the aforementioned test class name, dependency configuration, test mode, test source code file, and test data, a standardized test code class is automatically generated in the aforementioned generation directory to obtain the aforementioned test class, including the following steps:
[0073] Step S701: Determine the path of the structured query statement corresponding to the test data to obtain the test data path.
[0074] Step S702: Receive a preset operation applied to a preset icon to automatically generate the standardized test code class in the generated directory based on the test class name, the dependency configuration, the test mode, the test source code file, and the test data path, thereby obtaining the test class.
[0075] The test class generation process includes the following steps: Parameter input: Enter relevant parameters for the test class (such as class name, dependency configuration, etc.). Code and data path selection: Specify the functional code file to be tested and the test data storage path. Execution generation: Click the "Generate Test Class" button, and the system automatically matches the code logic and test data to generate standardized integration test code classes. Automated test class generation: Based on the selected test mode according to the parameter configuration, the system automatically generates integration test method classes that match the functional code logic, reducing manual coding errors and improving code consistency and testing efficiency. Intelligent test class generation mechanism: Supports the selection of multiple test models and can automatically generate test classes that are highly adapted to the target code, effectively improving the relevance and effectiveness of test cases.
[0076] In this embodiment, a solution for rapidly generating the underlying data and test classes required for integration testing through parameter configuration is implemented. This includes determining the path of the structured query statement corresponding to the test data to obtain the test data path; and after receiving a preset operation applied to a preset icon, automatically generating standardized test code classes in the generation directory based on the test class name, dependency configuration, test mode, test source code file, and test data path to obtain the test classes. This design allows testers to configure the parameters for generating test data and test classes precisely as needed through a simple and intuitive interface, achieving an intelligent and automated integration test code generation process. Through parameterized configuration, the system can intelligently extract business-related test data from the original library, map this data to the mapping library, and automatically generate integration test code classes that highly match the functional code logic. This automated data and code generation mechanism not only significantly shortens the time for manual coding and data generation but also effectively improves the accuracy and coverage of integration testing, optimizes the testing process, and ensures the efficiency and reliability of the testing process.
[0077] In some embodiments, the above method further includes the following steps:
[0078] Step S801: Establish a visual display interface;
[0079] Step S802: Use the JAVA SWING GUI component to visualize the above test data and test class on the above display interface.
[0080] In terms of presentation layer: the front end uses Java Swing GUI components. Java Swing components can present various data in an intuitive and easy-to-understand way, whether it's simple text information or complex tabular data. When displaying SQL scripts, the JTable component can clearly display the values and inserted fields in the SQL script. Each row represents the column name and value to be inserted in a script, allowing users to view and analyze data at a glance. Convenient interactive experience: a simple and intuitive tool interface design significantly reduces the operational threshold, helping operators quickly master the usage methods and significantly improving testing efficiency.
[0081] In this embodiment, the present invention further optimizes the display method of test data and test classes. By establishing a visual display interface, the test data and test classes are presented to the user in an intuitive form using the JAVA SWING GUI component. This display method not only improves the visibility of the data but also enhances the user's understanding of the test class code, making the testing process more transparent. Through the use of the GUI component, the specific information of the test data and test classes is graphically presented, including the fields and values of the data, as well as key details such as the method names and parameters of the test classes. This visualization allows users to quickly locate and check the correctness of the data and related test classes, thereby improving the efficiency and accuracy of the test preparation phase. In addition, the GUI component also provides rich interactive functions, such as data editing and test class preview, further enhancing the user experience and simplifying the testing process. The introduction of a visual display interface greatly improves the preparation work for integration testing, making the entire process more efficient, easier to manage, and easier to verify.
[0082] To enable those skilled in the art to better understand the technical solution of this application, the implementation process of the test parameter generation method of this application will be described in detail below with reference to specific embodiments.
[0083] This embodiment relates to a flowchart of a specific method for generating test parameters, such as... Figure 4 As shown, it includes the following steps:
[0084] Step S1: Start the process. The customer enters their customer number. The system checks if filtering conditions are needed. If so, the system enters a regular expression and then checks whether to export the entire database. If not, the system directly checks whether to export the entire database.
[0085] Step S2: Determine whether a full database export is required. If not, enter the table name to be exported and then select the database; if yes, directly select the database.
[0086] Step S3: After selecting the database, export the SQL and determine if the export was successful;
[0087] Step S4: Determine if the export was successful. If it fails, re-enter the customer number. If it succeeds, end the process.
[0088] This embodiment also relates to a flowchart of a specific method for generating test parameters, such as... Figure 5 As shown, it includes the following steps:
[0089] Step S1: Start the process, input parameters, and select test parameters;
[0090] Step S2: After selecting the test parameters, select the test class;
[0091] Step S3: After selecting the generation directory, select the SQLS path, and then generate the test class;
[0092] Step S4: After generating the test class, determine whether the generation was successful. If it fails, re-enter the parameters; if it succeeds, end the process.
[0093] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0094] This application also provides a test parameter generation apparatus. It should be noted that the test parameter generation apparatus of this application can be used to execute the test parameter generation method provided in this application. This apparatus is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0095] The following describes the test parameter generation apparatus provided in the embodiments of this application.
[0096] Figure 6 This is a schematic diagram of a test parameter generation apparatus according to an embodiment of this application. Figure 6 As shown, the device includes:
[0097] The system comprises an acquisition unit 10, a first generation unit 20, and a second generation unit 30. The acquisition unit 10 acquires first generation data, which is the data required to generate test data. The first generation data includes user identification information, original database information, mapping database information, and original data, which is data in the original database corresponding to the test data. The first generation unit 20 automatically generates the test data based on the first generation data and determines second generation data based on the test data. The second generation data is the data required to generate a test class and includes test source code files and the test data. The second generation unit automatically generates the test class based on the second generation data to generate test parameters, which include test data and the test class.
[0098] The test parameter generation device of this application includes an acquisition unit, a first generation unit, and a second generation unit. The acquisition unit is used to acquire first generation data, which is the data required to generate test data. The first generation data includes user identification information, original database information, mapping database information, and original data, which is the data in the original database corresponding to the test data. The first generation unit is used to automatically generate test data based on the first generation data and determine second generation data based on the test data. The second generation data is the data required to generate test classes and includes test source code files and test data. The second generation unit is used to automatically generate test classes based on the second generation data to generate test parameters, which include test data and test classes. This device can quickly generate the underlying data and test classes required for integration testing through parameter configuration, which can reduce the time spent on coding and manual data generation, improve the success rate and coverage of integration testing, and solve the problems of weak correlation of manually generated test data and low matching degree of manually written test method class code in traditional integration testing.
[0099] In some embodiments, the first generation unit includes a first acquisition module, a second acquisition module, a third acquisition module, and a first generation module. The first acquisition module is used to receive input user identification information; the second acquisition module is used to determine the original database based on the original database information and to determine the mapping database based on the mapping database information, wherein the original database information includes the database name of the original database and the mapping database information includes the database name of the mapping database; the third acquisition module is used to determine whether there is an exported table name and data filtering conditions, wherein the exported table name is the target table for exporting the original data from the original database and the data filtering conditions are used to filter the original data from the original database; the first generation module is used, if the exported table name and the data filtering conditions exist, to filter the original data from the original database based on the user identification information, the exported table name, and the data filtering conditions, and to export a structured query statement to the mapping database based on the original data to obtain the test data. By intelligently matching data and business rules in real-world scenarios, the generation of test data can more accurately cover various test scenarios.
[0100] In some embodiments, the first generation module further includes a fourth acquisition module and a second generation module. The fourth acquisition module is used to determine the target table based on the exported table name and to determine a regular expression based on the data filtering conditions. The second generation module is used to filter the original data from the target table using the regular expression based on the user identification information and the data filtering conditions. The original data is data that corresponds to the user identification information and meets the data filtering conditions. This ensures the accuracy and applicability of the test data, avoids interference from non-target data, and improves the efficiency and accuracy of integration testing.
[0101] In some embodiments, there are multiple exported table names. The device further includes a third generation module, a fourth generation module, and a fifth generation module. The third generation module is used to determine the original data by identifying all data corresponding to the user identification information in the target tables corresponding to all exported table names after determining whether exported table names and data filtering conditions exist. If exported table names exist but data filtering conditions do not exist, the fourth generation module is used to use regular expressions to filter the original data corresponding to the user identification information and satisfying the data filtering conditions from all tables in the original database. The fifth generation module is used to identify all data corresponding to the user identification information in all tables in the database as the original data if neither data filtering conditions nor exported table names exist, ensuring the accuracy of test data and comprehensive coverage of scenarios, and greatly improving the efficiency and quality of testing.
[0102] In some embodiments, the second generated data further includes a test class name, dependency configuration, and test mode. The test class name is a unique identifier for the generated test class. The dependency configuration includes runtime data for the test class, and the test mode includes the test category of the test class. The second generation unit further includes a sixth generation module and a seventh generation module. The sixth generation module is used to determine a generation directory, which is the storage location of the test class. The seventh generation module is used to automatically generate a standardized test code class in the generation directory based on the test class name, dependency configuration, test mode, test source code file, and test data, thus obtaining the test class. This significantly improves the efficiency of integration test preparation, reduces human error, ensures the accuracy and consistency of test results, and thus promotes the smooth progress of the integration test phase and improves test quality.
[0103] In some embodiments, the seventh generation module includes an eighth generation module and a ninth generation module. The eighth generation module is used to determine the path of the structured query statement corresponding to the test data, thereby obtaining the test data path. The ninth generation module is used to receive a preset operation applied to a preset icon, and automatically generate the standardized test code class in the generation directory based on the test class name, dependency configuration, test mode, test source code file, and test data path, thereby obtaining the test class. This significantly shortens the time for manual coding and data generation, effectively improves the accuracy and coverage of integration tests, optimizes the testing process, and ensures the efficiency and reliability of the testing process.
[0104] In some embodiments, the above-described apparatus further includes a tenth generation module and an eleventh generation module. The tenth generation module is used to establish a visual display interface; the eleventh generation module is used to use a JAVA SWING GUI component to visually display the test data and test classes on the display interface. This visualization process enables users to quickly locate and check the correctness of the data and related test classes, thereby improving the efficiency and accuracy of the test preparation phase.
[0105] The device for generating the aforementioned test parameters includes a processor and a memory. The aforementioned generation units are all stored as program units in the memory, and the processor executes these program units stored in the memory to achieve the corresponding functions. All of the aforementioned modules are located in the same processor; alternatively, the aforementioned modules may be located in different processors in any combination.
[0106] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can address the problems of weak correlation in manually generated test data and low matching accuracy in manually written test method code in traditional integration testing.
[0107] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0108] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute the method for generating the test parameters.
[0109] This invention provides a processor for running a program, wherein the program executes the method for generating the test parameters.
[0110] This invention provides a device including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements at least the steps of a method for generating test parameters. The device described herein may be a server, PC, PAD, mobile phone, etc.
[0111] This application also provides a computer program product that, when executed on a data processing device, is adapted to perform a program that initializes a generation method step having at least test parameters.
[0112] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0113] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0114] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0115] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0116] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0117] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0118] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0119] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0120] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0121] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0122] As can be seen from the above description, the embodiments of this application achieve the following technical effects:
[0123] 1) The method for generating the test parameters described in this application first obtains first generated data, which is the data required to generate test data. The first generated data includes user identification information, original database information, mapping database information, and original data, which is the data in the original database corresponding to the test data. Test data is automatically generated based on the first generated data, and second generated data is determined based on the test data. The second generated data is the data required to generate test classes, and includes test source code files and test data. Test classes are automatically generated based on the second generated data to generate test parameters, which include test data and test classes. This method can quickly generate the underlying data and test classes required for integration testing through parameter configuration, reducing coding and manual data generation time, improving the success rate and coverage of integration tests, and solving the problems of weak correlation in manually generated test data and low matching degree in manually written test method class code in traditional integration testing.
[0124] 2) The test parameter generation device of this application includes an acquisition unit, a first generation unit, and a second generation unit. The acquisition unit is used to acquire first generation data, which is the data required to generate test data. The first generation data includes user identification information, original database information, mapping database information, and original data, which is the data in the original database corresponding to the test data. The first generation unit is used to automatically generate test data based on the first generation data and determine second generation data based on the test data. The second generation data is the data required to generate test classes and includes test source code files and test data. The second generation unit is used to automatically generate test classes based on the second generation data to generate test parameters, which include test data and test classes. This device can quickly generate the underlying data and test classes required for integration testing through parameter configuration, which can reduce the time spent on coding and manual data generation, improve the success rate and coverage of integration testing, and solve the problems of weak correlation of manually generated test data and low matching degree of manually written test method class code in traditional integration testing.
[0125] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for generating test parameters, characterized in that, include: Obtain first generated data, which is the data required to generate test data. The first generated data includes user identification information, original database information, mapping database information, and original data. The original data is the data in the original database corresponding to the test data. The test data is automatically generated based on the first generated data, and the second generated data is determined based on the test data. The second generated data is the data required to generate the test class, and the second generated data includes the test source code file and the test data. The test class is automatically generated based on the second generated data to generate test parameters, which include test data and test class.
2. The method according to claim 1, characterized in that, The test data is automatically generated based on the first generated data, including: Receive the input user identification information; The original database is determined based on the original database information, and the mapping database is determined based on the mapping database information. The original database information includes the database name of the original database, and the mapping database information includes the database name of the mapping database. Determine whether there is an exported table name and data filtering conditions. The exported table name is the target table from the original database from which the original data is exported. The data filtering conditions are used to filter the original data from the original database. Given the existence of the exported table name and the data filtering conditions, the original data is obtained from the original database based on the user identification information, the exported table name, and the data filtering conditions. A structured query statement is then exported to the mapping database based on the original data to obtain the test data.
3. The method according to claim 2, characterized in that, Based on the user identification information, the exported table name, and the data filtering conditions, the original data is obtained by filtering from the original database, including: Based on the exported table name, determine the target table, and based on the data filtering conditions, determine the regular expression; Based on the user identification information and the data filtering conditions, the original data is obtained from the target table using the regular expression. The original data is data that corresponds to the user identification information and satisfies the data filtering conditions.
4. The method according to claim 2, characterized in that, There are multiple export table names. After determining whether an export table name and data filtering conditions exist, the method further includes: If the exported table name exists and the data filtering condition does not exist, all data in the target table corresponding to all exported table names that correspond to the user identification information are determined as the original data. If the data filtering conditions exist and the exported table name does not exist, regular expressions are used to filter the original data from all tables in the original database to obtain the original data that corresponds to the user identification information and satisfies the data filtering conditions. If the data filtering conditions and the exported table name do not exist, all data corresponding to the user identification information in all tables of the database shall be determined as the original data.
5. The method according to claim 1, characterized in that, The second generated data also includes a test class name, dependency configuration, and test mode. The test class name is a unique identifier for the generated test class. The dependency configuration includes runtime data for the test class. The test mode includes the test category of the test class. The test class is automatically generated based on the second generated data, including: Determine the generation directory, which is the storage location of the test class; Based on the test class name, the dependency configuration, the test mode, the test source code file, and the test data, a standardized test code class is automatically generated in the generation directory to obtain the test class.
6. The method according to claim 5, characterized in that, Based on the test class name, the dependency configuration, the test mode, the test source code file, and the test data, a standardized test code class is automatically generated in the generated directory, resulting in the test class, which includes: Determine the path of the structured query statement corresponding to the test data to obtain the test data path; Receive a preset operation applied to a preset icon to automatically generate the standardized test code class in the generation directory based on the test class name, the dependency configuration, the test mode, the test source code file, and the test data path, thereby obtaining the test class.
7. The method according to claim 1, characterized in that, The method further includes: Establish a visual display interface; The test data and test classes are visualized and displayed on the interface using the Java Swing GUI component.
8. A device for generating test parameters, characterized in that, include: An acquisition unit is used to acquire first generated data, which is the data required to generate test data. The first generated data includes user identification information, original database information, mapping database information, and original data, wherein the original data is the data in the original database corresponding to the test data. The first generation unit is configured to automatically generate the test data based on the first generation data, and determine the second generation data based on the test data. The second generation data is the data required to generate the test class, and the second generation data includes the test source code file and the test data. The second generation unit is used to automatically generate the test class based on the second generation data to generate test parameters, the test parameters including test data and test class.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method for generating test parameters according to any one of claims 1 to 7.
10. An electronic device, characterized in that, include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including a method for generating test parameters according to any one of claims 1 to 7.