A verification method and automated testing tool for back-end data accuracy
Through back-end data accuracy verification methods and automated testing tools, the problem of low back-end data testing efficiency caused by frequent iterations of Internet products is solved, efficient data verification and bug reduction are achieved, and the agility of the product development process is improved.
Patent Information
- Application Number
- CN202111122245.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-24
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-09-24
AI Technical Summary
In the context of frequent iterations of Internet products, it is difficult with existing technology to conduct complete regression testing of all functions in each iteration, resulting in low back-end data testing efficiency and frequent occurrence of underlying bugs.
A back-end data accuracy verification method and automated testing tool are proposed. SQL and request information are configured through YAML configuration files and CONFIG.INI files, and SQL is dynamically spliced. The automated testing tool is divided into 6 major modules: global initialization, use case set initialization , loop execution, comparison results, report generation and email sending modules to realize automatic verification of back-end data.
It significantly improves the efficiency of back-end data testing, reduces the number of underlying bugs, makes the product development process more agile, and improves test coverage and accuracy.
Smart Images

Figure CN113868129B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of information technology, and in particular relates to a back-end data accuracy verification method and an automated testing tool. Background Art
[0002] In the current context of frequent iterations of Internet products, due to the increasing complexity of products and systems, many TestCases can no longer be covered by previous functional tests, and the time for regression testing is getting shorter and shorter. It is difficult to perform a complete regression of all functions in each iteration. However, interface automation testing is becoming more and more important due to its simple implementation, low maintenance cost, and easy to improve coverage.
[0003] The present invention summarizes the experience and methods from the back-end data testing process, sorts out a back-end data accuracy verification method for the interface data verification part, and provides a corresponding automated testing tool, which greatly improves the efficiency of back-end data testing, makes functional testers and performance testers more convenient during testing, minimizes the number of underlying bugs, and makes the product development process more agile. Summary of the invention
[0004] The purpose of the present invention is to improve the efficiency of data testing, to make up for the deficiencies of existing data testing methods, to propose and develop a back-end data accuracy verification method and an automated testing tool, and the specific contents of the invention are as follows.
[0005] A backend data accuracy verification method, which can support the following test scenarios:
[0006] Scenario 1: A specific SQL corresponds to a request BODY, that is, write specific SQL and request information according to the screening conditions;
[0007] Scenario 2: One dynamic SQL corresponds to different request information, that is, it is dynamically spliced into SQL according to different filtering conditions. In the configuration file, only one SQL and multiple request parameter information need to be written to test the data comparison after different filtering conditions.
[0008] A method for verifying the accuracy of backend data, the specific implementation steps are as follows:
[0009] Step 1: Configure SQL and request information in the YAML configuration file;
[0010] The configuration file has different required file contents depending on the scenario, as follows:
[0011] Scenario 1: A specific SQL corresponds to a request body. The YAML configuration file contains the following configuration:
[0012] File name and PARAMETERS, where PARAMETERS includes URL and BODY. BODY includes SQL and DATA. URL represents the requested interface address, and SQL represents the control SQL obtained by the test. Specifically, DATA represents the request body for the requested interface information. And one SQL can only correspond to one DATA;
[0013] Scenario 2: A dynamic SQL corresponds to multiple request bodies. The YAML configuration file contains the following configuration:
[0014] File name and PARAMETERS, where PARAMETERS includes URL, SQL, and DATA. URL represents the requested interface address, SQL represents the control SQL obtained by the test, and DATA represents the request body for requesting interface information. One SQL can correspond to multiple DATA.
[0015] Step 2: Configure the CONFIG.INI file, including the configuration of the measured environment information, database connection information, recipient information, and YAML file information;
[0016] Configure the tested environment information, including test environment configuration and online environment configuration, specifically:
[0017] [private_debug]
[0018] tester=Wang San
[0019] environment=debug
[0020] versionCode=md-master-2.0
[0021] host = http: / / product.xxx.com
[0022] loginHost=http: / / product.xxx.com / login
[0023] loginInfo={"username":"xxx","password":"xxx"}
[0024] [private_release]
[0025] tester=Wang San
[0026] environment=release
[0027] versionCode=md-master-2.0
[0028] host = http: / / dev.xxx.com
[0029] loginHost=http: / / dev.xxx.com / login
[0030] loginInfo={"username":"xxx","password":"xxx"}
[0031] Among them, [private_debug] is the test environment configuration, [private_release] is the online environment configuration, tester is the tester, environment is the test environment or the online environment, versionCode is the version number of the tested system, host is the domain name address, loginHost is the login address, and loginInfo is the user name and password for logging into the system.
[0032] Database connection information, including database connection configuration, database name, database password, database address and database port number, specifically:
[0033] [db_conf]
[0034] db_database=xxx
[0035] db_password=xxx
[0036] db_host=192.168.xx.xx
[0037] db_port=xxx
[0038] [db_conf] is the database connection configuration, db_database is the database name, db_password is the database password, db_host is the database address, and db_port is the database port number.
[0039] Recipient information, including mailbox configuration, mailbox service address, sender address, recipient address, recipient username and recipient password, specifically:
[0040] [mail]
[0041] smtp_server=xx.xx.xx.com
[0042] sender=xx@linezonedata.com
[0043] receiver=xx@linezonedata.com
[0044] username=xx@linezonedata.com
[0045] password=xx
[0046] Where [mail] is the mailbox configuration, smtp_server is the mailbox service address, sender is the sender address, receiver is the recipient address, username is the recipient username, and password is the recipient password.
[0047] YAML file information:
[0048] [yaml]
[0049] data_yaml=StoreSummaryOneSql,StoreSummaryNodeLevel1
[0050] [yaml] is the YAML file configuration, data_yaml is the use cases in the YAML file to be executed. StoreSummaryOneSql and StoreSummaryNodeLevel1 refer to the YAML file names.
[0051] Step 3: Read the URL, SQL, and DATA of the YAML files (StoreSummaryOneSql and StoreSummaryNodeLevel1 files) through CONFIG.INI, and loop through each set of URL, SQL, and DATA.
[0052] Step 4: Access the backend data interface through URL and DATA, and store the data returned by the interface in Dataframe; read the tested data in the database by executing the control SQL obtained by the test, and store the query results in Dataframe.
[0053] Step 5: Compare the consistency of the two results in step 4 (the returned data and the query result of the control SQL), and use "." to indicate whether the use case has passed the test (that is, "." means the use case has passed, and "F" means the use case has failed).
[0054] Step 6: Generate a test report using allure.
[0055] Step 7: Send the execution result email to the recipient configured in the CONFIG.INI file.
[0056] The technical architecture of the automated testing tool of the present invention can be divided into six modules: a global initialization module, a use case set initialization module, a use case execution loop module, a result comparison module, a report generation module, and an email sending module.
[0057] The global initialization module initializes the global configuration;
[0058] The use case set initialization module stores the use case content in the data dictionary by reading the YAML configuration file; parses the data dictionary, constructs DATA and SQL into tuples and stores them in a list;
[0059] The loop execution use case module parameters DATA and SQL and then loops through the contents of each use case.
[0060] The comparison result module compares the Dataframe obtained by executing the tested interface with the Dataframe obtained by executing the control SQL, and marks the consistent ones with "." and the inconsistent ones with "F";
[0061] The report generation module uses the allure plug-in to generate a visual report;
[0062] The sending email module will send the execution result email after the use case is executed.
[0063] The execution method of the automated testing tool of the present invention is as follows:
[0064] Execution method 1: Right-click run.py and select Run'run' to execute all test cases.
[0065] Execution method 2: Some test cases can be executed through the PYTEST command.
[0066] Beneficial effects of the present invention:
[0067] The present invention proposes a data testing method for back-end data testing by combing and summarizing the back-end data testing methods, classifies the data scenario conditions, writes a verification program suitable for each scenario, and develops an automated testing tool for back-end data testing. Improving the back-end data testing system is conducive to improving data testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 In scenario 1 of the embodiment of the present invention, a specific SQL corresponds to a request body YAML file configuration content;
[0069] Figure 2 It is the configuration content of a dynamic SQL corresponding to multiple request body YAML files in scenario 1 of the embodiment of the present invention;
[0070] Figure 3 It is the specific configuration information of the environment information, database connection information, recipient information, and YAML file information measured in the embodiment of the present invention.
[0071] Figure 4 It is a specific flow chart of the back-end data accuracy verification method and automated testing tool used in the embodiment of the present invention.
[0072] Figure 5 This is a diagram of the results of the use case operation of an embodiment of the present invention. DETAILED DESCRIPTION
[0073] The present invention is described in detail below in conjunction with the accompanying drawings and tables, so that the purpose and results of the present invention are more obvious. This example is based on actual data testing conditions, writes test cases, and uses automated testing tools to achieve the purpose of testing the accuracy of backend data.
[0074] Step 1: Write a use case and configure SQL and request information in the YAML configuration file. The YAML files corresponding to scenario 1 and scenario 2 are as follows: Figure 1 , Figure 2 As shown;
[0075] Step 2: Configure the CONFIG.INI file to configure the measured environment information, database connection information, recipient information, and YAML file information. For specific configuration implementation examples, see Figure 3 ;
[0076] Step 3: Use automated testing tools to verify the accuracy of backend data. Figure 4 shown.
[0077] Step 4: Users can view the test results in the console; Figure 5 The test case execution result data after the test embodiment is executed using the automated testing tool of the present invention; wherein "." indicates that the test case has passed; "F" indicates that the test case has failed;
[0078] Step 6: Send the execution result email to the recipient configured in the CONFIG.INI file.
[0079] The present invention is not limited to the above specific implementations. A person skilled in the art can implement the present invention by using other various specific implementations based on the content disclosed in the present invention. Therefore, any design that adopts the design structure and ideas of the present invention and makes some simple changes or modifications falls within the protection scope of the present invention.
Claims
1. A backend data accuracy verification method, which can support the following test scenarios: Scenario 1: A specific SQL corresponds to a request BODY. Write specific SQL and request information according to the screening conditions. Scenario 2: A dynamic SQL corresponds to different request information, which is dynamically spliced into SQL according to different filtering conditions. In the configuration file, only one SQL and multiple request parameter information need to be written to test the data comparison after different filtering conditions. Features The specific implementation steps are as follows: Step 1: Configure SQL and request information in the YAML configuration file; Step 2: Configure the CONFIG.INI file, including the configuration of the measured environment information, database connection information, recipient information, and YAML file information; Step 3: Read the URL, SQL, and DATA of the YAML file through CONFIG.INI, and store the use case content in the data dictionary by reading the YAML configuration file; construct DATA and SQL into tuples and store them in a list; parameterize DATA and SQL, and execute each set of URL, SQL, and DATA in a loop; the YAML files are StoreSummaryOneSql files and StoreSummaryNodeLevel1 files; Step 4: Access the backend data interface through URL and DATA, and store the data returned by the interface in Dataframe; read the tested data in the database by executing the control SQL obtained by the test, and store the query results in Dataframe; Step 5: Compare the consistency of the two results in step 4, return the data and the query results of the control SQL; use ".." to indicate whether the test case has passed the test, ".." means the test case has passed, and "F" means the test case has failed; Step 6: Use allure to generate a test report; Step 7: Send the execution result email to the recipient configured in the CONFIG.INI file; Step 1 is implemented as follows: The configuration file has different required file contents depending on the scenario, as follows: Scenario 1: A specific SQL corresponds to a request body. The YAML configuration file contains the following configuration: File name and PARAMETERS, where PARAMETERS includes URL and BODY; BODY includes SQL and DATA. URL represents the requested interface address, and SQL represents the control SQL obtained by the test. Specifically, DATA represents the request body for the requested interface information; and one SQL can only correspond to one DATA. Scenario 2: A dynamic SQL corresponds to multiple request bodies. The YAML configuration file contains the following configuration: File name and PARAMETERS, where PARAMETERS includes URL, SQL, and DATA. URL represents the requested interface address, SQL represents the control SQL obtained by the test, and DATA represents the request body for requesting interface information. One SQL can correspond to multiple DATA. Step 2 is implemented as follows: Configure the tested environment information, including test environment configuration and online environment configuration, specifically: [private_debug] tester=Wang San environment=debug versionCode=md-master-2.0 host = http: / / product.xxx.com loginHost=http: / / product.xxx.com / login loginInfo={"username":"xxx","password":"xxx"} [private_release] tester=Wang San environment=release versionCode=md-master-2.0 host = http: / / dev.xxx.com loginHost=http: / / dev.xxx.com / login loginInfo={"username":"xxx","password":"xxx"} [private_debug] is the test environment configuration, [private_release] is the online environment configuration, tester is the tester, environment is the test environment or the online environment, versionCode is the version number of the tested system, host is the domain name address, loginHost is the login address, and loginInfo is the username and password for logging into the system; Database connection information, including database connection configuration, database name, database password, database address and database port number, specifically: [db_conf] db_database=xxx db_password=xxx db_host=192.168.xx.xx db_port=xxx [db_conf] is the database connection configuration, db_database is the database name, db_password is the database password, db_host is the database address, and db_port is the database port number; Recipient information, including mailbox configuration, mailbox service address, sender address, recipient address, recipient username and recipient password, specifically: [mail] smtp_server=xx.xx.xx.com sender=xx@linezonedata.com receiver=xx@linezonedata.com username=xx@linezonedata.com password=xx Where [mail] is the mailbox configuration, smtp_server is the mailbox service address, sender is the sender address, receiver is the recipient address, username is the recipient username, and password is the recipient password; YAML file information: [yaml] data_yaml=StoreSummaryOneSql,StoreSummaryNodeLevel1 [yaml] indicates the YAML file configuration, data_yaml indicates the use cases in the YAML file to be executed, and StoreSummaryOneSql and StoreSummaryNodeLevel1 refer to the YAML file names.
2. A back-end data accuracy verification method according to claim 1, Features The technical architecture of the automated testing tool is divided into six modules: global initialization module, use case set initialization module, loop execution use case module, comparison result module, report generation module, and email sending module; The global initialization module initializes the global configuration; The use case set initialization module stores the use case content in the data dictionary by reading the YAML configuration file; parses the data dictionary, constructs DATA and SQL into tuples and stores them in a list; The loop execution use case module parameters DATA and SQL and then loops through the contents of each use case. The comparison result module compares the Dataframe obtained by executing the tested interface with the Dataframe obtained by executing the control SQL, and marks the consistent ones with ".", and marks the inconsistent ones with "F"; The report generation module uses the allure plug-in to generate a visual report; The sending email module sends the execution result email after the use case is executed.
3. A back-end data accuracy verification method according to claim 2, Features The execution method of the automated testing tool is as follows: Execution method 1: Right-click run.py and select Run'run' to execute all test cases; Execution method 2: Some test cases can be executed through the PYTEST command.
