A fast transaction automated testing method and tool

By parsing the test case set and variable files in the yaml file, using APIs and recursive algorithms to process nested variables, and combining with multi-threaded testing tasks, the problem of limited automated testing resources is solved, and efficient execution of fast transaction automated testing is achieved.

CN118170676BActive Publication Date: 2024-09-10QUANT360
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410376221.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-29
Publication Date
2024-09-10
Estimated Expiration
2044-03-29

AI Technical Summary

Technical Problem

Automated testing requires a lot of time and resources, especially when testing time or resources are limited, which limits its applicable scenarios.

Method used

By obtaining the test case set and variable file in the yaml file, using the API to create template objects and rendering the template, parsing variables and using recursive algorithms to process nested variables, rapid transaction automation testing can be achieved. Specific methods include obtaining test case files in Excel format and converting them into yaml strings, using multiple threads to perform test tasks, and testing through simulation matching.

Benefits of technology

It achieves rapid generation and parsing of test case sets, reduces test writing and maintenance time, improves test efficiency, and can quickly execute a large number of test cases under limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118170676B
    Figure CN118170676B
Patent Text Reader

Abstract

The present invention provides a fast transaction automation test method and tool, obtains a test case set and a variable file in a yaml file, the test case set includes a test scenario and user data information, and the variable file includes variables required for trading; performs a first analysis on the test case set, creates a template object using an API, and renders the template object using a render method; performs a second analysis on the variables, the variables are at different levels in the variable file, replaces and assigns nested variables, and uses a recursive algorithm to process the variables to obtain the true value corresponding to the variables. The fast transaction automation test method and tool provided by the present invention implement fast transaction automation testing by performing a first analysis and a second analysis on the test case set and the variables, respectively.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automated testing technology, and in particular to a rapid transaction automated testing method and tool. Background Art

[0002] Automated testing can quickly execute a large number of test cases, making it more efficient than manual testing. It can cover a wide range of functions and scenarios in a short period of time, saving significant human resources and time compared to manual testing.

[0003] Currently, automated testing is divided into three categories: UI (User Interface) automated testing, script-driven automated testing, and data-driven automated testing. These three categories encompass three different approaches to automated testing, including simulating user actions, using different test scripts, and testing data and logic for different usage categories. Testing encompasses unit testing, functional testing, performance testing, and compatibility testing.

[0004] However, automated testing has some limitations. For example, automated testing requires a lot of time and resources to write, run, and maintain. This is especially true when testing time or resources are limited, which limits the applicable scenarios of automated testing.

[0005] Therefore, it is necessary to provide a fast transaction automation testing method and tool to solve the above problems. Summary of the Invention

[0006] The present invention aims to solve the problems and deficiencies in the prior art and provides a rapid transaction automation testing method and tool.

[0007] The present invention solves the above technical problems through the following technical solutions:

[0008] The present invention provides a rapid transaction automated testing method, the method comprising:

[0009] Obtain the test case set and variable file in the YAML file. The test case set includes test scenarios and user data information, and the variable file includes variables required for transactions.

[0010] Performing a first analysis on the test case set, creating a template object using an API, and rendering the template object using a render method;

[0011] A second analysis is performed on the variables, the variables are at different levels in the variable file, the nested variables are replaced and assigned values, and the variables are processed using a recursive algorithm to obtain the real values ​​corresponding to the variables.

[0012] Preferably, the test case set is generated by the following method:

[0013] Get the test case file in Excel format;

[0014] Converting the test case file in Excel format into a first object;

[0015] Convert the first object into a YAML string and generate the test case set.

[0016] Preferably, performing a first analysis on the test case set includes obtaining a directory and a file storage path of the test case set and then parsing the test case set.

[0017] Preferably, performing the second analysis on the variable includes obtaining a key-value pair of the variable, the key-value pair being data in the test case set, obtaining a corresponding calculation formula based on the key-value pair and automatically obtaining a calculation result, the calculation formula being specifically as follows:

[0018] Total assets = cash balance + market value of margin securities + value of other margin assets + adjustment amount.

