Automatic interface performance testing method

Through the interface performance automation testing method, parameterized data is automatically generated and combined with automated interface performance testing technology, the problem of traditional manual operation is solved, and efficient and intuitive interface performance testing and report generation is achieved.

CN119557152AInactive Publication Date: 2025-03-04YUKUAI CHUANGLING INTELLIGENT TECH (NANJING) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411691066.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-03-04
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional manual interface performance regression testing has defects such as inefficient testing, time-consuming and high cost, and it is difficult to meet the testing needs after increasing business volume and increasing service complexity.

Method used

A method of automatic interface performance testing is proposed, which automatically generates parameterized data and combines automated interface performance testing technology to realize the automation of interface performance testing. This method includes cleaning up historical test result files, generating parameterized files, executing interface performance test scripts, and format conversion.

Benefits of technology

Through automated testing methods, the testing efficiency and server utilization are improved, errors and maintenance workload caused by manual operations are reduced, and the generated test reports are more intuitive and easy to locate problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557152A_ABST
    Figure CN119557152A_ABST
Patent Text Reader

Abstract

The invention provides a method for automatically testing interface performance. The method comprises the following steps: S1, cleaning historical jtl file records; s2, generating a parameterized file; s3, executing the interface performance test script; s4, performing format conversion on the test report in the jtl format; according to the automatic interface performance testing method provided by the invention, the parameterized data automatic generation and the automatic interface performance testing technology are combined, so that the performance testing data maintenance is simpler, the subsequent maintenance workload is reduced after case writing is completed, and the result inaccuracy caused by data change is avoided; the interface script is executed, the idle time of the server is effectively utilized, the script execution efficiency is improved, and the server utilization rate is increased; the test report is more visual, success or failure can be visually displayed for the assertion report, the failure reason can be directly positioned without checking logs, and the problem can be conveniently solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of interface performance automation testing, and in particular to an interface performance automation testing method. Background Art

[0002] With the rapid development of Internet technology and the continuous expansion of corporate business, more and more systems and applications need to continuously perform interface performance regression testing; interface performance regression testing is an important means to ensure that the interface can continue to run stably and meet performance requirements in different versions and environments; with the increase in business volume and the complexity of services, the frequency and scope of interface performance regression testing are gradually expanding; however, traditional manual operations have defects such as low testing efficiency, time-consuming and labor-intensive, and high cost. Summary of the invention

[0003] The purpose of the present invention is to solve the shortcomings of the prior art and to propose an automatic testing method for interface performance.

[0004] To achieve the above object, the present invention adopts the following technical solutions: An interface performance automated testing method comprises the following steps: S1: clean up historical jtl file records; Use the clear_dir function to identify the directory where the test result files that need to be cleared are located, obtain a list of all files in the directory, recursively traverse all files in the file list, and delete files with .html and .jtl extensions, that is, delete html report files and jtl test result files.

[0005] S2: Generate parameterization file; Read the external Excel file through the pandas library, extract all the SQL scripts contained in the external Excel file, use the Python library to establish a database connection, and pass the SQL script to the database; The Python libraries include pyodbc, pymysql, etc. The database receives and executes the SQL script, executes each SQL script in turn, and uses the cursor.fetchall component to obtain the execution results from the database; When a SQL script is executed, check whether there are still SQL scripts to be executed in the database. If so, continue to execute until all SQL scripts received by the database are executed. After the execution is completed, format the execution results of all SQL scripts into parameterized data required for performance testing, and use the write_to_txt function to write the parameterized data into a txt file to obtain the parameterized file and save it to the specified directory. The parameterized data includes data in csv, txt and other formats; Furthermore, the time.time function is used to record the time of executing the SQL script, which includes the start time, the end time and the duration; after the parameterized file is generated, the result of whether the SQL script is successfully executed and the time are written into the Excel file.

[0006] S3: Execute interface performance test script; The background calls the jmeter component to read parameterized data from the parameterized file to replace the corresponding data in the interface performance test script and execute the interface performance test script; Furthermore, each interface performance test script corresponds to a unique interface performance test script name; After executing the interface performance test script, an html report is generated, and a storage directory is created according to the interface performance test script name, and the html report is saved in the specified storage directory.

[0007] Furthermore, when the interface performance test script is executed, a jtl format test report will be generated synchronously, and the jtl format test report will be saved in a designated storage directory.

[0008] Furthermore, during the test, the write.xlsx function is called to read and write data in the Excel file, and the write.txtFormat is used to read and write the required content in the txt file.

[0009] S4: Convert the jtl format test report; Convert the jtl format test report to png format through other graphics tools such as matplotlib.

[0010] Compared with the prior art, the present invention has the following beneficial effects: The present invention proposes an interface performance automation testing method, which combines parameterized data automatic generation with automated interface performance testing technology, making performance test data maintenance simpler, reducing the workload of subsequent maintenance after the use case is written, and preventing inaccurate results due to data changes; executing interface scripts effectively utilizes the server's idle time, improves script execution efficiency, and improves server utilization; avoiding the time-consuming, labor-intensive, and inefficient problem of manually executing interface test cases in the prior art; At the same time, the test report obtained by the method proposed in the present invention is more intuitive, and success or failure can be intuitively displayed in the assertion report. There is no need to check the log for troubleshooting, and the cause of the failure can be directly located, which is convenient for solving the problem. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1The present invention is a flowchart of the steps of an automatic interface performance testing method. DETAILED DESCRIPTION

[0012] In order to provide a further understanding of the purpose, structure, features, and functions of the present invention, the following detailed description is given in conjunction with the embodiments.

