Rule automated testing method, device, electronic device and storage medium

By synchronizing rules on the system and automatically generating test cases, simulating user behavior to trigger rules in a sandbox environment, comparing expected and actual results, the problems of low efficiency and high cost caused by manual reliance on rule testing in the existing technology are solved, and the problem of low efficiency and high cost is realized. The efficiency and accuracy of rules automated testing.

CN114860615BActive Publication Date: 2025-02-18FUTU NETWORK TECH (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210629406.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-02
Publication Date
2025-02-18
Estimated Expiration
2042-06-02

AI Technical Summary

Technical Problem

In the prior art, rule testing mainly relies on manual testing, which is inefficient and costly, and cannot achieve automated verification, which poses quality hazards and waste of resources.

Method used

By synchronizing multiple rules on the system and automatically generating corresponding test cases and their expected trigger results, simulate user behavior to trigger rules in a sandbox environment, and compare expected and actual trigger results to generate test results.

Benefits of technology

Automatic testing of rules is realized, reducing operation and maintenance labor, improving the effectiveness and accuracy of automation verification, and reducing testing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860615B_ABST
    Figure CN114860615B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a rule automation testing method, apparatus, device and storage medium, the method comprising: synchronizing multiple rules on the system and automatically generating multiple test cases corresponding to each rule, the test cases comprising the expected trigger results corresponding to each rule; constructing user data according to the test cases, and sending the user data to a sandbox, the sandbox being used to simulate the actual triggering environment for the multiple rules on the system; receiving the actual trigger results under the target rules matching the user data returned by the sandbox; comparing the expected trigger results with the actual trigger results, and generating test results based on the comparison results obtained. The embodiments of the present application can synchronize all the rules on the system to automatically generate corresponding test cases for automated verification, reduce operation and maintenance manpower, increase the effectiveness and accuracy of automated verification, and also reduce testing costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a rule automatic testing method, device, electronic device and storage medium. Background Art

[0002] Rules are the laws followed by operations and operating rules. In general, rules are systematic decision-making procedures that use information in a sustainable and predictable way. In the actual operating environment of a system with multiple rules, accidents of repeated or incorrect triggering of rules are often caused due to mismatched rules in operations, errors in the logic of rule code, etc. However, the current testing of rules mainly relies on manual testing, which is not only inefficient and time-consuming, but also cannot traverse all the rules running online under limited resources, posing quality risks. In addition, the technical templates relied on by manual testing in existing technologies have poor compatibility, insufficient scope of application, and require clear environment configuration. The automation rate is insufficient, which wastes operation and maintenance manpower. It also increases the cost of rule testing while losing the effectiveness and accuracy of automated verification. Summary of the invention

[0003] To solve the above technical problems, the embodiments of the present application provide a rule-based automated testing method, device, electronic device and storage medium.

[0004] According to one aspect of an embodiment of the present application, a rule automation testing method is provided, comprising:

[0005] Synchronize multiple rules on the system and automatically generate multiple test cases corresponding to each rule, wherein the test cases include expected trigger results corresponding to each rule;

[0006] Constructing user data according to the test case, and sending the user data to a sandbox, wherein the sandbox is used to simulate an actual triggering environment for the multiple rules on the system;

[0007] Receiving an actual trigger result under a target rule matching the user data returned by the sandbox;

[0008] The expected trigger result and the actual trigger result are compared, and a test result is generated according to the obtained comparison result.

[0009] According to one aspect of an embodiment of the present application, a rule-based automated testing device is provided, comprising:

[0010] A first generating module, used for synchronizing multiple rules on the system and automatically generating multiple test cases corresponding to each rule, wherein the test cases include expected triggering results corresponding to each rule;

[0011] A user data construction module, used for constructing user data according to the test case, and sending the user data to a sandbox, wherein the sandbox is used for simulating an actual triggering environment for the multiple rules on the system;

[0012] A receiving module, used to receive the actual trigger result returned by the sandbox under the target rule matching the user data;

[0013] The second generating module is used to compare the expected trigger result with the actual trigger result, and generate a test result according to the obtained comparison result.

[0014] In one embodiment of the present application, the user data construction module is specifically used to:

[0015] Constructing user attribute data and user behavior data according to the test case;

[0016] A user behavior event message is simulated based on the user attribute data and the user behavior data, and the simulated user behavior event message is sent to the sandbox as the user data.

[0017] In one embodiment of the present application, the user data construction module is further specifically used for:

[0018] Using the test case as an input parameter to call the user data interface included in the preset database;

[0019] Receive the user attribute data and user behavior data returned by the user data interface for the test case.

[0020] In one embodiment of the present application, the user data construction module is further specifically used for:

[0021] Simulating a user identity according to the user attribute data, and simulating a user behavior triggered under the user identity according to the user behavior data;

[0022] The user behavior event message is generated based on the simulated user behavior triggered under the user identity.

[0023] In one embodiment of the present application, the second generating module is specifically used for:

[0024] Determine an expected trigger result corresponding to the target rule from the multiple test cases;

[0025] The expected trigger result corresponding to the target rule is compared with the actual trigger result to generate the test result according to the obtained comparison result.

[0026] In one embodiment of the present application, the device further includes:

[0027] A calculation module, used for calculating an approximate value between the expected trigger result and the actual trigger result;

[0028] The error reporting module is used to send an error reporting message including an optimization solution to the background if the approximate value is less than a preset threshold.

[0029] In one embodiment of the present application, the device further includes:

[0030] A data cleaning module, configured to clean up the user data if the test result indicates that the test passed;

[0031] A data updating module is used to resend the user data to the sandbox if the test result indicates that the test fails, so as to update the test result based on the data returned by the sandbox.

[0032] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements the rule-based automated testing method as described above.

[0033] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the rule-based automated testing method as described above.

[0034] According to one aspect of an embodiment of the present application, a computer program product is also provided, including a computer program, which implements the steps in the rule testing method described above when executed by a processor.

[0035] In the technical solution provided in the embodiments of the present application, all online rules are synchronized and corresponding test cases and their corresponding expected trigger results are automatically generated. Then, the user behavior is simulated according to the data in the test case to trigger the rules in the actual environment of the sandbox simulation to generate the corresponding actual trigger results. The test results are obtained by comparing the actual trigger results with the expected trigger results. In this way, the corresponding test cases are automatically generated for the rules on the system and automated verification is performed, which can reduce operation and maintenance manpower, increase the effectiveness and accuracy of automated verification, and reduce testing costs.

[0036] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0038] Figure 1 The following schematically shows an exemplary system architecture block diagram applying the technical solution of the present application;