[0019] Preferably, rendering the template object using the render method includes obtaining an HTML tag name, a data object, and a child node, wherein the HTML tag name is a component or a function, the data object is used to create a virtual DOM node, and the child node supports strings and arrays.

[0020] Preferably, the testing method includes multiple threads, and the multiple threads respectively execute the testing tasks of multiple modules;

[0021] The multiple threads share system resources, including virtual address space, file descriptors, signal processing, and instruction processing methods;

[0022] The multiple threads each have their own call stack, register environment and thread-local storage.

[0023] Preferably, the multiple modules include the following test information: price type required for the transaction, trading market, trading variety, transaction status, fund check status and amount, and number of orders.

[0024] Preferably, the test task checks the time, price, and order quantity in the current test environment through immediate assertion. If the result of the immediate assertion is success, the test task ends; if the result of the immediate assertion is failure, the failure information is recorded and a new test task is started.

[0025] Preferably, the test task also includes performing simulated matching, wherein the simulated matching is to simulate exchange behavior to simulate intraday trading of the submitted transaction orders and to feed back simulated exchange data.

[0026] The present invention also provides a rapid transaction automation testing tool, the tool comprising:

[0027] A file acquisition module, which is used to obtain the test case set and variable file in the YAML file. The test case set includes test scenarios and user data information, and the variable file includes variables required for transactions;

[0028] A first parsing module, configured to perform a first parsing on the test case set, create a template object using an API, and render the template object using a render method;

[0029] The second parsing module is used to perform a second parsing on the variables, the variables are at different levels in the variable file, replace the nested variables and use a recursive algorithm to process the variables to obtain the real values ​​corresponding to the variables.

[0030] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:

[0031] The fast transaction automation testing method and tool provided by the embodiment of the present invention obtains a test case set and a variable file in a YAML file, wherein the test case set includes test scenarios and user data information, and the variable file includes variables required for transactions; performs a first analysis on the test case set, creates a template object using an API, and renders the template object using a render method; performs a second analysis on the variables, wherein the variables are at different levels in the variable file, replaces and assigns values ​​to nested variables, and processes the variables using a recursive algorithm to obtain the actual values ​​corresponding to the variables. By performing the first and second analyses on the test case set and variables, respectively, fast transaction automation testing is achieved;

[0032] Furthermore, the test case set is specifically generated by the following method: obtaining a test case file in Excel format; converting the test case file in Excel format into a first object; converting the first object into a YAML string and generating the test case set, thereby being able to quickly obtain the test case set;

[0033] Furthermore, rendering the template object using the render method includes obtaining an HTML tag name, a data object, and child nodes, wherein the HTML tag name is a component or a function, the data object is used to create a virtual DOM node, and the child node supports strings and arrays, thereby enabling rapid rendering of the template. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A flowchart of a rapid transaction automation testing method provided by one embodiment of the present invention;

[0035] Figure 2 A schematic diagram of the structure of a rapid transaction automation testing tool provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0036] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0037] The following specific embodiments are used to describe the technical solution of the present invention in detail. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0038] Based on the problems existing in the existing technology, such as Figure 1 As shown, the present invention provides a rapid transaction automated testing method, the method comprising:

[0039] Step S101: Obtain a test case set and a variable file in a YAML file, wherein the test case set includes test scenarios and user data information, and the variable file includes variables required for transactions;

[0040] Step S102: performing a first analysis on the test case set, creating a template object using an API, and rendering the template object using a render method;

[0041] Step S103: performing a second analysis on the variables, the variables being at different levels in the variable file, performing replacement assignments on the nested variables and processing the variables using a recursive algorithm to obtain the real values ​​corresponding to the variables.

[0042] Specifically, a YAML file is a highly readable format file used to express data serialization.

[0043] In a specific implementation, the test case set is generated by the following method:

[0044] Get the test case file in Excel format;

[0045] Converting the test case file in Excel format into a first object;

[0046] Convert the first object into a YAML string and generate the test case set.

