Risk control rule testing method and device
By parsing and automating the testing of risk control rules, the problems of high asset coupling and low manual efficiency in risk control rule testing have been solved, achieving efficient and low-cost risk control rule testing and improving test coverage and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DASHANGSUO FEITAI TESTING TECH CO LTD
- Filing Date
- 2025-12-18
- Publication Date
- 2026-05-26
AI Technical Summary
Existing technologies for risk control rule testing suffer from problems such as high coupling between assets and business scenarios, inability to share cross-business line tests, and low efficiency due to reliance on manual execution. This results in high testing costs, low coverage, and an inability to achieve full coverage before system deployment.
By parsing the risk control rules to be tested, extracting control items and calculation factors, and using the rule index library to call historical test case templates and data functions, test data and test messages are generated, thus automatically verifying the functional correctness of the risk control rules.
It has enabled low-cost, high-efficiency, and high-quality risk control rule testing, improving testing efficiency by nearly 3,000 times, enabling cross-business reuse of test assets, and reducing testing costs.
Smart Images

Figure CN122086751A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of risk control rule testing technology, and in particular to a method and apparatus for testing risk control rules. Background Technology
[0002] Currently, the industry primarily conducts regression testing on risk control rules actually used in production environments. Testers select a subset of risk control rules, design test cases, and manually complete data acquisition and querying, data construction and supplementation, transaction triggering, and risk control test result verification. Due to the complexity of the business logic of risk control rules and the ever-increasing number of rules, the industry currently faces the following pain points in risk control testing: 1. Risk control testing assets are highly coupled with business scenarios. In the securities and fund industry, there are dozens of risk control categories commonly used in risk control rules, each corresponding to different risk control needs (such as proportional control, price control, and buy / sell direction control). Each category has more than a hundred control factors (trading market, securities category, dimension category, industry attributes, etc.). When actually covering risk control rules, the test scenarios often exceed 100,000.
[0003] 2. Cross-business line rule testing cannot share test assets. The risk control business scenarios in the securities and fund industry are complex and diverse, including proprietary trading, asset management, and investment banking. Each business scenario has its unique risk characteristics and testing requirements, but the actual risk control rules and calculation factors involved are consistent. It is just that test scenarios need to be redesigned to cover the actual risk control rules. This results in the testing department having a lot of redundant test assets related to risk control, with many duplicate designs and a lack of shared test assets, leading to increased testing costs.
[0004] 3. Testing relies on manual execution, which is inefficient. Currently, over 95% of institutions in the industry still rely primarily on manual execution of test cases when conducting risk control testing. Assuming each risk control rule is covered by 30 test cases, 1000 risk control rules would require at least 30,000 test cases. Based on a relatively high manual testing efficiency of 50 test cases / person / day, it would take 600 person-days to complete one round of manual regression testing. In contrast, the typical system upgrade testing cycle is only about 5 days. Currently, without automation, it is impossible to complete a round of regression testing for all risk control rules by relying on manual testing.
[0005] Risk management is the lifeline of financial institutions. With the continuous development of the securities, fund and futures industries and the increasing requirements of risk supervision, more and more institutions are beginning to attach importance to the construction of risk control. However, the construction of a risk control system is only the first step. How to ensure the effectiveness and correctness of risk control through testing is the next challenge to be faced.
[0006] As transaction volume continues to grow and business operations expand, institutions will have more and more risk control rules at their disposal. Relying solely on manual regression testing not only requires significant investment in test execution but also a large amount of work to handle changes in test data. Furthermore, due to the limited efficiency of manual testing, it is impossible to achieve full coverage of risk control rules before the system goes live, leading to substantial risks after the system goes live. Summary of the Invention
[0007] This invention provides a method and apparatus for testing risk control rules, which addresses the shortcomings of existing technologies that rely on manual risk control rule testing, such as high cost, low efficiency, and low test coverage, and achieves low-cost, high-efficiency, and high-quality testing of risk control rules.
[0008] This invention provides a method for testing risk control rules, comprising: The risk control rule to be tested is parsed to extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; Based on the control item, the corresponding historical test case template and historical test data function are called from the pre-established rule index library; Based on the calculated factors and parameter values, as well as historical test case templates and historical test data functions, obtain or construct test data that meets the test requirements; Generate a test message based on the test data; The test message is used to test the risk control rule under test and verify the correctness of its function.
[0009] In one possible implementation, the method further includes: The risk control rule is parsed into atomic control items, and the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items, are extracted. The control items include at least one of the following: amount threshold control, ratio control, blacklist verification, price deviation control, and concentration control.
[0010] In one possible implementation, the method further includes: Based on the control items, the matching degree between the control items of the risk control rule to be tested and the historical risk control rules in the rule index is calculated using a factor bidirectional matching algorithm. Based on the matching degree, a target historical risk control rule similar to the risk control rule to be tested is determined, and the historical test case template and historical test data function corresponding to the target historical risk control rule are called.
[0011] In one possible implementation, the method further includes: Based on the calculated factors and parameter values, real-time query and acquisition of test data from a real production environment that meets the test requirements; If no real production environment data that meets the testing requirements is found, simulated test data will be generated based on historical test case templates and historical test data functions through preset logic.
[0012] In one possible implementation, the method further includes: The test data or simulated test data of the real production environment are assigned values according to the interface format of the system under test, and a test message is generated.
[0013] In one possible implementation, the method further includes: Send the test message to the risk control rule engine of the system under test; Obtain the execution result returned by the risk control rule engine for the test message, the execution result including blocking or allowing; Compare the execution results with the expected results of the risk control rule to be tested; Based on the comparison results, the correctness of the function of the risk control rule to be tested is determined.
[0014] The present invention also provides a testing device for risk control rules, comprising the following modules: The parsing module is used to parse the risk control rule to be tested, and extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; The calling module is used to call the corresponding historical test case templates and historical test data functions from a pre-established rule index library based on the control item. The acquisition module is used to acquire or construct test data that meets the test requirements based on the calculation factor and parameter values, as well as historical test case templates and historical test data functions. The generation module is used to generate test messages based on the test data; The testing module is used to test the risk control rule under test based on the test message, and to verify the functional correctness of the risk control rule under test.
[0015] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a test method for risk control rules as described above.
[0016] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a test method for risk control rules as described above.
[0017] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements a test method for risk control rules as described above.
[0018] The present invention provides a method and apparatus for testing risk control rules. This involves parsing the risk control rule to be tested, extracting its control items, and the calculation factors and parameter values involved in those control items. Based on the control items, corresponding historical test case templates and historical test data functions are retrieved from a pre-established rule index library. Test data meeting the testing requirements is obtained or constructed based on the calculation factors and parameter values, as well as the historical test case templates and historical test data functions. A test message is generated based on the test data. The test message is then used to test the risk control rule to be tested, verifying its functional correctness. Compared to the shortcomings of existing technologies, such as low efficiency, insufficient coverage, and the inability to reuse test assets across business operations through manual testing, this solution achieves low-cost, efficient, and high-quality testing of risk control rules. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the test system architecture for the risk control rules provided by this invention.
[0021] Figure 2 This is one of the flowcharts illustrating the testing method for risk control rules provided by this invention.
[0022] Figure 3 This is the second flowchart illustrating the testing method for risk control rules provided by this invention.
[0023] Figure 4This is a schematic diagram of the structure of the testing device for risk control rules provided by the present invention.
[0024] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0026] To facilitate understanding of the embodiments of the present invention, further explanations and descriptions will be provided below with reference to the accompanying drawings and specific embodiments. These embodiments do not constitute a limitation on the embodiments of the present invention.
[0027] Figure 1 This is a schematic diagram of the test system architecture for the risk control rules provided by this invention, as shown below. Figure 1 As shown, this system includes: (1) Risk control rule editor. The following functions are created in this invention: Risk control rule editor: Used to record the control items (referring to the logical judgment type of the risk control rule, i.e., what method is used to control risk), calculation factors (referring to the specific dimensions or variables on which the risk control rule is based when making judgments, i.e., what is being calculated), and the parameter values involved in the control items of the completed risk control rules.
[0028] Test Scenario Generator: Based on the control items and corresponding parameters of the risk control rules, different test scenarios are generated by pair testing methods combined with calculation factors to cover different scenarios of the risk control rules.
[0029] (2) Intelligent matching hub. The following functions are created in this invention: Rule Index Library: This library records the control items and calculation factors of established risk control rules. It is described as a rule index library through parsing algorithms for subsequent matching.
[0030] Matching Engine: By constructing a matching engine algorithm and combining it with feature data from the rule index library, risk control rules within the tested system are matched. When the matching engine calculates that the matching requirements are met, it means that the risk control rules in all matching results can be directly reused from the completed risk control test assets.
[0031] Scene Feature Library: Used to dynamically update and store completed and matching risk control rule numbers, assisting testers in achieving comprehensive coverage for sustainable integration.
[0032] (3) Data Engine. The following functions were created in this invention: Test data acquisition unit: dynamically acquires test data that meets the requirements in real time based on the parameter values of control items and calculation factors in the test scenario.
[0033] Test data builder: When the test data builder obtains a result of 0 during the data acquisition process, it means that there is no test data that meets the requirements in the current system. At this time, the acquisition conditions are passed to the test data builder, and the test data is constructed according to the established logic to ensure the comprehensiveness of the test data.
[0034] (4) Test execution engine. The following functions were created in this invention: Message generator: Generates messages based on the actual interface message format of the system under test and the test scenario, and assigns values to the test messages according to the actual requirements of the test scenario based on the test data obtained or constructed by the data engine, so as to meet the test requirements of specific scenarios.
[0035] Automated assertion library: During the construction of risk control rules, by sorting out the assertion logic involved in the relevant control items and calculation factors, the library calls the corresponding assertion logic according to the control items and calculation factors corresponding to the test scenario during actual testing, thereby realizing automated assertion.
[0036] Figure 2 This is one of the flowcharts illustrating the testing method for risk control rules provided by this invention, such as... Figure 2 As shown, the method includes the following: S21. Parse the risk control rule to be tested, and extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items.
[0037] The risk control rule editor is used to perform semantic parsing and atomic decomposition of natural language risk control rules set by business personnel (such as the limit of 2 million yuan for a single purchase of STAR Market stock of Product A). After parsing, the control item is identified as an amount threshold control, and the extracted calculation factors include {Product ID=Product A, Trading Market=STAR Market, Securities Type=Stock, Buy / Sell Direction=Buy}, with the parameter value being threshold=2,000,000. This step decouples the rule structure from the business semantics, transforming complex rules into standardized machine-readable data strings.
[0038] S22. Based on the control item, call the corresponding historical test case template and historical test data function from the pre-established rule index library.
[0039] The intelligent matching hub uses the control item parsed from S21 as the primary key for querying. It performs the first-level filtering in the rule index library to locate all historical risk control rule records of the same type (amount threshold control). Subsequently, it loads the test case design templates associated with these historical rules (containing atomic test logic such as boundary values, equivalence classes, and abnormal scenarios) and historical test data functions (such as parameterized scripts like get_securities_by_market() and create_limit_order()). This call process achieves first-level reuse of test assets through control item types.
[0040] S23. Based on the calculated factors and parameter values, as well as the historical test case templates and historical test data functions, obtain or construct test data that meets the test requirements.
[0041] The data engine first takes the calculated factors and parameter values extracted by S21 as input, executes the query logic in the historical test data function, and retrieves real securities codes and account data in the current test environment that meet the conditions {Product ID=Product A, Trading Market=STAR Market} in real time. If the query returns an empty result set (e.g., no STAR Market holdings in this environment), the test data constructor is automatically triggered. According to the boundary value requirements defined in the historical test case template (e.g., 1,999,999 yuan, 2,000,000 yuan, 2,000,001 yuan), it generates simulated STAR Market stock codes, virtual accounts, and corresponding capital data to ensure comprehensive coverage of the test scenario.
[0042] S24. Generate a test message based on the test data.
[0043] The message generator in the test execution engine dynamically assigns the test data (product ID, security code, order price, order quantity, etc.) obtained or constructed by S23 to the corresponding positions in the message fields according to the actual interface protocol specifications of the trading system under test, generating a test message that conforms to the interface format requirements and can be sent. This process decouples the test data from the interface protocol, allowing the same set of data to adapt to the message formats of different systems.
[0044] S25. Test the risk control rule to be tested based on the test message to verify the functional correctness of the risk control rule to be tested.
[0045] The automated test executor sends test messages generated by S24 to the risk control rule engine of the system under test, triggering the actual risk control calculation logic. The system returns the execution result (such as "Block - Exceeded Amount Limit" or "Release - Meets Requirements"). The test module compares the actual result with the expected result based on the parameter values. If a message of 2,000,001 yuan is blocked and a message of 1,999,999 yuan is released, the rule function is deemed correct.
[0046] The risk control rule testing method provided by this invention involves parsing the risk control rule to be tested, extracting the control items of the rule, as well as the calculation factors and parameter values involved in the control items; based on the control items, calling the corresponding historical test case templates and historical test data functions from a pre-established rule index library; obtaining or constructing test data that meets the testing requirements according to the calculation factors and parameter values, as well as the historical test case templates and historical test data functions; generating test messages based on the test data; and testing the risk control rule to be tested based on the test messages to verify the functional correctness of the risk control rule. Compared with the shortcomings of existing technologies, such as low efficiency, insufficient coverage, and inability to reuse test assets across businesses, this method achieves low-cost, efficient, and high-quality testing of risk control rules.
[0047] Figure 3 This is the second flowchart illustrating the testing method for risk control rules provided by this invention, as shown below. Figure 3 As shown, the method includes the following: S31. Parse the risk control rule into atomic control items, and extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items.
[0048] Control items refer to the logical judgment type of risk control rules, that is, what method is used to control risk, including at least one of the following: amount threshold control, ratio control, blacklist verification, price deviation control, and concentration control.
[0049] Common types of control items include: Amount threshold control: such as a single transaction amount ≤ 50 million Proportional control: For example, the industry holding ratio should be ≤30%. Blacklist verification: such as prohibiting trading of ST stocks. Price deviation: If the order price deviates from the market price by ±10%. Concentration control: such as holdings of a single security not exceeding 5% of total assets. The calculation factor refers to the specific dimension or variable on which risk control rules are based, i.e., what is being calculated.
[0050] Common types of calculated factors include: Trading dimensions: Trading markets (Shanghai and Shenzhen main boards / ChiNext / STAR Market), Securities categories (stocks / bonds / funds) Product Dimension: Product Type (Public / Private / Asset Management), Portfolio Number Subject Dimensions: Client ID, Trader ID, Institutional Code Time dimension: Trading session (opening / closing), date type (weekday / holiday) Risk dimensions: industry attributes (Shenwan Level 1 industry), securities rating, and market capitalization.
[0051] S32. Based on the control item, the matching degree between the control item of the risk control rule to be tested and the historical risk control rules in the rule index library is calculated using the factor bidirectional matching algorithm.
[0052] S33. Based on the matching degree, determine the target historical risk control rule that is similar to the risk control rule to be tested, and call the historical test case template and historical test data function corresponding to the target historical risk control rule.
[0053] The intelligent matching hub performs precise matching in the rule index library, employing a factor-based bidirectional matching algorithm to calculate the matching degree between the control items of the risk control rule to be tested and historical risk control rules in the rule index library. This step reduces the matching complexity from a full library scan to a subset of rules of the same type, improving matching efficiency.
[0054] The formula for calculating the matching degree using the factor-based two-way matching algorithm is: MatchScore = Σ(wi × Sim(Fi_rule, Fj_asset)) Where wi is the preset weight coefficient, Sim is the cosine similarity function, Fi_rule is the calculation factor of the risk control rule to be tested, and Fj_asset is the calculation factor of historical risk control rules in the rule index library.
[0055] When the MatchScore exceeds the preset threshold, the corresponding historical risk control rule is determined as the target historical risk control rule.
[0056] This judgment step ensures that only high similarity rules trigger asset reuse, avoiding testing bias caused by low-quality reuse.
[0057] Furthermore, the historical test case templates and historical test data functions corresponding to the target historical risk control rules are invoked.
[0058] S34. Based on the calculated factors and parameter values, query and obtain test data from the real production environment that meets the test requirements in real time.
[0059] S35. If no real production environment data that meets the test requirements is found, simulated test data will be generated based on historical test case templates and historical test data functions through preset logic.
[0060] The data engine first takes the extracted calculation factors and parameter values as input, executes the query logic in the historical test data function, and retrieves real securities codes and account data that meet the conditions in the current test environment in real time. If the query returns an empty result set, the test data builder is automatically triggered to generate simulated STAR Market stock codes, virtual accounts, and corresponding fund data according to the boundary value requirements defined in the historical test case template, ensuring comprehensive coverage of the test scenario.
[0061] S36. Assign values to the test data or simulated test data of the real production environment according to the interface format of the system under test, and generate a test message.
[0062] S37. Send the test message to the risk control rule engine of the system under test.
[0063] The message generator in the test execution engine dynamically assigns the acquired or constructed test data to the corresponding positions in the message fields according to the actual interface protocol specifications of the transaction system under test, generating a test message that conforms to the interface format requirements and can be sent.
[0064] Furthermore, the generated test messages are sent to the risk control rule engine of the system under test through an automated test executor, triggering the actual risk control calculation logic.
[0065] S38. Obtain the execution result returned by the risk control rule engine for the test message, the execution result including interception or allowance.
[0066] The test execution engine receives the real-time processing results of the test messages from the risk control rule engine of the system under test through synchronous calls or asynchronous listening mechanisms. This execution result is a standardized risk control decision response message, whose core field is a Boolean decision identifier. "ALLOW" indicates that the trading instruction meets the risk control rules and is allowed to proceed to the subsequent trading chain; A REJECT indicates that a trading order has triggered a risk control threshold and was rejected by the rules engine. It includes a risk control violation code (e.g., "EXCEED_AMOUNT_LIMIT_2000000"), a violation description (e.g., single order amount exceeding the 2 million yuan limit), and the triggering rule ID (e.g., R001), among other diagnostic information. The retrieval process uses a preset timeout mechanism (e.g., 500 milliseconds) to ensure a complete response; if no response is returned within the timeout period, it is marked as an abnormal result.
[0067] S39. Compare the execution result with the expected result of the risk control rule to be tested; based on the comparison result, determine the functional correctness of the risk control rule to be tested.
[0068] The automated assertion library automatically generates a dictionary of expected results for each test message based on extracted parameter values (such as threshold = 2000000) and other data.
[0069] The comparison engine verifies each item: For test messages with an amount of 1,999,999, the expected result is "allow". If the actual execution result is also "allow", then the test is considered to have passed. For a test message with an amount of 2000001, the expected result is "intercepted" and the violation code includes EXCEED_AMOUNT_LIMIT. If the actual result meets this pattern, it is considered to pass; otherwise, it is marked as a failure.
[0070] If the actual execution results of all preset test data (including boundary values and outliers) match the expected results by 100%, the risk control rule under test is deemed to be correct. If any mismatch exists, the specific calculation factor and parameter value combination is located, a defect report is output, and the rule logic repair process is triggered, thus achieving closed-loop verification from test execution to quality feedback.
[0071] This invention constructs a risk control rule parsing and matching module. Through parsing algorithms, it analyzes the logic of risk control rules, converts key information in the target risk control rules into a simplified data string for storage, and associates it with relevant assets such as test case design templates and test data functions. When reusing assets, a matching algorithm is used to match all existing risk control rules in the database with the data string of the target risk control rule. If the risk control rules are consistent (ignoring non-critical factors such as control thresholds, alarm operations, and affected accounts), all matching risk control rules can directly reuse all test assets associated with the target risk control rule. Through actual environment matching verification, currently, up to 54 risk control rules can reuse the test asset of one target rule, effectively improving the reusability of test assets and reducing testing costs. Subsequent additions of risk control rules can also be continuously matched to achieve asset reuse, and newly added or missing logic is continuously supplemented and developed.
[0072] Since there are tens of thousands of test scenarios corresponding to the full set of risk control rules, the number is enormous. The system upgrade version testing cycle is only 3 to 5 days. Under normal manual execution, each person can complete 40 to 80 risk control scenarios per day. Within the cycle, only 1% to 5% of the risk control rules in the tested system can be covered. However, the testing method of this invention has an average execution efficiency of 120 milliseconds per test case. A full set of automated regression execution of risk control can be completed in one day. Compared with manual testing, the efficiency is improved by nearly 3,000 times, and the testing efficiency is greatly improved.
[0073] The testing apparatus for risk control rules provided by the present invention will be described below. The testing apparatus for risk control rules described below and the testing method for risk control rules described above can be referred to in correspondence.
[0074] Figure 4 This is a schematic diagram of the structure of the testing device for risk control rules provided by the present invention, specifically including: The parsing module 401 is used to parse the risk control rule to be tested, and extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; The calling module 402 is used to call the corresponding historical test case template and historical test data function from the pre-established rule index library based on the control item; The acquisition module 403 is used to acquire or construct test data that meets the test requirements based on the calculation factor and parameter values, as well as the historical test case template and historical test data function. Generation module 404 is used to generate test messages based on the test data; The test module 405 is used to test the risk control rule under test based on the test message and verify the functional correctness of the risk control rule under test.
[0075] In one possible implementation, the parsing module 401 is specifically used to parse the risk control rule into atomic control items, extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items. The control items include at least one of amount threshold control, ratio control, blacklist verification, price deviation control, and concentration control.
[0076] In one possible implementation, the calling module 402 is specifically used to calculate the matching degree between the control item of the risk control rule to be tested and the historical risk control rules in the rule index library based on the control item using a factor bidirectional matching algorithm; determine the target historical risk control rule similar to the risk control rule to be tested based on the matching degree, and call the historical test case template and historical test data function corresponding to the target historical risk control rule.
[0077] In one possible implementation, the acquisition module 403 is specifically used to query and acquire test data of a real production environment that meets the test requirements in real time based on the calculation factor and parameter value; if no real production environment data that meets the test requirements is found, simulated test data is generated by constructing a preset logic based on historical test case templates and historical test data functions.
[0078] In one possible implementation, the generation module 404 is specifically used to assign values to the test data or simulated test data of the real production environment according to the interface format of the system under test, and generate test messages.
[0079] In one possible implementation, the test module 405 is specifically configured to send the test message to the risk control rule engine of the system under test; obtain the execution result returned by the risk control rule engine in response to the test message, the execution result including blocking or allowing; compare the execution result with the expected result of the risk control rule under test; and determine the functional correctness of the risk control rule under test based on the comparison result.
[0080] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, communications interface 520, and memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a test method for risk control rules. This method includes: parsing the risk control rule to be tested, extracting the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; based on the control items, calling the corresponding historical test case templates and historical test data functions from a pre-established rule index library; obtaining or constructing test data that meets the test requirements according to the calculation factors and parameter values, as well as the historical test case templates and historical test data functions; generating a test message based on the test data; and testing the risk control rule to be tested based on the test message to verify the functional correctness of the risk control rule to be tested.
[0081] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0082] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute a testing method for risk control rules provided by the above methods. The method includes: parsing the risk control rule to be tested, extracting the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; based on the control items, calling the corresponding historical test case templates and historical test data functions from a pre-established rule index library; obtaining or constructing test data that meets the testing requirements according to the calculation factors and parameter values, as well as the historical test case templates and historical test data functions; generating a test message based on the test data; and testing the risk control rule to be tested based on the test message to verify the functional correctness of the risk control rule to be tested.
[0083] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a testing method for executing the risk control rules provided by the above-described methods. The method includes: parsing the risk control rule to be tested, extracting control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; based on the control items, calling corresponding historical test case templates and historical test data functions from a pre-established rule index library; obtaining or constructing test data that meets the testing requirements according to the calculation factors and parameter values, as well as the historical test case templates and historical test data functions; generating a test message based on the test data; and testing the risk control rule to be tested based on the test message to verify the functional correctness of the risk control rule to be tested.
[0084] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0085] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A testing method for risk control rules, characterized in that, include: The risk control rule to be tested is parsed to extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; Based on the control item, the corresponding historical test case template and historical test data function are called from the pre-established rule index library; Based on the calculated factors and parameter values, as well as historical test case templates and historical test data functions, obtain or construct test data that meets the test requirements; Generate a test message based on the test data; The test message is used to test the risk control rule under test and verify the correctness of its function.
2. The method according to claim 1, characterized in that, The process involves parsing the risk control rule to be tested, extracting the control items of the risk control rule, as well as the calculation factors and parameter values involved in the control items, including: The risk control rule is parsed into atomic control items, and the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items, are extracted. The control items include at least one of the following: amount threshold control, ratio control, blacklist verification, price deviation control, and concentration control.
3. The method according to claim 2, characterized in that, The step of calling the corresponding historical test case templates and historical test data functions from the pre-established rule index library based on the control item includes: Based on the control items, the matching degree between the control items of the risk control rule to be tested and the historical risk control rules in the rule index is calculated using a factor bidirectional matching algorithm. Based on the matching degree, a target historical risk control rule similar to the risk control rule to be tested is determined, and the historical test case template and historical test data function corresponding to the target historical risk control rule are called.
4. The method according to claim 3, characterized in that, The step of obtaining or constructing test data that meets the test requirements based on the calculated factors and parameter values or historical test case templates and historical test data functions includes: Based on the calculated factors and parameter values, real-time query and acquisition of test data from a real production environment that meets the test requirements; If no real production environment data that meets the testing requirements is found, simulated test data will be generated based on historical test case templates and historical test data functions through preset logic.
5. The method according to claim 4, characterized in that, The generation of test messages based on the test data includes: The test data or simulated test data of the real production environment are assigned values according to the interface format of the system under test, and a test message is generated.
6. The method according to claim 5, characterized in that, The step of testing the risk control rule under test based on the test message to verify the functional correctness of the risk control rule under test includes: Send the test message to the risk control rule engine of the system under test; Obtain the execution result returned by the risk control rule engine for the test message, the execution result including blocking or allowing; Compare the execution results with the expected results of the risk control rule to be tested; Based on the comparison results, the correctness of the function of the risk control rule to be tested is determined.
7. A testing device for risk control rules, characterized in that, include: The parsing module is used to parse the risk control rule to be tested, and extract the control items of the risk control rule to be tested, as well as the calculation factors and parameter values involved in the control items; The calling module is used to call the corresponding historical test case templates and historical test data functions from a pre-established rule index library based on the control item. The acquisition module is used to acquire or construct test data that meets the test requirements based on the calculation factor and parameter values, as well as historical test case templates and historical test data functions. The generation module is used to generate test messages based on the test data; The testing module is used to test the risk control rule under test based on the test message, and to verify the functional correctness of the risk control rule under test.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements a test method for the risk control rules as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements a test method for the risk control rules as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements a test method for the risk control rules as described in any one of claims 1 to 6.