[0039] Figure 2 A flowchart of a rule-based automated testing method provided by an embodiment of the present application is schematically shown;

[0040] Figure 3 yes Figure 2 Step S220 in the illustrated embodiment is a flow chart in an exemplary embodiment;

[0041] Figure 4 yes Figure 3 Step S222 in the illustrated embodiment is a flow chart in an exemplary embodiment;

[0042] Figure 5 yes Figure 2 Step S240 in the illustrated embodiment is a flow chart in an exemplary embodiment;

[0043] Figure 6 is a flow chart of a rule-based automated testing method shown in another exemplary embodiment of the present application;

[0044] Figure 7 The structure diagram of the rule-based automated testing device provided in the embodiment of the present application is schematically shown;

[0045] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0046] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0047] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0048] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0049] The term "multiple" as used in this application refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.

[0050] In addition, the described features, structures or characteristics may be combined in any suitable manner in one or more embodiments, and in the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical solutions of the present application may be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present application.

[0051] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0052] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0053] Figure 1 The exemplary system architecture block diagram applying the technical solution of the present application is schematically shown.

[0054] like Figure 1As shown, the system architecture 100 may include a terminal device 110, a network 120 and a server 130. The terminal device 110 may include a smart phone, a tablet computer, a laptop computer, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc. The server 130 may be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The network 120 may be a communication medium of various connection types that can provide a communication link between the terminal device 110 and the server 130, for example, a wired communication link or a wireless communication link.

[0055] This implementation environment can be specifically implemented as an exemplary test system, in which the terminal device 110 is implemented as a test terminal, and the server 130 is a test server. The server 130 automatically synchronizes multiple rules on the system to be tested and automatically generates multiple test cases corresponding to each rule. The test case includes the expected trigger result corresponding to each rule, and then constructs user data according to the test case, and sends the user data to the sandbox. The sandbox is used to simulate the actual trigger environment for multiple rules on the system, thereby receiving the actual trigger result under the target rule matching the user data returned by the sandbox, and finally comparing the expected trigger result with the actual trigger result, and then generating the test result according to the comparison result. The server 130 can also send the obtained test results to the terminal device 110 for visual display so that relevant testers can obtain them.

