Interface testing method and device, equipment and storage medium
By deploying traffic plugins in business applications and automating the generation of test cases, the problem of low efficiency in business interface testing in existing technologies is solved, achieving efficient and low-cost interface testing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2026-03-13
AI Technical Summary
Existing technologies have low efficiency in testing business interfaces, as they require manual writing of test cases, which leads to low testing efficiency.
By deploying traffic plugins in business applications, traffic in kernel interfaces is captured and encapsulated, and then parsed and filtered using computer equipment to automatically generate test cases, thus enabling testing of business interfaces.
It improves testing efficiency, reduces testing costs, enhances the versatility and accuracy of testing, and eliminates the need for manually written test cases.
Smart Images

Figure CN121664709A_ABST
Abstract
Description
Technical Field
[0001] This application relates to fields such as Internet technology, and in particular to an interface testing method, apparatus, device, and storage medium. Background Technology
[0002] With the development of internet technology, business applications can provide various services for users' lives, work, and studies. For example, video conferencing applications can provide remote video conferencing services. To provide users with more convenient services, it is necessary to test the business interfaces of business applications before they go live or after they are updated, to test whether the functional logic of the business interfaces meets user needs. Currently, in the process of testing business interfaces, test cases need to be written manually, resulting in relatively low testing efficiency. Summary of the Invention
[0003] This application provides an interface testing method, apparatus, device, and storage medium to improve testing efficiency.
[0004] One embodiment of this application provides an interface testing method, including:
[0005] Receive the first encapsulated traffic packet sent by the traffic plugin in the business application; the first encapsulated traffic packet is obtained by the traffic plugin encapsulating the test parameters corresponding to N business interfaces of the application and the first traffic set, the first traffic set including the traffic obtained by the traffic plugin from the kernel interface of the application; N is a positive integer;
[0006] The first encapsulated traffic packet is parsed to obtain the first traffic set and the test parameters corresponding to the N service interfaces.
[0007] From the first set of traffic mentioned above, traffic pairs associated with the above N business interfaces are selected respectively; each traffic pair includes the original request traffic received by the corresponding business interface, and the original response traffic returned by the corresponding business interface to respond to the original request traffic.
[0008] Based on the test parameters corresponding to the above N business interfaces and the traffic pairs corresponding to the above N business interfaces respectively, the above N business interfaces are tested and the test results are obtained.
[0009] One embodiment of this application provides an interface testing apparatus, including:
[0010] Optional, filtering module, specifically used for:
[0011] Obtain the traffic filtering rules for the aforementioned business applications;
[0012] According to the above traffic filtering rules, the traffic in the first traffic set is filtered to obtain the filtered first traffic set.
[0013] Based on the first set of filtered traffic, determine the traffic pairs associated with the above N service interfaces respectively.
[0014] Optional, filtering module, specifically used for:
[0015] Based on the dependencies and stability of the business interfaces in the above business applications, the target business interface associated with the test auxiliary data is determined from the above N business interfaces.
[0016] From the first traffic set mentioned above, obtain the initial request traffic and initial response traffic of the target business interface mentioned above;
[0017] Based on the aforementioned test auxiliary data, the initial response traffic of the aforementioned target business interface is adjusted to obtain the adjusted initial response traffic. Based on the aforementioned test auxiliary data, the initial request traffic of the aforementioned target business interface is adjusted to obtain the adjusted initial request traffic.
[0018] Send the adjusted initial request traffic and the adjusted response traffic to the target service interface.
[0019] The response traffic returned by the target business interface based on the adjusted initial request traffic and the adjusted response traffic is used as the original response traffic of the target business interface.
[0020] The initial request traffic of the aforementioned target business interface is used as the original response traffic of the aforementioned target business interface.
[0021] Optional, test module, specifically used for:
[0022] Based on the test parameters corresponding to the above N business interfaces, obtain the test cases corresponding to the above N business interfaces; the above test cases are generated based on the traffic in the above kernel interfaces when the above business application is in a stable state;
[0023] Based on the test cases and test parameters corresponding to the above N business interfaces, and the traffic pairs corresponding to the above N business interfaces respectively, the above N business interfaces are tested to obtain test results.
[0024] Optionally, when N is greater than 1, the above test case includes N test steps, and each test step includes the corresponding test request traffic and the test response traffic corresponding to the above test request traffic;
[0025] Optional, test module, specifically used for:
[0026] When the test parameters corresponding to the above N business interfaces indicate that the test types of the above N business interfaces all belong to the same scenario test type, obtain the acquisition time of the traffic pairs corresponding to the above N business interfaces respectively.
[0027] Based on the acquisition time of the traffic pairs corresponding to the above N business interfaces, the request order corresponding to the above N business interfaces is determined.
[0028] Based on the request order corresponding to the above N business interfaces, the test request traffic and test response traffic corresponding to the above N test steps, and the traffic pairs corresponding to the above N business interfaces, the above N business interfaces are tested to obtain the test results.
[0029] Optional, test module, specifically used for:
[0030] Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N;
[0031] Determine the second similarity between the test response traffic in the i-th test step and the original response traffic in the i-th traffic pair;
[0032] Based on the first similarity and the second similarity mentioned above, the test result of the business interface corresponding to the i-th traffic pair is determined.
[0033] Optional, test module, specifically used for:
[0034] Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N;
[0035] From the test response traffic included in the above N test steps, obtain the test response traffic of the last test step; from the traffic pairs corresponding to the above N business interfaces, obtain the original response traffic of the business interface whose request order is the last.
[0036] Determine the third similarity between the test response traffic where the test step is last and the original response traffic of the business interface where the request order is last;
[0037] Based on the third similarity score and the first similarity scores corresponding to the original request traffic of the N business interfaces, the test results of the N business interfaces are determined.
[0038] Optionally, the above test cases include the test request traffic corresponding to each of the above N business interfaces and the test vector traffic corresponding to each test request traffic;
[0039] Optional, test module, specifically used for:
[0040] When the test parameters corresponding to the above N business interfaces indicate that the test type of the above N business interfaces all belong to the single interface test type, determine the fourth similarity between the test request traffic and the original request traffic of each business interface;
[0041] Determine the fifth similarity between the test response traffic and the original response traffic for each business interface;
[0042] Based on the fourth and fifth similarity scores corresponding to the above N business interfaces, the test results corresponding to the above N business interfaces are determined.
[0043] Optionally, the apparatus may also include a generation module;
[0044] The generation module is used to receive the second encapsulated traffic packet sent by the service device corresponding to the above-mentioned service application; the second encapsulated traffic packet is obtained by the above-mentioned service device from the second traffic set, and the second traffic set includes the traffic obtained by the traffic plugin from the above-mentioned kernel interface when the above-mentioned service application is in a stable state;
[0045] The second encapsulated traffic packet is parsed to obtain the second traffic set.
[0046] Select traffic pairs for the interfaces to be tested from the second traffic set mentioned above; the interfaces to be tested include the aforementioned N business interfaces.
[0047] Based on the traffic pairs of the interface to be tested, generate test cases for the interface to be tested.
[0048] Optional, a generation module, specifically used for:
[0049] Replace the dynamic data in the initial request traffic of the above-mentioned interface under test with a specified character to obtain the processed initial request traffic of the above-mentioned interface under test.
[0050] Delete the dynamic data in the initial response traffic of the traffic pair of the above-mentioned interface to be tested, and obtain the processed initial response traffic of the above-mentioned interface to be tested.
[0051] Based on the processed initial request traffic and processed initial response traffic of the interface to be tested, generate test cases for the interface to be tested.
[0052] Optional, a generation module, specifically used for:
[0053] When the initial request traffic after processing of the above-mentioned interface to be tested meets the simulation rules, the initial response traffic after processing of the above-mentioned interface to be tested is adjusted according to the configuration information corresponding to the above-mentioned simulation rules to obtain the test response traffic of the above-mentioned interface to be tested.
[0054] The initial request traffic of the interface to be tested is used as the test request traffic of the interface to be tested.
[0055] Based on the test request traffic and test response traffic of the interface to be tested, determine the test cases for the interface to be tested.
[0056] One embodiment of this application provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the method described above.
[0057] One embodiment of this application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method.
[0058] One embodiment of this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.
[0059] In this application, a traffic plugin is deployed in a business application to capture traffic from the application's kernel interface. The captured traffic and test parameters from N business interfaces are encapsulated to obtain a first encapsulated traffic packet, which is then sent to a computer device (testing device). The computer device parses and filters the first encapsulated traffic packet to obtain traffic pairs and test parameters for each business interface. Based on these pairs and parameters, the business interfaces are tested to obtain test results. This eliminates the need for manual test case writing for each business interface, improving testing efficiency. Furthermore, the testing process is business-independent, enhancing test versatility. The same traffic plugin can be used for testing multiple business interfaces, reducing testing costs and increasing plugin utilization. Attached Figure Description
[0060] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0061] Figure 1This is a schematic diagram of the structure of an interface testing system provided in this application;
[0062] Figure 2a This is a schematic diagram of another interface testing system provided in this application;
[0063] Figure 2b This is a schematic diagram of the structure of a test case generation system provided in this application;
[0064] Figure 3 This is a flowchart illustrating an interface testing method provided in this application;
[0065] Figure 4 This is a schematic diagram of a test configuration interface provided in this application;
[0066] Figure 5 This is a schematic diagram of a process for obtaining a first encapsulated traffic packet provided in this application;
[0067] Figure 6 This is a flowchart illustrating an interface testing method provided in this application;
[0068] Figure 7 This is a schematic diagram of a process for filtering traffic in a first traffic set, as provided in this application.
[0069] Figure 8 This is a flowchart illustrating a test business interface provided in this application;
[0070] Figure 9 This is a schematic diagram of a test case configuration interface provided in this application;
[0071] Figure 10 This is a schematic diagram of a process for obtaining a second encapsulated traffic packet provided in this application;
[0072] Figure 11 This application provides a flowchart illustrating the process of handling the initial request traffic in a traffic pair of an interface to be tested.
[0073] Figure 12 This application provides a flowchart illustrating the process of handling the initial response traffic in a traffic pair of an interface to be tested.
[0074] Figure 13 This is a schematic diagram of a process for filtering traffic in a second traffic set provided in this application;
[0075] Figure 14 This is a schematic diagram of a test case for a scenario-based test type provided in this application;
[0076] Figure 15 This is a schematic diagram of the structure of an interface testing device provided in an embodiment of this application;
[0077] Figure 16 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0078] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0079] To facilitate a clearer understanding of this application, the interface testing system that implements this application will be introduced first, such as... Figure 1 As shown, this interface testing system includes a business server, a test server, and a terminal cluster. The terminal cluster can include one or more terminals; the number of terminals will not be limited here. Figure 1 As shown, taking a terminal cluster consisting of four terminals as an example, the terminal cluster can specifically include a first terminal, a second terminal, a third terminal, and a fourth terminal. It can be understood that the first terminal, the second terminal, the third terminal, and the fourth terminal can all connect to the business server and the test server via the network, so that each terminal can interact with the business server and the test server through the network connection.
[0080] Understandably, test servers and business servers can be independent physical servers, server clusters or distributed systems consisting of at least two physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud knowledge bases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0081] It is understood that the term "terminal" can specifically refer to in-vehicle terminals, smartphones, tablets, laptops, desktop computers, smart speakers, speakers with screens, smart TVs, smartwatches, etc., but is not limited to these. Various terminals and servers can be directly or indirectly connected via wired or wireless communication. Furthermore, the number of terminals and servers can be one or at least two; this application does not impose any limitation on this.
[0082] Each terminal may include a business application to be tested. This application can be an application that is about to be launched, undergoing feature updates, or otherwise requires testing. The business application to be tested can be a standalone application, a web application, or a mini-program within a host application. It can also include content input applications (i.e., input methods), social applications, shopping applications, content publishing applications, and game applications.
[0083] The terminal's business application includes a traffic plugin. This plugin captures traffic from the kernel interface of the business application, including request traffic sent from the application to the server and response traffic returned by the server. The traffic plugin can also encapsulate the test parameters and captured traffic of the business interface into encapsulated traffic packets. These packets are then sent to the test server, allowing the server to generate test cases and perform tests on the business interface.
[0084] In this context, a business server can refer to a device that provides backend services for business applications. For example, a business server may include various business interfaces of the business application, processing terminal request traffic through these interfaces to return response traffic. A business interface can be a specific functional module that processes the request traffic of the business application.
[0085] In this context, a test server can refer to a device used to test business applications. For example, a test server can receive encapsulated traffic packets sent by a traffic plugin in a terminal, generate test cases based on the encapsulated traffic packets, test the business interfaces of the business application based on the test cases, obtain test results, and return the test results to the terminal.
[0086] In one embodiment, Figure 2a This application provides a schematic diagram of the structure of a test case generation system, as shown below. Figure 2a As shown, the test case generation system may include a front-end, a back-end, and a database. The front-end may include a web page (i.e., a webpage) that displays the business application on a terminal, as well as a traffic plugin in the business application.
[0087] In this context, the backend can refer to a test server, which is used to perform data cleaning, rule matching, and test case assembly on the traffic in the second initial traffic set. The second initial traffic set can refer to the traffic acquired when the business application is in a stable state. Data cleaning refers to cleaning the traffic in the second initial traffic set to remove traffic irrelevant to the interface under test, resulting in the second traffic set. Rule matching refers to checking whether the traffic in the second traffic set meets the filtering rules to further clean the traffic. Test case assembly refers to combining the traffic in the second traffic set to obtain test cases for the business interface.
[0088] The database can include a rule set, a test set, and a test case library. The rule set can be used to store traffic filtering rules for filtering the second traffic set, the test set can be used to store the business interfaces to be tested, and the test case library can be used to store the generated test cases.
[0089] The stability of a business application can be determined based on its historical runtime logs. For example, a stable state might mean that the number of anomalies encountered during the historical time period is less than a threshold. The number of anomalies can be determined from the application's runtime logs during that period. Anomalies could include returning incorrect response traffic or failing to return response traffic for an extended period.
[0090] In one embodiment, Figure 2b A schematic diagram of the structure of an interface testing system provided in this application is shown below. Figure 2b As shown, the interface testing system includes a front-end, a back-end, and a database. The front-end may include a web page (i.e., a webpage) displayed by a terminal for the business application, as well as a traffic plugin in the business application.
[0091] The backend can refer to a test server, which performs data cleaning, data assertion, and report generation on the traffic in the initial traffic set. Data cleaning involves filtering out invalid traffic from the initial traffic set to obtain the first traffic set. Data assertion involves testing the N business interfaces based on traffic pairs from the first traffic set, test parameters, and test cases from the test case library to obtain test results. Report generation involves generating a test report based on the test results and summary information. The summary information is obtained by summarizing the business modules to which the business interfaces belong, and includes information such as test pass rate, test type, rule type, test environment, test version, and coverage. This test report is stored and provided to third-party evaluations or archived for historical quality trend analysis.
[0092] The database can be used to store rule sets, test sets, and test reports. Rule sets can include traffic filtering rules, traffic processing rules, etc., and test sets can include business interfaces to be tested in business applications.
[0093] Further, please see Figure 3 This is a flowchart illustrating an interface testing method provided in an embodiment of this application. Figure 3 As shown, this method can Figure 1 The test server in the middle can be used to execute it, or it can be executed by... Figure 1 The method can be executed by any terminal in the system, or it can be executed jointly by a terminal and a server. The device used to execute this interface testing method in this application can be collectively referred to as a computer device. The method may include the following steps:
[0094] S101. Receive the first encapsulated traffic packet sent by the traffic plugin in the business application; the first encapsulated traffic packet is obtained by the traffic plugin encapsulating the test parameters corresponding to N business interfaces of the application and the first traffic set, the first traffic set including the traffic obtained by the traffic plugin from the kernel interface of the application; N is a positive integer.
[0095] In this application, the computer device can receive the first encapsulated traffic packet sent by the traffic plugin in the business application, and return the encapsulated traffic packet to the computer device for processing through the traffic plugin. This helps to reduce the processing pressure on the terminal corresponding to the business application and helps to ensure that the business application runs normally during the testing of the business interface of the business application, that is, it will not block the normal network requests of the business application.
[0096] For ease of distinction, the request traffic in the first traffic set can be called the initial request traffic, and the response traffic in the first traffic set can be called the initial response traffic. The initial request traffic can be the request data received by the business interface in the business application, and the initial response traffic can be the response data returned by the business interface in the business application in response to the request data.
[0097] The initial request traffic includes a request address, request headers, request parameters, and a request body. The request header contains information about the requested business interface, the domain name of the business server hosting the business interface, and the data types the terminal can receive. Request parameters may include the request type, and the request body describes the data to be returned. The request address can refer to the address of the terminal sending the initial request traffic. The initial response traffic includes a response header, a response address, and a response body. The response header may include information about the business interface returning the initial response traffic, the domain name of the business server hosting the business interface, and the data type of the returned data. The response body includes the data returned based on the initial request traffic, and the response address can refer to the address of the business server.
[0098] The first encapsulated traffic packet can be obtained by the traffic plugin through the following steps: 1. Displaying a test configuration interface through the traffic plugin in the business application, and in response to configuration operations on the test configuration interface, obtaining the test configuration information obtained from the configuration operations performed on the test configuration interface. The test configuration information includes test parameters for N business interfaces to be tested. 2. Capturing traffic from the kernel interface of the business application through the traffic plugin to obtain a first initial traffic set. 3. Filtering the traffic in the first initial traffic set based on the request type, domain name, etc. in the test parameters to obtain a first traffic set; processing the initial traffic in the first traffic set according to the target data format to obtain a processed initial traffic set; encapsulating the processed first traffic set with the test type, rule identifier, and service IP in the test parameters to obtain the first encapsulated traffic packet. Filtering the initial traffic set through the traffic plugin helps to filter out traffic that does not conform to the specified domain name and specified request type, reducing the processing pressure on the computer equipment.
[0099] The target data format can refer to the data format corresponding to the computer device, that is, the target data format can refer to the format that the computer device can parse, that is, the data format that is compatible with the computer device.
[0100] The test parameters can include at least one of the following: test type, request type, domain name, service IP, and rule identifier. Test types include single-interface test types and scenario test types. A single-interface test refers to testing a single business interface; a scenario test refers to testing multiple related business interfaces. Related business interfaces refer to those belonging to the same business scenario. When testing the login scenario of a business application, it is necessary to test the login verification interface and login display interface, etc., in the business application. That is, the login verification interface and the login display interface belong to the same business scenario, and therefore belong to the same scenario test type. The login verification interface verifies the user's login information and obtains a verification result, indicating either successful or failed verification. The login display interface is used to return data to be displayed on the login page when the verification result is successful.
[0101] The request type is used to filter traffic based on a specified request type, which can include POST (add), GET (query), DELETE (delete), PUT (modify), etc. This specified request type can refer to the request type associated with N business interfaces. The domain name indicates the domain name used to filter traffic related to a specified domain, which can also refer to the domain name associated with N business interfaces. The service IP can refer to the service address (i.e., the IP address of the computer device) used to process the traffic after it reaches the computer device. The rule identifier indicates the rule set, which is used to process the traffic after it reaches the computer device. The rule set can include traffic filtering rules and traffic processing rules. Traffic filtering rules are used to further filter traffic unrelated to the N business interfaces, while traffic processing rules can be used to adjust and process the traffic.
[0102] The traffic in the first traffic set can refer to the traffic obtained when the business application needs to be tested. When the business application needs to be tested, it can mean that a new functional module has been added to the business application, or after the version of the business application has been updated, or after the functional module in the business application has been updated, etc.
[0103] In one embodiment, the test configuration interface provided in this application is as follows: Figure 4As shown, the test configuration interface 41a includes a request type configuration component 42a, a domain name configuration component 43a, a service IP configuration component 44a, a rule configuration component 45a, and a test type configuration component 46a. The request type configuration component 42a can be used to configure the request type of the traffic to be filtered (i.e., the traffic to be recorded). The candidate request types in the request type configuration component 42a are POST, GET, DELETE, and PUT. Users can select the specified request type for the traffic to be filtered. The domain name configuration component 43a can be used to input the specified domain name of the filtered traffic. The service IP configuration component 44a can be used to input the service address for the backend processing traffic. The rule configuration component 45a can be used to configure rule identifiers, such as selecting a rule name and number. The rule identifier indicates the rules for filtering and other processing of the acquired traffic. The test type configuration component 46a can be used to configure the test type of the business interface (i.e., specify the request type). Test types include single-interface test types and scenario test types.
[0104] In one embodiment, Figure 5 The present application provides a schematic diagram of a process for obtaining a first encapsulated traffic packet, the process of obtaining the first encapsulated traffic packet including the following steps S51 to S57:
[0105] S51. Obtain initial request traffic; Obtain initial request traffic from the kernel interface of the business application through the traffic plugin in the business application. This initial request traffic belongs to the first initial traffic set.
[0106] S52. Is a domain name specified? Determine whether the domain name in the obtained initial request traffic is the specified domain name. If yes, proceed to step S53; otherwise, proceed to step S51 to obtain the next initial request traffic.
[0107] S53. Is a request type specified? Determine whether the request type in the obtained initial request traffic is the specified request type. If yes, proceed to step S54; otherwise, proceed to step S51 to obtain the next initial request traffic.
[0108] S54. Format the traffic; format the initial request traffic according to the target data format described above to obtain the initial request traffic with the target data format described above. Similarly, for the initial response traffic corresponding to the initial request traffic, refer to steps S51 to S54 above to obtain the initial response traffic with the target data format described above.
[0109] S55. Should recording be stopped? If a stop recording command is received, recording can be stopped, i.e., data acquisition through the data acquisition plugin will cease, and step S56 will be executed. If no stop recording command is received, recording can continue, i.e., data acquisition through the data acquisition plugin will continue, and step S51 will be executed. The stop recording command can refer to a command to stop acquiring data.
[0110] S56. Encapsulate the traffic packet; upon receiving the end-of-recording command, the traffic scenario can encapsulate the test type, rule identifier, initial response traffic with the aforementioned target data format, and initial request traffic with the aforementioned target data format to obtain a first encapsulated traffic packet. The aforementioned first traffic set includes the initial response traffic with the aforementioned target data format and the initial request traffic with the aforementioned target data format.
[0111] S57 sends the data to the specified service IP; the first encapsulated traffic packet is sent to the specified service IP (i.e., the computer device) via the traffic plugin.
[0112] In summary, by using traffic plugins to clean the acquired traffic based on specified domains and request types, excessive processing pressure on the backend (i.e., computer equipment) can be avoided, thereby improving the testing efficiency for business interfaces.
[0113] S102. Parse the first encapsulated traffic packet to obtain the first traffic set and the test parameters corresponding to the N service interfaces.
[0114] In this application, the computer device can parse the first encapsulated traffic packet according to the decapsulation format corresponding to the target encapsulation format to obtain the first traffic set and the test parameters corresponding to N service interfaces.
[0115] S103. From the first traffic set mentioned above, select the traffic pairs that are associated with the above N business interfaces respectively; each traffic pair includes the original request traffic received by the corresponding business interface and the original response traffic returned by the corresponding business interface to respond to the original request traffic.
[0116] In this application, the computer device can filter out traffic pairs associated with the aforementioned N business interfaces from the aforementioned first traffic set based on the interface information corresponding to the N business interfaces; the computer device can determine the original request traffic of the i-th business interface based on the initial request traffic in the first traffic set that matches the interface information of the i-th business interface; and determine the original response traffic of the i-th business interface based on the initial response traffic in the first traffic set that matches the interface information of the i-th business interface.
[0117] S104. Based on the test parameters corresponding to the above N service interfaces and the traffic pairs corresponding to the above N service interfaces respectively, test the above N service interfaces and obtain the test results.
[0118] In this application, a computer device can test N business interfaces based on test parameters and traffic pairs corresponding to each of the N business interfaces, obtaining test results. These test results reflect whether the N business interfaces have passed the test; that is, the test results include the test result for each business interface. The test result for a business interface indicates whether the corresponding business interface has passed the test, or it indicates that the corresponding business interface has failed the test. By testing the business interfaces using test parameters and traffic pairs, manual test case writing is eliminated, improving testing efficiency and reducing testing costs.
[0119] The computer equipment can input the test parameters corresponding to the above N service interfaces and the traffic pairs corresponding to the above N service interfaces into the test model. The test model then tests the above N service interfaces based on the test parameters and the traffic pairs corresponding to the above N service interfaces, and obtains the test results.
[0120] The test model can refer to an artificial intelligence (AI) model, which may include mixed-model large models, generative adversarial networks (GANs), variational autoencoders (VAEs), recurrent neural networks (RNNs), long short-term memory networks (LSTMs), and Transformer models.
[0121] It should be noted that the interface testing method in this application has the following advantages: (1) Low cost: It does not require a cumbersome packet capture process, nor does it require the development of corresponding test frameworks for each protocol, nor does it require a dedicated deployment environment, nor does it require writing complex test case code. Anyone can use it directly. (2) High efficiency: The solution proposed in this application automatically performs interface testing while manual operation is in progress. It does not require operators to capture packets one by one to confirm the results. It automatically tests the interfaces in the traffic and can statistically analyze relevant information such as coverage and pass rate. (3) Reliable quality: The traffic of this technology comes from real online scenarios, and the data is complete and authentic. The order of each request and the integrity of the scenario can also be guaranteed. (4) Not dependent on a fixed environment: The solution mentioned in this application is an independent third-party implementation. It does not require additional environment deployment, nor does it require intrusion into business code. That is, it does not require intrusion into the source code of the business application, nor does it require modification of the application under test. It can be used completely independently, which can improve the security of business interface testing. (5) Wide applicability: This application can not only be used to test the HTTP protocol, but also is applicable to protocols such as WebSocket and FTP. At the same time, this application can not only be provided to testers, but also to others or even customers. It does not rely on a dedicated testing environment or require additional testing costs; the traffic plugin is ready to use immediately after installation.
[0122] In this application, a traffic plugin is deployed in a business application to capture traffic from the application's kernel interface. The captured traffic and test parameters from N business interfaces are encapsulated to obtain a first encapsulated traffic packet, which is then sent to a computer device (testing device). The computer device can parse and filter the first encapsulated traffic packet to obtain traffic pairs and test parameters for each business interface. Based on these pairs and parameters, the business interfaces are tested to obtain test results. This eliminates the need for manual test case writing for each business interface, improving testing efficiency. Furthermore, the same traffic plugin can be used for testing multiple business interfaces, reducing testing costs and increasing plugin utilization.
[0123] Further, please see Figure 6 This is a flowchart illustrating an interface testing method provided in an embodiment of this application. Figure 6 As shown, this method can Figure 1 The test server in the middle can be used to execute it, or it can be executed by... Figure 1 The method can be executed by any terminal in the system, or it can be executed jointly by a terminal and a server. The device used to execute this interface testing method in this application can be collectively referred to as a computer device. The method may include the following steps:
[0124] S201. Receive the first encapsulated traffic packet sent by the traffic plugin in the business application; the first encapsulated traffic packet is obtained by the traffic plugin encapsulating the test parameters corresponding to N business interfaces of the application and the first traffic set, the first traffic set including the traffic obtained by the traffic plugin from the kernel interface of the application; N is a positive integer.
[0125] S202. Parse the first encapsulated traffic packet to obtain the first traffic set and the test parameters corresponding to the N service interfaces.
[0126] S203. Obtain the traffic filtering rules of the above-mentioned business applications.
[0127] In this application, the computer device can obtain the traffic filtering rules of the business application from the database according to the rule identifier in the test parameters. The traffic filtering rules can be used to filter out invalid traffic. For example, the traffic filtering rules can be used to filter out the traffic of a specified business interface. The specified business interface can be an interface that is not related to N business interfaces, or the specified business interface can be a business interface whose test result is more than the number of times the test fails within a historical time period. That is, the specified business interface can be an abnormal business interface.
[0128] S204. According to the above-mentioned traffic filtering rules, the traffic in the first traffic set is filtered to obtain the filtered first traffic set.
[0129] In this application, the computer device can filter out invalid traffic in the first traffic set according to the filtering rules, and retain the valid traffic in the first traffic set to obtain the filtered first traffic set. This avoids the computer device processing invalid traffic, reduces the interference of invalid traffic on the testing of business interfaces, and improves the testing accuracy and efficiency of business interfaces.
[0130] In one embodiment, Figure 7 This application provides a schematic flowchart for filtering traffic in a first traffic set. The filtering process for traffic in the first traffic set may include the following steps S71 to S74:
[0131] S71. Parse the first encapsulated traffic packet to obtain the current traffic, rule identifier, and test type; the computer device can parse the first encapsulated traffic packet to obtain the test type and rule identifier; according to the acquisition time corresponding to the traffic packet, parse the traffic in the first traffic set from the first encapsulated traffic packet in sequence as the current traffic, which can refer to the initial request traffic or the initial response traffic.
[0132] S72. Query the database based on the rule identifier to obtain the traffic filtering rules.
[0133] S73. Does the traffic filtering rule meet the criteria? If the traffic filtering rule is met, proceed to step S74. If the traffic filtering rule is not met, the current traffic can be retained, and step S71 can be executed to parse the next traffic from the first encapsulated traffic packet as the new current traffic. This process continues until all traffic in the first encapsulated traffic packet has been processed by step S73 to obtain the filtered first traffic set.
[0134] S74. Delete the current traffic; when the traffic filtering rules are met, the current traffic can be deleted and the process can return to step S71.
[0135] In summary, by using computer equipment based on traffic rules to filter invalid traffic in the first encapsulated traffic packet, invalid traffic can be prevented from interfering with the testing of business interfaces, thereby improving the testing accuracy of business interfaces.
[0136] S205. Based on the first set of filtered traffic, determine the traffic pairs associated with the above N service interfaces respectively.
[0137] In this application, a computer device can determine the traffic pairs associated with each of the N business interfaces from the filtered first traffic set based on the interface information corresponding to each of the N business interfaces.
[0138] In one implementation, step S205 includes: when the final response traffic of a certain business interface in a business application depends on the response traffic of other business interfaces, and the stability of the other business interfaces on which the business interface depends is less than a stability threshold, i.e., the accuracy of the response traffic returned by the other business interfaces is relatively low, the initial response traffic and initial request traffic of the business interface need to be adjusted according to test auxiliary data and returned to the business interface, which then returns the final response traffic. Specifically, the computer device can determine the target business interface associated with the test auxiliary data from the N business interfaces based on the dependencies between business interfaces in the business application and the stability of the business interfaces, and obtain the initial request traffic and initial response traffic of the target business interface from the first traffic set. Based on the test auxiliary data, the initial response traffic of the target business interface is adjusted to obtain the adjusted initial response traffic; based on the test auxiliary data, the initial request traffic of the target business interface is adjusted to obtain the adjusted initial request traffic; and the adjusted initial request traffic and the adjusted response traffic are sent to the target business interface. The system receives the response traffic returned by the target business interface based on the adjusted initial request traffic and the adjusted response traffic, and uses this as the original response traffic of the target business interface; it also uses the initial request traffic of the target business interface as the original response traffic of the target business interface. By adjusting the initial request traffic and initial response traffic of the business interface based on test auxiliary data and obtaining the final response traffic of the business interface, the system can improve the accuracy of testing the business interface.
[0139] The target business interface can refer to a business application whose final response traffic depends on other business interfaces, and whose stability is less than a stability threshold. The stability of these other business interfaces can be determined by the frequency of resource anomalies occurring when they process request traffic, or by the frequency of tests failing within a historical timeframe. For example, there might be a negative correlation between stability and frequency: higher frequency generally indicates lower stability of other business interfaces, and vice versa.
[0140] The test auxiliary data can refer to data pre-written into the computer device. It can also refer to the response traffic returned by other business interfaces that the target business interface depends on when the stability exceeds a stability threshold. The aforementioned adjustment of the initial response traffic of the target business interface based on this test auxiliary data, resulting in the adjusted initial response traffic, can refer to performing calculations and processing on the test auxiliary data and the initial response traffic of the target business interface. These calculations and processing can include summation, difference, XOR, etc.
[0141] The process of adjusting the initial request traffic of the target business interface based on the test auxiliary data to obtain the adjusted initial request traffic includes: generating request traffic to instruct the target business interface to process the adjusted initial response traffic based on the test auxiliary data and the initial request traffic, which serves as the adjusted initial response traffic; the specific processing method for the adjusted initial response traffic can be determined based on the processing logic of the target business interface.
[0142] The initial response traffic of the target business interface can be generated by the target business interface and has not been processed by other business interfaces it depends on. If there are remaining business interfaces other than the target business interface among the N business interfaces, the initial response traffic of the remaining business interfaces in the first traffic set can be used as the original response traffic of the remaining business interfaces; the initial request traffic of the remaining business interfaces in the first traffic set can be used as the original request traffic of the remaining business interfaces.
[0143] S206. Based on the test parameters corresponding to the above N service interfaces and the traffic pairs corresponding to the above N service interfaces respectively, test the above N service interfaces and obtain the test results.
[0144] In one embodiment, step S206 includes: the computer device obtaining test cases corresponding to the N service interfaces based on the test type in the test parameters corresponding to the N service interfaces; the test cases are generated based on the traffic in the kernel interface when the service application is in a stable state. Based on the test cases and test parameters corresponding to the N service interfaces, and the traffic pairs corresponding to the N service interfaces respectively, the N service interfaces are tested to obtain test results.
[0145] Specifically, when the test types for N business interfaces all belong to the same scenario test type, test cases for the corresponding scenario test type can be obtained from the test case library. This means the test case indicates that a specific business scenario should be tested, and all N business interfaces correspond to the same test case. The computer equipment can then test the N business interfaces based on the test cases, test parameters, and traffic pairs corresponding to each of the N business interfaces, obtaining the test results. Conversely, when the test types for N business interfaces all belong to the single-interface test type, test cases for each business interface can be obtained from the test case library. Based on the test cases, test parameters, and traffic pairs for each business interface, each business interface can be tested, obtaining the test results for each business interface.
[0146] It should be noted that the N business interfaces can include business interfaces of one or more scenario test types, or the N business interfaces can include business interfaces of scenario test types and business interfaces of single interface test types. Alternatively, the test type of the N business interfaces may all be single interface test types. When the N business interfaces can include business interfaces of multiple scenario test types, the testing methods for the N business interfaces can refer to the testing methods when the test types of the N business interfaces all belong to the same scenario test type. When the N business interfaces can include business interfaces of scenario test types and business interfaces of single interface test types, the testing methods for business interfaces belonging to scenario test types can refer to the testing methods when the test types of the N business interfaces all belong to the same scenario test type, and the testing methods for business interfaces belonging to single interface test types can refer to the testing methods for business interfaces belonging to the same single interface test type.
[0147] In one embodiment, Figure 8 This application provides a flowchart illustrating a testing process for a business interface. The testing process for the business interface may include the following steps S81 to S82:
[0148] S81. Based on the test type, retrieve the test cases for the business interface to which the current traffic belongs from the test case library.
[0149] S82. Determine the test type. This involves testing the business interface based on the test type, test cases, and traffic pairs of that interface to obtain the test results. Specifically, if the business interface's test type is a single-interface test, the test can be performed based on the traffic pairs and test cases of interfaces belonging to the single-interface test type, yielding the test results for that interface. Similarly, if the business interface belongs to a scenario test type, the test can be performed based on the traffic pairs and test cases of interfaces belonging to the same scenario test type, yielding the test results for those interfaces as well.
[0150] In one embodiment, when N is greater than 1, the test case includes N test steps, each test step including a corresponding test request traffic and a test response traffic corresponding to the test request traffic; the above-mentioned testing of the N business interfaces based on the test cases and test parameters corresponding to the N business interfaces and the traffic pairs corresponding to the N business interfaces to obtain test results includes: when the test parameters corresponding to the N business interfaces indicate that the test types of the N business interfaces all belong to the same scenario test type, the computer device can obtain the acquisition time of the traffic pairs corresponding to the N business interfaces respectively. The acquisition time of the traffic pairs can refer to the reception time of the initial request traffic corresponding to the original request traffic, or the acquisition time of the traffic pairs can be the return time of the initial response traffic corresponding to the original response request. The computer device can determine the request order corresponding to the N business interfaces based on the acquisition time of the traffic pairs corresponding to the N business interfaces respectively. The computer device can test the N business interfaces based on the request order corresponding to the N business interfaces respectively, the test request traffic and test response traffic corresponding to the N test steps respectively, and the traffic pairs corresponding to the N business interfaces respectively to obtain test results. By testing multiple business interfaces, comprehensive testing of the business interfaces can be achieved by testing the corresponding business scenarios.
[0151] Among them, test request traffic and test response traffic can refer to the traffic that the business application can return under normal circumstances, that is, test request traffic and test response traffic can refer to the correct and error-free traffic in the business application.
[0152] In one embodiment, the above-mentioned testing of the N business interfaces based on the request order corresponding to the N business interfaces, the test request traffic and test response traffic included in the N test steps, and the traffic pairs corresponding to the N business interfaces to obtain test results includes: the computer device can use a similarity algorithm to determine a first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interfaces with request order i, where i is a positive integer less than or equal to N, and a second similarity between the test response traffic in the i-th test step and the original response traffic in the i-th traffic pair. The test result of the business interface corresponding to the i-th traffic pair can be determined based on the first similarity and the second similarity. By testing the business interfaces based on the test request traffic, test response traffic, original request traffic, and original response traffic of the business interfaces in the test steps, the accuracy of the tests can be improved.
[0153] For example, if the first similarity of the i-th traffic pair is greater than the first similarity threshold, and the second similarity of the i-th traffic pair is less than or equal to the second similarity threshold, it indicates that the original request traffic in the i-th traffic pair is correct, but the original response traffic in the i-th traffic pair is incorrect. A test result is generated to indicate that the business interface test corresponding to the i-th traffic pair has failed. Conversely, if the first similarity of the i-th traffic pair is greater than the first similarity threshold, and the second similarity of the i-th traffic pair is greater than the second similarity threshold, it indicates that both the original request traffic and the original response traffic in the i-th traffic pair are correct. A test result is generated to indicate that the business interface test corresponding to the i-th traffic pair has passed. When the first similarity corresponding to the i-th traffic pair is less than or equal to the first similarity threshold, and the second similarity corresponding to the i-th traffic pair is greater than the second similarity threshold, it indicates that the original request traffic in the i-th traffic pair is incorrect, while the original response traffic in the i-th traffic pair is correct. That is, the business interface corresponding to the i-th traffic pair returned the correct original response traffic based on the incorrect original request traffic. Under normal circumstances, the application of the business interface corresponding to the i-th traffic pair returns an indication that the original request traffic in the i-th traffic pair is incorrect, which indicates that the business interface corresponding to the i-th traffic pair has an anomaly and generates a test result to indicate that the test of the business interface corresponding to the i-th traffic pair has failed. If the first similarity of the i-th traffic pair is less than or equal to the first similarity threshold, and the second similarity of the i-th traffic pair is less than or equal to the second similarity threshold, it indicates that both the original request traffic and the original response traffic in the i-th traffic pair are incorrect. If the original response traffic in the i-th traffic pair is not an indication that the original request traffic in the i-th traffic pair is incorrect, a test result indicating that the business interface test corresponding to the i-th traffic pair has failed is generated. If the original response traffic in the i-th traffic pair is an indication that the original request traffic in the i-th traffic pair is incorrect, a test result indicating that the business interface test corresponding to the i-th traffic pair has passed is generated.
[0154] In one embodiment, the testing of the N business interfaces is performed based on the request order corresponding to each of the N business interfaces, the test request traffic and test response traffic included in each of the N test steps, and the traffic pairs corresponding to each of the N business interfaces, to obtain test results. This includes: the computer device determining a first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair based on a similarity algorithm; the i-th traffic pair is the traffic pair of the business interfaces with request order i, where i is a positive integer less than or equal to N. From the test response traffic included in each of the N test steps, the test response traffic of the last test step is obtained; from the traffic pairs corresponding to each of the N business interfaces, the original response traffic of the business interface with the last request order is obtained. A third similarity is determined between the test response traffic of the last test step and the original response traffic of the business interface with the last request order; and the test results of the N business interfaces are determined based on the third similarity and the first similarity corresponding to the original request traffic of each of the N business interfaces. This eliminates the need to compare all original response traffic with the test response traffic one by one, improving testing efficiency.
[0155] For example, if the first similarity scores corresponding to the original request traffic of N business interfaces are all greater than the first similarity threshold, and the third similarity scores are greater than the third similarity threshold, it indicates that the original request traffic and test request traffic in the business scenario corresponding to the N business interfaces are similar or the same, and the original response traffic returned by the business interface with the last request order is the same as the test response traffic of the last test step. That is, all the original request traffic and the original response traffic returned by the business interface with the last request order are correct, and a test result is generated to indicate that the N business interfaces have passed the test. If the first similarity scores corresponding to the original request traffic of N business interfaces are all greater than the first similarity threshold, and the third similarity scores are less than or equal to the third similarity threshold, it indicates that the original request traffic and test request traffic in the business scenario corresponding to the N business interfaces are similar or the same, but the original response traffic returned by the business interface with the last request order is different from the test response traffic of the last test step. That is, all the original request traffic is correct, but the original response traffic returned by the business interface with the last request order is incorrect, and a test result is generated to indicate that the N business interfaces have passed the test. If the original request traffic of N business interfaces contains corresponding first similarity scores that are all less than or equal to the first similarity threshold, and third similarity scores that are greater than the third similarity threshold, it indicates that there is erroneous original request traffic among the original request traffic of the N business interfaces. Furthermore, the original response traffic returned by the business interface whose request order is last is the same as the test response traffic of the last test step. That is, even though the original request traffic is erroneous, the correct original response traffic is returned. In other words, there is an erroneous business interface among the N business interfaces. Therefore, test results can be generated to indicate that the test of the N business interfaces has failed. If the original request traffic of N business interfaces contains corresponding first similarity scores that are all less than or equal to the first similarity threshold, and third similarity scores that are less than or equal to the third similarity threshold, it indicates that there are erroneous original request traffic among the original request traffic corresponding to the N business interfaces, and the original response traffic returned by the business interface with the last request order is different from the test response traffic of the last test step. When the original response traffic returned by the business interface with the last request order is not an indication that the original request traffic corresponding to the N business interfaces is erroneous, a test result indicating that the test of the N business interfaces has failed is generated; when the original response traffic returned by the business interface with the last request order is an indication that the original request traffic corresponding to the N business interfaces is erroneous, a test result indicating that the test of the N business interfaces has passed is generated.
[0156] In one embodiment, the test cases include test request traffic corresponding to each of the N business interfaces and test vector traffic corresponding to each test request traffic. The above-mentioned testing of the N business interfaces based on the test cases and test parameters corresponding to the N business interfaces, and the traffic pairs corresponding to the N business interfaces, to obtain test results includes: when the test parameters corresponding to the N business interfaces indicate that the test type of the N business interfaces all belong to the single-interface test type, determining the fourth similarity between the test request traffic and the original request traffic of each business interface; determining the fifth similarity between the test response traffic and the original response traffic of each business interface; and determining the test results corresponding to the N business interfaces based on the fourth and fifth similarities respectively. Under the single-interface test type, by comparing the original request traffic with the test request traffic and the original response traffic with the test response traffic of each business interface one by one, the testing of each business interface is achieved, improving test accuracy.
[0157] For example, if the fourth similarity score of a business interface is greater than the fourth similarity threshold and the fifth similarity score is greater than the fifth similarity threshold, it indicates that the original request traffic and original response traffic of the business interface are accurate, and a test result indicating that the business interface has passed the test can be generated. If the fourth similarity score of a business interface is greater than the fourth similarity threshold and the fifth similarity score is less than or equal to the fifth similarity threshold, it indicates that the original request traffic of the business interface is accurate, but the original response traffic of the business interface is incorrect, and a test result indicating that the business interface has failed the test can be generated. If the fourth similarity score of a business interface is less than or equal to the fourth similarity threshold and the fifth similarity score is less than or equal to the fifth similarity threshold, and the original response traffic of the business interface does not indicate that the original request traffic is incorrect, a test result indicating that the business interface has failed the test can be generated. If the fourth similarity score of a business interface is less than or equal to the fourth similarity threshold and the fifth similarity score is less than or equal to the fifth similarity threshold, and the original response traffic of the business interface indicates that the original request traffic is incorrect, a test result indicating that the business interface has passed the test can be generated.
[0158] In one embodiment, the computer device can receive a second encapsulated traffic packet sent by the business device corresponding to the aforementioned business application. The second encapsulated traffic packet is obtained by the business device encapsulating a second traffic set, which includes traffic obtained by the traffic plugin from the kernel interface when the business application is in a stable state. The second encapsulated traffic packet is parsed to obtain the second traffic set. Traffic pairs for the interface to be tested are selected from the second traffic set. The interface to be tested includes the aforementioned N business interfaces. Test cases are generated for the interface to be tested based on the traffic pairs. By automatically generating test cases using the second traffic set, manual test case writing is eliminated, improving test case generation efficiency and reducing costs.
[0159] It's important to note that computer devices can determine the results of test cases based on the automation execution engine. For example, in a traditional script-based automation framework, the test cases are converted into code format using the framework's API to obtain executable test cases. In a data / behavior-driven automation framework, the test cases can be converted into data format, such as JSON or YAML, to obtain executable test cases.
[0160] In one embodiment, the test response traffic in the test case also includes assertion rules. These assertion rules instruct how to determine whether the original request traffic and original response traffic are correct based on the test case. The assertion rules can include type assertions, range assertions, equivalence assertions, Boolean assertions, etc. For example, if the original request traffic and test request traffic request the business service to return image-type traffic, and the original response traffic returns image-type traffic, then the business interface test corresponding to the original response traffic is determined to have passed.
[0161] In one embodiment, the similarity (second similarity, third similarity) between the original response traffic and the test response traffic can be determined based on the assertion rules, the original response traffic, and the test response traffic, and the similarity (first similarity, fourth similarity) between the original request traffic and the test request traffic can be determined based on the assertion rules, the original request traffic, and the test request traffic.
[0162] In one embodiment, the traffic plugin may further include a test case configuration interface, through which test case parameters can be configured. These test case parameters may include one or more of the following: protocol type, specified request type, specified domain name, service address, identifier of the test case to be generated, priority level of the test case to be generated, type of the test case to be generated, rule identifier, operator information, and tag of the test case to be generated. The traffic scenario can obtain a second traffic set based on the test case parameters and encapsulate it to obtain a second encapsulated traffic package.
[0163] For example, this application provides a test case configuration interface such as Figure 9 As shown, the test case configuration interface 91a includes a protocol type configuration component 92a, a request type configuration component 93a, a domain name configuration component 94a, a service IP configuration component 95a, an identifier configuration component 96a, a priority configuration component 97a, a category configuration component 98a, a tag configuration component 99a, a rule configuration component 91b, and a tester configuration component 92b. The protocol type configuration component 92a specifies the protocol type of the traffic to be acquired, such as HTTP or WebSocket. The request type configuration component 93a allows configuring the request type of the traffic to be filtered (i.e., the traffic to be recorded). The request type configuration component 93a provides candidate request types, namely POST, GET, DELETE, and PUT. Users can select the candidate request type to specify the request type of the traffic to be filtered. The domain name configuration component 94a allows inputting the specified domain name of the filtered traffic, and the service IP configuration component 95a allows inputting the service address for the backend processing the traffic. The identifier configuration component 96a is used to configure the identifier of the generated test cases, such as name and number. The rule configuration component 96a can be used to configure rule identifiers, such as selecting rule name and number. The priority configuration component 97a can be used to configure the priority level of the test cases to be generated. The priority level reflects the execution order of the test cases; the higher the priority level, the earlier the test case is executed; the lower the priority level, the later the test case is executed. The category configuration component 98a can be used to configure the type to which the test case belongs. The label configuration component 99a can be used to set labels for the test cases. The rule configuration component 91b can be used to configure rule identifiers, such as selecting rule name and number. Rule identifiers are used to indicate rules for filtering or other processing of the acquired traffic. The tester configuration component 92b can be used to configure the information of the users who test the business application; that is, the users who test the business application can be referred to as operators.
[0164] It should be noted that this application is applicable not only to the HTTP(S) protocol and the WebSocket protocol.
[0165] In one embodiment, Figure 10 This application provides a schematic diagram of a process for obtaining a second encapsulated traffic packet. The process for obtaining the first encapsulated traffic packet includes the following steps S1011 to S1017:
[0166] S1011. Obtain initial request traffic; When the business application is in a stable state, obtain the initial request traffic from the kernel interface of the business application through the traffic plugin in the business application. This initial request traffic belongs to the second initial traffic set.
[0167] S1012. Is a domain name specified? Determine whether the domain name in the obtained initial request traffic is a specified domain name. If yes, proceed to step S1013; otherwise, proceed to step S1011 to obtain the next initial request traffic.
[0168] S1013. Is a request type specified? Determine whether the request type in the obtained initial request traffic is the specified request type. If yes, proceed to step S1014; otherwise, proceed to step S1011 to obtain the next initial request traffic.
[0169] S1014. Format the traffic; format the initial request traffic according to the target data format described above to obtain the initial request traffic with the target data format described above. Similarly, for the initial response traffic corresponding to the initial request traffic, refer to the above steps S1011 to S1014 to obtain the initial response traffic with the target data format described above.
[0170] S1015. Should recording be stopped? If a stop recording command is received, recording can be stopped, i.e., data acquisition through the data acquisition plugin will cease, and step S1016 will be executed. If no stop recording command is received, recording can continue, i.e., data acquisition through the data acquisition plugin will continue, and step S1011 will be executed. The stop recording command can refer to a command to stop acquiring data.
[0171] S1016. Encapsulate the traffic packet; upon receiving the end-of-recording command, the traffic scenario can encapsulate the priority program, the type and label of the test case to be acquired, the rule identifier, the operator's information, the initial response traffic with the aforementioned target data format, and the initial request traffic with the aforementioned target data format to obtain a second encapsulated traffic packet. The aforementioned second traffic set includes the initial response traffic with the aforementioned target data format and the initial request traffic with the aforementioned target data format.
[0172] S1017 sends to the specified service IP; the second encapsulated traffic packet is sent to the specified service IP (i.e., computer device) via the traffic plugin.
[0173] In summary, by using traffic plugins to clean the acquired traffic based on specified domains and request types, excessive processing pressure on the backend (i.e., computer equipment) can be avoided, thereby improving the efficiency of generating test cases.
[0174] In one embodiment, generating test cases for the interface under test based on the traffic pairs of the interface under test includes: the computer device replacing dynamic data in the initial request traffic of the traffic pairs of the interface under test with specified characters to obtain the processed initial request traffic of the interface under test; deleting dynamic data in the initial response traffic of the traffic pairs of the interface under test to obtain the processed initial response traffic of the interface under test; and generating test cases for the interface under test based on the processed initial request traffic and processed initial response traffic of the interface under test.
[0175] The specified characters mentioned above can refer to characters without actual meaning, such as placeholder characters. The dynamic data mentioned above can refer to data that is unrelated to business interface testing. For example, dynamic data can include timestamps, traceIDs (identifiers of the links corresponding to the transmission traffic), etc. The timestamp can refer to the generation time of the corresponding traffic.
[0176] For example, such as Figure 11 As shown, the computer device can perform the following steps S1111 to S1114 on the initial request traffic in the traffic pair of the interface to be tested:
[0177] S1111, Formatting; The initial request traffic includes request headers, request addresses, request parameters, and request bodies. The computer device can format the request headers, request addresses, request parameters, and request bodies, that is, make the content of all initial request traffic unique. In this way, all test cases must be composed of these formatted standard contents. If an interface changes, only the interface information needs to be modified, and all test cases referencing this content can be regenerated at once.
[0178] S1112. Is it dynamic data? The computer device can determine whether the request body or request header contains dynamic data. If it contains dynamic data, proceed to step S1113; if it does not contain dynamic data, proceed to step S1114.
[0179] S1113. Parameter replacement: If dynamic data is included, a specified character can be used to replace the dynamic data in the initial request traffic to obtain the processed initial request traffic of the interface to be tested. Specifically, when the dynamic data is a timestamp, a placeholder can be used to replace the timestamp in the initial request traffic. When waiting for the initial request traffic to be transmitted to the business server corresponding to the business application, the transmission time of the initial request traffic can be used to replace the specified character to obtain the processed initial request traffic of the interface to be tested.
[0180] S1114. Storage, namely, storing the request header ID, request address ID, request parameter ID, and request body ID. The request header ID can be an identifier used to identify the request header in the initial request traffic after processing of the interface under test. The request address ID can be an identifier used to identify the request address in the initial request traffic after processing of the interface under test. The request parameter ID can be an identifier used to identify the request parameter in the initial request traffic after processing of the interface under test. The request body ID can be an identifier used to identify the request body in the initial test request traffic after processing of the interface under test.
[0181] For example, such as Figure 12 As shown, the computer device can perform the following steps S1211 to S1216 on the initial response traffic in the traffic pair of the interface to be tested:
[0182] S1211, Formatting; The initial response traffic includes a response header, a response address, and a response body. The computer device can format the response header, response address, and response body to make the content of all initial response traffic unique.
[0183] S1212. Is it dynamic data? The computer device can determine whether the response body or response header contains dynamic data. If it contains dynamic data, proceed to step S1213; if it does not contain dynamic data, proceed to step S1214.
[0184] S1213. If dynamic data is included, dynamic data in the initial response traffic can be discarded.
[0185] S1214. If dynamic data is not included, assertion rules can be obtained from the database based on the rule identifier. Assertion rules can refer to the way to judge whether the original request traffic and original response traffic are correct based on test cases.
[0186] S1215, Combine, combine assertion rules, formatted response headers, response addresses and response bodies to obtain the processed initial response traffic, and add the processed initial response traffic to the database.
[0187] S1216. Generate the flow identifier corresponding to the processed initial response flow, and call the flow identifier the assertion ID (i.e. assertion identifier) of the processed initial response flow.
[0188] After obtaining the processed initial response traffic and the processed initial request traffic, test cases for the interface to be tested can be generated based on the processed initial response traffic and the processed initial request traffic. The processed initial response traffic and the initial request traffic both belong to the second traffic set.
[0189] In one embodiment, generating test cases for the interface under test based on the processed initial request traffic and processed initial response traffic includes: when the processed initial request traffic of the interface under test meets the simulation rules, adjusting the processed initial response traffic of the interface under test according to the configuration information corresponding to the simulation rules to obtain the test response traffic of the interface under test. The computer device can use the initial request traffic of the interface under test as the test request traffic of the interface under test; and determine test cases for the interface under test based on the test request traffic and test response traffic.
[0190] The simulation rule can refer to adjusting the final response traffic configuration information of the interface to be tested, that is, the final response traffic of the test result needs to depend on the response traffic of other business interfaces, and the stability of other business interfaces is less than the stability threshold.
[0191] In one embodiment, after receiving the second encapsulated traffic packet, the computer device can perform filtering or other processing on the traffic in the second traffic set within the second encapsulated traffic packet. Figure 13 This application provides a schematic diagram of a process for filtering traffic in a second traffic set. The filtering process for traffic in the second traffic set may include the following steps S1311 to S1315:
[0192] S1311. Parse the second encapsulated traffic packet to obtain the current traffic, rule identifier, and test type; the computer device can parse the second encapsulated traffic packet to obtain the rule identifier and other information, such as tags and priority levels; according to the acquisition time corresponding to the traffic packet, parse the traffic in the second traffic set from the second encapsulated traffic packet in sequence as the current traffic, which can refer to the processed initial request traffic or the processed initial response traffic.
[0193] S1312. Query the database based on rule identifiers to obtain a blacklist, a whitelist, and simulation rules. The blacklist can be used to store business interfaces that do not need to be tested, or business interfaces that have been deleted from the business application. The whitelist can be used to store business interfaces that need to be tested. The simulation rules can be used to store which interfaces need to have their initial response traffic adjusted.
[0194] S1313, Rule hit; Determine whether the current traffic belongs to the blacklist or whitelist. If it belongs to the blacklist, execute step S1311; if it does not belong to the blacklist and belongs to the whitelist, execute step S1314 and store the current traffic.
[0195] S1314. Store test traffic. Test traffic includes test response traffic and test request traffic. If the current traffic is the processed initial request traffic, use the current traffic as test request traffic. If the current traffic is the processed initial response traffic, use the current traffic as test response traffic.
[0196] S1315. If the current traffic meets the simulation rules, test traffic is obtained based on the simulation rules. If the current traffic is the processed initial response traffic, the current traffic can be adjusted based on the configuration information corresponding to the simulation rules to obtain test response traffic. If the current traffic is the processed initial request traffic, the current traffic is used as test request traffic.
[0197] After acquiring the test request traffic and test response traffic, the test request traffic and test vector traffic of the interface under test can be used as test cases for the interface under test under a single interface test type. The computer device can determine the test steps corresponding to the test request traffic based on the transmission time of the test request traffic of each interface under test, and arrange the test request traffic and test response traffic according to the test steps to obtain test cases for each interface under test under a scenario test type.
[0198] For example, such as Figure 14 As shown, test cases for scenario test types include basic test case information and test steps. Basic test case information may include information about the creator of the test case, the test set to which it belongs, priority level, creation time, tag, module to which it belongs, test case type, test case ID, etc. Test steps include test step 01, test step 02, test step 03, etc. Each test step includes the request header ID, request address ID, request parameter ID, and request body ID corresponding to the test request traffic, as well as the assertion ID corresponding to the test response traffic. Test steps can be determined based on the transmission time corresponding to each test request response.
[0199] It should be noted that the test case generation process of this application has the following advantages: (1) Low cost: It does not require a cumbersome packet capture process, does not intrude on the business code environment, does not require writing test case code, has no learning cost, and can be used directly by anyone. (2) High efficiency: It can automatically capture and convert traffic by simply operating the business application normally, which is much more efficient than the traditional manual coding. It can be used in any complex system. It also does not require extra environment setup and adaptation. The traffic plugin is ready to use after installation. (3) Reliable quality: The traffic comes from real online scenarios, and the data is complete and real. The order of each request and the integrity of the scenario can also be guaranteed. (4) Wide applicability: It can be used not only to test the HTTP protocol, but also to the WebSocket protocol. At the same time, it has no requirements for the business being tested. Theoretically, it can be used in any web system, which is universal. (5) Support for multiple platforms: It supports cross-platform operation and can run on any platform. It is compatible with all business applications (only the corresponding traffic plugin needs to be developed). (6) Low maintenance cost: This application does not require a large amount of test case code. When the business changes, only the corresponding interface needs to be modified to regenerate all related test cases without re-recording.
[0200] In this application, a traffic plugin is deployed in a business application to capture traffic from the application's kernel interface. The captured traffic and test parameters from N business interfaces are encapsulated to obtain a first encapsulated traffic packet, which is then sent to a computer device (testing device). The computer device can parse and filter the first encapsulated traffic packet to obtain traffic pairs and test parameters for each business interface. Based on these pairs and parameters, the business interfaces are tested to obtain test results. This eliminates the need for manual test case writing for each business interface, improving testing efficiency. Furthermore, the same traffic plugin can be used for testing multiple business interfaces, reducing testing costs and increasing plugin utilization.
[0201] Please see Figure 15 This is a schematic diagram of the structure of an interface testing device provided in an embodiment of this application. Figure 15 As shown, the interface testing device may include:
[0202] The receiving module 1511 is used to receive a first encapsulated traffic packet sent by the traffic plugin in the business application; the first encapsulated traffic packet is obtained by the traffic plugin encapsulating the test parameters corresponding to N business interfaces of the application and a first traffic set, the first traffic set including the traffic obtained by the traffic plugin from the kernel interface of the application; N is a positive integer.
[0203] The parsing module 1512 is used to parse the first encapsulated traffic packet to obtain the first traffic set and the test parameters corresponding to the N service interfaces.
[0204] The filtering module 1513 is used to filter out traffic pairs associated with the above N business interfaces from the first traffic set; each traffic pair includes the original request traffic received by the corresponding business interface and the original response traffic returned by the corresponding business interface to respond to the original request traffic.
[0205] The test module 1514 is used to test the above N business interfaces based on the test parameters corresponding to the above N business interfaces and the traffic pairs corresponding to the above N business interfaces respectively, and obtain the test results.
[0206] Optional, the filtering module 1513 is specifically used for:
[0207] Obtain the traffic filtering rules for the aforementioned business applications;
[0208] According to the above traffic filtering rules, the traffic in the first traffic set is filtered to obtain the filtered first traffic set.
[0209] Based on the first set of filtered traffic, determine the traffic pairs associated with the above N service interfaces respectively.
[0210] Optional, the filtering module 1513 is specifically used for:
[0211] Based on the dependencies and stability of the business interfaces in the above business applications, the target business interface associated with the test auxiliary data is determined from the above N business interfaces.
[0212] From the first traffic set mentioned above, obtain the initial request traffic and initial response traffic of the target business interface mentioned above;
[0213] Based on the aforementioned test auxiliary data, the initial response traffic of the aforementioned target business interface is adjusted to obtain the adjusted initial response traffic. Based on the aforementioned test auxiliary data, the initial request traffic of the aforementioned target business interface is adjusted to obtain the adjusted initial request traffic.
[0214] Send the adjusted initial request traffic and the adjusted response traffic to the target service interface.
[0215] The response traffic returned by the target business interface based on the adjusted initial request traffic and the adjusted response traffic is used as the original response traffic of the target business interface.
[0216] The initial request traffic of the aforementioned target business interface is used as the original response traffic of the aforementioned target business interface.
[0217] Optional, test module 1514, specifically used for:
[0218] Based on the test parameters corresponding to the above N business interfaces, obtain the test cases corresponding to the above N business interfaces; the above test cases are generated based on the traffic in the above kernel interfaces when the above business application is in a stable state;
[0219] Based on the test cases and test parameters corresponding to the above N business interfaces, and the traffic pairs corresponding to the above N business interfaces respectively, the above N business interfaces are tested to obtain test results.
[0220] Optionally, when N is greater than 1, the above test case includes N test steps, and each test step includes the corresponding test request traffic and the test response traffic corresponding to the above test request traffic;
[0221] Optional, test module 1514, specifically used for:
[0222] When the test parameters corresponding to the above N business interfaces indicate that the test types of the above N business interfaces all belong to the same scenario test type, obtain the acquisition time of the traffic pairs corresponding to the above N business interfaces respectively.
[0223] Based on the acquisition time of the traffic pairs corresponding to the above N business interfaces, the request order corresponding to the above N business interfaces is determined.
[0224] Based on the request order corresponding to the above N business interfaces, the test request traffic and test response traffic corresponding to the above N test steps, and the traffic pairs corresponding to the above N business interfaces, the above N business interfaces are tested to obtain the test results.
[0225] Optional, test module 1514, specifically used for:
[0226] Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N;
[0227] Determine the second similarity between the test response traffic in the i-th test step and the original response traffic in the i-th traffic pair;
[0228] Based on the first similarity and the second similarity mentioned above, the test result of the business interface corresponding to the i-th traffic pair is determined.
[0229] Optional, test module 1514, specifically used for:
[0230] Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N;
[0231] From the test response traffic included in the above N test steps, obtain the test response traffic of the last test step; from the traffic pairs corresponding to the above N business interfaces, obtain the original response traffic of the business interface whose request order is the last.
[0232] Determine the third similarity between the test response traffic where the test step is last and the original response traffic of the business interface where the request order is last;
[0233] Based on the third similarity score and the first similarity scores corresponding to the original request traffic of the N business interfaces, the test results of the N business interfaces are determined.
[0234] Optionally, the above test cases include the test request traffic corresponding to each of the above N business interfaces and the test vector traffic corresponding to each test request traffic;
[0235] Optional, test module 1514, specifically used for:
[0236] When the test parameters corresponding to the above N business interfaces indicate that the test type of the above N business interfaces all belong to the single interface test type, determine the fourth similarity between the test request traffic and the original request traffic of each business interface;
[0237] Determine the fifth similarity between the test response traffic and the original response traffic for each business interface;
[0238] Based on the fourth and fifth similarity scores corresponding to the above N business interfaces, the test results corresponding to the above N business interfaces are determined.
[0239] Optionally, the apparatus may also include a generation module 1515;
[0240] The generation module 1515 is used to receive the second encapsulated traffic packet sent by the service device corresponding to the above-mentioned service application; the second encapsulated traffic packet is obtained by the above-mentioned service device from the second traffic set, and the second traffic set includes the traffic obtained by the traffic plugin from the above-mentioned kernel interface when the above-mentioned service application is in a stable state;
[0241] The second encapsulated traffic packet is parsed to obtain the second traffic set.
[0242] Select traffic pairs for the interfaces to be tested from the second traffic set mentioned above; the interfaces to be tested include the aforementioned N business interfaces.
[0243] Based on the traffic pairs of the interface to be tested, generate test cases for the interface to be tested.
[0244] Optionally, module 1515 is generated, specifically for:
[0245] Replace the dynamic data in the initial request traffic of the above-mentioned interface under test with a specified character to obtain the processed initial request traffic of the above-mentioned interface under test.
[0246] Delete the dynamic data in the initial response traffic of the traffic pair of the above-mentioned interface to be tested, and obtain the processed initial response traffic of the above-mentioned interface to be tested.
[0247] Based on the processed initial request traffic and processed initial response traffic of the interface to be tested, generate test cases for the interface to be tested.
[0248] Optionally, module 1515 is generated, specifically for:
[0249] When the initial request traffic after processing of the above-mentioned interface to be tested meets the simulation rules, the initial response traffic after processing of the above-mentioned interface to be tested is adjusted according to the configuration information corresponding to the above-mentioned simulation rules to obtain the test response traffic of the above-mentioned interface to be tested.
[0250] The initial request traffic of the interface to be tested is used as the test request traffic of the interface to be tested.
[0251] Based on the test request traffic and test response traffic of the interface to be tested, determine the test cases for the interface to be tested.
[0252] In this application, a traffic plugin is deployed in a business application to capture traffic from the application's kernel interface. The captured traffic and test parameters from N business interfaces are encapsulated to obtain a first encapsulated traffic packet, which is then sent to a computer device (testing device). The computer device can parse and filter the first encapsulated traffic packet to obtain traffic pairs and test parameters for each business interface. Based on these pairs and parameters, the business interfaces are tested to obtain test results. This eliminates the need for manual test case writing for each business interface, improving testing efficiency. Furthermore, the same traffic plugin can be used for testing multiple business interfaces, reducing testing costs and increasing plugin utilization.
[0253] Please see Figure 16 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 16 As shown, the aforementioned computer device 1000 can refer to a terminal or server, including: a processor 1001, a network interface 1004, and a memory 1005. Furthermore, the aforementioned computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. The communication bus 1002 is used to implement communication between these components. In some embodiments, the user interface 1003 may include a display screen and a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as at least one disk storage device. The memory 1005 may also optionally be at least one storage device located remotely from the aforementioned processor 1001. Figure 16 As shown, the memory 1005, which is a computer-readable storage medium, may include an operating system, a network communication module, a user interface module, and computer programs.
[0254] exist Figure 16 In the computer device 1000 shown, the network interface 1004 provides network communication functionality; the user interface 1003 is mainly used to provide an input interface; and the processor 1001 can be used to call the computer program stored in the memory 1005 to execute the following steps in the embodiments of this application:
[0255] Receive the first encapsulated traffic packet sent by the traffic plugin in the business application; the first encapsulated traffic packet is obtained by the traffic plugin encapsulating the test parameters corresponding to N business interfaces of the application and the first traffic set, the first traffic set including the traffic obtained by the traffic plugin from the kernel interface of the application; N is a positive integer;
[0256] The first encapsulated traffic packet is parsed to obtain the first traffic set and the test parameters corresponding to the N service interfaces.
[0257] From the first set of traffic mentioned above, traffic pairs associated with the above N business interfaces are selected respectively; each traffic pair includes the original request traffic received by the corresponding business interface, and the original response traffic returned by the corresponding business interface to respond to the original request traffic.
[0258] Based on the test parameters corresponding to the above N business interfaces and the traffic pairs corresponding to the above N business interfaces respectively, the above N business interfaces are tested and the test results are obtained.
[0259] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0260] Obtain the traffic filtering rules for the aforementioned business applications;
[0261] According to the above traffic filtering rules, the traffic in the first traffic set is filtered to obtain the filtered first traffic set.
[0262] Based on the first set of filtered traffic, determine the traffic pairs associated with the above N service interfaces respectively.
[0263] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0264] Based on the dependencies and stability of the business interfaces in the above business applications, the target business interface associated with the test auxiliary data is determined from the above N business interfaces.
[0265] From the first traffic set mentioned above, obtain the initial request traffic and initial response traffic of the target business interface mentioned above;
[0266] Based on the aforementioned test auxiliary data, the initial response traffic of the aforementioned target business interface is adjusted to obtain the adjusted initial response traffic. Based on the aforementioned test auxiliary data, the initial request traffic of the aforementioned target business interface is adjusted to obtain the adjusted initial request traffic.
[0267] Send the adjusted initial request traffic and the adjusted response traffic to the target service interface.
[0268] The response traffic returned by the target business interface based on the adjusted initial request traffic and the adjusted response traffic is used as the original response traffic of the target business interface.
[0269] The initial request traffic of the aforementioned target business interface is used as the original response traffic of the aforementioned target business interface.
[0270] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0271] Based on the test parameters corresponding to the above N business interfaces, obtain the test cases corresponding to the above N business interfaces; the above test cases are generated based on the traffic in the above kernel interfaces when the above business application is in a stable state;
[0272] Based on the test cases and test parameters corresponding to the above N business interfaces, and the traffic pairs corresponding to the above N business interfaces respectively, the above N business interfaces are tested to obtain test results.
[0273] Optionally, when N is greater than 1, the above test case includes N test steps, and each test step includes the corresponding test request traffic and the test response traffic corresponding to the above test request traffic;
[0274] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0275] When the test parameters corresponding to the above N business interfaces indicate that the test types of the above N business interfaces all belong to the same scenario test type, obtain the acquisition time of the traffic pairs corresponding to the above N business interfaces respectively.
[0276] Based on the acquisition time of the traffic pairs corresponding to the above N business interfaces, the request order corresponding to the above N business interfaces is determined.
[0277] Based on the request order corresponding to the above N business interfaces, the test request traffic and test response traffic corresponding to the above N test steps, and the traffic pairs corresponding to the above N business interfaces, the above N business interfaces are tested to obtain the test results.
[0278] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0279] Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N;
[0280] Determine the second similarity between the test response traffic in the i-th test step and the original response traffic in the i-th traffic pair;
[0281] Based on the first similarity and the second similarity mentioned above, the test result of the business interface corresponding to the i-th traffic pair is determined.
[0282] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0283] Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N;
[0284] From the test response traffic included in the above N test steps, obtain the test response traffic of the last test step; from the traffic pairs corresponding to the above N business interfaces, obtain the original response traffic of the business interface whose request order is the last.
[0285] Determine the third similarity between the test response traffic where the test step is last and the original response traffic of the business interface where the request order is last;
[0286] Based on the third similarity score and the first similarity scores corresponding to the original request traffic of the N business interfaces, the test results of the N business interfaces are determined.
[0287] Optionally, the above test cases include the test request traffic corresponding to each of the above N business interfaces and the test vector traffic corresponding to each test request traffic;
[0288] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0289] When the test parameters corresponding to the above N business interfaces indicate that the test type of the above N business interfaces all belong to the single interface test type, determine the fourth similarity between the test request traffic and the original request traffic of each business interface;
[0290] Determine the fifth similarity between the test response traffic and the original response traffic for each business interface;
[0291] Based on the fourth and fifth similarity scores corresponding to the above N business interfaces, the test results corresponding to the above N business interfaces are determined.
[0292] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0293] Receive the second encapsulated traffic packet sent by the service device corresponding to the above-mentioned service application; the second encapsulated traffic packet is obtained by the above-mentioned service device from encapsulating the second traffic set, and the second traffic set includes the traffic obtained by the above-mentioned traffic plugin from the above-mentioned kernel interface when the above-mentioned service application is in a stable state;
[0294] The second encapsulated traffic packet is parsed to obtain the second traffic set.
[0295] Select traffic pairs for the interfaces to be tested from the second traffic set mentioned above; the interfaces to be tested include the aforementioned N business interfaces.
[0296] Based on the traffic pairs of the interface to be tested, generate test cases for the interface to be tested.
[0297] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0298] Replace the dynamic data in the initial request traffic of the above-mentioned interface under test with a specified character to obtain the processed initial request traffic of the above-mentioned interface under test.
[0299] Delete the dynamic data in the initial response traffic of the traffic pair of the above-mentioned interface to be tested, and obtain the processed initial response traffic of the above-mentioned interface to be tested.
[0300] Based on the processed initial request traffic and processed initial response traffic of the interface to be tested, generate test cases for the interface to be tested.
[0301] Optionally, the processor 1001 can be used to invoke a computer program stored in the memory 1005 to perform the following steps in the embodiments of this application:
[0302] When the initial request traffic after processing of the above-mentioned interface to be tested meets the simulation rules, the initial response traffic after processing of the above-mentioned interface to be tested is adjusted according to the configuration information corresponding to the above-mentioned simulation rules to obtain the test response traffic of the above-mentioned interface to be tested.
[0303] The initial request traffic of the interface to be tested is used as the test request traffic of the interface to be tested.
[0304] Based on the test request traffic and test response traffic of the interface to be tested, determine the test cases for the interface to be tested.
[0305] In this application, a traffic plugin is deployed in a business application to capture traffic from the application's kernel interface. The captured traffic and test parameters from N business interfaces are encapsulated to obtain a first encapsulated traffic packet, which is then sent to a computer device (testing device). The computer device can parse and filter the first encapsulated traffic packet to obtain traffic pairs and test parameters for each business interface. Based on these pairs and parameters, the business interfaces are tested to obtain test results. This eliminates the need for manual test case writing for each business interface, improving testing efficiency. Furthermore, the same traffic plugin can be used for testing multiple business interfaces, reducing testing costs and increasing plugin utilization.
[0306] It should be understood that the computer device described in the embodiments of this application can execute the interface testing method described in the corresponding embodiments above, or it can execute the interface testing device described in the corresponding embodiments above, and will not be repeated here. In addition, the beneficial effects of using the same method will not be repeated here.
[0307] In practice, the collection and processing of data in this application should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the data subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the data subject.
[0308] Furthermore, it should be noted that this application also provides a computer-readable storage medium storing a computer program executed by the interface testing device mentioned above. This computer program includes program instructions, which, when executed by the processor, enable the execution of the interface testing method described in the corresponding embodiments above. Therefore, further details will not be repeated here. Additionally, the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer-readable storage medium embodiments of this application, please refer to the description of the method embodiments of this application.
[0309] As an example, the above program instructions can be deployed and executed on a computer device, or deployed and executed on at least two computer devices in one location, or executed on at least two computer devices distributed in at least two locations and interconnected by a communication network. At least two computer devices distributed in at least two locations and interconnected by a communication network can form a blockchain network.
[0310] The aforementioned computer-readable storage medium may be the interface testing apparatus provided in any of the foregoing embodiments or the central storage unit of the aforementioned computer device, such as the hard disk or central storage of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, smart memory card (SMC), secure digital (SD) card, flash memory card, etc., provided on the computer device. Furthermore, the computer-readable storage medium may include both the central storage unit and external storage devices of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0311] The terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish content in different media, rather than to describe a specific order. Furthermore, the term "comprising," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0312] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0313] In practice, the collection and processing of data in this application should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the data subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the data subject.
[0314] This application also provides a computer program product, including a computer program. When executed by a processor, the computer program implements the interface testing method and decoding method described in the preceding embodiments, and therefore will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the embodiments of the computer program product involved in this application, please refer to the description of the method embodiments of this application.
[0315] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0316] The methods and related apparatus provided in this application are described with reference to the method flowcharts and / or structural diagrams provided in this application. Specifically, each block of the method flowchart and / or structural diagram, as well as combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable network-connected device to create a machine, such that the instructions, which execute via the processor of the computer or other programmable network-connected device, generate instructions for implementing the process. Figure 1 A schematic diagram of one or more processes and / or structures. Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable network-connected device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 A schematic diagram of one or more processes and / or structures. Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable network-connected device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 A process or multiple processes and / or structures illustrate the steps of the functions specified in one or more boxes.
[0317] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. An interface testing method, characterized in that, include: Receive the first encapsulated traffic packet sent by the traffic plugin in the business application; The first encapsulated traffic package is obtained by the traffic plugin by encapsulating the test parameters corresponding to the N business interfaces of the application and the first traffic set, the first traffic set including the traffic obtained by the traffic plugin from the kernel interface of the application; N is a positive integer; The first encapsulated traffic packet is parsed to obtain the first traffic set and the test parameters corresponding to the N service interfaces; From the first traffic set, traffic pairs associated with the N business interfaces are selected respectively; each traffic pair includes the original request traffic received by the corresponding business interface, and the original response traffic returned by the corresponding business interface in response to the original request traffic; Based on the test parameters corresponding to the N service interfaces and the traffic pairs corresponding to the N service interfaces respectively, the N service interfaces are tested to obtain the test results.
2. The method as described in claim 1, characterized in that, The step of filtering out traffic pairs associated with the N service interfaces from the first traffic set includes: Obtain the traffic filtering rules of the business application; According to the traffic filtering rules, the traffic in the first traffic set is filtered to obtain the filtered first traffic set. Based on the filtered first traffic set, determine the traffic pairs associated with the N service interfaces respectively.
3. The method as described in claim 2, characterized in that, The step of determining the traffic pairs associated with the N service interfaces based on the filtered first traffic set includes: Based on the dependencies between business interfaces in the business application and the stability of the business interfaces, determine the target business interface associated with the test auxiliary data from the N business interfaces; Obtain the initial request traffic and initial response traffic of the target business interface from the first traffic set; Based on the test auxiliary data, the initial response traffic of the target business interface is adjusted to obtain the adjusted initial response traffic. Based on the test auxiliary data, the initial request traffic of the target business interface is adjusted to obtain the adjusted initial request traffic. The adjusted initial request traffic and the adjusted response traffic are sent to the target service interface; The response traffic returned by the target service interface based on the adjusted initial request traffic and the adjusted response traffic is used as the original response traffic of the target service interface. The initial request traffic of the target business interface is used as the original response traffic of the target business interface.
4. The method as described in claim 1, characterized in that, The step involves testing the N service interfaces based on the test parameters corresponding to the N service interfaces and the traffic pairs corresponding to the N service interfaces, and obtaining test results, including: Based on the test parameters corresponding to the N business interfaces, test cases corresponding to the N business interfaces are obtained; the test cases are generated based on the traffic in the kernel interface when the business application is in a stable state. Based on the test cases and test parameters corresponding to the N business interfaces, and the traffic pairs corresponding to the N business interfaces respectively, the N business interfaces are tested to obtain the test results.
5. The method as described in claim 4, characterized in that, When N is greater than 1, the test case includes N test steps, and each test step includes the corresponding test request traffic and the test response traffic corresponding to the test request traffic; The step involves testing the N business interfaces based on the test cases and test parameters corresponding to the N business interfaces, and the traffic pairs corresponding to the N business interfaces respectively, to obtain test results, including: When the test parameters corresponding to the N business interfaces indicate that the test types of the N business interfaces all belong to the same scenario test type, obtain the acquisition time of the traffic pairs corresponding to the N business interfaces respectively; Based on the acquisition time of the traffic pairs corresponding to the N business interfaces, the request order corresponding to the N business interfaces is determined. Based on the request order corresponding to each of the N business interfaces, the test request traffic and test response traffic corresponding to each of the N test steps, and the traffic pairs corresponding to each of the N business interfaces, the N business interfaces are tested to obtain the test results.
6. The method as described in claim 5, characterized in that, The test results are obtained by testing the N business interfaces based on the request order corresponding to each of the N business interfaces, the test request traffic and test response traffic included in each of the N test steps, and the traffic pairs corresponding to each of the N business interfaces, including: Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N; Determine the second similarity between the test response traffic in the i-th test step and the original response traffic in the i-th traffic pair; Based on the first similarity and the second similarity, the test result of the business interface corresponding to the i-th traffic pair is determined.
7. The method as described in claim 5, characterized in that, The test results are obtained by testing the N business interfaces based on the request order corresponding to each of the N business interfaces, the test request traffic and test response traffic included in each of the N test steps, and the traffic pairs corresponding to each of the N business interfaces, including: Determine the first similarity between the test request traffic in the i-th test step and the original request traffic in the i-th traffic pair; the i-th traffic pair is the traffic pair of the business interface with request order i, where i is a positive integer less than or equal to N; From the test response traffic included in each of the N test steps, obtain the test response traffic of the last test step; from the traffic pairs corresponding to the N business interfaces, obtain the original response traffic of the business interface whose request order is the last. Determine the third similarity between the test response traffic where the test step is last and the original response traffic of the business interface where the request order is last; The test results of the N business interfaces are determined based on the third similarity and the first similarity corresponding to the original request traffic of the N business interfaces.
8. The method as described in claim 4, characterized in that, The test cases include the test request traffic corresponding to the N business interfaces and the test vector traffic corresponding to each test request traffic; The step involves testing the N business interfaces based on the test cases and test parameters corresponding to the N business interfaces, and the traffic pairs corresponding to the N business interfaces respectively, to obtain test results, including: When the test parameters corresponding to the N business interfaces indicate that the test types of the N business interfaces all belong to the single interface test type, determine the fourth similarity between the test request traffic and the original request traffic of each business interface; Determine the fifth similarity between the test response traffic and the original response traffic for each business interface; Based on the fourth and fifth similarity scores corresponding to the N business interfaces, the test results corresponding to the N business interfaces are determined.
9. The method as described in claim 2, characterized in that, The method further includes: The system receives a second encapsulated traffic packet sent by the service device corresponding to the service application. The second encapsulated traffic packet is obtained by the service device by encapsulating a second traffic set. The second traffic set includes the traffic obtained by the traffic plugin from the kernel interface when the service application is in a stable state. The second encapsulated traffic packet is parsed to obtain the second traffic set; The traffic pairs of the interfaces to be tested are selected from the second traffic set; the interfaces to be tested include the N service interfaces; Based on the traffic pairs of the interface to be tested, generate test cases for the interface to be tested.
10. The method as described in claim 9, characterized in that, The step of generating test cases for the interface under test based on the traffic pairs of the interface under test includes: The dynamic data in the initial request traffic of the traffic pair of the interface to be tested is replaced with a specified character to obtain the processed initial request traffic of the interface to be tested. Delete the dynamic data in the initial response traffic of the traffic pair of the interface to be tested to obtain the processed initial response traffic of the interface to be tested; Based on the processed initial request traffic and processed initial response traffic of the interface to be tested, test cases are generated for the interface to be tested.
11. The method as described in claim 10, characterized in that, The step of generating test cases for the interface under test based on the processed initial request traffic and processed initial response traffic includes: When the initial request traffic after processing of the interface to be tested meets the simulation rules, the initial response traffic after processing of the interface to be tested is adjusted according to the configuration information corresponding to the simulation rules to obtain the test response traffic of the interface to be tested. The initial request traffic of the interface to be tested is used as the test request traffic of the interface to be tested; Based on the test request traffic and test response traffic of the interface to be tested, determine the test cases for the interface to be tested.
12. An interface testing device, characterized in that, include: The receiving module is used to receive the first encapsulated traffic packet sent by the traffic plugin in the business application. The first encapsulated traffic package is obtained by the traffic plugin by encapsulating the test parameters corresponding to the N business interfaces of the application and the first traffic set, the first traffic set including the traffic obtained by the traffic plugin from the kernel interface of the application; N is a positive integer; The parsing module is used to parse the first encapsulated traffic packet to obtain the first traffic set and the test parameters corresponding to the N service interfaces; The filtering module is used to filter out traffic pairs associated with the N service interfaces from the first traffic set; each traffic pair includes the original request traffic received by the corresponding service interface and the original response traffic returned by the corresponding service interface in response to the original request traffic. The testing module is used to test the N service interfaces based on the test parameters corresponding to the N service interfaces and the traffic pairs corresponding to the N service interfaces respectively, and obtain the test results.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.