[0013] like Figure 1 As shown, an interface performance automated testing method comprises the following steps: S1: clean up historical jtl file records; Use the clear_dir function to identify the directory where the test result files that need to be cleared are located, obtain a list of all files in the directory, recursively traverse all files in the file list, and delete files with .html and .jtl extensions, that is, delete html report files and jtl test result files.

[0014] Due to the high frequency of automated execution and the large number of scripts executed each time, a large number of test report result files will be generated. Automatic cleanup can quickly clean up the result files generated by the previous execution to prepare for the next test.

[0015] S2: Generate parameterization file; Read the external Excel file through the pandas library, extract all the SQL scripts contained in the external Excel file, use the Python library to establish a database connection, and pass the SQL script to the database; The Python libraries include pyodbc, pymysql, etc. The database receives and executes the SQL script, executes each SQL script in turn, and uses the cursor.fetchall component to obtain the execution results from the database; When a SQL script is executed, check whether there are still SQL scripts to be executed in the database. If so, continue to execute until all SQL scripts received by the database are executed. After the execution is completed, format the execution results of all SQL scripts into parameterized data required for performance testing, and use the write_to_txt function to write the parameterized data into a txt file to obtain the parameterized file and save it to the specified directory. The parameterized data includes data in csv, txt and other formats; Furthermore, the time.time function is used to record the time of executing the SQL script, which includes the start time, the end time and the duration; after the parameterized file is generated, the result of whether the SQL script is successfully executed and the time are written into the Excel file.

[0016] Each interface has its own parameterized file. The test system data is dynamic. Automated testing requires a large amount of dynamic parameterized information. The automatic generation mechanism of parameterized files can generate multiple parameterized files in a short time while ensuring the accuracy and validity of the parameterized data. At the same time, the execution results are recorded in the file to ensure the accuracy of the test.

[0017] S3: Execute interface performance test script; The background calls the jmeter component to read parameterized data from the parameterized file to replace the corresponding data in the interface performance test script and execute the interface performance test script; Furthermore, each interface performance test script corresponds to a unique interface performance test script name; After executing the interface performance test script, an html report is generated, and a storage directory is created according to the interface performance test script name, and the html report is saved in the specified storage directory.

[0018] Furthermore, when the interface performance test script is executed, a jtl format test report will be generated synchronously, and the jtl format test report will be saved in a designated storage directory.

[0019] Furthermore, during the test, the write.xlsx function is called to read and write data in the Excel file, and the write.txtFormat is used to read and write the required content in the txt file.

[0020] A project needs to regularly test a large number of interface performance test scripts. By calling the jmeter automatic script execution mechanism in the background, a large number of script executions can be completed in a short period of time.

[0021] S4: Convert the jtl format test report; Convert the jtl format test report to png format through other graphics tools such as matplotlib.

[0022] Each test will generate a large number of resource monitoring files in jtl format. jtl has poor readability. After conversion to png format, it has good readability and is convenient for comparing test results.

[0023] The present invention has been described by the above-mentioned relevant embodiments, however, the above-mentioned embodiments are only examples for implementing the present invention. It must be pointed out that the disclosed embodiments do not limit the scope of the present invention. On the contrary, changes and modifications made without departing from the spirit and scope of the present invention are all within the scope of patent protection of the present invention.

Claims

1. An interface performance automated testing method, characterized in that: The following steps are involved: S1: clean up historical jtl file records; Use the clear_dir function to identify the directory where the test result files to be cleared are located, obtain a list of all files in the directory, recursively traverse all files in the file list, and delete files with .html and .jtl extensions, that is, delete html report files and jtl test result files; S2: Generate parameterization file; Read the external Excel file through the pandas library, extract all the SQL scripts contained in the external Excel file, use the Python library to establish a database connection, and pass the SQL script to the database; The database receives and executes the SQL script, executes each SQL script in turn, and uses the cursor.fetchall component to obtain the execution results from the database; S3: Execute interface performance test script; The background calls the jmeter component to read parameterized data from the parameterized file to replace the corresponding data in the interface performance test script and execute the interface performance test script; S4: Convert the jtl format test report; Convert the jtl format test report to png format through other graphics tools such as matplotlib.

2. The interface performance automated testing method according to claim 1, characterized in that: In step S2, when a SQL script is executed, check whether there are still SQL scripts to be executed in the database. If so, continue to execute until all SQL scripts received by the database are executed; after execution, format the execution results of all SQL scripts into parameterized data required for performance testing, and use the write_to_txt function to write the parameterized data into a txt file to obtain the parameterized file and save it to the specified directory.

3. The interface performance automated testing method according to claim 1, characterized in that: Furthermore, each interface performance test script corresponds to a unique interface performance test script name; After executing the interface performance test script, an html report is generated, and a storage directory is created according to the interface performance test script name, and the html report is saved in the specified storage directory.

4. The interface performance automated testing method according to claim 1, characterized in that: Furthermore, when the interface performance test script is executed, a jtl format test report will be generated synchronously, and the jtl format test report will be saved in a specified storage directory; During the test, call the write.xlsx function to read and write data in the Excel file, and use write.txtFormat to read and write the required content in the txt file.

5. The interface performance automated testing method according to claim 2, characterized in that: Use the time.time function to record the time of executing the SQL script, which includes the start time, end time and duration; After the parameterized file is generated, the result and time of whether the SQL script is successfully executed are written into the Excel file.

Citation Information

Patent Citations

  • Electronic device, interface automatic test method, and storage medium

    CN109634841A

  • Test data processing method and system oriented to host system

    CN115495356A

  • Automatic test method for interface performance and related equipment

    CN116521531A