[0056] According to the implementation requirements, the system architecture in the embodiment of the present application can have any number of terminal devices, networks and servers. For example, the server 130 can be a server group composed of multiple server devices. In addition, the technical solution provided in the embodiment of the present application can be applied to the terminal device 110, can also be applied to the server 130, or can be implemented by the terminal device 110 and the server 130 together, and the present application does not make any special restrictions on this.

[0057] The data query method provided by the present application is described in detail below in conjunction with specific implementation methods.

[0058] Figure 2 A flowchart of a rule automation testing method provided by an embodiment of the present application is schematically shown. The method can be executed by a server, such as by Figure 1 The method can also be executed by a terminal device, such as by Figure 1 The terminal device 110 shown executes the operation, which is not limited here.

[0059] If Figure 2 As shown, the rule automation testing method provided in the embodiment of the present application includes steps S210 to S240, which are described in detail as follows:

[0060] Step S210, synchronizing multiple rules on the system and automatically generating multiple test cases corresponding to each rule, wherein the test cases include expected trigger results corresponding to each rule.

[0061] As mentioned above, rules are the laws followed by operations and operating rules. In this embodiment, rules are systematic decision-making procedures that use information in a sustainable and predictable manner. When the triggering of external information or when the conditions for triggering the rules are met, the corresponding triggering results are generated according to the rules. The triggering results may include: rewards, penalties, discounts and other events with results. For example, triggering the reward rule will get the corresponding reward result, triggering the penalty rule will get the corresponding penalty result, triggering the discount rule will get the corresponding discount result, and so on.

[0062] In this embodiment, all rules on the system are synchronized, and when the rules are changed or new rules are added, all rules on the platform are automatically traversed. There are generally a large number of rules on the system. Since the rules influence and restrict each other, they constitute a systematic decision-making program. In this embodiment, test cases are automatically generated according to the dimensions of a single rule. Test cases refer to the test cases required for testing the trigger conditions corresponding to the rule. In other words, the test cases referred to in this embodiment are precedent data required for the corresponding single rule when performing automated testing. Specifically, the rules referred to in this embodiment can be reward rules, preferential policies, exemption rules and penalty rules launched by various systems. Taking the reward rules running on the system as an example, banks, financial institutions, securities companies, etc. will run different reward rules according to the behavior of users under a certain identity. In this embodiment, the system automatically traverses all existing rules on the platform, and according to the dimensions of a single rule, triggers all possible events under the rule and generates multiple test cases corresponding to all possible events, wherein the test case includes the expected reward result of this event.

[0063] For example, the securities company's system runs the rules of registration, account opening, deposit, and transfer. Specifically, registration refers to the computer user entering the user name and password to obtain the recognition of the computer network system; account opening refers to: opening an account is to open a stock trading account at a securities company. The existing account opening methods include: offline account opening and online account opening; registering an account to apply for account opening; depositing refers to: depositing funds into a stock account; transfer refers to: generally refers to futures trading, transferring the expiring contract to the next month or a later month. In this embodiment, the above registration, account opening, deposit, and transfer rules need to be triggered and verified according to the dimensions of a single rule to generate multiple corresponding test cases.

[0064] It should be understood that the dimension of a single rule refers to automatically generating various possible trigger test cases under each single rule according to the trigger verification of each rule in all the rules configured on the system. In other words, without considering other rules, only all possible triggers under the current single rule are considered.

[0065] Taking the deposit ladder rule as an example, it should be noted that in this embodiment, the deposit ladder means that the user transfers funds to the stock account in batches, that is, all the deposit amounts of the user are superimposed, and trigger events are generated according to the different deposit amounts obtained by superposition, and then different reward results are generated according to the deposit rules. Exemplarily, in this embodiment, when the user deposits 5000HKD (Hong Kong Dollar) in net value within the rule time range, reward 1 is obtained, and when the user deposits 30000HKD in net value, reward 2 can be obtained. Among them, reward 1 and reward 2 are different rewards provided for different deposit amounts. This rule means that when user A deposits 5000HKD, he can get reward 1, and when user A deposits 25000HKD again, reward 2 is superimposed; user B can get reward 1 and reward 2 for a one-time deposit of 30000HKD.

[0066] For this deposit ladder rule, multiple corresponding test cases are automatically generated, and verification is mainly carried out based on the deposit amount and deposit time:

[0067] Test case 1: Single-step triggering of ladder 1 (user A deposits 5000HKD and gets reward 1);

[0068] Test case 2: Single-step triggering of ladder 2 (user B deposits 5,000 HKD, then deposits 25,000 HKD again, and gets reward 1 and reward 2);