[0047] Specifically, the first object is an object that can be recognized by the Python tool.

[0048] In a specific implementation, performing a first analysis on the test case set includes obtaining a directory and a file storage path of the test case set and then parsing the test case set.

[0049] In a specific implementation, performing the second analysis on the variable includes obtaining a key-value pair of the variable, the key-value pair being data in the test case set, obtaining a corresponding calculation formula based on the key-value pair, and automatically obtaining a calculation result. The calculation formula is specifically as follows:

[0050] Total assets = cash balance + market value of margin securities + value of other margin assets + adjustment amount.

[0051] Specifically, multiple curly braces are used when defining variables, representing different levels. This development approach facilitates quick and accurate identification of the source of any issues that arise during testing. Furthermore, if a calculation formula requires modification, only the variable within the curly braces needs to be modified, making it easier to maintain and modify variable definitions for testing.

[0052] For example, the calculation of the frozen amount of the in-transit collateral purchase fee "current_buy_fee_frz_amt" in the "Total Fees for Daily and Mid-Day Collateral Purchases" requires the introduction of new variable key-value pairs. This is done layer by layer until there are no more curly brackets in the variable. At this point, the calculation of the "Total Fees for Daily and Mid-Day Collateral Purchases" is complete.

[0053] In a specific implementation, rendering the template object using the render method includes obtaining an HTML tag name, a data object, and a child node. The HTML tag name is a component or a function. The data object is used to create a virtual DOM node. The child node supports strings and arrays.

[0054] In a specific implementation, the test method includes multiple threads, and the multiple threads respectively execute the test tasks of multiple modules;

[0055] The multiple threads share system resources, including virtual address space, file descriptors, signal processing, and instruction processing methods;

[0056] The multiple threads each have their own call stack, register environment and thread-local storage.

[0057] Specifically, different threads need to call test cases from corresponding modules to verify whether the system results meet expectations. At the same time, we support parallel testing of two trading systems and the interaction of fund data in the accounts, using multi-process concurrent logic to achieve this.

[0058] In a specific implementation, the multiple modules include the following test information: price type required for the transaction, trading market, trading variety, transaction status, fund check status and amount, and number of orders.

[0059] In a specific implementation, the test task checks the time, price, and order quantity in the current test environment through an immediate assertion. If the result of the immediate assertion is success, the test task ends. If the result of the immediate assertion is failure, the failure information is recorded and a new test task is started.

[0060] In a specific implementation, the test task also includes performing simulated matching, which simulates the exchange behavior of conducting simulated intraday trading on the submitted transaction orders and feeding back simulated exchange data.

[0061] Based on the problems existing in the existing technology, such as Figure 2 As shown, the present invention also provides a rapid transaction automation testing tool, the tool comprising:

[0062] A file acquisition module 21 is used to acquire a test case set and a variable file from a YAML file. The test case set includes test scenarios and user data information, and the variable file includes variables required for transactions.

[0063] A first parsing module 22 is configured to perform a first parsing on the test case set, create a template object using an API, and render the template object using a render method;

[0064] The second parsing module 23 is used to perform a second parsing on the variables, the variables are in different levels in the variable file, replace and assign values ​​to the nested variables and use a recursive algorithm to process the variables to obtain the real values ​​corresponding to the variables.

[0065] The following is an example of fast transaction automation testing methods and tools:

[0066] First, you need to define the case name in the test module, where the case name is a task in the test module, the price type, trading market, trading product, transaction status, fund check status and amount, number of orders, etc. required for the transaction, and the information configuration required for the order or other transaction types.

[0067] Specifically, based on the script-driven principle, two modules need to be configured during use. One part is the startup item configuration, which includes system-wide configuration contents such as server parameter configuration, environment parameter configuration, and client configuration; the startup item configuration information must be consistent with the server parameters, environment parameters, and other configurations of the tested trading system. After ensuring that all information is consistent, start the rapid trading automation test.

[0068] The startup configuration parameters have the following effects:

[0069] Uploading and decompressing test data: Before testing, you need to create a data file that complies with exchange specifications as test data, package the test data, upload it to the OES trading system, and analyze it;

