Test scene generation method and device, program product and storage medium
By automatically generating test scenarios and using element association models and rule engines to analyze the business element status of financial service interfaces, the problem of low efficiency in traditional manual design is solved, achieving efficient and accurate test scenario generation and ensuring system stability and reliability.
Patent Information
- Application Number
- CN202511094839.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-11-18
AI Technical Summary
Traditional financial service interface testing scenario design relies on manual coding, resulting in high design costs and poor results, and failing to effectively guarantee code quality and system stability.
By acquiring interface parameters, the initial state of business elements, and test objectives, dynamic state analysis is performed using a pre-determined element association model and rule engine to generate candidate test scenarios. Dynamic association verification and abnormal state optimization are then performed to obtain the target test scenario.
It enables automated generation of test scenarios, reduces design complexity and cost, improves testing efficiency and accuracy, and ensures the stability and reliability of the system under complex business scenarios.
Smart Images

Figure CN120973677A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing, and in particular to a test scene generation method, device, program product and storage medium. Background Technology
[0002] Service interface development in the financial sector often involves multiple business elements (core data items that must be recorded, verified, or processed in financial transactions) as service parameters (input or output fields exposed by the interface). These business elements are not isolated; they often have "condition-action" or "cause-constraint" relationships. For example, when the transaction amount exceeds a threshold and the account status is normal, the system must automatically freeze funds and trigger risk control review; if the transaction occurs on a non-working night, secondary verification is mandatory.
[0003] Because each rule can potentially generate regular, exceptional, and edge cases, the test space for APIs expands exponentially. In actual development, to ensure code quality, developers typically need to write test scenarios to verify the functionality and stability of service code. Traditionally, this relies on developers manually writing test scenarios. However, due to developers' lack of in-depth understanding of business scenario design, test case design is often unprofessional, resulting in high design costs and unsatisfactory test results, failing to effectively safeguard code quality. This situation not only increases testing costs but also impacts overall development efficiency and system reliability. Summary of the Invention
[0004] This invention provides a test scenario generation method, device, program product, and storage medium, which can accurately and comprehensively generate test scenarios automatically, reduce test design complexity and cost, improve test efficiency and accuracy, shorten test cycle, ensure system stability and reliability in complex business scenarios, and enhance risk resistance.
[0005] In a first aspect, embodiments of the present invention provide a test scenario generation method, including:
[0006] Obtain the data to be generated; wherein, the data to be generated includes interface parameters, the initial state of business elements, and test objectives;
[0007] Based on a pre-determined element association model and a pre-configured rule engine, dynamic state analysis is performed on the data to be generated to obtain the state transition path of the business element.
[0008] Candidate test scenarios are generated based on the state transition path;
[0009] The candidate test scenarios are dynamically correlated and verified, and abnormal states are optimized to obtain the target test scenario.
[0010] Secondly, embodiments of the present invention provide a test scenario generation device, the device comprising:
[0011] The data acquisition module is used to acquire data to be generated; wherein, the data to be generated includes interface parameters, the initial state of business elements, and test objectives;
[0012] The data processing module is used to perform dynamic state analysis on the data to be generated based on a pre-determined element association model and a pre-configured rule engine to obtain the state transition path of the business element.
[0013] The first scenario generation module is used to generate candidate test scenarios based on the state transition path;
[0014] The second scenario generation module is used to perform dynamic correlation verification and abnormal state optimization on the candidate test scenarios to obtain the target test scenario.
[0015] Thirdly, embodiments of the present invention also provide an electronic device, the 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 program to implement the test scenario generation method as described in any of the embodiments of the present invention.
[0016] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the test scenario generation method as described in any of the embodiments of the present invention.
[0017] Fifthly, embodiments of the present invention provide a computer program product, including a computer program that, when executed by a processor, implements the test scenario generation method as described in any of the embodiments of the present invention.
[0018] In this embodiment of the invention, data to be generated is acquired; wherein, the data to be generated includes interface parameters, the initial state of business elements, and test objectives; dynamic state analysis is performed on the data to be generated based on a pre-determined element association model and a pre-configured rule engine to obtain the state transition path of the business elements; candidate test scenarios are generated based on the state transition path; dynamic association verification and abnormal state optimization are performed on the candidate test scenarios to obtain the target test scenario. The method of this embodiment of the invention, through the coupled calculation of the element association model and the rule engine, accurately determines the state transition path of business elements based on the data to be generated, realizing automated deduction from "discrete input" to "full path," avoiding omissions and subjective biases caused by traditional manual enumeration, thereby improving the generation efficiency of candidate test scenarios. By dynamically verifying and optimizing the candidate test scenarios, more comprehensive and accurate test scenarios can be obtained, reducing test design complexity and cost, improving test efficiency and accuracy, shortening the test cycle, ensuring the stability and reliability of the system under complex business scenarios, and enhancing risk resistance. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a first flowchart of a test scenario generation method provided in an embodiment of the present invention;
[0021] Figure 2 This is a second flowchart of a test scenario generation method provided in an embodiment of the present invention;
[0022] Figure 3 This is a schematic diagram of the structure of a test scene generation device provided in an embodiment of the present invention;
[0023] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0024] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0025] Figure 1This is a first flowchart of a test scenario generation method provided by an embodiment of the present invention. The method of this embodiment can accurately and comprehensively generate test scenarios automatically, reducing test design complexity and cost, improving test efficiency and accuracy, shortening the test cycle, ensuring the stability and reliability of the system under complex business scenarios, and enhancing its risk resistance. The information collected in the method of this embodiment is information and data authorized by a first user or fully authorized by all parties. The collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with the relevant laws, regulations, and standards of relevant countries and regions, and necessary confidentiality measures are taken. It does not violate public order and good morals, and provides corresponding operation entry points for the first user to choose to authorize or refuse. This method can be executed by a test scenario generation device provided by an embodiment of the present invention, which can be implemented in software and / or hardware. The following embodiments will illustrate this using the integration of the device in an electronic device as an example. The electronic device can be a server or computer device carrying a banking system, etc., refer to... Figure 1 The method may specifically include the following steps:
[0026] Step 101: Obtain the data to be generated.
[0027] The "Data to be Generated" section contains data used to generate test scenarios. This data includes interface parameters, the initial states of business elements, and test objectives. Interface parameters are the input fields that must be filled in when calling the financial interface, as well as the output fields returned by the interface. For example, an interbank transfer interface requires information such as the amount and transaction time; returned fields include transaction status and arrival time. Business elements are key data items in the financial business context. The initial state of a business element is its actual value at the moment the test begins. For example, business elements for a transfer transaction include: account balance; whether the account is currently active, frozen, or closed; and the remaining amount of the daily used limit. Test objectives describe the purpose of the test.
[0028] Specifically, when a user needs to generate test scenarios for the system, the user can upload test requirements to the system. After receiving the test requirements, the system can obtain interface parameters from the interface documentation within the test requirements, and obtain the initial state of business elements and test objectives from the requirement documentation.
[0029] Step 102: Perform dynamic state analysis on the data to be generated based on the pre-determined element association model and the pre-configured rule engine to obtain the state transition path of the business elements.
[0030] The element association model is pre-built to represent the static or dynamic relationships that may exist between all business elements, and the states that each business element can transition to under different conditions. The element association model can be composed of a matrix or graph structure, and can include nodes, edges, and weights. Nodes can represent business elements, edges can represent the influence relationships between business elements, and weights can represent the thresholds that trigger the corresponding edges, such as time windows or currencies. The rule engine includes executable business rules. The state transition path represents the transition of a business element from its initial state to its final state. The state transition path can be an ordered sequence of changes. For example, the state transition path could be: Account Status: Normal → Frozen → Unfrozen; Daily Use Limit: 0 → 50000 → 100000.
[0031] In one optional implementation, after obtaining the data to be generated, the system reads the element association model from persistent storage. All rules for all business elements are loaded through the rule engine. Based on the business element association model and the dynamic state transition rules in the rule engine, the interface parameters and the initial states of the business elements are initialized and input. The business element association model and dynamic state transition rules drive changes in the states of the business elements, thereby automatically generating multiple test scenarios. For example, after obtaining the data to be generated, the system fills the data into a predefined data structure. The rule engine can traverse all rules according to priority, matching the rule conditions with the data structure. If a match is successful, the corresponding business element value in the data structure is updated according to the matched rule body. For each successful rule match, the next state of the relevant business element is updated according to the element association model; the updated new state is written back to the data structure, and the next round of matching continues until no rule can be triggered or the termination condition is met. During this process, the system can record each state change with a timestamp to obtain a complete state transition sequence, i.e., a state transition path.
[0032] Step 103: Generate candidate test scenarios based on state transition paths.
[0033] The candidate test scenarios are initially generated based on the state transition paths. Specifically, after obtaining the state transition paths of each business element, the system can generate a test skeleton for each path. The test skeleton includes a test case number, title (a brief description of the rule triggering conditions), preconditions (initial values of the business element), interface parameters (interface field values), and expected results (final business element state, interface return code, and assertion point). After obtaining the test skeleton, multiple sets of orthogonal values are generated for the interface parameters, provided the triggering rules are met. For example, a normal value: 10,000; a boundary value: 100,000 (just triggered freeze); an abnormal value: -1 (negative number). Each generated set of values yields an independent candidate test case. Furthermore, the candidate test cases can be categorized according to the triggering rules. For example, a normal scenario (amount < 100,000, no freeze triggered); a boundary scenario (amount = 100,000, critical point); and an abnormal scenario (amount 500,000, multiple rules triggered simultaneously). Finally, candidate test scenarios are obtained based on all candidate test cases.
[0034] Step 104: Perform dynamic correlation verification and abnormal state optimization on the candidate test scenarios to obtain the target test scenario.
[0035] The target test scenario is an optimized version of the candidate test scenarios. Dynamic correlation verification includes mathematically checking whether the "actual state chain generated by the scenario" and the "theoretical rules" are consistent. Anomaly optimization includes automatically patching, weighting, and simplifying inconsistent or high-risk candidate test scenarios. Specifically, after obtaining the candidate test scenarios, the element state sequence in each candidate test scenario can be converted into an actual correlation matrix R. R is compared element-by-element with a pre-determined theoretical rule matrix R*, and the deviation matrix D is calculated. Paths with deviations exceeding a preset threshold are marked as anomalies. While ensuring test scenario coverage, redundant or low-risk scenarios are eliminated, and missing high-risk scenarios are added, so that the risk value of the final target test scenario is minimized and converged.
[0036] In one optional implementation, after obtaining candidate test scenarios, the correlation strength of each business element is determined based on the candidate test scenarios, and a correlation matrix is constructed based on the correlation strength; dynamic correlation verification is performed on the correlation matrix and a pre-defined dynamic state transition rule matrix to obtain dynamic correlation verification results; abnormal state optimization is performed on the candidate test scenarios to obtain abnormal state optimization results, and the candidate test scenarios are adjusted based on the dynamic correlation verification results and abnormal state optimization results to obtain the target test scenario. Optimizing abnormal states in the candidate test scenarios to obtain abnormal state optimization results includes: detecting abnormal states in the candidate test scenarios; calculating the comprehensive risk value of the candidate test scenarios according to a pre-determined risk parameter calculation method and the abnormal states; and optimizing the candidate test scenarios based on the comprehensive risk value to obtain abnormal state optimization results.
[0037] The technical solution of this embodiment involves acquiring data to be generated, including interface parameters, the initial state of business elements, and test objectives. Based on a pre-determined element association model and a pre-configured rule engine, dynamic state analysis is performed on the data to be generated to obtain the state transition paths of the business elements. Candidate test scenarios are generated based on these state transition paths. Dynamic association verification and abnormal state optimization are performed on the candidate test scenarios to obtain the target test scenario. This technical solution, through the coupled calculation of the element association model and the rule engine, accurately determines the state transition paths of business elements based on the data to be generated, achieving automated deduction from "discrete input" to "full path," avoiding omissions and subjective biases caused by traditional manual enumeration, thereby improving the generation efficiency of candidate test scenarios. By dynamically verifying and optimizing the candidate test scenarios, more comprehensive and accurate test scenarios can be obtained, reducing test design complexity and cost, improving test efficiency and accuracy, shortening the test cycle, ensuring the stability and reliability of the system under complex business scenarios, and enhancing risk resistance.
[0038] Figure 2 This is a second flowchart of a test scenario generation method provided in an embodiment of the present invention. This embodiment is a refinement based on the above embodiment. The specific method can be as follows: Figure 2 As shown, the method may include the following steps:
[0039] Step 201: Obtain the document data and business rule data of the service interface; extract key content from the document data to obtain the key business elements of the document data.
[0040] The key business information includes user information, transaction information, and business information; service interface documents and business rule data can be pre-uploaded to the system by users. Key business elements are used to establish an element association model. Specifically, after obtaining the document data and business rule data, the system can parse the interface documents, including parsing the input / output fields of each endpoint and marking the business meaning of the fields (such as amount, time, user class). Simultaneously, it parses the business rule data, including parsing business rules, such as breaking down natural language rules into "condition-action" sequences. After obtaining the parsed document data, key content can be extracted from the document data according to specific needs and the specific content of the document data to obtain the key business elements of the document data. For example, the key content in this solution can be user information, transaction information, and business information.
[0041] Step 202: Conduct a correlation analysis on each key business element to determine the correlation between each key business element.
[0042] The relationships include direct and indirect relationships. Direct relationships can be elements that appear simultaneously within a single rule or the same field validation. Indirect relationships can be dependencies passed down through intermediate elements. Specifically, after obtaining the key business elements, elements that appear simultaneously within the same rule can be marked as "directly related" and assigned a strength value of 1, based on the business rule data records. Dependencies passed down through intermediate elements can be determined using data flow diagrams or transitive closure algorithms to obtain the indirect relationships between the key business elements.
[0043] For example, the business rule data includes Rule A: Single transaction amount ≥ 100,000 RMB and account status normal → account status changed to frozen; Rule B: Transaction time falls between 22:00 and 06:00 the next day on Saturday or Sunday → SMS secondary verification is required; Rule C: Daily cumulative amount > 500,000 RMB → handling fee doubled; Rule D: Account status is frozen → no further withdrawals are allowed. Key business elements include: amount, currency, transaction time, account status, daily cumulative amount, SMS verification flag, and handling fee rate, etc. Pairing the elements appearing in each rule together, the direct relationships of each key business element are obtained, as shown in Table 1 below:
[0044]
[0045] Table 1
[0046] Step 203: Determine the element association model based on the key business information and the relationship between each key business element.
[0047] Specifically, the element association model is used to represent the static or dynamic relationships that may exist between all business elements, and the states that each business element can jump to under different conditions. The element association model can be composed of a matrix or graph structure. After obtaining the key business information and the relationships between each key business element, the element association model can be determined based on the key business information and the relationships between each key business element. In this solution, optionally, determining the element association model based on the key business information and the relationships between each key business element includes: establishing an association matrix structure based on each key business information; editing the association matrix structure according to the relationships between each key business element to obtain candidate element association models; and verifying and optimizing the candidate element association models according to predetermined verification rules and verification data to obtain the element association model.
[0048] The association matrix structure is a tool that uses a two-dimensional table to quantify and visualize the relationships between business elements. In this solution, the rows and columns of the association matrix structure represent the same set of business elements (e.g., amount, account status, transaction time, and transaction fee rate). After obtaining the key business elements, a matrix structure can be constructed based on the names of the key business elements. The association relationships between the key business elements obtained in the above steps are then filled into the association matrix structure to obtain the candidate element association model.
[0049] The validation rules and validation data are pre-defined and used to validate the candidate element association model. Validation data can be real transaction data or other financial data generated by the system during historical periods. The validation rules in this solution can include business consistency rules and data consistency rules. For example, the business consistency rules can be used to determine whether the state transitions predicted by the candidate element association model are completely consistent with the validation data. If they are inconsistent, it is determined that the candidate element association model needs to be optimized. For example, erroneous values (values inconsistent with the validation data) in the candidate element association model can be modified to obtain the element association model. If they are consistent, no optimization of the candidate element association model is required.
[0050] In this solution, discrete business rules are transformed into computable values by constructing a matrix, which can accurately determine the strong or weak relationships between business elements, thereby accurately establishing an element relationship model.
[0051] Step 204: Obtain the data to be generated; perform dynamic state analysis on the data to be generated based on the pre-determined element association model and the pre-configured rule engine to obtain the state transition path of the business elements.
[0052] The data to be generated includes interface parameters, the initial state of business elements, and test objectives. The rule engine includes executable business rules. The state transition path represents the transition of a business element from its initial state to its final state, and can be an ordered sequence of changes. Optionally, in this solution, dynamic state analysis is performed on the data to be generated based on a pre-determined element association model and a pre-configured rule engine to obtain the state transition path of the business elements. This includes: determining the current state of the business elements based on the interface parameters and the initial state of the business elements using the element association model; and matching the rules of each business scenario in the rule engine with the current state of each business element to obtain the state transition path of each business element in each business scenario.
[0053] Specifically, after obtaining the data to be generated, the data is analyzed according to the element association model, and then loaded into the model skeleton (the matrix or graph structure corresponding to the element association model) to obtain the current state of the business element. For example, if the interface parameters have already specified "account status = normal, daily used limit = 0", then that is determined as the current state of the business element. If the interface parameters are not set, then the initial state of the business element is determined as the current state.
[0054] In this solution, business scenarios can include regular scenarios, boundary scenarios, and abnormal scenarios. Each rule in the rule engine can include a trigger condition (Boolean expression), an action, and a business scenario tag to which the business element belongs. For example, the rules in the rule engine include: Rule A: Scenario = Regular; Condition = Amount < 100,000 and Account Status = Normal; Action = Account Status Remains Normal. Rule B: Scenario = Boundary Condition = Amount = 100,000 and Account Status = Normal; Action = Account Status Changes to Frozen. Rule C: Scenario = Abnormal; Condition = Amount > 100,000 and Account Status = Normal; Action = Account Status Changes to Frozen, SMS Verification Set to Required. Current status of the business element: Amount = 150,000, Account Status = Normal, SMS Verification Flag = None, Transaction Fee Rate = 0.1%. The rules of each business scenario in the rule engine are matched with the current status of each business element. Rule A condition: 150,000 < 100,000? → False → Skip; Rule B condition: 150,000 = 100,000? →False → Skip; Rule C condition: 150,000 > 100,000 and account status = normal? →True. After matching Rule C, execute Rule C: Account status: normal → frozen; SMS verification flag: none → required; Transaction fee rate remains at 0.1%. Further, generate the status transition path: [Amount = 150,000, Account status = normal, SMS verification flag = none] → [Amount = 150,000, Account status = frozen, SMS verification flag = required]. By introducing a rule engine and element association model, the system can comprehensively analyze the business elements in the financial market service interface, ensuring that all possible dynamic status transition paths of the business elements are verified.
[0055] Step 205: Generate candidate test scenarios based on state transition paths.
[0056] Step 206: Determine the correlation strength of each business element based on the candidate test scenario, and construct a correlation matrix based on the correlation strength; perform dynamic correlation verification on the correlation matrix and the pre-set dynamic state transition rule matrix to obtain the dynamic correlation verification results.
[0057] The correlation strength refers to the degree to which business elements change together along a state transition path. Based on the generated candidate test scenarios, the initial state, intermediate state, and target state of each business element are extracted to obtain the correlation strength of each business element. The initial state, intermediate state, and target state are mapped to the correlation matrix R, and the formula for calculating the correlation matrix is as follows:
[0058]
[0059] Among them, S i (t) is the state value of business element i at time t, S j (t) is the state value of business element j at time t, T is the time step of the state transition, and S is the time step of the state transition. i (t-1) is the state value of business element i at time t, and S j (t-1) is the state value of business element j at the next time step t, r ij It is an element of the business element association matrix R, that is, the association strength between business element i and business element j.
[0060] The generated association matrix R is matched and verified with the preset dynamic state transition rule matrix to determine whether the actual relationship between business elements conforms to the dynamic rules. The deviation matrix between the association matrix R and the theoretical matrix R* is calculated as follows:
[0061]
[0062] Where D is the deviation matrix, and N is the number of business elements. These are the element values in the theoretical dynamic rule matrix; based on the results of the deviation matrix D, the abnormal positions in the state transition of business elements are located, and dynamic association verification is performed. The calculation formula for the abnormal state path is as follows:
[0063]
[0064] Among them, P ij It represents the percentage deviation of the state transition between business elements i and j.
[0065] Step 207: Optimize the candidate test scenarios for abnormal states to obtain the optimization results. Adjust the candidate test scenarios based on the dynamic correlation verification results and the optimization results to obtain the target test scenario.
[0066] Anomaly optimization involves removing, supplementing, weighting, or rearranging parts of candidate test scenarios that deviate from business rules or pose high risks, thereby obtaining the target test scenario. Optionally, this solution optimizes candidate test scenarios to obtain optimization results, including: detecting anomalies in candidate test scenarios; calculating the comprehensive risk value of candidate test scenarios based on pre-determined risk parameter calculation methods and anomalies; and optimizing candidate test scenarios based on the comprehensive risk value to obtain optimization results.
[0067] Specifically, after obtaining candidate test scenarios, abnormal states in each candidate test scenario can be detected one by one based on dynamic state transition rules, and the comprehensive risk value of each test scenario can be calculated:
[0068]
[0069] Among them, R s W represents the overall risk value in the candidate test scenario. y P is the weight of the y-th abnormal state. y C is the probability of the y-th abnormal state occurring. y y is the impact cost of the y-th abnormal state, and n is the number of abnormal states involved in the test scenario.
[0070] Furthermore, based on the obtained comprehensive risk value R s The candidate test scenarios are optimized and dynamically adjusted to ensure that the target test scenarios can cover high-risk business states. The optimization formula is as follows:
[0071] Among them, S opt S represents the target test scenario. orig These are candidate test scenarios. It is the highest risk parameter value among the candidate test scenarios, α is the risk optimization coefficient, and T adj It is a dynamic adjustment factor. For the target test scenario S opt Verification was conducted to ensure high stability of the target test scenario under dynamic state transition paths. The optimization effect was evaluated using a convergence function. The changes in risk parameters before and after optimization, as well as execution efficiency, were combined for calculation and verification. The calculation expression is as follows: Among them, C f It refers to the degree of convergence in the scene optimization process. Candidate test scenario S origRisk parameters, S represents the optimized set of test scenarios. opt Risk parameters for the target test scenario, T exec (S opt ) is in S opt The number of times scenario tests are executed is given, where m is the total number of test scenarios and e is the index of the test scenario. By evaluating and supplementing candidate test scenarios, it is ensured that the triggering conditions and expected results of each state transition are verified. This not only helps to discover potential defects in business logic but also quickly captures abnormal states in edge scenarios, resulting in more accurate and comprehensive target test scenarios, ensuring the stability and correctness of the financial market service interface.
[0072] This solution visualizes candidate and target test scenarios. For example, it generates state transition diagrams, using different colors to distinguish different scenario types. A risk heatmap is also generated, with the vertical axis representing business element pairs and the horizontal axis representing test scenario numbers. By graphically aggregating large amounts of discrete data and complex state transition paths, testers can quickly grasp the overall test coverage, risk distribution, and execution status of key business scenarios, avoiding the tedious task of reviewing test cases one by one. Through color coding, heatmaps, or interactive timelines, the system can intuitively mark abnormal states, deviation nodes, and high-risk areas, significantly shortening problem localization time and improving the efficiency of test scenario generation.
[0073] In this embodiment, the technical solution involves acquiring document data and business rule data from the service interface; extracting key content from the document data to obtain key business elements. Key business information includes user information, transaction information, and business information; performing correlation analysis on each key business element to determine the relationships between them; these relationships include direct and indirect relationships; and determining an element association model based on the key business information and the relationships between key business elements. Next, data to be generated is acquired; dynamic state analysis is performed on the data to be generated according to the pre-determined element association model and a pre-configured rule engine to obtain the state transition paths of the business elements. The data to be generated includes interface parameters, the initial state of the business elements, and the test objective; the association strength of each business element is determined based on candidate test scenarios, and an association matrix is constructed based on the association strength; dynamic association verification is performed on the association matrix and a pre-set dynamic state transition rule matrix to obtain dynamic association verification results. Abnormal state optimization is performed on the candidate test scenarios to obtain abnormal state optimization results, and the candidate test scenarios are adjusted based on the dynamic association verification results and the abnormal state optimization results to obtain the target test scenario. The technical solution in this embodiment, by introducing a rule engine and dynamic state transition rules, enables the system to comprehensively analyze the business elements in the financial market service interface and automatically generate test scenarios for different input parameters and business element states. It effectively covers normal scenarios, abnormal scenarios, and edge scenarios, ensuring that all possible dynamic state transition paths of business elements are verified. By evaluating and supplementing candidate test scenarios, it ensures that the triggering conditions and expected results of each state transition are verified. This not only uncovers potential defects in business logic but also quickly captures abnormal states in edge scenarios, ensuring the stability and correctness of the financial market service interface. By generating test scenarios and performing dynamic verification through automated means, manual intervention is reduced, and testing efficiency is improved.
[0074] Figure 3 This is a schematic diagram of a test scenario generation device provided in an embodiment of the present invention. This device is suitable for executing the test scenario generation method provided in an embodiment of the present invention. Figure 3 As shown, the device may specifically include:
[0075] The data acquisition module 301 is used to acquire data to be generated; wherein, the data to be generated includes interface parameters, the initial state of business elements, and test targets;
[0076] The data processing module 302 is used to perform dynamic state analysis on the data to be generated based on a pre-determined element association model and a pre-configured rule engine to obtain the state transition path of the business element.
[0077] The first scenario generation module 303 is used to generate candidate test scenarios based on the state transition path;
[0078] The second scenario generation module 304 is used to perform dynamic correlation verification and abnormal state optimization on the candidate test scenarios to obtain the target test scenario.
[0079] Optionally, the data processing module 302 is specifically used to: obtain document data and business rule data from the service interface;
[0080] The document data is subjected to key content extraction to obtain the key business elements of the document data; wherein, the key business information includes user information, transaction information and business information;
[0081] A correlation analysis is performed on each of the key business elements to determine the relationships between them; wherein, the relationships include direct relationships and indirect relationships.
[0082] The element association model is determined based on the key business information and the relationships between the key business elements.
[0083] Optionally, the data processing module 302 is further configured to: establish an association matrix structure based on each of the key business information;
[0084] Edit the association matrix structure based on the relationships between the key business elements to obtain the candidate element association model;
[0085] The candidate element association model is verified and optimized according to the predetermined verification rules and verification data to obtain the element association model.
[0086] Optionally, the data processing module 302 is further configured to: determine the current state of the business element based on the interface parameters and the initial state of the business element through the element association model;
[0087] The rules of each business scenario in the rule engine are matched with the current state of each business element to obtain the state transition path of each business element in each business scenario.
[0088] Optionally, the second scenario generation module 304 is specifically used to: determine the association strength of each of the business elements based on the candidate test scenario, and construct an association matrix based on the association strength; perform dynamic association verification on the association matrix and a pre-set dynamic state transition rule matrix to obtain dynamic association verification results;
[0089] The candidate test scenario is optimized for abnormal states to obtain the optimization results. Based on the dynamic correlation verification results and the optimization results, the candidate test scenario is adjusted to obtain the target test scenario.
[0090] Optionally, the second scene generation module 304 is further configured to: detect abnormal states of the candidate test scene;
[0091] The comprehensive risk value of the candidate test scenario is calculated based on the predetermined risk parameter calculation method and the abnormal state.
[0092] Based on the comprehensive risk value, the candidate test scenario is optimized for abnormal states to obtain the optimized abnormal state result.
[0093] Optionally, the second scene generation module 304 is specifically used to: visualize the candidate test scene and the target test scene.
[0094] The test scenario generation device provided in this embodiment of the invention can execute the test scenario generation method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method execution. Content not described in detail in this embodiment can be referred to the description in any method embodiment of the invention.
[0095] This invention also provides a computer program product.
[0096] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer program products, which may include one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be an application-specific or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0097] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, with reference to... Figure 4 , Figure 4 The electronic device 12 shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this application. Figure 4 As shown, the electronic device 12 is represented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0098] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0099] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0100] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 4 Not shown; usually referred to as a "hard drive"). Although Figure 4 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this application.
[0101] A program / utility 40 having a set (at least one) of program modules 46 may be stored, for example, in memory 28. Such program modules 46 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 46 typically perform the functions and / or methods described in the embodiments of this application.
[0102] Electronic device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a first user to interact with electronic device 12, and / or with any device that enables electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, electronic device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of electronic device 12 via bus 18. It should be understood that, although... Figure 4 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RA identification systems, tape drives, and data backup storage systems.
[0103] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing a test scenario generation method provided in this embodiment of the invention: acquiring data to be generated; wherein, the data to be generated includes interface parameters, the initial state of business elements, and test objectives; performing dynamic state analysis on the data to be generated according to a pre-determined element association model and a pre-configured rule engine to obtain the state transition path of the business elements; generating candidate test scenarios based on the state transition path; and performing dynamic association verification and abnormal state optimization on the candidate test scenarios to obtain the target test scenario.
[0104] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a test scenario generation method as provided in all embodiments of this invention: acquiring data to be generated; wherein the data to be generated includes interface parameters, initial states of business elements, and test targets; performing dynamic state analysis on the data to be generated according to a pre-determined element association model and a pre-configured rule engine to obtain state transition paths of the business elements; generating candidate test scenarios based on the state transition paths; and performing dynamic association verification and abnormal state optimization on the candidate test scenarios to obtain a target test scenario. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electronic device, apparatus, or device that is electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an electronic device, apparatus, or device that executes instructions.
[0105] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in conjunction with an electronic device, apparatus, or device that executes instructions.
[0106] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0107] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the first user's computer, partially on the first user's computer, as a standalone software package, partially on the first user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the first user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0108] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A method for generating test scenarios, characterized in that, The method includes: Obtain the data to be generated; wherein, the data to be generated includes interface parameters, the initial state of business elements, and test objectives; Based on a pre-determined element association model and a pre-configured rule engine, dynamic state analysis is performed on the data to be generated to obtain the state transition path of the business element. Candidate test scenarios are generated based on the state transition path; The candidate test scenarios are dynamically correlated and verified, and abnormal states are optimized to obtain the target test scenario.
2. The method according to claim 1, characterized in that, Before acquiring the data to be generated, the method further includes: Obtain the document data and business rule data of the service interface; The document data is subjected to key content extraction to obtain the key business elements of the document data; wherein, the key business information includes user information, transaction information and business information; A correlation analysis is performed on each of the key business elements to determine the relationships between them; wherein, the relationships include direct relationships and indirect relationships. The element association model is determined based on the key business information and the relationships between the key business elements.
3. The method according to claim 2, characterized in that, Determining the element association model based on the key business information and the relationships between the key business elements includes: Establish an association matrix structure based on the key business information described above; Edit the association matrix structure based on the relationships between the key business elements to obtain the candidate element association model; The candidate element association model is verified and optimized according to the predetermined verification rules and verification data to obtain the element association model.
4. The method according to claim 1, characterized in that, Based on a pre-determined element association model and a pre-configured rule engine, dynamic state analysis is performed on the data to be generated to obtain the state transition path of the business element, including: The current state of the business element is determined based on the interface parameters and the initial state of the business element through the element association model. The rules of each business scenario in the rule engine are matched with the current state of each business element to obtain the state transition path of each business element in each business scenario.
5. The method according to claim 1, characterized in that, The candidate test scenarios are dynamically correlated and validated, and abnormal states are optimized to obtain the target test scenario, including: The association strength of each business element is determined based on the candidate test scenario, and an association matrix is constructed based on the association strength; dynamic association verification is performed on the association matrix and the pre-set dynamic state transition rule matrix to obtain the dynamic association verification result. The candidate test scenario is optimized for abnormal states to obtain the optimization results. Based on the dynamic correlation verification results and the optimization results, the candidate test scenario is adjusted to obtain the target test scenario.
6. The method according to claim 5, characterized in that, The candidate test scenario is optimized for abnormal states to obtain the optimized abnormal state results, including: Detect abnormal states in the candidate test scenarios; The comprehensive risk value of the candidate test scenario is calculated based on the predetermined risk parameter calculation method and the abnormal state. Based on the comprehensive risk value, the candidate test scenario is optimized for abnormal states to obtain the optimized abnormal state result.
7. The method according to claim 1, characterized in that, The method further includes: visualizing the candidate test scenario and the target test scenario.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements a test scenario generation method according to any one of claims 1-7.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the test scenario generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the test scenario generation method as described in any one of claims 1 to 7.