[0069] Test case 3: Deposit the maximum tiered amount once to get all rewards, and deposit the maximum tiered amount repeatedly without triggering rewards repeatedly (user C deposits 30,000 HKD, and then deposits 30,000 HKD again to get rewards 1 and 2);

[0070] Test case 4: A single deposit is less than the threshold amount, and the reward is not triggered (user D deposits 4999.99HKD, and the reward is not triggered);

[0071] Test case 5: The net value is less than the deposit amount (there is a withdrawal record), and the reward is not triggered (user E deposits 4999.99HKD, withdraws 0.01HKD, and deposits 0.01HKD. At this time, the net deposit of 4999.99HKD does not trigger the reward);

[0072] Test case 6: A deposit is initiated before the rule start time, and the deposit is received within the rule time range, but the reward is not triggered;

[0073] Test case 7: A deposit is initiated after the rule expiration time, but is received before the rule expiration time, and the reward is not triggered;

[0074] Test case 8: A deposit is initiated within the rule time range, but the deposit is received after the rule expiration time, and the reward is not triggered.

[0075] Step S220, constructing user data according to the test case, and sending the user data to a sandbox, where the sandbox is used to simulate the actual triggering environment for multiple rules on the system.

[0076] It should be noted that a sandbox is a virtual environment in which programs running in this environment are independent and will not affect your current operating system. When the sandbox is closed, all operations will be restored. Sandboxes can be used to test programs and software that may be risky. It is a virtualization technology. In this embodiment, a sandbox is an isolated environment provided for running user data trigger rules. The corresponding user data is constructed according to the event messages in the automatically generated multiple test cases, wherein an event message refers to an event message in a test case that triggers the expected trigger result, for example, in the above test case 2, "After user B deposited 5000HKD, he deposited 25000HKD again", that is, the so-called event message refers to a message sent by an object, for example: a user presses a button, a file changes, etc., which are all event messages.

[0077] Exemplarily, the user attribute data and user behavior data corresponding to the test case are obtained by parsing the corresponding event message in the test case. Specifically, the user attribute data includes: user ID (Identity document), user ID account level, user identity location, user IP (Identification of Position) address, user company and other data related to user attributes; user behavior data refers to user-triggered behavior, such as registration, account opening, deposit and transfer and other data related to user behavior. By combining the user's attribute data and the user's behavior data, the user behavior event message constructed by the user data simulation is obtained, and the obtained user behavior event message is sent to the sandbox environment for simulating the actual trigger environment of the system for multiple rules, so as to generate the corresponding actual trigger result by triggering the target rule corresponding to the user data in the sandbox environment. Specifically, in the sandbox environment, the user behavior event message sent by the system and constructed according to the user attribute data and user behavior data in the test case is monitored, and the user-related attributes and behavior data in the user event behavior message are obtained through the interface provided by the user-related service in the sandbox environment and matched with the corresponding target rule, and then the actual trigger result is generated according to the logic of the target rule.

[0078] Step S230, receiving the actual trigger result under the target rule matching the user data returned by the sandbox.

[0079] It should be understood that the actual trigger result refers to the corresponding trigger result generated by matching the rules matching the user data in multiple rules as the target rules in the sandbox environment used to simulate the actual environment of the system for multiple rules according to the user data constructed in the test case, and triggering the rules under the target rules according to the user data. That is, after receiving the user data and actually triggering the target rule, the sandbox returns the actual trigger result triggered by the user data under the target rule to the system.

[0080] Take the aforementioned test case 2 as an example, the user data extracted therein is that user B deposited 5000HKD and then deposited 25000HKD again. Further, the extracted user attribute data "user B" extracts the user behavior data: "After depositing 5000HKD, deposit 25000HKD again". According to the extracted user attribute data and user behavior data, a user event behavior message of a specific user, namely user B, is constructed: "Under the identity of user B, after depositing 5000HKD, deposit 25000HKD again" is sent to the sandbox used to simulate the actual trigger environment of the rules on the system. The sandbox obtains the user-related attributes and behavior data in the user event behavior message through the interface provided by the user-related service in the sandbox environment according to the monitored user event behavior message, matches the corresponding target rule, and then generates the actual trigger result according to the logic of the target rule. . Specifically, taking the aforementioned test case 2 as an example, in the sandbox, the user-related attributes and behavior data obtained through the relevant user interface according to the user behavior event message is "User B deposits 5,000 HKD and then deposits 25,000 HKD again". The target rule matched is the deposit rule, and the actual trigger result obtained under the deposit rule is "Get reward 1, reward 2".

