Test data generation method and device, equipment and medium
By monitoring the business database to generate event logs and applying pre-configured rules to automatically generate test data, the problem of low efficiency of traditional manual combing is solved and efficient test data generation is achieved.
Patent Information
- Application Number
- CN202410424346.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-09
- Publication Date
- 2025-10-17
AI Technical Summary
The traditional method of manually combing business data to generate test data is inefficient and cannot support the data needs of large-scale automated testing projects.
By monitoring the business database, obtaining the event logs triggered by the changed business data, and using pre-configured data collection rules and classification rules, automatically judging and generating test data.
It improves the efficiency of test data generation and can support the data needs of large-scale automated testing projects.
Smart Images

Figure CN120803900A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the computer technology field, in particular to a test data generation method and device, equipment and medium. BACKGROUND
[0002] With the development of computer technology, software automatic testing technology appears, and software automatic testing generally uses data-driven form to improve testing efficiency and flexibility. Each test scenario needs corresponding test data. Most test data can be obtained from a business database, and each test scenario has its corresponding characteristics. Therefore, before testing, business data needs to be collected from the business database, and then the business data is further processed and filtered according to the data characteristics of the test scenario, so that the original business data in the business database is finally converted into test data used by the test scenario.
[0003] In the traditional technology, a test personnel usually manually combs the original business data to further process and filter the original business data to obtain test data used by the test scenario. However, the traditional manual combing of business data has low test data generation efficiency and cannot support the data requirements of large-scale automatic testing projects. SUMMARY
[0004] Therefore, it is necessary to provide a test data generation method, device, equipment and medium capable of improving test data generation efficiency to solve the above technical problems.
[0005] In a first aspect, the present application provides a test data generation method, which comprises:
[0006] When the business database has data changes, an event log triggered by the changed business data is obtained, and the event log contains the business data;
[0007] At least one preconfigured data collection rule is obtained;
[0008] For each data collection rule in the at least one data collection rule, when the business data contained in the event log matches the data collection rule, the data collection rule is recorded in a matched rule list;
[0009] When the data collection rule is recorded in the matched rule list and the recorded data collection rule is a valid data collection rule, at least one preconfigured data classification rule is obtained;
[0010] The acquisition module is further configured to: when the business database has data change, acquiring an event log triggered by the changed business data, the event log containing the business data; and acquiring at least one data collection rule pre-configured.
[0011] In a second aspect, the present application provides a test data generation device, the device comprising:
[0012] The acquisition module is configured to: when the business database has data change, acquiring an event log triggered by the changed business data, the event log containing the business data; and acquiring at least one data collection rule pre-configured.
[0013] The recording module is configured to: for each of the at least one data collection rule, when the business data contained in the event log matches the data collection rule, recording the data collection rule to a matched rule list.
[0014] The acquisition module is further configured to: when the matched rule list records the data collection rule and the recorded data collection rule is a valid data collection rule, acquiring at least one data classification rule pre-configured.
[0015] The marking module is configured to: for each of the at least one data classification rule, when the business data contained in the event log matches the data classification rule, assigning a label indicated by the data classification rule to the business data to obtain test data.
[0016] In one embodiment, the acquisition module is further configured to: monitoring the business database by a pre-set database monitoring component; when the database monitoring component detects that the business database has data change, acquiring an event log triggered by the changed business data; and storing the acquired event log into a pre-set message queue.
[0017] In one embodiment, the device further comprises:
[0018] The matching module is configured to, when a first collection field in a data collection rule is configured as first collection syntax data, acquire second collection syntax data configured for a second collection field in the data collection rule; generate a collection correlation query statement according to the first collection syntax data and the second collection syntax data; query service attribute data indicated by the collection correlation query statement from the service database, the service attribute data being included in the service data; replace the first collection syntax data configured for the first collection field with the service attribute data; and match the replaced service attribute data with target data indicated by the data collection rule.
[0019] In one embodiment, the first collection syntax data includes a first service field and a second service field having a foreign key correlation relationship, the first service field being a field of a first service data table in the service database, the second service field being a primary key field of a second service data table in the service database, the second collection syntax data including a third service field of the second service data table, and the collection correlation query statement including the first service field, the second service field, and the third service field; and the matching module is further configured to locate record data indicated by the second service field having the foreign key correlation relationship with the first service field from the second service data table in the service database, and query service attribute data indicated by the third service field from the located record data.
[0020] In one embodiment, the apparatus further includes:
[0021] The configuration module is configured to, in response to a collection correlation configuration operation for a collection correlation configuration page, configure a first collection field in the data collection rule as first collection syntax data indicated by the collection correlation configuration operation, and configure a second collection field in the data collection rule as second collection syntax data indicated by the collection correlation configuration operation.
[0022] In one embodiment, the test data is stored in a pre-set test data repository, at least one piece of historical test data marked as a valid state is also stored in the test data repository, the historical test data is generated based on historical service data included in a historical event log, and the apparatus further includes:
[0023] The updating module is configured to, when the data collection rule is recorded in the matched rule list and the recorded data collection rule is an invalid data collection rule, mark the historical test data collected by the data collection rule as invalid in the test data repository.
[0024] In one embodiment, the apparatus further comprises:
[0025] The matching module is configured to, when a first classification field in the data classification rule is configured as first classification syntax data, acquire second classification syntax data configured for a second classification field in the data classification rule; generate a classification association query statement according to the first classification syntax data and the second classification syntax data; query service attribute data indicated by the classification association query statement from the service database, the service attribute data being included in the service data; replace the first classification syntax data configured for the first classification field with the service attribute data; and match the replaced service attribute data with target data indicated by the data classification rule.
[0026] In one embodiment, the first classification syntax data includes a first service field and a second service field having a foreign key association relationship, the first service field being a field of a first service data table in the service database, the second service field being a primary key field of a second service data table in the service database, the second classification syntax data including a third service field of the second service data table, and the classification association query statement including the first service field, the second service field, and the third service field; and the matching module is further configured to locate record data indicated by the second service field having the foreign key association relationship with the first service field from the second service data table of the service database, and query service attribute data indicated by the third service field from the located record data.
[0027] In one embodiment, the apparatus further comprises:
[0028] The configuration module is configured to, in response to a classification association configuration operation for a classification association configuration page, configure a first classification field in the data classification rule as first classification syntax data indicated by the classification association configuration operation, and configure a second classification field in the data classification rule as second classification syntax data indicated by the classification association configuration operation.
[0029] In one embodiment, the test data is stored in a pre-set test data repository, and the acquisition module is further configured to acquire a label input by a test object of the system to be tested through a pre-set hypertext transfer protocol interface, and query test data carrying the label input by the test object from the test data repository; wherein the queried test data is used to test the system to be tested.
[0030] In one embodiment, the apparatus further comprises:
[0031] The configuration module is configured to, in response to a data collection rule configuration operation for the data collection rule configuration page, acquire at least one data collection rule indicated by the data collection rule configuration operation; and store the acquired at least one data collection rule into a pre-set data collection rule list.
[0032] In one embodiment, the apparatus further comprises:
[0033] The configuration module is configured to, in response to a data collection rule configuration operation for the data collection rule configuration page, acquire at least one data collection rule indicated by the data collection rule configuration operation; and store the acquired at least one data collection rule into a pre-set data collection rule list.
[0034] In a third aspect, the present application provides a computer device, comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the method embodiments of the present application when executing the computer program.
[0035] In a fourth aspect, the present application provides a computer readable storage medium storing a computer program, and the computer program implements the steps in the method embodiments of the present application when executed by a processor.
[0036] In a fifth aspect, the present application provides a computer program product comprising a computer program, and the computer program implements the steps in the method embodiments of the present application when executed by a processor.
[0037] The above-mentioned test data generation method, device, equipment and medium monitor the business database, and when there is a data change in the business database, obtain an event log containing business data triggered by the changed business data. Obtain at least one pre-configured data collection rule, and for each data collection rule in at least one data collection rule, when the business data contained in the event log matches the targeted data collection rule, record the targeted data collection rule in the matched rule list. When a data collection rule is recorded in the matched rule list, and the recorded data collection rule is an effective data collection rule, obtain at least one pre-configured data classification rule. For each data classification rule in at least one data classification rule, when the business data contained in the event log matches the targeted data classification rule, assign the label indicated by the targeted data classification rule to the business data to obtain test data. Compared with the traditional method of obtaining test data by manually combing business data, the present application monitors the business database, obtains the event log triggered by the changed business data, and automatically determines whether to retain or discard the obtained event log through pre-set data collection rules that meet the requirements of the test scenario. When event logs are retained, the business data in the retained event logs are automatically labeled with the data classification rules indicated by the pre-set data classification rules that meet the test scenario requirements, thereby obtaining test data that meets the test scenario requirements, improving the efficiency of test data generation, and supporting the data requirements of large-scale automated testing projects. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A diagram illustrating an application environment of a test data generation method according to an embodiment;
[0039] Figure 2 A schematic flow chart of a test data generating method according to an embodiment;
[0040] Figure 3 A schematic diagram of the test data generation principle in one embodiment;
[0041] Figure 4 A schematic diagram of the monitoring principle of event logs in a business database in one embodiment;
[0042] Figure 5 A schematic diagram of the data acquisition principle in one embodiment;
[0043] Figure 6 A schematic diagram of a data classification principle in one embodiment;
[0044] Figure 7 A schematic diagram of the test data pulling principle in one embodiment;
[0045] Figure 8An overall architecture diagram for test data generation and use in one embodiment;
[0046] Figure 9 A flowchart for collecting matches and classifying matches in the test data generation process in one embodiment;
[0047] Figure 10 An architecture diagram for a data management system in one embodiment;
[0048] Figure 11 A flowchart for a test data generation method in another embodiment;
[0049] Figure 12 A block diagram of a test data generation apparatus in one embodiment;
[0050] Figure 13 A block diagram of a test data generation apparatus in another embodiment;
[0051] Figure 14 An internal structure diagram of a computer device in one embodiment;
[0052] Figure 15 An internal structure diagram of a computer device in another embodiment. DETAILED DESCRIPTION
[0053] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not intended to limit the present application.
[0054] The test data generation method provided by the present application can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can be separately configured to store data that server 104 needs to process. The data storage system can be integrated with server 104 or placed in the cloud or on another server. Terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, in-vehicle terminals, intelligent voice interaction devices, aircraft, smart home appliances, and portable wearable devices. Smart home appliances can include smart speakers, smart TVs, and smart air conditioners. Portable wearable devices can include smart watches, smart bracelets, head-mounted devices, etc. Server 104 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides network security services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, cloud security, host security, CDN, and basic cloud computing services such as big data and artificial intelligence platforms. Terminal 102 and server 104 can be connected directly or indirectly via wired or wireless communication, which is not limited in this application.
[0055] When there is a data change in the business database, the server 104 can obtain the event log generated by the changed business data, and the event log contains business data. The server 104 can obtain at least one pre-configured data collection rule from the terminal 102. For each data collection rule in at least one data collection rule, when the business data contained in the event log matches the targeted data collection rule, the targeted data collection rule is recorded in the matched rule list. When a data collection rule is recorded in the matched rule list, and the recorded data collection rule is an effective data collection rule, the server 104 can obtain at least one pre-configured data classification rule from the terminal 102. For each data classification rule in at least one data classification rule, when the business data contained in the event log matches the targeted data classification rule, the server 104 can assign the label indicated by the targeted data classification rule to the business data to obtain test data. It can be understood that this embodiment does not limit this. It can be understood that, Figure 1 The application scenarios are only for illustration and are not limited to this.
[0056] In one embodiment, Figure 2 As shown, a test data generation method is provided. The method can be applied to a computer device, which can be a terminal or a server. That is, the method can be executed by the terminal or server alone, or can be implemented through interaction between the terminal and the server. This embodiment uses the method applied to a computer device as an example to illustrate, and includes the following steps:
[0057] Step 202, when the business database has data changes, an event log triggered by the changed business data is obtained, and the event log contains the business data.
[0058] The business database is a database for storing business data generated by a business system. The data change in the business database means that the business data stored in the business database is changed. For example, a new piece of business data is added to the business database, or a piece of business data is deleted from the business database, which indicates that the business database has data changes. The event log is log data for recording database operations on the business database. It can be understood that the event log contains business data indicated by the database operation. For example, the database operation is a write operation, and when a piece of business data is written into the business database, an event log for recording the writing of the piece of business data is triggered, and the event log contains the business data written by the write operation.
[0059] Specifically, when the business database has data changes, the computer device can trigger the generation of an event log containing the changed business data based on the changed business data.
[0060] In one embodiment, when the business database has data changes, the third-party device can trigger the generation of an event log containing the changed business data based on the changed business data. Further, the third-party device can send the generated event log to the computer device, and the computer device can receive the event log sent by the third-party device.
[0061] Step 204, at least one pre-configured data collection rule is obtained.
[0062] The data collection rule is a rule for judging whether the business data contained in the event log needs to be collected as test data.
[0063] In one embodiment, the configuration database contains a data collection rule list, and the data collection rule list can store at least one pre-configured data collection rule. The computer device can obtain at least one pre-configured data collection rule from the data collection rule list of the configuration database.
[0064] In one embodiment, the computer device can configure at least one data collection rule according to the data required by the test scenario, and store the configured at least one data collection rule in the local repository. When the business database has data changes, after obtaining the event log triggered by the changed business data, the computer device can obtain at least one pre-configured data collection rule from the local repository of the computer device.
[0065] In step 206, for each data collection rule in the at least one data collection rule, when the business data contained in the event log matches the data collection rule, the data collection rule is recorded in the matched rule list.
[0066] The matched rule list is a data table used to record the data collection rules that match the business data contained in the event log. The matching of the business data contained in the event log with the data collection rule refers to matching the business data contained in the event log with the target data indicated by the data collection rule.
[0067] Specifically, for each data collection rule in the at least one data collection rule, when the business data contained in the event log matches the data collection rule, i.e., the business data contained in the event log hits the data collection rule, the computer device can record the data collection rule in the matched rule list. It can be understood that if the business data contained in the event log fails to match all the pre-configured data collection rules, all the data collection rules that fail to match will not be recorded in the matched rule list, i.e., the matched rule list is empty.
[0068] In one embodiment, the at least one pre-configured data collection rule is stored in a data collection rule list, and the computer device can match the business data contained in the event log with each data collection rule in the data collection rule list by traversing the data collection rule list.
[0069] In one embodiment, the business data contains business attribute data, where the business attribute data is attribute data of a business, such as a city, a time, a merchant identifier, a merchant name, and the like. The matching of the business attribute data contained in the event log with the data collection rule can include at least one of the following multiple matching modes. The multiple matching modes are as follows: full matching, where the business attribute data is completely consistent with the target data indicated by the data collection rule; not-equal matching, where the business attribute data is not completely consistent with the target data indicated by the data collection rule; size matching, where the business attribute data is compared with the target data indicated by the data collection rule in terms of size; containing matching, where the business attribute data and the target data indicated by the data collection rule contain each other; not containing matching, where the business attribute data and the target data indicated by the data collection rule do not contain each other; regular expression matching, where the business attribute data is hit by a regular expression; length matching, where the business attribute data satisfies a specified length; and bit operation matching, where the business attribute data and the target data indicated by the data collection rule are subjected to a bit operation, and the operation result satisfies a preset condition.
[0070] For ease of understanding, let's take an example. For the full match mode, if the business attribute data is "City A" and the target data indicated by the data collection rule is also "City A," the business attribute data and the target data indicated by the data collection rule are considered to be completely matched. For the unequal match mode, if the business attribute data is "FFF" and the target data indicated by the data collection rule is "FFFF," the business attribute data and the target data indicated by the data collection rule are considered to be not completely matched.
[0071] In one embodiment, when no data collection rule is recorded in the matched rule list, that is, the matched rule list is empty, it means that the business data contained in the event log does not match the targeted data collection rule. At this time, the computer device can discard the event log, that is, the business data contained in the event log will not be collected as test data.
[0072] Step 208 : When a data collection rule is recorded in the matched rule list and the recorded data collection rule is a valid data collection rule, at least one pre-configured data classification rule is obtained.
[0073] The effective data collection rules are the effective data collection rules. If the business data contained in the event log matches the effective data collection rules, the business data contained in the event log will be collected as test data. The data classification rules are used to determine whether the business data contained in the event log should be labeled as test data.
[0074] Specifically, data collection rules include valid data collection rules and invalid data collection rules. Invalid data collection rules are invalid collection rules. It is understood that if business data contained in an event log matches an invalid data collection rule, the business data contained in the event log will not be collected as test data. When a data collection rule is recorded in the matched rule list and the recorded data collection rule is an valid data collection rule, the computer device can retrieve at least one pre-configured data classification rule.
[0075] In one embodiment, the configuration database includes a data classification rule list, which may store at least one pre-configured data classification rule. The computer device may obtain the at least one pre-configured data classification rule from the data classification rule list in the configuration database.
[0076] In one embodiment, the computer device may configure at least one data classification rule based on the data required by the test scenario and store the at least one configured data classification rule in a local repository. When a data collection rule is recorded in the matched rule list and the recorded data collection rule is an effective data collection rule, the computer device may retrieve the at least one pre-configured data classification rule from the local repository of the computer device.
[0077] Step 210 : For each data classification rule in at least one data classification rule, when the business data included in the event log matches the targeted data classification rule, a label indicated by the targeted data classification rule is assigned to the business data to obtain test data.
[0078] Matching the business data contained in the event log with the data classification rules refers to matching the business data contained in the event log with the target data indicated by the data classification rules.
[0079] Specifically, each data classification rule corresponds to a label for labeling business data. It can be understood that the data classification rules correspond to the labels one-to-one. For each data classification rule in at least one data classification rule, when the business data contained in the event log matches the targeted data classification rule, that is, the business data contained in the event log hits the targeted data classification rule, the computer device can assign the label indicated by the targeted data classification rule to the business data, that is, label the business data with the label indicated by the targeted data classification rule to obtain test data. It can be understood that the computer device can parse the business data from the event log and label the business data with the label indicated by the targeted data classification rule. It can be understood that each piece of business data can be labeled with at least one label, and the labeled business data is the generated test data.
[0080] In one embodiment, at least one pre-configured data classification rule is stored in a data classification rule list. The computer device can match the business data contained in the event log with each data classification rule in the data classification rule list by traversing the data classification rule list.
[0081] In an embodiment, the business data includes business attribute data, where the business attribute data is attribute data of the business, such as city, time, merchant identifier, and merchant name, etc. The business attribute data included in the event log is matched with the data classification rule, and the matching mode can include at least one of the following multiple matching modes. The multiple matching modes are respectively: full match, where the business attribute data is completely consistent with the target data indicated by the data classification rule. Inequality match, where the business attribute data is not completely consistent with the target data indicated by the data classification rule. Size match, where the business attribute data is compared with the size relationship of the target data indicated by the data classification rule. Containment match, where the business attribute data and the target data indicated by the data classification rule are matched with each other. Non-containment match, where the business attribute data and the target data indicated by the data classification rule are not matched with each other. Regular expression match, where the business attribute data is matched by a regular expression. Length match, where the business attribute data satisfies a specified length. Bit operation match, where the business attribute data and the target data indicated by the data classification rule are subjected to bit operation, and the operation result satisfies a preset condition. It can be understood that the matching mode of the data classification rule can be the same as the matching mode of the data collection rule, but the functions are different, that is, the matching purpose of the data collection rule is to collect the event log, and the matching purpose of the data classification rule is to mark the business data included in the collected event log to obtain the test data.
[0082] For the purpose of understanding, an example is given. For the full match matching mode, if the business attribute data is "B city", and the target data indicated by the data classification rule is also "B city", it is determined that the business attribute data is completely consistent with the target data indicated by the data classification rule. For the inequality match, if the business attribute data is "KKK", and the target data indicated by the data classification rule is "KKKK", it is determined that the business attribute data is not completely consistent with the target data indicated by the data classification rule.
[0083] In an embodiment, an application scenario is provided, such as Figure 3As shown, the business system can generate business data and store the business data into a business database. The computer device can monitor the business database, when there is data change in the business database, obtain the event log containing the business data triggered by the changed business data, and obtain at least one pre-configured data collection rule. For each data collection rule in the at least one data collection rule, when the business data contained in the event log matches the data collection rule, record the data collection rule to a matched rule list. When there is a data collection rule recorded in the matched rule list and the recorded data collection rule is a valid data collection rule, the computer device can obtain at least one pre-configured data classification rule. For each data classification rule in the at least one data classification rule, when the business data contained in the event log matches the data classification rule, label the business data with the label indicated by the data classification rule, obtain test data, and store the test data into a test data storage. The test object can pull the required test data from the test data storage and test the system to be tested.
[0084] In the above test data generation method, the business database is monitored, when there is data change in the business database, the event log containing the business data triggered by the changed business data is obtained. At least one pre-configured data collection rule is obtained, for each data collection rule in the at least one data collection rule, when the business data contained in the event log matches the data collection rule, the data collection rule is recorded to a matched rule list. When there is a data collection rule recorded in the matched rule list and the recorded data collection rule is a valid data collection rule, at least one pre-configured data classification rule is obtained. For each data classification rule in the at least one data classification rule, when the business data contained in the event log matches the data classification rule, the label indicated by the data classification rule is assigned to the business data, and the test data is obtained. Compared with the traditional way of obtaining test data by manually sorting business data, the present application monitors the business database, obtains the event log triggered by the changed business data, and automatically determines whether to retain or discard the obtained event log by the pre-set data collection rule meeting the test scenario requirement. In the case of retaining the event log, the business data in the retained event log is automatically labeled with the label indicated by the data classification rule by the pre-set data classification rule meeting the test scenario requirement, the test data meeting the test scenario requirement is obtained, the generation efficiency of the test data is improved, and the data requirement of large-scale automated test project can be supported.
[0085] In one embodiment, when the business database has data changes, the event log triggered by the changed business data is obtained, including: monitoring the business database by a preset database monitoring component; when the database monitoring component detects that the business database has data changes, the event log triggered by the changed business data is obtained; and the obtained event log is stored in a pre-set message queue.
[0086] The database monitoring component is a component or framework for monitoring the event log in the business database. The message queue is a middleware for passing and storing messages between application programs. It can be understood that storing the event log in the message queue can realize the characteristics of data flow control, peak shaving and high expansion, so as to improve the stability of test data generation.
[0087] Specifically, the database monitoring component has the ability to perceive changes in business data in the business database. The computer device can monitor the business database through the preset database monitoring component. When the business database has data changes, the database monitoring component can trigger the generation of the event log corresponding to the changed business data. It can be understood that when the database monitoring component detects that the business database has data changes, the computer device can obtain the event log triggered by the changed business data in time, and store the obtained event log in a pre-set message queue.
[0088] In one embodiment, as shown in Figure 4 The business system can generate a large amount of business data, and store the business data in business database 1, business database 2 and business database 3 respectively. It can be understood that the business data stored in business database 1, business database 2 and business database 3 is different. The computer device can monitor business database 1, business database 2 and business database 3 through database monitoring component 1, database monitoring component 2 and database monitoring component 3 respectively, and obtain the event log containing business data triggered by the changed business data when the business database has data changes, and store the obtained event log in the message queue for rule engine 1, rule engine 2 and rule engine 3 to consume. It can be understood that rule engine 1, rule engine 2 and rule engine 3 are respectively configured with data collection rules and data classification rules for collecting and classifying the business data in the event log. It can be understood that rule engine 1, rule engine 2 and rule engine 3 are configured the same, and are used to process the event log in the message queue in parallel to further improve the efficiency of test data generation.
[0089] In the above embodiment, the business database is monitored by the database monitoring component to timely perceive data changes of the business database. When the database monitoring component detects that there is a data change in the business database, the event log triggered by the changed business data can be acquired in a timely manner, so that the generation efficiency of the test data can be further improved, and the timeliness of the test data generation can be ensured. Meanwhile, by storing the acquired event log in the message queue, data concurrency can be avoided, and the stability of the test data generation can be improved.
[0090] In one embodiment, the method further comprises: when the first collection field in the data collection rule is configured as the first collection syntax data, acquiring second collection syntax data configured for a second collection field in the data collection rule; generating a collection correlation query statement according to the first collection syntax data and the second collection syntax data; querying the business attribute data indicated by the collection correlation query statement from the business database, the business attribute data being contained in the business data; replacing the first collection syntax data configured for the first collection field with the business attribute data; and matching the replaced business attribute data with the target data indicated by the data collection rule.
[0091] The first collection field is used to specify the data that needs to be collected and correlated and rendered. The rendering can be understood as replacement. The second collection field is used to associate the main business data table and the target business data table by foreign key in the collection process. The first collection syntax data is the collection syntax data configured for the first collection field. The second collection syntax data is the collection syntax data configured for the second collection field.
[0092] Specifically, the computer device is provided with a rule engine, and the data collection rule is set in the rule engine. As shown in Figure 5 When the rule engine parses the data collection rule, if it is detected that the first collection field of the data collection rule is configured as the first collection syntax data, it is identified as a collection correlation query. At this time, the computer device can acquire the second collection syntax data configured for the second collection field in the data collection rule, and generate a collection correlation query statement according to the first collection syntax data and the second collection syntax data. The computer device can query the business attribute data indicated by the collection correlation query statement from the business database, wherein the business attribute data is contained in the business data. Further, the computer device can replace the first collection syntax data configured for the first collection field with the business attribute data, and match the replaced business attribute data with the target data indicated by the data collection rule.
[0093] In the above embodiment, when the first collection field in the data collection rule is configured as the first collection syntax data, the second collection syntax data configured according to the second collection field in the data collection rule is obtained, the collection correlation query statement is generated according to the first collection syntax data and the second collection syntax data, and the business attribute data indicated by the collection correlation query statement is queried from the business database, so that the business attribute data can be successfully obtained, and the stability of the test data generation is improved. Further, the first collection syntax data configured according to the first collection field is replaced by the business attribute data, and the replaced business attribute data is matched with the target data indicated by the data collection rule, so that the generation efficiency of the test data is further improved.
[0094] In one embodiment, the first collection syntax data includes a first business field and a second business field having an external key correlation relationship, the first business field is a field of a first business data table in the business database, and the second business field is a primary key field of a second business data table in the business database. The second collection syntax data includes a third business field of the second business data table, and the collection correlation query statement includes the first business field, the second business field and the third business field. The business attribute data indicated by the collection correlation query statement is queried from the business database, including: locating the record data indicated by the second business field having the external key correlation relationship with the first business field from the second business data table of the business database; and querying the business attribute data indicated by the third business field from the located record data.
[0095] In one embodiment, the first collection syntax data includes a first business field and a second business field having an external key correlation relationship, the first business field is a field of a first business data table in the business database, and the second business field is a primary key field of a second business data table in the business database. The second collection syntax data includes a third business field of the second business data table, and the collection correlation query statement includes the first business field, the second business field and the third business field. The business attribute data indicated by the collection correlation query statement is queried from the business database, including: locating the record data indicated by the second business field having the external key correlation relationship with the first business field from the second business data table of the business database; and querying the business attribute data indicated by the third business field from the located record data.
[0096] Specifically, the computer device is provided with a rule engine, and a data collection rule is set in the rule engine. When the rule engine parses the data collection rule and detects that a first collection field of the data collection rule is configured as first collection syntax data, the computer device can obtain second collection syntax data configured for a second collection field in the data collection rule, and generate a collection correlation query statement according to the first collection syntax data and the second collection syntax data, wherein the collection correlation query statement contains a first business field, a second business field and a third business field. The computer device can locate record data indicated by the second business field having an external key correlation relationship with the first business field from a second business data table of a business database, and query business attribute data indicated by the third business field from the located record data, wherein the business attribute data is contained in business data. Further, the computer device can replace the first collection syntax data configured for the first collection field with the business attribute data, and match the replaced business attribute data with target data indicated by the data collection rule.
[0097] For example, the business data is order data, the business attribute data is order attribute data, and the business attribute data is the city where a merchant is located. All business attribute data of the order data is stored in an order table A and a merchant information table B. The order table A has a merchant id field, the merchant id field is a primary key of the merchant information table B, and the merchant information table B records a merchant city field. The first collection field is field_template, and the first collection syntax data configured for the first collection field field_template is databaseB.B.merchant_city, which means the city where the merchant in the merchant information table B in the business database B is located. The second collection field is field_mapping, and the second collection syntax data configured for the second collection field field_mapping is merchant_id:id, which means the merchant id field in the order table A has an external key correlation relationship with the merchant id field in the merchant information table B. It can be understood that by setting the first collection field as field_template and the second collection field as field_mapping, the order table A and the merchant information table B can be associated to perform correlation query when collecting data. If the order attribute data is "F city", the computer device can replace databaseB.B.merchant_city with "F city", and match the replaced "F city" with target data indicated by the data collection rule.
[0098] In the above embodiment, by locating the record data indicated by the second business field having the foreign key association relationship with the first business field from the second business data table of the business database, and querying the business attribute data indicated by the third business field from the located record data, the business attribute data can be further ensured to be successfully obtained, so as to further improve the stability of the test data generation.
[0099] In one embodiment, the method further includes a collecting association query configuration step, and the collecting association query configuration step includes: in response to a collecting association configuration operation for a collecting association configuration page, configuring a first collection field in the data collection rule as first collection syntax data indicated by the collecting association configuration operation; and configuring a second collection field in the data collection rule as second collection syntax data indicated by the collecting association configuration operation.
[0100] In one embodiment, the method further includes a collecting association query configuration step, and the collecting association query configuration step includes: in response to a collecting association configuration operation for a collecting association configuration page, configuring a first collection field in the data collection rule as first collection syntax data indicated by the collecting association configuration operation; and configuring a second collection field in the data collection rule as second collection syntax data indicated by the collecting association configuration operation.
[0101] Specifically, the tester of the to-be-tested system can configure the association query of the data collection rule in the visual collecting association configuration page. The computer device can configure a first collection field in the data collection rule as first collection syntax data indicated by a collecting association configuration operation for the visual collecting association configuration page, and configure a second collection field in the data collection rule as second collection syntax data indicated by the collecting association configuration operation.
[0102] In the above embodiment, the collecting association query is configured through the visual collecting association configuration page, which can improve the flexibility and convenience of the collecting association query configuration, and thus the efficiency of the collecting association query configuration can be improved.
[0103] In one embodiment, the test data is stored in a pre-set test data storage library, and at least one piece of historical test data marked as a valid state is also stored in the test data storage library. The historical test data is generated based on historical business data contained in a historical event log. The method further includes: when the data collection rule is recorded in the matched rule list, and the recorded data collection rule is an invalid data collection rule, marking the historical test data collected through the data collection rule as an invalid state in the test data storage library.
[0104] Specifically, when a data change occurs in a business database, the computer device may trigger the generation of an event log containing the changed business data based on the changed business data and retrieve at least one pre-configured data collection rule. For each of the at least one data collection rule, if the business data contained in the event log matches the targeted data collection rule, the computer device may record the targeted data collection rule in a matched rule list. The data collection rules include active and inactive data collection rules. If a data collection rule is recorded in the matched rule list and is an active data collection rule, the computer device may retrieve at least one pre-configured data classification rule. For each of the at least one data classification rule, if the business data contained in the event log matches the targeted data classification rule, the computer device may assign a tag indicated by the targeted data classification rule to the business data to obtain test data. Furthermore, the computer device may store the test data in a pre-configured test data repository. It should be noted that the test data repository also stores at least one piece of historical test data marked as active. This historical test data is generated based on historical business data contained in historical event logs. If a data collection rule is recorded in the matched rule list and the recorded data collection rule is invalid, the historical test data collected using the data collection rule will be marked as invalid in the test data repository. It is understood that if the business data contained in the event log matches the invalid data collection rule, the business data contained in the event log will not be collected as test data.
[0105] In the above embodiment, when a data collection rule is recorded in the matched rule list and the recorded data collection rule is an invalid data collection rule, the accuracy of test data generation can be improved by marking the historical test data collected by the data collection rule as invalid in the test data repository, thereby improving the accuracy of testing the system to be tested based on the test data.
[0106] In one embodiment, the method also includes: when the first classification field in the targeted data classification rule is configured as the first classification grammatical data, obtaining the second classification grammatical data configured for the second classification field in the targeted data classification rule; generating a classification association query statement based on the first classification grammatical data and the second classification grammatical data; querying the business attribute data indicated by the classification association query statement from the business database, the business attribute data being included in the business data; replacing the first classification grammatical data configured for the first classification field with the business attribute data; and matching the replaced business attribute data with the target data indicated by the targeted data classification rule.
[0107] The first classification field specifies the data to be categorized, associated, queried, and rendered. Rendering can be understood as replacement. The second classification field is used to establish a foreign key association between the primary business data table and the target business data table during the classification process. The first classification syntax data is the classification syntax data configured for the first classification field. The second classification syntax data is the classification syntax data configured for the second classification field.
[0108] Specifically, a rule engine is provided in the computer device, and the data classification rules are provided in the rule engine. Figure 6 As shown, when the rule engine parses the data classification rule, if it detects that the first classification field of the data classification rule is configured as the first classification syntax data, it is identified as a classification association query. At this time, the computer device can obtain the second classification syntax data configured for the second classification field in the targeted data classification rule, and generate a classification association query statement based on the first classification syntax data and the second classification syntax data. The computer device can query the business attribute data indicated by the classification association query statement from the business database, wherein the business attribute data is included in the business data. Furthermore, the computer device can replace the first classification syntax data configured for the first classification field with the business attribute data, and match the replaced business attribute data with the target data indicated by the targeted data classification rule.
[0109] In the above embodiment, when the first classification field in the targeted data classification rule is configured as the first classification syntax data, by obtaining the second classification syntax data configured for the second classification field in the targeted data classification rule, generating a classification association query statement based on the first classification syntax data and the second classification syntax data, and querying the business attribute data indicated by the classification association query statement from the business database, it is possible to ensure that the business attribute data is successfully obtained, thereby improving the stability of test data generation. Furthermore, by replacing the first classification syntax data configured for the first classification field with the business attribute data, and matching the replaced business attribute data with the target data indicated by the targeted data classification rule, the efficiency of test data generation can be further improved.
[0110] In one embodiment, the first classification syntax data includes a first business field and a second business field having a foreign key association relationship, the first business field is a field of a first business data table in the business database, the second business field is a primary key field of a second business data table in the business database, the second classification syntax data includes a third business field of the second business data table, and the classification association query statement includes the first business field, the second business field, and the third business field. The computer device queries the business attribute data indicated by the classification association query statement from the business database, including: locating the record data indicated by the second business field having the foreign key association relationship with the first business field from the second business data table of the business database; and querying the business attribute data indicated by the third business field from the located record data.
[0111] The first business data table and the second business data table are both data tables in the business database. It can be understood that the above-mentioned main business data table is the first business data table, and the above-mentioned target business data table is the second business data table. Each piece of business data includes multiple pieces of business attribute data. The multiple pieces of business attribute data in the same piece of business data can be recorded in different data tables of the business database. For example, the multiple pieces of business attribute data in the same piece of business data can be recorded in the first business data table and the second business data table of the business database. The primary key field is a field used to uniquely determine a record data in the business data table. For example, a record data can be uniquely determined in the second business data table of the business database through the primary key field, i.e., the second business field. It can be understood that the record data includes at least one piece of business attribute data of business data.
[0112] Specifically, the computer device is provided with a rule engine, and the data classification rule is set in the rule engine. When the rule engine parses the data classification rule and detects that the first classification field of the data classification rule is configured as the first classification syntax data, the computer device can obtain the second classification syntax data configured for the second classification field in the data classification rule, and generate a classification association query statement according to the first classification syntax data and the second classification syntax data, wherein the classification association query statement includes the first business field, the second business field, and the third business field. The computer device can locate the record data indicated by the second business field having the foreign key association relationship with the first business field from the second business data table of the business database, and query the business attribute data indicated by the third business field from the located record data, wherein the business attribute data is included in the business data. Further, the computer device can replace the first classification syntax data configured for the first classification field with the business attribute data, and match the replaced business attribute data with the target data indicated by the data classification rule.
[0113] For example, the business data is order data, the business attribute data is order attribute data, and the business attribute data is the city where the merchant is located. All business attribute data of the order data is stored in the order table A and the merchant information table B. The order table A has a merchant id field, the merchant id field is the primary key of the merchant information table B, and the merchant information table B records the merchant city field. The first classification field is field_template, and the first classification syntax data configured for the first classification field field_template is databaseB.B.merchant_city, which means the city where the merchant in the merchant information table B in the business database B is located. The second classification field is field_mapping, and the second classification syntax data configured for the second classification field field_mapping is merchant_id:id, which means that the merchant id field in the order table A and the merchant id field in the merchant information table B have a foreign key association relationship. It can be understood that by the first classification field field_template and the second classification field field_mapping, the order table A and the merchant information table B can be associated to facilitate associated query when classifying data. If the order attribute data is "F city", the computer device can replace databaseB.B.merchant_city with "F city", and match the replaced "F city" with the target data indicated by the data classification rule.
[0114] In the above embodiment, by locating the record data indicated by the second business field having a foreign key association relationship with the first business field from the second business data table of the business database, and querying the business attribute data indicated by the third business field from the located record data, the business attribute data can be further ensured to be obtained smoothly, thereby further improving the stability of the test data generation.
[0115] In one embodiment, the method further includes a classification association query configuration step, and the classification association query configuration step includes: in response to a classification association configuration operation on a classification association configuration page, configuring the first classification field in the data classification rule as the first classification syntax data indicated by the classification association configuration operation; and configuring the second classification field in the data classification rule as the second classification syntax data indicated by the classification association configuration operation.
[0116] The classification association configuration page is a visual page for configuring the associated query in the data classification rule.
[0117] Specifically, a tester of the system to be tested can configure an association query for the data classification rule on a visual classification association configuration page. In response to a classification association configuration operation on the visual classification association configuration page, the computer device can configure a first classification field in the data classification rule as first classification syntax data indicated by the classification association configuration operation, and configure a second classification field in the data classification rule as second classification syntax data indicated by the classification association configuration operation.
[0118] In the above embodiment, the classification association query is configured through a visual classification association configuration page, which can improve the flexibility and convenience of the classification association query configuration, thereby improving the efficiency of the classification association query configuration.
[0119] In one embodiment, the test data is stored in a pre-set test data repository, and the method further includes: obtaining a label input by a test subject of the system to be tested through a pre-set hypertext transfer protocol interface; querying the test data carrying the label input by the test subject from the test data repository; wherein the test data obtained by the query is used to test the system to be tested.
[0120] Specifically, the computer device can obtain the tags input by the test subject of the system under test through a pre-configured Hypertext Transfer Protocol (http) interface. Furthermore, the computer device can query the test data repository for test data containing the tags input by the test subject. It is understood that the test subject can test the system under test based on the test data obtained from the query.
[0121] For example, Figure 7 As shown, the computer device can obtain the label "City A" entered by the test subject of the system under test through a pre-set Hypertext Transfer Protocol interface. Furthermore, the computer device can query the test data repository for test data containing the label "City A" entered by the test subject. It is understood that the test subject can test the system under test based on the test data containing the label "City A" obtained from the query.
[0122] In the above embodiment, the tags input by the test subject of the system under test are obtained through the provided external Hypertext Transfer Protocol interface, and test data containing the tags input by the test subject is pulled from the test data repository, thereby improving the efficiency of test data acquisition. Furthermore, the system under test can be tested directly using the pulled test data, thereby improving the testing efficiency of the system under test.
[0123] In one embodiment, the method further comprises a data collection rule configuration step, the data collection rule configuration step comprising: in response to a collection rule configuration operation on a collection rule configuration page, obtaining at least one data collection rule indicated by the collection rule configuration operation; and storing the obtained at least one data collection rule into a pre-set data collection rule list.
[0124] The collection rule configuration page is a visual page for configuring data collection rules.
[0125] Specifically, a tester of the system to be tested can configure data collection rules in the visual collection rule configuration page to obtain at least one data collection rule. It can be understood that the computer device can obtain at least one data collection rule indicated by a collection rule configuration operation on the visual collection rule configuration page in response to the collection rule configuration operation, and store the obtained at least one data collection rule into a pre-set data collection rule list.
[0126] In the above embodiment, the data collection rules are configured through the visual collection rule configuration page, which can improve the flexibility and convenience of data collection rule configuration, thereby improving the configuration efficiency of data collection rules.
[0127] In one embodiment, the method further comprises a data classification rule configuration step, the data classification rule configuration step comprising: in response to a classification rule configuration operation on a classification rule configuration page, obtaining at least one data classification rule indicated by the classification rule configuration operation; and storing the obtained at least one data classification rule into a pre-set data classification rule list.
[0128] The classification rule configuration page is a visual page for configuring data classification rules.
[0129] Specifically, a tester of the system to be tested can configure data classification rules in the visual classification rule configuration page to obtain at least one data classification rule. It can be understood that the computer device can obtain at least one data classification rule indicated by a classification rule configuration operation on the visual classification rule configuration page in response to the classification rule configuration operation, and store the obtained at least one data classification rule into a pre-set data classification rule list.
[0130] In the above embodiment, the data classification rules are configured through the visual classification rule configuration page, which can improve the flexibility and convenience of data classification rule configuration, thereby improving the configuration efficiency of data classification rules.
[0131] In one embodiment, as Figure 8As shown, the rule engine can be configured with data collection rules and data classification rules. The tester of the system to be tested can configure the data collection rules in the visualized collection rule configuration page to obtain at least one data collection rule. It can be understood that the computer device can obtain the at least one data collection rule indicated by the collection rule configuration operation on the visualized collection rule configuration page, and store the obtained at least one data collection rule in the pre-set data collection rule list. The tester of the system to be tested can also configure the data classification rules in the visualized classification rule configuration page to obtain at least one data classification rule. It can be understood that the computer device can obtain the at least one data classification rule indicated by the classification rule configuration operation on the visualized classification rule configuration page, and store the obtained at least one data classification rule in the pre-set data classification rule list. The business system can generate business data and store the business data in the business database. When the database monitoring component detects that the business database has data changes, the computer device can obtain the event log triggered by the changed business data in time, standardize the obtained event log, and store the standardized event log in the pre-set message queue. It can be understood that standardization refers to converting the data format of the event log into the format specified by the database monitoring component. The rule engine can obtain the event log from the message queue, collect the business data contained in the event log through the data collection rules, and give the business data contained in the event log a label indicated by the data classification rules to obtain test data, and store the test data in the test data storage library. Further, the computer device can obtain the test object of the system to be tested or the label input by the system to be tested through the pre-set hypertext transfer protocol interface. The computer device can query the test data carrying the label input by the test object from the test data storage library, wherein the obtained test data can be used to test the system to be tested.
[0132] In one embodiment, as Figure 9As shown, the configuration database stores the data collection rules, the data classification rules and the correlation queries obtained by configuring the rule engine, wherein the correlation queries include collection correlation queries and classification correlation queries. The computer device can obtain the event log from the message queue, and pull the data collection rule list containing at least one data collection rule, the data classification rule list containing at least one data classification rule, the collection correlation query and the classification correlation query from the configuration database. The data collection rule list is traversed, and for each data collection rule in the at least one data collection rule, when the business data contained in the event log matches the data collection rule, the data collection rule is recorded to the matched rule list. When the business data contained in the event log does not match the data collection rule, the next data collection rule is matched. After the data collection rule list has been traversed, when the matched rule list is empty, i.e., no data collection rule is recorded in the matched rule list, the computer device can discard the corresponding event log. When the matched rule list records a data collection rule, and the recorded data collection rule is a valid data collection rule, at least one data classification rule is obtained by pre-configuration. The data classification rule list is traversed, and for each data classification rule in the at least one data classification rule, when the business data contained in the event log matches the data classification rule, the label indicated by the data classification rule is assigned to the business data, the test data is obtained, and the test data is stored in the test data storage. When the matched rule list records a data collection rule, and the recorded data collection rule is an invalid data collection rule, the computer device can mark the historical test data collected by the data collection rule as invalid in the test data storage, so as to update the test data in the test data storage, thereby improving the accuracy of the test data generation.
[0133] In one embodiment, as Figure 10As shown, the tester of the to-be-tested system can configure the data collection rule in the visual collection rule configuration page to obtain at least one data collection rule. It can be understood that the computer device can obtain the at least one data collection rule indicated by the collection rule configuration operation on the visual collection rule configuration page, and store the obtained at least one data collection rule in the data collection rule list of the pre-set rule configuration database. The tester of the to-be-tested system can also configure the data classification rule in the visual classification rule configuration page to obtain at least one data classification rule. It can be understood that the computer device can obtain the at least one data classification rule indicated by the classification rule configuration operation on the visual classification rule configuration page, and store the obtained at least one data classification rule in the data classification rule list of the pre-set association query configuration library. The computer device can obtain the test data to be stored in the test data storage library. Further, the computer device can obtain the label input by the test object of the to-be-tested system or the to-be-tested system through the pre-set hypertext transfer protocol interface. The computer device can query the test data carrying the label input by the test object from the test data storage library, wherein the obtained test data can be used to test the to-be-tested system.
[0134] As shown in the Figure 11 In one embodiment, a test data generation method is provided, which can be applied to a computer device, which can be a terminal or a server, i.e., the method can be executed by the terminal or the server alone, or can be realized through interaction between the terminal and the server. This embodiment takes the case where the method is applied to a computer device for example, and the method specifically includes the following steps:
[0135] Step 1102, monitoring the business database through the pre-set database monitoring component.
[0136] Step 1104, when the database monitoring component monitors that the business database has data changes, obtaining the event log triggered by the changed business data; the event log contains business data.
[0137] Step 1106, storing the obtained event log in the pre-set message queue.
[0138] Step 1108, obtaining at least one pre-configured data collection rule.
[0139] Step 1110, for each data collection rule in the at least one data collection rule, when the first collection field in the data collection rule is configured as the first collection syntax data, obtaining the second collection syntax data configured in the second collection field in the data collection rule.
[0140] In step 1112, a collection correlation query statement is generated according to the first collection syntax data and the second collection syntax data.
[0141] In step 1114, the service attribute data indicated by the collection correlation query statement is queried from the service database, and the service attribute data is contained in the service data.
[0142] In step 1116, the first collection syntax data configured for the first collection field is replaced by the service attribute data.
[0143] In step 1118, the replaced service attribute data is matched with the target data indicated by the data collection rule.
[0144] In step 1120, when the service data contained in the event log matches the data collection rule, the data collection rule is recorded to the matched rule list.
[0145] In step 1122, when there is no data collection rule recorded in the matched rule list, the event log is discarded.
[0146] In step 1124, when there is a data collection rule recorded in the matched rule list, and the recorded data collection rule is an invalid data collection rule, in the test data storage library, the historical test data collected by the data collection rule is marked as invalid.
[0147] In step 1126, when there is a data collection rule recorded in the matched rule list, and the recorded data collection rule is a valid data collection rule, at least one data classification rule is obtained in advance.
[0148] In step 1128, for each data classification rule in the at least one data classification rule, when the first classification field in the data classification rule is configured as the first classification syntax data, the second classification syntax data configured for the second classification field in the data classification rule is obtained.
[0149] In step 1130, a classification correlation query statement is generated according to the first classification syntax data and the second classification syntax data.
[0150] In step 1132, the service attribute data indicated by the classification correlation query statement is queried from the service database, and the service attribute data is contained in the service data.
[0151] In step 1134, the first classification syntax data configured for the first classification field is replaced by the service attribute data.
[0152] In step 1136, the replaced service attribute data is matched with the target data indicated by the data classification rule.
[0153] Step 1138, when the business data contained in the event log matches the data classification rule, the label indicated by the data classification rule is assigned to the business data, the test data is obtained, and the test data is stored in the pre-set test data storage.
[0154] Step 1140, through the pre-set hypertext transfer protocol interface, the label input by the test object of the test object of the to-be-tested system is obtained.
[0155] Step 1142, from the test data storage, the test data carrying the label input by the test object is queried, and the test data obtained by the query is used to test the to-be-tested system.
[0156] The application also provides an application scenario of the test data generation method. Specifically, the test data generation method can be applied to a test data generation scenario of a financial payment refund system. It can be understood that the business database of the application is used to store order data generated by a payment business system, the business attribute data is order attribute data, and the to-be-tested system is a financial payment refund system. Specifically, the computer device can monitor the order database through the pre-set database monitoring component. When the database monitoring component detects that the order database has data changes, the event log triggered by the changed order data is obtained; the event log contains order data. The obtained event log is stored in the pre-set message queue.
[0157] The computer device can obtain at least one pre-configured data collection rule. For each data collection rule in the at least one data collection rule, when the first collection field in the data collection rule is configured as first collection syntax data, the second collection syntax data configured for the second collection field in the data collection rule is obtained. According to the first collection syntax data and the second collection syntax data, a collection correlation query statement is generated. From the order database, the order attribute data indicated by the collection correlation query statement is queried, and the order attribute data is contained in the order data. The first collection syntax data configured for the first collection field is replaced by the order attribute data. The replaced order attribute data is matched with the target data indicated by the data collection rule.
[0158] When the order data contained in the event log matches the data collection rule, the computer device can record the data collection rule to the matched rule list. When there is no data collection rule recorded in the matched rule list, the event log is discarded. When there is a data collection rule recorded in the matched rule list, and the recorded data collection rule is an invalid data collection rule, in the test data storage library, the historical test data collected by the data collection rule is marked as invalid. When there is a data collection rule recorded in the matched rule list, and the recorded data collection rule is a valid data collection rule, at least one data classification rule is obtained. For each data classification rule in the at least one data classification rule, when the first classification field in the data classification rule is configured as first classification syntax data, the second classification syntax data configured for the second classification field in the data classification rule is obtained. According to the first classification syntax data and the second classification syntax data, a classification association query statement is generated; from the order database, the order attribute data indicated by the classification association query statement is queried, and the order attribute data is contained in the order data. The first classification syntax data configured for the first classification field is replaced by the order attribute data. The replaced order attribute data is matched with the target data indicated by the data classification rule. When the order data contained in the event log matches the data classification rule, the label indicated by the data classification rule is assigned to the order data, test data is obtained, and the test data is stored in the pre-set test data storage library.
[0159] Through the pre-set hypertext transfer protocol interface, the label input by the test object of the financial payment refund system is obtained. From the test data storage library, the test data carrying the label input by the test object is queried, and the queried test data is used to test the financial payment refund system.
[0160] It can be understood that, compared with the traditional way of obtaining test data by manually combing order data, the present application obtains the changed order data triggered to generate an event log by monitoring the order database, and automatically determines whether to retain or discard the obtained event log by pre-setting a data collection rule that meets the test scenario requirements. In the case of retaining the event log, the order data in the retained event log is automatically labeled with the label indicated by the data classification rule by pre-setting a data classification rule that meets the test scenario requirements, obtaining test data that meets the test scenario requirements, and improving the test data generation efficiency for supporting the test of the financial payment refund system.
[0161] The present application also provides an application scenario, which applies the above-mentioned test data generation method. Specifically, the test data generation method can be applied to the test data generation scenario of the commodity after-sales service system. It can be understood that the business database of the present application is used to store the commodity order data generated by the commodity purchasing system, and the system to be tested is the commodity after-sales service system. It can be understood that compared with the traditional method of obtaining test data by manually combing the commodity order data, the present application monitors the commodity order database, obtains the event log triggered by the changed commodity order data, and automatically determines whether the obtained event log is retained or discarded through the pre-set data collection rules that meet the requirements of the test scenario. In the case of retaining the event log, the commodity order data in the retained event log is automatically labeled with the data classification rule indication through the pre-set data classification rules that meet the requirements of the test scenario, and the test data that meets the requirements of the test scenario is obtained, thereby improving the efficiency of test data generation for supporting the commodity after-sales service system.
[0162] It should be understood that, although the various steps in the flow chart of the above-mentioned embodiments are shown in sequence, these steps are not necessarily performed in sequence. Unless clearly stated herein, the execution of these steps does not have strict order restrictions, and these steps can be performed in other sequences. Moreover, at least a portion of the steps in the above-mentioned embodiments may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.
[0163] In one embodiment, Figure 12 As shown, a test data generating device 1200 is provided, which specifically includes:
[0164] The acquisition module 1202 is used to obtain an event log generated by triggering a data change in the business database, wherein the event log includes the business data; and obtain at least one pre-configured data collection rule;
[0165] The recording module 1204 is configured to record, for each data collection rule in the at least one data collection rule, the data collection rule in a matched rule list when business data included in the event log matches the data collection rule;
[0166] The acquisition module 1202 is further configured to acquire at least one pre-configured data classification rule when a data collection rule is recorded in the matched rule list and the recorded data collection rule is an effective data collection rule;
[0167] The marking module 1206 is configured to, for each data classification rule, when the business data contained in the event log matches the data classification rule, assign a label indicated by the data classification rule to the business data, and obtain test data.
[0168] In an embodiment, the obtaining module 1202 is further configured to monitor the business database by a preset database monitoring component; when the database monitoring component detects that the business database has data changes, obtain an event log triggered by the changed business data; and store the obtained event log in a preset message queue.
[0169] In an embodiment, as shown in Figure 13 The test data generation apparatus 1200 further includes:
[0170] The matching module 1208 is configured to, when the first collection field in the data collection rule is configured as first collection syntax data, obtain second collection syntax data configured for a second collection field in the data collection rule; generate a collection correlation query statement according to the first collection syntax data and the second collection syntax data; query business attribute data indicated by the collection correlation query statement from the business database, the business attribute data being contained in the business data; replace the first collection syntax data configured for the first collection field with the business attribute data; and match the replaced business attribute data with target data indicated by the data collection rule.
[0171] In an embodiment, the first collection syntax data contains a first business field and a second business field having a foreign key correlation relationship, the first business field being a field of a first business data table in the business database, and the second business field being a primary key field of a second business data table in the business database, the second collection syntax data containing a third business field of the second business data table, and the collection correlation query statement containing the first business field, the second business field and the third business field; the matching module 1208 is further configured to locate record data indicated by the second business field having a foreign key correlation relationship with the first business field from the second business data table of the business database; and query business attribute data indicated by the third business field from the located record data.
[0172] In an embodiment, as shown in Figure 13 The test data generation apparatus 1200 further includes:
[0173] The configuration module 1210 is configured to, in response to the collection association configuration operation for collecting the association configuration page, configure a first collection field in the data collection rule as first collection syntax data indicated by the collection association configuration operation; and configure a second collection field in the data collection rule as second collection syntax data indicated by the collection association configuration operation.
[0174] In one embodiment, the test data is stored in a preset test data repository, and at least one piece of historical test data marked as a valid state is also stored in the test data repository, the historical test data being generated based on historical business data contained in a historical event log, such as Figure 13 As shown in the figure, the test data generation apparatus 1200 further includes:
[0175] The update module 1212 is configured to, when the data collection rule is recorded in the matched rule list and the recorded data collection rule is an invalid data collection rule, mark the historical test data collected by the data collection rule as invalid in the test data repository.
[0176] In one embodiment, as Figure 13 As shown in the figure, the test data generation apparatus 1200 further includes:
[0177] The matching module 1208 is configured to, when the first classification field in the targeted data classification rule is configured as the first classification syntax data, acquire second classification syntax data configured for a second classification field in the targeted data classification rule; generate a classification association query statement according to the first classification syntax data and the second classification syntax data; query business attribute data indicated by the classification association query statement from a business database, the business attribute data being contained in business data; replace the first classification syntax data configured for the first classification field with the business attribute data; and match the replaced business attribute data with target data indicated by the targeted data classification rule.
[0178] In one embodiment, the first classification syntax data contains a first business field and a second business field having a foreign key association relationship, the first business field being a field of a first business data table in the business database, and the second business field being a primary key field of a second business data table in the business database, the second classification syntax data containing a third business field of the second business data table, and the classification association query statement containing the first business field, the second business field and the third business field; the matching module 1208 is further configured to locate record data indicated by the second business field having the foreign key association relationship with the first business field from the second business data table of the business database; and query business attribute data indicated by the third business field from the located record data.
[0179] In one embodiment, as Figure 13As shown, the test data generating device 1200 further includes:
[0180] Configuration module 1210 is used to configure the first classification field in the data classification rule as the first classification syntax data indicated by the classification association configuration operation in response to the classification association configuration operation on the classification association configuration page; and configure the second classification field in the data classification rule as the second classification syntax data indicated by the classification association configuration operation.
[0181] In one embodiment, the test data is stored in a pre-set test data repository, and the acquisition module 1202 is further used to obtain the labels input by the test subject of the system to be tested through a pre-set hypertext transfer protocol interface; and query the test data carrying the labels input by the test subject from the test data repository; wherein the test data obtained by the query is used to test the system to be tested.
[0182] In one embodiment, Figure 13 As shown, the test data generating device 1200 further includes:
[0183] The configuration module 1210 is configured to obtain at least one data collection rule indicated by the collection rule configuration operation in response to the collection rule configuration operation on the collection rule configuration page; and store the obtained at least one data collection rule in a preset data collection rule list.
[0184] In one embodiment, Figure 13 As shown, the test data generating device 1200 further includes:
[0185] The configuration module 1210 is configured to obtain at least one data classification rule indicated by the classification rule configuration operation in response to the classification rule configuration operation on the classification rule configuration page; and store the obtained at least one data classification rule in a preset data classification rule list.
[0186] The test data generation apparatus described above, by monitoring the service database, when the service database has data changes, obtains the event log containing the service data triggered by the changed service data. At least one data collection rule is obtained in advance. For each data collection rule in the at least one data collection rule, when the service data contained in the event log matches the data collection rule, the data collection rule is recorded to the matched rule list. When the data collection rule is recorded in the matched rule list and the recorded data collection rule is a valid data collection rule, at least one data classification rule is obtained in advance. For each data classification rule in the at least one data classification rule, when the service data contained in the event log matches the data classification rule, the label indicated by the data classification rule is assigned to the service data, and the test data is obtained. Compared with the traditional way of obtaining test data by manually combing service data, the present application monitors the service database, obtains the event log triggered by the changed service data, and automatically determines whether to retain or discard the obtained event log by the pre-set data collection rule meeting the test scene requirement. In the case of retaining the event log, the data classification rule meeting the test scene requirement is pre-set, and the service data in the retained event log is automatically labeled with the label indicated by the data classification rule, and the test data meeting the test scene requirement is obtained, which improves the generation efficiency of the test data and can support the data requirement of large-scale automatic test project.
[0187] Each module in the test data generation apparatus described above can be realized by software, hardware and a combination thereof in whole or in part. The modules described above can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0188] In one embodiment, a computer device, which can be a server, is provided, and an internal structure diagram of the computer device can be as shown in FIG. 1. Figure 14As shown in the figure. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through the system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control ability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with the terminal outside through the network connection. The computer program is executed by the processor to realize a test data generation method.
[0189] In one embodiment, a computer device is provided, which can be a terminal, and its internal structure diagram can be as shown in the figure. Figure 15 As shown in the figure. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through the system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control ability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with the terminal outside through the network connection. The computer program is executed by the processor to realize a test data generation method.
[0190] Those skilled in the art can understand that, Figure 14 and Figure 15It should be noted that the structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0191] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.
[0192] In one embodiment, a computer readable storage medium is provided, storing a computer program, which, when executed by a processor, implements the steps in the above method embodiments.
[0193] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the steps in the above method embodiments.
[0194] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0195] A person of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium and can include the processes of the above method embodiments when executed. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not as a limitation, RAM can be in various forms such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0196] Any combination of the technical features in the above embodiments can be made, and for the sake of brevity, not all possible combinations are described above, however, as long as the combination of the technical features does not exist in contradiction, it shall be considered within the scope of the present disclosure.
[0197] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it shall not be understood as a limitation on the patent scope of the present application. It shall be pointed out that, for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, and these shall be within the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A test data generation method, characterized in that: The method comprises: When there is a data change in the business database, an event log generated by triggering the changed business data is obtained, wherein the event log contains the business data; Obtain at least one pre-configured data collection rule; For each of the at least one data collection rule, when the business data included in the event log matches the targeted data collection rule, recording the targeted data collection rule into a matched rule list; When the data collection rule is recorded in the matched rule list and the recorded data collection rule is an effective data collection rule, obtaining at least one pre-configured data classification rule; For each of the at least one data classification rule, when the business data contained in the event log matches the targeted data classification rule, a label indicated by the targeted data classification rule is assigned to the business data to obtain test data.
2. The method according to claim 1, characterized in that When there is a data change in the business database, obtaining the event log triggered by the changed business data includes: Monitoring the business database through a preset database monitoring component; When the database monitoring component detects that there is a data change in the business database, it obtains the event log generated by the changed business data; The acquired event log is stored in a preset message queue.
3. The method according to claim 1, characterized in that The method further comprises: When the first collection field in the targeted data collection rule is configured as the first collection syntax data, obtaining the second collection syntax data configured for the second collection field in the targeted data collection rule; generating a collection-related query statement according to the first collection grammatical data and the second collection grammatical data; querying the business attribute data indicated by the collection-related query statement from the business database, wherein the business attribute data is included in the business data; Replacing the first acquisition syntax data obtained for the first acquisition field configuration with the service attribute data; The replaced business attribute data is matched with the target data indicated by the data collection rule.
4. The method according to claim 3, characterized in that The first acquisition syntax data includes a first business field and a second business field having a foreign key association relationship, the first business field is a field of a first business data table in the business database, the second business field is a primary key field of a second business data table in the business database, the second acquisition syntax data includes a third business field of the second business data table, and the acquisition association query statement includes the first business field, the second business field, and the third business field; The querying of the business attribute data indicated by the collection-related query statement from the business database includes: Locating, from the second business data table of the business database, record data indicated by the second business field having the foreign key association relationship with the first business field; The service attribute data indicated by the third service field is searched from the located record data.
5. The method according to claim 3, characterized in that The method further includes a configuration step of collecting associated queries, wherein the configuration step of collecting associated queries includes: In response to a collection association configuration operation on a collection association configuration page, configuring a first collection field in the data collection rule to be first collection syntax data indicated by the collection association configuration operation; The second collection field in the data collection rule is configured as the second collection syntax data indicating the collection association configuration operation.
6. The method according to claim 1, characterized in that The test data is stored in a pre-set test data repository, the test data repository also storing at least one piece of historical test data marked as valid, the historical test data being generated based on historical business data contained in a historical event log, the method further comprising: When the data collection rule is recorded in the matched rule list and the recorded data collection rule is an invalid data collection rule, the historical test data collected by the data collection rule is marked as invalid in the test data repository.
7. The method according to claim 1, characterized in that The method further comprises: When the first classification field in the targeted data classification rule is configured as the first classification syntax data, obtaining the second classification syntax data configured for the second classification field in the targeted data classification rule; generating a classification association query statement according to the first classification grammatical data and the second classification grammatical data; querying the business attribute data indicated by the classification association query statement from the business database, wherein the business attribute data is included in the business data; Replacing the first classification syntax data obtained by configuring the first classification field with the business attribute data; The replaced business attribute data is matched with the target data indicated by the data classification rule.
8. The method according to claim 7, characterized in that The first classification grammatical data includes a first business field and a second business field having a foreign key association relationship, the first business field is a field of a first business data table in the business database, the second business field is a primary key field of a second business data table in the business database, the second classification grammatical data includes a third business field of the second business data table, and the classification association query statement includes the first business field, the second business field, and the third business field; The querying of the business attribute data indicated by the classification association query statement from the business database includes: Locating, from the second business data table of the business database, record data indicated by the second business field having the foreign key association relationship with the first business field; The service attribute data indicated by the third service field is searched from the located record data.
9. The method according to claim 7, characterized in that The method further includes a step of configuring a classification association query, wherein the step of configuring the classification association query includes: In response to a classification association configuration operation on a classification association configuration page, configuring a first classification field in the data classification rule as first classification syntax data indicated by the classification association configuration operation; The second classification field in the data classification rule is configured as the classification association configuration operation indicating second classification syntax data.
10. The method according to claim 1, characterized in that The test data is stored in a pre-set test data repository, and the method further includes: Obtaining the label input by the test subject of the system to be tested through a pre-set hypertext transfer protocol interface; Querying the test data repository for test data carrying the label input by the test subject; The test data obtained by querying is used to test the system to be tested.
11. The method according to claim 1, wherein The method further includes a step of configuring data collection rules, wherein the step of configuring data collection rules includes: In response to a collection rule configuration operation on a collection rule configuration page, obtaining at least one data collection rule indicated by the collection rule configuration operation; The at least one acquired data collection rule is stored in a preset data collection rule list.
12. The method according to any one of claims 1 to 11, characterized in that The method further includes a step of configuring data classification rules, wherein the step of configuring data classification rules includes: In response to a classification rule configuration operation on a classification rule configuration page, obtaining at least one data classification rule indicated by the classification rule configuration operation; The at least one acquired data classification rule is stored in a preset data classification rule list.
13. A test data generating device, characterized in that: The device comprises: An acquisition module is configured to acquire an event log generated by triggering a data change in a business database, wherein the event log includes the business data; and acquire at least one pre-configured data collection rule; a recording module configured to, for each of the at least one data collection rule, record the targeted data collection rule in a matched rule list when the business data contained in the event log matches the targeted data collection rule; The acquisition module is further configured to acquire at least one pre-configured data classification rule when the data collection rule is recorded in the matched rule list and the recorded data collection rule is an effective data collection rule; A labeling module is used to assign a label indicated by the targeted data classification rule to the business data for each of the at least one data classification rule when the business data contained in the event log matches the targeted data classification rule, thereby obtaining test data.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.
15. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.