[0070] Verify the startup / shutdown and status of the OES (Annotated Trading System) trading system environment: Execute startup / shutdown commands via SSH (Secure Shell), obtain the return information, perform regular expression matching, and assert the startup / shutdown values ​​to determine whether the system has been successfully started or shut down. If startup fails during environment initialization, the test is terminated.

[0071] Client login verification: By starting the client connection profile in the configuration parameters, try to log in to the trading server, log in to all accounts that need to be tested, and terminate the test if the login fails to avoid inaccurate test results caused by account errors;

[0072] Customize the test case configuration file based on a YAML file and select the test case modules to be tested. During the configuration process, the YAML file first undergoes format verification to prevent test case execution failures due to format errors. Secondly, the test case information in the test file is distributed to different cases / tasks and the test plan is executed.

[0073] YAML files ensure the accuracy of calculation results in stock and financial transactions. Stock and financial transactions involve complex calculations, often requiring complex logic to determine a single result. Writing test cases often requires a deep understanding of this logic, which can be time-consuming. Therefore, existing transaction calculation logic can be organized and summarized, loaded into automated testing programs using YAML files, and stored as key-value pairs. Simply enter the key in the key-value pair, retrieve the calculation formula based on the key, and calculate the final result. There's no need to worry about calculating the values ​​of checksum fields, eliminating the time-consuming process of calculating the final value required for the transaction and avoiding numerical errors caused by manual calculations.

[0074] Immediate assertions monitor and verify that order execution results in the trading system are consistent with expectations. Using the built-in coverage statistics of assertions, comprehensive coverage testing of fast trading system functions such as order execution and querying is possible. Immediate assertions check necessary conditions and results, such as time, price, and order quantity, within the current test environment. If the assertion fails, the test fails.

[0075] Simulated matching simulates exchange behavior, conducts simulated intraday trading on submitted trade orders, and feeds simulated exchange data back to the test system to assert whether the test has passed.

[0076] After automated testing is complete, the system automatically generates a corresponding automated test report, including the test case execution results and any issues encountered during testing. Specifically, the test report includes: the version status of the trading system (OES) and interface (API), as well as the start and end time and date of execution, the executor, and the brokerage firm to which the version belongs. It also lists basic information about the test module, including the module name, the number of executed use cases for each business module, and the time of execution. For example, the Shanghai and Shenzhen collateral purchase and sale in the margin trading business actually executed 575 use cases, and all tests passed. Each module's detailed display lists the detailed name of each use case and annotates the execution results. If the execution fails, the specific reason for the failure is noted.

[0077] From simulated order placement to the trading system, simulated matching is performed, and the returns collected by the fast trading system are compared and analyzed to obtain test case test results. Test results include expected results, actual results, and use case execution status data. These data are packaged and stored in a new queue. After all business function test cases are executed, they are summarized and analyzed to generate a test case report.

[0078] In summary, the fast transaction automation testing method and tool provided by the embodiment of the present invention obtains a test case set and a variable file in a YAML file, wherein the test case set includes test scenarios and user data information, and the variable file includes variables required for transactions; performs a first parsing on the test case set, creates a template object using an API, and renders the template object using a render method; performs a second parsing on the variables, wherein the variables are at different levels in the variable file, replaces and assigns values ​​to nested variables, and processes the variables using a recursive algorithm to obtain the true values ​​corresponding to the variables. By performing the first and second parsing on the test case set and variables, respectively, fast transaction automation testing is achieved;

[0079] Furthermore, the test case set is specifically generated by the following method: obtaining a test case file in Excel format; converting the test case file in Excel format into a first object; converting the first object into a YAML string and generating the test case set, thereby being able to quickly obtain the test case set;

[0080] Furthermore, rendering the template object using the render method includes obtaining an HTML tag name, a data object, and child nodes, wherein the HTML tag name is a component or a function, the data object is used to create a virtual DOM node, and the child node supports strings and arrays, thereby enabling rapid rendering of the template.