[0081] Step S240, comparing the expected trigger result with the actual trigger result, and generating a test result according to the obtained comparison result.

[0082] Compare the expected trigger result in the test case with the actual trigger result triggered in the sandbox simulating the actual environment, and compare whether the actual trigger result is consistent with the expected trigger result, and generate the corresponding test result based on the comparison result. For example, taking the reward rule as an example, the reward results in the expected trigger result of the test case are reward 1 and reward 2, and the reward results in the actual trigger result in the sandbox environment based on the user data constructed according to the test case are also reward 1 and reward 2. This proves that the expected trigger result in the test case and the actual trigger result generated in the sandbox simulating the actual trigger environment based on the user data constructed according to the test case are consistent, and thus it can be concluded that the test result of the test case is passed.

[0083] In this embodiment, by automatically comparing the consistency of the actual trigger result in the sandbox and the expected trigger result in the test case, it is possible to reduce the operation and maintenance manpower, increase the effectiveness and accuracy of automated verification, and reduce the testing cost.

[0084] In another exemplary embodiment of the present application, please refer to Figure 3 , Figure 2 Step S220 in the illustrated embodiment may be further implemented as steps S211 to S222 as shown below:

[0085] Step S221, constructing user attribute data and user behavior data according to the test case;

[0086] Step S222, simulating a user behavior event message based on the user attribute data and the user behavior data, and sending the simulated user behavior event message as user data to the sandbox.

[0087] Constructing user data according to the test case includes constructing user attribute data and user behavior data according to the test case. Specifically, extract the corresponding user attribute data and user behavior data in the event message in the test case, wherein, taking the online reward rules of a securities company as an example, the user attribute data includes the company, account ID and other attribute-related information, and the user behavior data includes registration, account opening, deposit and transfer and other user behavior-related information. In other words, simulate the user behavior event message according to the user attribute data and user behavior data extracted from the test case, for example: user B (account ID: 123456) deposits 40,000HKD, and send the simulated user behavior event message to the sandbox used to simulate the actual trigger environment for multiple rules on the system.

[0088] In this embodiment, the user data in the automatically generated test case is constructed and the user event message is simulated, which ensures the consistency of the user data that triggers the target rule in the sandbox environment and the user data in the automatically generated test case, and further ensures the accuracy of the test results.

[0089] Based on the above embodiment, in another exemplary embodiment of the present application, please refer to Figure 4 , step S221 can further implement steps S2211 to S2212 as shown below:

[0090] Step S2211, calling the user data interface included in the preset database using the test case as an input parameter;

[0091] Step S2212, receiving user attribute data and user behavior data returned by the user data interface for the test case.

[0092] It should be noted that the input parameter means: the value of the input parameter is required by the called function, that is, when calling a function, parameters are usually passed, the code inside the function remains unchanged, and different data is processed for different parameters. Common input parameter methods include positional parameter passing, keyword parameter passing, default value parameter, multi-value parameter, etc. In this embodiment, the test case is used as the input parameter passing method to call the corresponding function in order to obtain the user data interface in the preset database, and then the user attribute data and user behavior data corresponding to the test case are constructed in the preset database according to the user data interface.

[0093] In this embodiment, user attribute data and user behavior data are constructed from preset data based on the test case as an input parameter, thereby ensuring the relevance of the test case and the user data constructed therefrom, and further ensuring the accuracy and validity of the test results.

[0094] Further, based on the above embodiment, in another exemplary embodiment provided by a rule-based automated testing method of the present application, the method further includes:

[0095] The user identity is simulated according to the user attribute data, and the user behavior triggered under the user identity is simulated according to the user behavior data; and a user behavior event message is generated based on the simulated user behavior triggered under the user identity.

[0096] According to the user attribute data and user behavior data further extracted from the user data extracted from the test case, the user behavior event message is simulated. Specifically, the identity information corresponding to the user is simulated according to the user attribute data, and the user behavior is simulated according to the user behavior data under the identity information corresponding to the user, thereby generating a user behavior event message based on the simulated user behavior triggered under the user identity. For example: user A, IP address: Guangdong, user location: user, company: xxxxx company, age: 35 years old, and other data related to user attributes simulate the user identity; similarly, the user behavior data is obtained by constructing simulated user behavior data through a relational database and a corresponding communication protocol, for example: 30000 in warehouse, 5000 out, 6000 in, thus, the simulated user behavior event message can be constructed according to the user data as: user A, IP address: Guangdong, user location: user, company: xxxxx company, age 35 years old, 30000 in warehouse, 5000 out, 6000 in warehouse, and then the target rule is matched from all rules in the actual environment of the sandbox synchronized system, and the corresponding actual trigger result is generated under the target rule.

