Test method for realizing asynchronous operation interface test platform based on Celery
Through the technical architecture design of Django+Vue+Celery+Requests, the automation and full coverage of interface testing are achieved, and the problems of insufficient flexibility and dependence on professional programming skills in the existing technology are solved, the testing efficiency and coverage are improved, and the testing efficiency and coverage are enhanced. Team engagement and innovation capabilities.
Patent Information
- Application Number
- CN202411135236.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-11-08
AI Technical Summary
The existing interface testing technology is insufficiently flexible, relies on professional programming skills, limited testing coverage and low efficiency, which limits the participation and team innovation capabilities of non-technical background personnel.
The technical architecture design test platform is adopted for Django+Vue+Celery+Requests. Through the graphical interface and asynchronous task queue system, the interface test cases are automated and full coverage are achieved, reducing the dependence of programming capabilities.
It improves the efficiency and coverage of interface testing, reduces the difficulty of getting started, enhances team participation and innovation capabilities, ensures comprehensive and in-depth testing of interfaces, and improves product quality and stability.
Smart Images

Figure CN118916292A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of server interface automated testing, and in particular to a testing method for implementing an asynchronous operation interface testing platform based on Celery. Background Art
[0002] At present, the development of interface tests mainly adopts the technology stack of Python+requests+pytest+allure. This technical solution uses the flexibility and richness of the Python language, combined with the requests library to send HTTP requests, pytest as a test framework to provide test case organization and execution, and allure for reporting and displaying test results.
[0003] Limitations of existing technologies:
[0004] Lack of flexibility: Current interface test cases are often fixed in design, making it difficult to quickly respond to changes in requirements or interface adjustments. This rigidity results in more time and effort required to update and maintain test cases during the actual development process, affecting the adaptability and efficiency of testing.
[0005] High coding skills required: This technical solution places high demands on testers’ programming skills. Only with the corresponding programming knowledge and coding skills can testers effectively carry out interface testing. This limits the participation of testers with non-technical backgrounds in the development of interface test cases, reducing the overall participation and creativity of the team.
[0006] Limited test coverage: Due to the above reasons, the number and coverage of interface test cases often fail to meet the comprehensiveness and depth requirements of the project. This limitation may lead to a lack of sufficient testing of certain functional points of the software product, increasing the risk of defects after the product is released.
[0007] Test efficiency issues: In the existing testing process, the execution of test cases and result analysis often require manual intervention, which not only increases the testing cycle but also increases the possibility of errors.
[0008] Resource and skills limitations: Reliance on specialized development skills limits the diversity and innovation of the testing team, while also increasing the cost of training and skills development.
[0009] In summary, although the existing technology has met the basic needs of interface testing to a certain extent, its inherent limitations have become a bottleneck for further improving testing efficiency and quality. Therefore, it is necessary to explore a new interface testing method to overcome the shortcomings of the existing technology and meet the growing needs of software development and testing. Summary of the invention
[0010] In view of the problems existing in the prior art, the present invention provides a testing method for implementing an asynchronous operation interface testing platform based on Celery.
[0011] The present invention adopts the mode of Django+vue+celery+requests to design the test platform, so that interface testing can add interface test cases without code ability, and mobilize the entire test group to achieve full coverage of test cases. The test platform is built by adopting the technical architecture combined with Django, Vue, Celery and Requests, which brings a new and convenient experience for interface testing. Django, as a powerful back-end framework, is responsible for processing data storage, business logic and interaction with the database, and provides solid back-end support for the entire platform. Vue plays its advantages at the front end, builds an intuitive, friendly and highly interactive user interface, and allows users to operate easily.
[0012] The introduction of the Celery framework enables asynchronous processing of tasks, allowing interface test tasks to run efficiently in the background without affecting other user operations, greatly improving the overall performance and response speed of the platform. The Requests library is used to send HTTP requests, interact with the interface being tested, obtain responses and verify results. Most importantly, this innovative design makes interface testing no longer dependent on professional coding capabilities. Even testers without a deep programming foundation can easily add interface test cases. In practical applications, this approach fully mobilizes the enthusiasm and participation of the entire test team. Whether you are an experienced test expert or a novice in the field of testing, you can contribute to achieving full coverage of use cases.
[0013] For example, in the past, only a few people who were proficient in code could participate in complex interface testing. But now, through this platform, testers who are not familiar with code can also quickly create test cases. For example, to test the intelligent cabinet door opening status query interface, they only need to fill in the relevant parameters on the interface, and the platform can automatically execute the test and give the results. This greatly improves the test efficiency and ensures that all types of interfaces can be fully and effectively tested, thereby improving the quality and stability of the product.
[0014] In order to achieve the above object, the present invention provides a testing method for implementing an asynchronous operation interface testing platform based on Celery, comprising the following steps:
[0015] Step a: Enter the detailed information of the interface test case in the VUE front-end interface;
[0016] Step b: Store the input test case information into the api table of the database;
[0017] Step c: Design test cases by filtering the interfaces added in step a and combining multiple interface steps in the order of business requirements to form a complete test case, which is stored in the apicase table of the database;
[0018] Step d: Use the Celery asynchronous task queue system to parse and execute the use case;
[0019] Step e: Call the corresponding parser to parse the different step types in step d, convert them into executable data, and call the special parser to parse when encountering a custom function;
[0020] Step f: Execute the parsed information and store the execution results in the report table of the database;
[0021] Step g: Support parameterized test cases, allow the use of built-in functions to dynamically generate test parameters, achieve flexible execution of test cases, and allow test cases to be executed multiple times based on different parameters.
[0022] Preferably, the front-end interface in step a provides graphical operations, including dragging, parameter input and assertion rule configuration, to simplify the process of creating and modifying test cases.
[0023] Preferably, the detailed information of the interface test case in step a includes the interface path, request header, request body, request method, domain name, as well as SQL statements, curl commands and redis commands;
[0024] The interface path is used to uniquely identify and locate a specific API endpoint;
[0025] The request header is used to specify the header information of the HTTP request;
[0026] The request body is used to carry the data part of the HTTP request;
[0027] The request method is used to specify the operation type of the HTTP request;
[0028] The domain name is used to specify the network domain name or IP address of the API service;
[0029] The SQL statement is used to define SQL commands for operating the database, including query and update;
[0030] The curl command is used to create a curl script that interacts with the API through the command line, supporting various HTTP methods and header settings;
[0031] The redis command is used to interact with the Redis cache system and supports data storage, retrieval and deletion operations.
[0032] Preferably, the interface test case also includes: configuration of request timeout settings to ensure the sensitivity of the test to response time;
[0033] The interface test case also includes configuration of a request retry mechanism, allowing automatic retry of requests upon failure;
[0034] The interface test case also includes the definition of error handling rules when a request fails, defining redirection, logging or throwing an exception.
[0035] Preferably, the Celery asynchronous task queue system in step d includes task monitoring and logging functions, as well as a notification mechanism in case of execution exceptions;
[0036] When the Celery asynchronous task queue system receives a task to execute an interface use case, it will query the api table based on the use case number to obtain the interface data, SQL statements, curl commands, redis commands, and other content corresponding to each step in the interface use case.
[0037] Preferably, the Celery asynchronous task queue system further includes a task priority setting, allowing the user to assign different priorities according to the urgency of the test task;
[0038] The Celery asynchronous task queue system also provides a task execution history function, allowing users to query and analyze the historical execution status of test tasks.
[0039] The Celery asynchronous task queue system also supports an automatic task retry mechanism, which automatically re-executes the task according to the preset conditions and times when the execution fails;
[0040] The Celery asynchronous task queue system allows users to define resource limits for task execution;
[0041] The Celery asynchronous task queue system also supports distributed task execution, allowing test tasks to be processed in parallel on multiple nodes to improve execution efficiency;
[0042] The Celery asynchronous task queue system provides security control for task execution, including verification of task execution permissions and audit logs of user operations;
[0043] The Celery asynchronous task queue system also provides a real-time feedback mechanism for task execution results, allowing users to obtain progress and result information in real time during task execution.
[0044] Preferably, the execution result in step f includes response time, status code, response content and assertion verification result, and has the functions of data storage, historical test result search and screening;
[0045] The response time is the time from sending a request to receiving a response, which is used to evaluate interface performance;
[0046] The status code is an HTTP response status code, which is used to identify whether the request is successful or failed, and the reason for the failure;
[0047] The response content is the data returned by the interface, in JSON, XML or other formats, for further analysis and assertion verification;
[0048] The assertion verification result is the comparison result between the assertion condition preset in the test case and the actual response content, which is used to verify whether the data returned by the interface meets expectations.
[0049] Preferably, the execution result also includes an evaluation of interface performance, concurrent processing capability, throughput and resource usage;
[0050] The execution results also include the results of security testing, detection of SQL injection and cross-site scripting (XSS) security vulnerabilities;
[0051] The execution results also include exception handling results, capturing and recording exceptions or errors that occur during the test process;
[0052] The execution result also includes statistics of test coverage, which counts the coverage of interface functions by test cases;
[0053] The execution results also include the execution log of the test case, recording the key operations and decision points during the test;
[0054] The execution results also include a record of the test case execution environment, including the database used, service version and configuration parameters;
[0055] The execution results also include a record of resources and dependencies used during the test case execution, recording external APIs, files or network resources;
[0056] The execution results also include the calculation and recording of user-defined custom indicators, recording the performance indicators of specific business logic;
[0057] The execution results also include a visual display of the test results, and the visual display uses charts, graphs or dashboards.
[0058] The execution results also include a summary and analysis of the test results, and provide an automatic generation function for the test report.
[0059] The execution results also include storage and management of data collected during the test process to facilitate historical comparison and trend analysis.
[0060] Preferably, the built-in functions in step g include __time() and __time_format() functions, which have timestamp acquisition, date formatting, and date calculation functions; parameterized testing supports dynamic parameters such as timestamp and date formatting, improving the reusability and flexibility of test cases.
[0061] Preferably, the parameterized test case in step g further includes the following sub-steps:
[0062] g1: Identify dynamic parameter patterns defined in test cases, such as timestamp and date formatting function calls;
[0063] g2: Call the built-in __time() function to get the current or specified offset timestamp;
[0064] g3: Call the built-in __time_format() function to convert the timestamp into a date string in the specified format;
[0065] g4): Replace the parameter placeholders in the test case with the dynamic values obtained in steps g2) and g3);
[0066] g5: Execute test cases according to replaced parameters to ensure the timeliness and accuracy of test data.
[0067] The technical solution of the present invention has the following beneficial effects:
[0068] The present invention adopts the mode of Django+vue+celery+requests to design the test platform, so that interface testing can add interface test cases without code ability, and mobilize the entire test group to achieve full coverage of test cases. The test platform is built by adopting the technical architecture combined with Django, Vue, Celery and Requests, which brings a new and convenient experience for interface testing. Django, as a powerful back-end framework, is responsible for processing data storage, business logic and interaction with the database, and provides solid back-end support for the entire platform. Vue plays its advantages at the front end, builds an intuitive, friendly and highly interactive user interface, and allows users to operate easily.
[0069] The introduction of the Celery framework enables asynchronous processing of tasks, allowing interface test tasks to run efficiently in the background without affecting other user operations, greatly improving the overall performance and response speed of the platform. The Requests library is used to send HTTP requests, interact with the interface being tested, obtain responses and verify results. Most importantly, this innovative design makes interface testing no longer dependent on professional coding capabilities. Even testers without a deep programming foundation can easily add interface test cases. In practical applications, this approach fully mobilizes the enthusiasm and participation of the entire test team. Whether you are an experienced test expert or a novice in the field of testing, you can contribute to achieving full coverage of use cases.
[0070] The present invention uses graphical operations on Web pages, so that even users with non-technical backgrounds can easily design and execute test cases, greatly reducing the entry difficulty of interface testing. This method makes the use case design process clear and concise. Users do not need to face complex code or command line operations. They only need to fill in and set relevant information in an intuitive page to easily complete the use case design. For example, users can enter detailed information, expected results, etc. of the interface through a graphical form, which greatly reduces the difficulty and threshold of use case design.
[0071] The application of the Celery asynchronous task queue of the present invention enables multiple test cases to be executed in parallel, significantly reduces waiting time, improves the efficiency of test work, shortens the test cycle, and reasonably allocates computing resources through asynchronous execution and task priority setting, optimizes resource utilization efficiency, and supports distributed task execution, further improving the scalability and processing power of the system; the execution results include the detection of security vulnerabilities such as SQL injection and XSS, improves the security of software products, and reduces potential security risks. The real-time feedback mechanism allows users to obtain progress and result information in real time during task execution, which improves the speed of problem solving; the execution results of the Celery asynchronous task queue include response time, status code, response content and assertion verification results, as well as interface performance evaluation, security testing, exception handling and test coverage statistics, providing a comprehensive evaluation of system performance and security.
[0072] The Celery system of the present invention provides task priority setting, execution history recording, automatic retry mechanism, resource limit definition, etc., optimizes resource allocation, and improves the intelligence level of task management.
[0073] The present invention ensures the integrity and traceability of the test data by storing the execution result data in a database, and supports a search function for the test results, so that users can quickly locate and filter specific results.
[0074] The introduction of built-in functions in the present invention provides a variety of options for assertions, making assertions closer to actual business logic and improving the adaptability and accuracy of tests. The introduction of built-in functions brings higher flexibility to assertions of special parameters and special fields. No longer limited to fixed assertion methods, the most appropriate assertion method can be selected according to specific business needs and data characteristics. For example, for fields involving amounts, specific functions can be used to assert numerical ranges; for string type fields, assertion operations such as inclusion and matching can be performed.
[0075] The use case dimension of the present invention adopts the method of use case step execution, each step can be requesting an interface, querying a database, calling a curl command, or executing a redis command, etc., which has high flexibility and diversity. This design can meet the needs of complex test scenarios and simulate real business processes. For example, a complete shopping process test case may include multiple steps such as querying product information, adding products to a shopping cart, and settlement, and each step can adopt different operation methods.
[0076] The parser of the present invention supports complex comparison operations, so that the test platform can accurately identify problems in the interface response, and enhance the meticulousness of the test; the independent assertion parser provides a rich comparison method, including size comparison, inclusion judgment, and assertion of a specific item when the response result is a list. This makes the assertion process more meticulous and accurate, and can effectively detect various potential problems. For example, for an interface that returns a list of goods, it can assert whether a specific product is in the list, or whether the number of goods in the list meets expectations.
[0077] The method of the present invention reduces the dependence on the programming ability of the tester, so that even testers without a deep programming foundation can participate in the creation and maintenance of interface test cases, expanding the participation and coverage of the test team. The present invention enables more testers to participate in the development of test cases, thereby increasing the number and coverage of test cases, and more comprehensively meeting the depth and breadth requirements of the project for interface testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 Adding a page diagram to the interface of the present invention
[0079] Figure 2 Add page diagram for the use case of the present invention. DETAILED DESCRIPTION
[0080] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments.
[0081] Reference Figure 1 to Figure 2The present invention provides a testing method for implementing an asynchronous operation interface testing platform based on Celery, comprising the following steps:
[0082] Step a: Enter the detailed information of the interface test case in the VUE front-end interface; the VUE front-end interface provides an intuitive and responsive user experience, reduces the difficulty of operation, and improves user satisfaction; ensure that the entered test case information is accurate, laying a solid foundation for subsequent test steps;
[0083] Reference Figure 1 For example, when the user needs to test a smart cabinet door opening interface, fill in the interface name, path, request method (select POST here), headers information (this is not a required item. When the user does not fill it in, the system will use the default request header information), request parameters, response jsonschema data, assertion rules (an array, each item in it is a tuple, the left is the expected result, and the right is the actual result, such as [("true", "¥.r.success"), (0,"¥.r.dataList.length_gt")]) and other information in the VUE interface. After entering the interface information, the system will record this information in the api table for use in use case writing. In addition to adding interfaces, you can also add sql statements, curl commands, and redis commands here.
[0084] Step b: Store the input test case information in the API table of the database; Storing the test case information in the database ensures that the data will not be lost due to system failures and facilitates tracking and auditing of the change history of the test case;
[0085] Step c: Design test cases, filter the interfaces added in step a, and combine multiple interface steps in the order of business requirements to form a complete test case, which is stored in the apicase table of the database; Test case reuse: Improve the reusability of test cases and reduce duplication of work by combining existing interface steps; Combine interface steps according to the order of business requirements to ensure that the test case is consistent with the actual business logic;
[0086] Reference Figure 2,Specific test case description, for example, for a test of a smart cabinet door opening process, first select the smart cabinet door opening interface as the first step, the system will automatically bring out the information entered in the first step, such as parameter information, etc. Users only need to modify the parameter value according to the use case scenario, and add [("v_open_id", "¥.r.data.transactionsId")] in the extraction rule. This expression means to define a temporary variable named v_open_id, and assign the value parsed by jsonpath parsing ¥.r.data.transactionsId in the response to it; then select sql query whether the door opening is executed successfully as the second step, and set the associated open_id (here use ¥{v_open_id} assignment); finally select the door opening status query result as the third step, here the parameter still needs the value of open_id, as long as ¥{v_open_id} assignment. In this way, multiple orderly steps form a complete smart cabinet door opening process test case.
[0087] Step d: Use the Celery asynchronous task queue system to parse and execute the test case; Introducing Celery asynchronous tasks to execute test cases has significant advantages. It supports multiple tasks at the same time, greatly improving execution efficiency; when multiple people execute test cases at the same time, they no longer need to wait in line, but can be processed concurrently, which significantly shortens the overall testing time. For example, in a large project, multiple testers can submit their own test cases at the same time, and the system can quickly allocate resources and execute these test cases at the same time.
[0088] Step e: Call the corresponding parser to parse the different step types in step d, convert them into executable data, and call the special parser to parse when encountering a custom function;
[0089] Taking the smart cabinet door opening process as an example, step d of the use case needs to query the database. Celery first queries the corresponding SQL number through the use case number, and then queries the API table according to the number to obtain the SQL statement, "SELECT status FROM library name. table name WHERE open_api = {v_open_id}". This SQL contains the variable v_open_id. At this time, the SQL parser will obtain the value of v_open_id from the variable pool and replace it. The parsed SQL becomes "SELECT status FROM library name. table name WHERE open_api = 12345678", and then it is handed over to the SQL executor for execution.
[0090] Step f: Execute the parsed information and store the execution results in the report table of the database; this measure ensures the integrity and traceability of the test data, and historical test results can be easily checked at any time. At the same time, the search function for test results is supported, allowing users to quickly locate and filter out the specific results they need. For example, users can quickly find test results that meet their requirements by entering keywords, time ranges, and other conditions.
[0091] Step g: Support parameterized test cases, allow the use of built-in functions to dynamically generate test parameters, achieve flexible execution of test cases, and allow test cases to be executed multiple times according to different parameters; built-in functions dynamically generate test parameters to improve the versatility and flexibility of test cases; allow test cases to be executed multiple times according to different parameters, increase the diversity of test scenarios, and improve test coverage.
[0092] Furthermore, the front-end interface in step a provides graphical operations, including dragging, parameter input and assertion rule configuration, to simplify the process of creating and modifying test cases; improve user experience: the graphical interface enables users to interact with the system more naturally and comfortably through intuitive dragging and clicking operations, and non-technical users can also easily create and modify test cases through simplified graphical operations, which reduces the technical threshold for writing test scripts; drag-and-drop operations reduce the time required for traditional coding and accelerate the development process of test cases; the graphical interface reduces errors that may be introduced by manual coding and improves the accuracy of test case writing; the parameter input function allows users to flexibly configure test parameters according to different test requirements, thereby enhancing the adaptability of test cases; the assertion rule configuration function enables users to define detailed verification points to ensure that the test results can fully reflect the interface behavior; the graphical interface makes the process of creating and modifying test cases more transparent, facilitating collaboration and communication between team members; through the configuration of assertion rules, users can simulate and verify complex business logic and test scenarios; users can adjust the layout and functions of the graphical interface according to personal preferences and work habits to improve personalized experience.
[0093] Furthermore, the detailed information of the interface test case in step a includes the interface path, request header, request body, request method, domain name, as well as SQL statements, curl commands and redis commands;
[0094] The interface path is used to uniquely identify and locate a specific API endpoint to avoid ambiguity or errors during testing.
[0095] The request header is used to specify the header information of the HTTP request, and the header information is Content-Type and Authorization;
[0096] The request body is used to carry the data part of the HTTP request and is in JSON, XML or form data format;
[0097] The request method is used to specify the operation type of the HTTP request, which includes GET, POST, PUT, and DELETE. It complies with the RESTful API design principles and enhances the readability and usability of the interface.
[0098] The domain name is used to specify the network domain name or IP address of the API service; it ensures that the request can be correctly sent to the target server and supports service discovery in distributed and microservice architectures.
[0099] The SQL statements are used to define SQL commands for operating the database, including query and update; they provide data preparation and verification capabilities for test cases, ensuring the accuracy of test data and the validity of test results.
[0100] The curl command is used to create a curl script that interacts with the API through the command line, supporting various HTTP methods and header settings;
[0101] The redis command is used to interact with the Redis cache system and supports data storage, retrieval and deletion operations.
[0102] Furthermore, the interface test case also includes: configuration of request timeout settings to ensure the test's sensitivity to response time; increasing the test's sensitivity to interface response time to promptly detect performance bottlenecks or delay issues, ensuring that the test fails quickly if no response is received within a predetermined time, avoiding invalid waiting and improving the reliability of the test.
[0103] The interface test case also includes the configuration of a request retry mechanism, allowing the request to be automatically retried upon failure; allowing automatic retry upon request failure increases the test's tolerance for temporary errors and ensures the continuity and stability of the test; through the retry mechanism, the probability of request success is increased, especially in the face of network fluctuations or unstable services.
[0104] The interface test case also includes the definition of error handling rules when the request fails, and defines redirection, logging or throwing exceptions. Defining redirection rules ensures that a clear error response or jump to an alternative service can be provided when a request fails, enhancing the user experience. By logging, detailed records are provided for problem diagnosis and historical analysis, which helps to quickly locate the cause of the problem; by throwing exceptions, the test case can clearly express the reason for the test failure, which is convenient for subsequent error handling and reporting.
[0105] Furthermore, the Celery asynchronous task queue system in step d includes task monitoring and logging functions, as well as a notification mechanism in case of execution exceptions; when the Celery asynchronous task queue system receives a task to execute an interface use case, it will query the api table based on the use case number to obtain the interface data, SQL statements, curl commands, redis commands, and other content corresponding to each step in the interface use case. Introducing Celery asynchronous tasks to execute test cases has significant advantages. It supports multiple tasks at the same time, greatly improving execution efficiency. When multiple people execute use cases at the same time, they no longer need to wait in line, but can be processed concurrently, which significantly shortens the overall testing time. For example, in a large project, multiple testers can submit their own test cases at the same time, and the system can quickly allocate resources and execute these use cases simultaneously.
[0106] Furthermore, the Celery asynchronous task queue system further includes task priority settings, allowing users to assign different priorities according to the urgency of test tasks; allowing users to assign priorities according to the urgency of tasks to ensure that high-priority tasks can be processed first. Through priority settings, the system can allocate resources more effectively and improve the response speed of key tasks.
[0107] The Celery asynchronous task queue system also provides a task execution history function, allowing users to query and analyze the historical execution status of test tasks.
[0108] The Celery asynchronous task queue system also supports an automatic task retry mechanism, which automatically re-executes the task according to preset conditions and times when the execution fails; users can query and analyze the historical execution status of tasks to help identify test trends and potential problems. The historical records provide data support for the adjustment and optimization of test strategies.
[0109] The Celery asynchronous task queue system allows users to define resource limits for task execution, such as memory usage limits and execution time limits, to prevent resource abuse.
[0110] The Celery asynchronous task queue system also supports distributed task execution, allowing test tasks to be processed in parallel on multiple nodes, improving execution efficiency, achieving task load balancing, and optimizing resource utilization efficiency.
[0111] The Celery asynchronous task queue system provides security control for task execution, including verification of task execution permissions and audit logs of user operations; by executing permission verification and audit logs, the security of the system is enhanced to prevent unauthorized access. Audit logs provide necessary records for compliance checks and security audits.
[0112] The Celery asynchronous task queue system also provides a real-time feedback mechanism for task execution results, allowing users to obtain real-time progress and result information during task execution. Users can monitor task progress in real time and understand test status in a timely manner. The real-time feedback mechanism allows users to respond quickly when problems are discovered, which speeds up problem solving.
[0113] Furthermore, the execution result in step f includes response time, status code, response content and assertion verification result.
[0114] The response time is the time from sending a request to receiving a response, which is used to evaluate interface performance;
[0115] The status code is an HTTP response status code, which is used to identify whether the request is successful or failed, and the reason for the failure;
[0116] The response content is the data returned by the interface, in JSON, XML or other formats, for further analysis and assertion verification;
[0117] The assertion verification result is the comparison result between the assertion condition preset in the test case and the actual response content, which is used to verify whether the data returned by the interface meets expectations.
[0118] This embodiment combines response time, status code, response content, and assertion verification results to provide comprehensive test coverage, ensuring that all aspects of the interface are verified; these execution results are easily integrated into automated test reports, improving the readability and practicality of automated tests. It can be easily integrated into the CI / CD process as a basis for build and deployment decisions. Detailed execution results help to quickly locate the source of the problem and speed up the diagnosis process. Based on the assertion verification results, test cases can be optimized and improved to improve test quality. Analysis of response content and assertion verification help verify the correctness of business logic and ensure that business requirements are met; through verification of response content, data consistency and accuracy are ensured, especially in interface tests involving database operations.
[0119] Furthermore, the execution result also includes an evaluation of interface performance, concurrent processing capability, throughput and resource usage; performance bottlenecks can be identified and optimized to improve the overall performance of the system.
[0120] The execution result also includes the result of security testing, detection of SQL injection and cross-site scripting (XSS) security vulnerabilities; it can enhance the security of the system and prevent data leakage and malicious attacks.
[0121] The execution results also include exception handling results, capturing and recording exceptions or errors that occur during the test process; exceptions or errors that occur during the test process can be quickly identified and recorded, making it easier for the development team to locate and fix problems.
[0122] The execution result also includes statistics of test coverage, which counts the coverage of interface functions by test cases, thereby improving the integrity and reliability of the test.
[0123] The execution results also include the execution log of the test case, which records the key operations and decision points in the test process; it helps to track the test process and reproduce problems.
[0124] The execution results also include a record of the test case execution environment, including the database used, service version and configuration parameters; this can ensure the repeatability of the test results and the consistency of the environment.
[0125] The execution results also include a record of resources and dependencies used during the test case execution, and a record of external APIs, files, or network resources; the use of external APIs, files, or network resources can be better managed and monitored.
[0126] The execution results also include the calculation and recording of user-defined custom indicators, recording the performance indicators of specific business logic; the performance of specific business logic can be monitored to meet specific business needs.
[0127] The execution results also include a visual display of the test results, which uses charts, graphs or dashboards to make it easier to understand the test data and help team members quickly obtain key information.
[0128] The execution results also include a summary and analysis of the test results, and provide an automatic test report generation function, which can save time, improve the efficiency of report generation, and ensure the consistency and accuracy of the report.
[0129] The execution results also include storage and management of data collected during the test process to facilitate historical comparison and trend analysis, providing data support for continuous improvement.
[0130] Furthermore, the built-in functions in step g include __time() and __time_format() functions, which have the functions of timestamp acquisition, date formatting, and date calculation; parameterized testing supports dynamic parameters such as timestamp and date formatting, thereby improving the reusability and flexibility of test cases.
[0131] The parameterized test case in step g further includes the following sub-steps:
[0132] g1: Identify dynamic parameter patterns defined in test cases, such as timestamp and date formatting function calls;
[0133] g2: Call the built-in __time() function to get the current or specified offset timestamp;
[0134] g3: Call the built-in __time_format() function to convert the timestamp into a date string in the specified format;
[0135] g4): Replace the parameter placeholders in the test case with the dynamic values obtained in steps g2) and g3);
[0136] g5: Execute test cases according to replaced parameters to ensure the timeliness and accuracy of test data.
[0137] For example, in the query interface, if you want to test the query range, set the start time and end time ({"startDate":"2024-07-01","endDate":"2024-07-07"}). Normally, the data for this period will be queried, but in reality, it is not queried because the database automatically deletes the data in this period. The database only saves the data for the last 7 days. Then I need to modify our use case again and modify the appropriate start and end time. Such a use case is not flexible enough. Is there any way to solve this problem? To solve this problem, the platform introduces a function mechanism.
[0138] For example, after introducing the parameters into the function:
[0139] {"startDate":"${__time_format(${__time('S',-604800)})}","endDate":"${__time_format(${__time})}"}, where ${__time} returns the current timestamp, and then ${__time_format(${__time})}"} is used to format the current timestamp into the date format of yyyy-mm-dd and return it. ${__time_format(${__time('S',-604800)})} returns the date 7 days ago, so that when the use case is repeatedly executed, the query is always the data of the past seven days. In the above example, the function is filled in the VUE interface and passed to the background through a string. The background needs to call the function parser to parse the function from the string and hand it over to the function executor for execution. Then, the result after execution is replaced with the original parameter and handed over to the use case executor to execute the use case.
[0140] As can be seen from the above embodiments, the present invention enables even users with non-technical backgrounds to easily design and execute test cases through graphical operations on Web pages, greatly reducing the entry difficulty of interface testing. This method makes the use case design process clear and concise. Users do not need to face complex code or command line operations. They only need to fill in and set relevant information in an intuitive page to easily complete the use case design. For example, users can enter detailed information, expected results, etc. of the interface through a graphical form, which greatly reduces the difficulty and threshold of use case design.
[0141] The application of the Celery asynchronous task queue of the present invention enables multiple test cases to be executed in parallel, significantly reduces waiting time, improves the efficiency of test work, shortens the test cycle, and reasonably allocates computing resources through asynchronous execution and task priority setting, optimizes resource utilization efficiency, and supports distributed task execution, further improving the scalability and processing power of the system; the execution results include the detection of security vulnerabilities such as SQL injection and XSS, improves the security of software products, and reduces potential security risks. The real-time feedback mechanism allows users to obtain progress and result information in real time during task execution, which improves the speed of problem solving; the execution results of the Celery asynchronous task queue include response time, status code, response content and assertion verification results, as well as interface performance evaluation, security testing, exception handling and test coverage statistics, providing a comprehensive evaluation of system performance and security.
[0142] The Celery system of the present invention provides task priority setting, execution history recording, automatic retry mechanism, resource limit definition, etc., optimizes resource allocation, and improves the intelligence level of task management.
[0143] The present invention ensures the integrity and traceability of the test data by storing the execution result data in a database, and supports a search function for the test results, so that users can quickly locate and filter specific results.
[0144] The introduction of built-in functions in the present invention provides a variety of options for assertions, making assertions closer to actual business logic and improving the adaptability and accuracy of tests. The introduction of built-in functions brings higher flexibility to assertions of special parameters and special fields. No longer limited to fixed assertion methods, the most appropriate assertion method can be selected according to specific business needs and data characteristics. For example, for fields involving amounts, specific functions can be used to assert numerical ranges; for string type fields, assertion operations such as inclusion and matching can be performed.
[0145] The use case dimension of the present invention adopts the method of use case step execution, each step can be requesting an interface, querying a database, calling a curl command, or executing a redis command, etc., which has high flexibility and diversity. This design can meet the needs of complex test scenarios and simulate real business processes. For example, a complete shopping process test case may include multiple steps such as querying product information, adding products to a shopping cart, and settlement, and each step can adopt different operation methods.
[0146] The parser of the present invention supports complex comparison operations, so that the test platform can accurately identify problems in the interface response, and enhance the meticulousness of the test; the independent assertion parser provides a rich comparison method, including size comparison, inclusion judgment, and assertion of a specific item when the response result is a list. This makes the assertion process more meticulous and accurate, and can effectively detect various potential problems. For example, for an interface that returns a list of goods, it can assert whether a specific product is in the list, or whether the number of goods in the list meets expectations.
[0147] The method of the present invention reduces the dependence on the programming ability of the tester, so that even testers without a deep programming foundation can participate in the creation and maintenance of interface test cases, expanding the participation and coverage of the test team. The present invention enables more testers to participate in the development of test cases, thereby increasing the number and coverage of test cases, and more comprehensively meeting the depth and breadth requirements of the project for interface testing.
[0148] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the inventive concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.
Claims
1. A testing method for implementing an asynchronous operation interface testing platform based on Celery. It is characterized in that The following steps are involved: Step a: Enter the detailed information of the interface test case in the VUE front-end interface; Step b: Store the input test case information into the api table of the database; Step c: Design test cases by filtering the interfaces added in step a and combining multiple interface steps in the order of business requirements to form a complete test case, which is stored in the apicase table of the database; Step d: Use the Celery asynchronous task queue system to parse and execute the use case; Step e: Call the corresponding parser to parse the different step types in step d, convert them into executable data, and call the special parser to parse when encountering a custom function; Step f: Execute the parsed information and store the execution results in the report table of the database; Step g: Support parameterized test cases, allow the use of built-in functions to dynamically generate test parameters, achieve flexible execution of test cases, and allow test cases to be executed multiple times based on different parameters.
2. According to the test method of implementing the asynchronous operation interface test platform based on Celery according to claim 1, It is characterized in that The front-end interface in step a provides graphical operations, including dragging, parameter input, and assertion rule configuration, to simplify the process of creating and modifying test cases.
3. According to the test method of implementing an asynchronous operation interface test platform based on Celery according to claim 1, It is characterized in that The detailed information of the interface test case in step a includes the interface path, request header, request body, request method, domain name, as well as SQL statements, curl commands and redis commands; The interface path is used to uniquely identify and locate a specific API endpoint; The request header is used to specify the header information of the HTTP request; The request body is used to carry the data part of the HTTP request; The request method is used to specify the operation type of the HTTP request; The domain name is used to specify the network domain name or IP address of the API service; The SQL statements are used to define SQL commands for operating the database, including query and update; The curl command is used to create a curl script that interacts with the API through the command line, supporting various HTTP methods and header settings; The redis command is used to interact with the Redis cache system and supports data storage, retrieval and deletion operations.
4. According to the test method of implementing an asynchronous operation interface test platform based on Celery according to claim 1, It is characterized in that The interface test case also includes: configuration of request timeout settings to ensure the sensitivity of the test to response time; The interface test case also includes configuration of a request retry mechanism, allowing automatic retry of requests upon failure; The interface test case also includes the definition of error handling rules when a request fails, defining redirection, logging or throwing an exception.
5. According to the test method of implementing an asynchronous operation interface test platform based on Celery according to claim 1, It is characterized in that The Celery asynchronous task queue system in step d includes task monitoring and logging functions, as well as a notification mechanism in case of execution exceptions; When the Celery asynchronous task queue system receives a task to execute an interface use case, it will query the api table based on the use case number to obtain the interface data, SQL statements, curl commands, redis commands, and other content corresponding to each step in the interface use case.
6. According to claim 5, the testing method for implementing an asynchronous operation interface testing platform based on Celery, It is characterized in that The Celery asynchronous task queue system further includes a task priority setting, allowing users to assign different priorities according to the urgency of the test task; The Celery asynchronous task queue system also provides a task execution history function, allowing users to query and analyze the historical execution status of test tasks. The Celery asynchronous task queue system also supports an automatic task retry mechanism, which automatically re-executes the task according to the preset conditions and times when the execution fails; The Celery asynchronous task queue system allows users to define resource limits for task execution; The Celery asynchronous task queue system also supports distributed task execution, allowing test tasks to be processed in parallel on multiple nodes to improve execution efficiency; The Celery asynchronous task queue system provides security control for task execution, including verification of task execution permissions and audit logs of user operations; The Celery asynchronous task queue system also provides a real-time feedback mechanism for task execution results, allowing users to obtain progress and result information in real time during task execution.
7. The test method for implementing an asynchronous operation interface test platform based on Celery according to claim 1, It is characterized in that The execution results in step f include response time, status code, response content and assertion verification results, and have the functions of data storage, historical test result search and screening; The response time is the time from sending a request to receiving a response, which is used to evaluate interface performance; The status code is an HTTP response status code, which is used to identify whether the request is successful or failed, and the reason for the failure; The response content is the data returned by the interface, in JSON, XML or other formats, for further analysis and assertion verification; The assertion verification result is the comparison result between the assertion condition preset in the test case and the actual response content, which is used to verify whether the data returned by the interface meets expectations.
8. According to claim 7, the test method for implementing an asynchronous operation interface test platform based on Celery, It is characterized in that The execution results also include an evaluation of interface performance, concurrent processing capability, throughput, and resource usage; The execution results also include the results of security testing, detection of SQL injection and cross-site scripting (XSS) security vulnerabilities; The execution results also include exception handling results, capturing and recording exceptions or errors that occur during the test process; The execution result also includes statistics of test coverage, which counts the coverage of interface functions by test cases; The execution results also include the execution log of the test case, recording the key operations and decision points during the test; The execution results also include a record of the test case execution environment, including the database used, service version and configuration parameters; The execution results also include a record of resources and dependencies used during the test case execution, recording external APIs, files or network resources; The execution results also include the calculation and recording of user-defined custom indicators, recording the performance indicators of specific business logic; The execution results also include a visual display of the test results, and the visual display uses charts, graphs or dashboards. The execution results also include a summary and analysis of the test results, and provide an automatic generation function for the test report. The execution results also include storage and management of data collected during the test process to facilitate historical comparison and trend analysis.
9. The test method for implementing an asynchronous operation interface test platform based on Celery according to claim 1, It is characterized in that The built-in functions in step g include __time() and __time_format() functions, which have the functions of timestamp acquisition, date formatting, and date calculation; parameterized testing supports dynamic parameters such as timestamp and date formatting, which improves the reusability and flexibility of test cases.
10. The test method for implementing an asynchronous operation interface test platform based on Celery according to claim 9, It is characterized in that The parameterized test case in step g further includes the following sub-steps: g1: Identify dynamic parameter patterns defined in test cases, such as timestamp and date formatting function calls; g2: Call the built-in __time() function to get the current or specified offset timestamp; g3: Call the built-in __time_format() function to convert the timestamp into a date string in the specified format; g4: Replace the parameter placeholders in the test case with the dynamic values obtained in steps g2) and g3); g5: Execute test cases according to replaced parameters to ensure the timeliness and accuracy of test data.
Citation Information
Cited By
Automatic interface testing method and system based on asynchronous mode
CN120950420A