[0081] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A fast transaction automation testing method, It is characterized in that The method comprises: Obtain the test case set and variable file in the yaml file, wherein the test case set includes the test scenario and user data information, and the variable file includes the variables required for the transaction; Performing a first analysis on the test case set, creating a template object using an API, and rendering the template object using a render method; Performing a second analysis on the variables, the variables being at different levels in the variable file, performing replacement assignments on the nested variables and processing the variables using a recursive algorithm to obtain true values ​​corresponding to the variables; The test case set is specifically generated by the following method: Get the test case file in Excel format; Converting the test case file in Excel format into a first object; Convert the first object into a YAML string and generate the test case set; The first parsing of the test case set includes obtaining a directory and a file storage path of the test case set and then parsing the test case set; The second analysis of the variable includes obtaining a key-value pair of the variable, the key-value pair being data in the test case set, obtaining a corresponding calculation formula according to the key-value pair and automatically obtaining a calculation result, the calculation formula being specifically as follows: Total assets = cash balance + market value of guaranteed securities + value of other guaranteed assets + adjustment amount; Rendering the template object using the render method includes obtaining an HTML tag name, a data object, and a child node, wherein the HTML tag name is a component or a function, the data object is used to create a virtual DOM node, and the child node supports strings and arrays; The testing method includes multiple threads, and the multiple threads respectively execute the testing tasks of multiple modules; The multiple threads share system resources, which include virtual address space, file descriptors, signal processing, and instruction processing methods; The multiple threads each have their own call stack, register environment and thread local storage.

2. The fast transaction automated testing method according to claim 1, It is characterized in that The multiple modules include the following test information: price type required for the transaction, trading market, trading product, transaction status, fund check status and amount, and number of orders.

3. The fast transaction automated testing method according to claim 1, It is characterized in that The test task checks the time, price, and order quantity in the current test environment through an immediate assertion. If the result of the immediate assertion is success, the test task ends. If the result of the immediate assertion is failure, the failure information is recorded and a new test task is started.

4. The fast transaction automated testing method according to claim 3, It is characterized in that The test task also includes simulated matching, which simulates the exchange behavior of simulating intraday trading of the submitted transaction orders and feeding back simulated exchange data.

5. A fast transaction automation testing tool, It is characterized in that The tools include: A file acquisition module, which is used to acquire a test case set and a variable file in a yaml file, wherein the test case set includes a test scenario and user data information, and the variable file includes variables required for transactions; A first parsing module, which is used to perform a first parsing on the test case set, create a template object using an API, and render the template object using a render method; A second parsing module is used to perform a second parsing on the variables, the variables are at different levels in the variable file, replace and assign values ​​to the nested variables, and use a recursive algorithm to process the variables to obtain the real values ​​corresponding to the variables; The test case set is specifically generated by the following method: Get the test case file in Excel format; Converting the test case file in Excel format into a first object; Convert the first object into a YAML string and generate the test case set; The first parsing of the test case set includes obtaining a directory and a file storage path of the test case set and then parsing the test case set; The second analysis of the variable includes obtaining a key-value pair of the variable, the key-value pair being data in the test case set, obtaining a corresponding calculation formula according to the key-value pair and automatically obtaining a calculation result, the calculation formula being specifically as follows: Total assets = cash balance + market value of guaranteed securities + value of other guaranteed assets + adjustment amount; Rendering the template object using the render method includes obtaining an HTML tag name, a data object, and a child node, wherein the HTML tag name is a component or a function, the data object is used to create a virtual DOM node, and the child node supports strings and arrays; The testing tool includes multiple threads, and the multiple threads respectively execute the testing tasks of multiple modules; The multiple threads share system resources, which include virtual address space, file descriptors, signal processing, and instruction processing methods; The multiple threads each have their own call stack, register environment and thread local storage.

Citation Information

Patent Citations

  • Test method and device, electronic equipment and storage medium

    CN117493158A

  • System and method for creating and executing portable software

    US20110296528A1

  • Testing method and apparatus

    WO2021088724A1