[0097] In this embodiment, the user data constructed in the test case simulates the user event behavior message and sends it to the sandbox environment, ensuring the consistency of the user data used to trigger the rules in the sandbox and the user data constructed by the test case, further ensuring the validity of the test results.

[0098] Based on the above embodiment, in another exemplary embodiment of the present application, please refer to Figure 5 , step S240 can further implement steps S241 to S242 as shown below:

[0099] Step S241, determining the expected trigger result corresponding to the target rule from multiple test cases;

[0100] Step S242, comparing the expected trigger result corresponding to the target rule with the actual trigger result, so as to generate a test result according to the obtained comparison result.

[0101] According to the target test case corresponding to the user data traceability, specifically, the target test case used to construct the input preset database of the user data as an input parameter is determined according to the user data passed into the sandbox, and the expected trigger result contained in the target test case is determined, and the expected trigger result and the actual trigger result are compared to generate the corresponding test result based on the comparison result.

[0102] Still taking the aforementioned deposit rule as an example, if the target test case obtained by tracing the user data is the above test case 3 (after user C deposits 30,000 HKD, he deposits 30,000 HKD again and gets reward 1 and reward 2), the expected trigger result is: get reward 1 and reward 2; the actual trigger result generated by the rule triggered in the sandbox environment according to the user data constructed by inputting the target test case as an input parameter into the preset database is: get reward 1 and reward 2. The comparison result obtained by comparing the expected trigger result with the actual trigger result is that the expectation is consistent with the actual, so the test result of test case 3 under the deposit rule is passed.

[0103] In this embodiment, the actual triggering result triggered by the user data is obtained in a sandbox simulating an actual triggering environment for multiple rules on the user data input system constructed according to the test case, thereby ensuring the accuracy of the test result.

[0104] Further, based on the above embodiment, in another embodiment provided by a rule-based automated testing method of the present application, the method further includes:

[0105] Step S250, calculating an approximate value between the expected trigger result and the actual trigger result;

[0106] Step S260: If the approximate value is less than a preset threshold, an error message including an optimization solution is sent to the background.

[0107] Specifically, the testing process for the rules may also include: tracing the source of the user data sent to the sandbox environment to obtain the input parameter target test case for generating the user data, and obtaining the corresponding expected trigger result from the target test case, and calculating the approximate value between the expected trigger result and the actual trigger result of the user data in the sandbox environment. Specifically, in this embodiment, the expected trigger result and the actual trigger result are first quantified to obtain the expected trigger data and the actual trigger data, which can be replaced by a preset data correspondence relationship to obtain data of the same type; then the approximate value Sim (Dat_pre, Dat_act) between the expected trigger data Dat_pre and the actual trigger data Dat_act is calculated as:

[0108] Sim(Dat_pre,Dat_act)=α·e -Dat_pre-Dat_act (Dat_pre+Dat_act)

[0109] Among them, α represents a preset approximation factor. In this embodiment, when the calculated approximation value is less than the preset approximation value threshold, it means that the test fails, indicating that there is a large difference between the expected trigger result and the actual trigger result. Therefore, a corresponding optimization plan is generated based on the comparison result between the expected trigger result and the actual trigger result, and the error message including the optimization plan is sent to the background. That is, when the test result of the rule fails, an optimization plan is generated based on the comparison result between the actual trigger result and the expected trigger result, so that the system can be automatically corrected according to the optimization plan or corrected by relevant personnel.

[0110] Further, based on the above embodiment, in another embodiment provided by a rule-based automated testing method of the present application, the method further includes:

[0111] If the test result indicates that the test passed, clean up the user data;

[0112] If the test result indicates that the test fails, the user data is sent to the sandbox again to update the test result based on the data returned by the sandbox.

[0113] When the test result indicates that the current test has passed, the user data constructed according to the test case is cleaned up. If the test result indicates that the current test has not passed, the error site data is checked to confirm whether the error is due to a code operation error or an operational configuration error, and the user data is resent to the sandbox that simulates the actual environment of the system to update the test results based on the data returned by the sandbox. In this way, the test case data and test data that have passed on the system are cleaned up to reduce the load on the server operation; the failed data is retriggered to update the test results to help correct the test system.

[0114] Figure 6 A flowchart of a rule automatic testing method provided by a specific embodiment of the present application is shown as follows:

[0115] S1. Multiple rules on the automated background synchronization system;

[0116] S2. The automation backend sends the updated multiple rules to the sandbox environment;

[0117] S3. The automation background automatically generates multiple test cases corresponding to each rule, and the test cases include the expected trigger results corresponding to each rule;

[0118] S4. construct user data according to the test case and send the user data to the sandbox;

[0119] S5. The sandbox triggers the matching target rule according to the user data and generates the actual trigger result under the target rule;

[0120] S6. The sandbox returns the generated actual trigger result to the automation background;

[0121] S7. The automated background compares the expected trigger result in the test case with the actual trigger result sent by the sandbox, and generates a test result based on the comparison result.

[0122] The background automatically synchronizes multiple rules on the system environment, and updates the synchronized rules to the sandbox environment. In this embodiment, the sandbox is used to simulate the actual trigger environment for multiple rules on the system. The background automatically generates multiple test cases corresponding to each rule on the system, wherein the test case includes the expected trigger result corresponding to each rule. The background constructs the user data corresponding to each test case according to the test case as an input parameter input into the preset database, and sends the constructed user data to the sandbox used to simulate the actual trigger environment for multiple rules on the system, and matches the target rule in the sandbox, and generates the corresponding actual trigger result under the target rule. The sandbox returns the actual trigger result generated by the user data to the background, and the background compares the actual trigger result with the expected trigger result in the test case, and generates the test result based on the comparison result between the actual trigger result and the test case. Testing the rules on the system through background automation reduces the dependence on manual testing, and improves the accuracy of the test results while improving the test efficiency.

[0123] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0124] Figure 7 is a block diagram of a rule automation testing device 300 shown in an exemplary embodiment of the present application. The device can be applied to Figure 2 The implementation environment shown is specifically configured in the intelligent terminal 110 or the server 130. The device may also be applicable to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment applicable to the device.

[0125] like Figure 7 As shown, the exemplary rule-based automated testing device 300 includes:

[0126] The first generation module 310 is configured to synchronize multiple rules on the system and automatically generate multiple test cases corresponding to each rule, and the test cases include the expected trigger results corresponding to each rule; the user data construction module 320 is configured to construct user data according to the test cases and send the user data to the sandbox, and the sandbox is used to simulate the actual trigger environment for multiple rules on the system; the receiving module 330 is configured to receive the actual trigger results under the target rules matching the user data returned by the sandbox; the second generation module 340 is configured to compare the expected trigger results with the actual trigger results, and generate test results based on the comparison results obtained.

[0127] In this exemplary rule automation testing device, multiple test cases corresponding to multiple rules on the system and expected trigger results included in the test cases are automatically generated, and user data is constructed according to the test cases. The target rules in the sandbox for simulating the actual trigger environment for multiple rules on the system are triggered by the user data to generate corresponding actual trigger results, so that the test results can be obtained by comparing the actual trigger results with the expected trigger results. This embodiment can not only avoid the dependence of rule testing on manual labor and reduce testing costs, but also ensure the accuracy and effectiveness of rule testing.

[0128] In one embodiment of the present application, the user data construction module is specifically used to:

[0129] Construct user attribute data and user behavior data based on test cases;

[0130] A user behavior event message is simulated based on the user attribute data and the user behavior data, and the simulated user behavior event message is sent to the sandbox as user data.

[0131] In one embodiment of the present application, the user data construction module is further specifically used for:

[0132] Use the test case as an input parameter to call the user data interface contained in the preset database;

[0133] Receive user attribute data and user behavior data returned by the user data interface for the test case.

[0134] In one embodiment of the present application, the user data construction module is further specifically used for:

[0135] Simulate the user identity based on the user attribute data, and simulate the user behavior triggered under the user identity based on the user behavior data;

[0136] A user behavior event message is generated based on the simulated user behavior triggered under the user identity.

[0137] In one embodiment of the present application, the second generation module is specifically used to:

[0138] Determine the expected triggering results corresponding to the target rules from multiple test cases;

[0139] The expected trigger result corresponding to the target rule is compared with the actual trigger result to generate a test result based on the obtained comparison result.

[0140] In one embodiment of the present application, the device further includes:

[0141] A calculation module, used for calculating an approximate value between an expected trigger result and an actual trigger result;

[0142] The error reporting module is used to send an error message containing an optimization solution to the background if the approximate value is less than a preset threshold.

[0143] In one embodiment of the present application, the device further includes:

[0144] A data cleaning module, used to clean up user data if the test result indicates that the test passed;

[0145] The data update module is used to resend the user data to the sandbox if the test result indicates that the test has not passed, so as to update the test result based on the data returned by the sandbox.

[0146] It should be noted that the rule-based automated testing device provided in the above embodiment and the rule-based automated testing method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here. In practical applications, the rule-based automated testing device provided in the above embodiment can allocate the above functions to different functional modules as needed, i.e., divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0147] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the rule automation testing method provided in the above-mentioned embodiments.

[0148] Figure 8 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Figure 8 The computer system 1200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0149] like Figure 8As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1202 or the program loaded from the storage part 1208 to the random access memory (RAM) 1203, such as executing the method described in the above embodiment. In the RAM 1203, various programs and data required for system operation are also stored. The CPU 1201, the ROM 1202 and the RAM 1203 are connected to each other through the bus 1204. The input / output (I / O) interface 1205 is also connected to the bus 1204.

[0150] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0151] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1209, and / or installed from a removable medium 1211. When the computer program is executed by a central processing unit (CPU) 1201, various functions defined in the system of the present application are executed.

[0152] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0153] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0154] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0155] Another aspect of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the rule-automated testing method described above is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0156] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the rule-automated testing method provided in each of the above embodiments.

[0157] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.

Claims

1. A rule-based automated testing method, characterized in that: include: Synchronize multiple rules on the system and automatically generate multiple test cases corresponding to each rule, wherein the test cases include expected trigger results corresponding to each rule; Constructing user data according to the test case, and sending the user data to a sandbox, wherein the sandbox is used to simulate an actual triggering environment for the multiple rules on the system; Receiving an actual trigger result under a target rule matching the user data returned by the sandbox; Comparing the expected trigger result with the actual trigger result, and generating a test result according to the obtained comparison result; The constructing user data according to the test case and sending the user data to the sandbox includes: Using the test case as an input parameter to call the user data interface included in the preset database; Receiving user attribute data and user behavior data returned by the user data interface for the test case; A user behavior event message is simulated based on the user attribute data and the user behavior data, and the simulated user behavior event message is sent to the sandbox as the user data.

2. The rule-based automated testing method according to claim 1, wherein: The simulating the user behavior event message based on the user attribute data and the user behavior data includes: Simulating a user identity according to the user attribute data, and simulating a user behavior triggered under the user identity according to the user behavior data; The user behavior event message is generated based on the simulated user behavior triggered under the user identity.

3. The rule-based automated testing method according to claim 1, wherein: The comparing the expected trigger result with the actual trigger result and generating a test result according to the obtained comparison result includes: Determine an expected trigger result corresponding to the target rule from the multiple test cases; The expected trigger result corresponding to the target rule is compared with the actual trigger result to generate the test result according to the obtained comparison result.

4. The rule-based automated testing method according to claim 1, wherein: After comparing the expected trigger result with the actual trigger result and generating a test result according to the obtained comparison result, the method further includes: Calculating an approximate value between the expected trigger result and the actual trigger result; If the approximate value is less than a preset threshold, an error message including an optimization solution is sent to the background.

5. The rule-based automated testing method according to claim 1, wherein: After comparing the expected trigger result with the actual trigger result and generating a test result according to the obtained comparison result, the method further includes: If the test result indicates that the test passed, clearing the user data; If the test result indicates that the test fails, the user data is resent to the sandbox to update the test result based on the data returned by the sandbox.

6. A rule-based automated testing device, characterized in that: include: A first generating module, used for synchronizing multiple rules on the system and automatically generating multiple test cases corresponding to each rule, wherein the test cases include expected triggering results corresponding to each rule; A user data construction module, used for constructing user data according to the test case, and sending the user data to a sandbox, wherein the sandbox is used for simulating an actual triggering environment for the multiple rules on the system; A receiving module, used to receive the actual trigger result returned by the sandbox under the target rule matching the user data; A second generating module, used for comparing the expected trigger result with the actual trigger result, and generating a test result according to the obtained comparison result; The user data construction module is also used to call the user data interface contained in the preset database using the test case as an input parameter; receive the user attribute data and user behavior data returned by the user data interface for the test case; simulate user behavior event messages based on the user attribute data and the user behavior data, and send the simulated user behavior event messages as the user data to the sandbox.

7. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the rule-based automated testing method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the rule-automated testing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for testing program

    CN105786707A

  • Mandatory access control rule test method and system, terminal and storage medium

    CN110716863A

  • Data processing test control method and device, computer equipment and storage medium

    CN110781090A