Interface automation continuous integration test method, device, equipment and storage medium
By collecting and cleaning traffic data, generating a set of test cases and executing them automatically, the problem of high labor costs in traditional interface testing is solved and efficient automated testing is achieved.
Patent Information
- Application Number
- CN202110240392.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-04
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2041-04-14
AI Technical Summary
Traditional interface testing requires manual packet capture and test case writing, resulting in high labor costs and low efficiency.
Collect online traffic data, clean the data and generate target traffic data, use the combination generation tool to generate the target test case set, and distribute the execution through the test machine information scheduling, and finally make assertion results judgment.
Automated interface testing is achieved, which reduces manual intervention and improves testing efficiency and accuracy.
Smart Images

Figure CN115017027B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of testing, in particular to an interface automatic continuous integration test method and device, computer equipment and storage medium. BACKGROUND
[0002] Application Programming Interface Testing (API testing) is a software testing method, which verifies the performance indicators such as function completeness, reliability and security of services by calling APIs in the integration testing process.
[0003] The traditional interface test data needs to be manually captured and tested by the user, and the human cost of interface testing is very large. SUMMARY
[0004] The present application provides an interface automatic continuous integration test method and device, computer equipment and storage medium, which is used to realize automatic interface testing.
[0005] The present application provides an interface automatic continuous integration test method, which comprises the following steps:
[0006] Collecting traffic data on the line, and performing data cleaning on the collected traffic data to obtain cleaned target traffic data;
[0007] Calling a combination generation tool to generate a target test case set based on the target traffic data; the target test case set is used for testing cases of target interfaces or target services;
[0008] Scheduling and distributing the target test case set based on test machine information to perform, and obtaining the corresponding execution result;
[0009] Asserting the execution result according to the expected result corresponding to the target test case set to obtain an assertion result.
[0010] The present application provides an interface automatic continuous integration test device, which comprises the following steps:
[0011] The acquisition module collects traffic data on the line, and performs data cleaning on the collected traffic data to obtain cleaned target traffic data;
[0012] The generation module is configured to call a combination generation tool to generate a target test case set based on the target traffic data; the target test case set is used for testing cases of target interfaces or target services;
[0013] An execution module is configured to schedule and distribute execution of the target test case set based on test machine information, and obtain corresponding execution results.
[0014] A determination module is configured to perform assertion on the execution results according to expected results corresponding to the target test case set, and obtain assertion results.
[0015] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the interface automatic continuous integration test method when executing the computer program.
[0016] A computer readable storage medium stores a computer program, and the computer program is executable on a processor to implement the interface automatic continuous integration test method.
[0017] The application provides an interface automatic continuous integration test method and device, a computer device, and a storage medium. Traffic data on a line is collected, and the collected traffic data is cleaned to obtain target traffic data after cleaning. A combination generation tool is called to generate a target test case set based on the target traffic data. The target test case set is used for testing a target interface or a target service. The target test case set is scheduled and distributed for execution based on test machine information, and corresponding execution results are obtained. The execution results are asserted according to expected results corresponding to the target test case set, and assertion results are obtained. Thus, the application realizes automatic interface testing. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 An interface automatic continuous integration test method flowchart is provided for an embodiment of the application.
[0019] Figure 2 A flowchart for generating a target test case set is provided for an embodiment of the application.
[0020] Figure 3 A flowchart for generating a target test case set is provided for an embodiment of the application.
[0021] Figure 4 A flowchart for screening test cases meeting conditions as test cases is provided for an embodiment of the application.
[0022] Figure 5 A flowchart for screening test cases meeting conditions as test cases is provided for an embodiment of the application.
[0023] Figure 6 A structural block diagram of an interface automatic continuous integration test device is provided for an embodiment of the application.
[0024] Figure 7 A schematic diagram of a computer device is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to better understand the above technical solutions, the technical solutions of the embodiments of the present application will be described in detail below through the drawings and specific embodiments. It should be understood that the specific features in the embodiments of the present application and the embodiments are detailed descriptions of the technical solutions of the embodiments of the present application, and are not limitations of the technical solutions of the present application. In the case of no conflict, the technical features in the embodiments of the present application and the embodiments can be combined with each other.
[0026] Please refer to Figure 1 , which is an interface automatic continuous integration test method in the embodiments of the present application, and the method specifically includes steps S101-S104.
[0027] S101, collecting flow data on the line, and performing data cleaning on the collected flow data to obtain cleaned target flow data.
[0028] In the present embodiment, the flow data can be collected at regular intervals, or the flow data can be collected in real time to ensure the perception and recording of new access increments.
[0029] In order to ensure the security of the data in the flow data, the sensitive information in the obtained flow data needs to be replaced and desensitized. Specifically, the collected flow data is cleaned to obtain cleaned target flow data, including: when the collected flow data contains first type flow data belonging to a specified service, the website parameter contained in the first type flow data is replaced with a preset desensitized website parameter to obtain the cleaned target flow data; when the collected flow data contains second type flow data of a specified type information, the specified type information contained in the second type flow data is desensitized to obtain the cleaned target flow data.
[0030] Specifically, the collected flow data is cleaned according to a preset rule library to obtain cleaned target flow data. According to different business needs, the request data involved in the obtained target flow data is replaced and subsequently intervened by setting rules. Among them, it includes the url parameter of the get method in the http request, and the url parameter and the body parameter of the post request. Customized replacement of different fields. The purpose of replacement is to determine the sensitive information that the target flow data may involve by different business parties.
[0031] In an embodiment provided by the application, parameters in the target traffic data that have no influence on coverage and the number of optional values of which is greater than a preset number of optional values are deleted. For example, there are a large number of common parameters such as user_id and device_id in the business, the number of optional values of which is large but has little influence on code coverage, and therefore these common parameters need to be deleted.
[0032] In S102, a combination generation tool is invoked to generate a target test case set based on the target traffic data; the target test case set is used for testing a target interface or a target service.
[0033] The generation of the target test case set is performed by extracting a batch of common parameters (the batch of parameters can belong to different secondary requests) from the target traffic data recorded for each interface; by a preset combination algorithm, the parameters are combined two by two to increase the number of expanded test cases, and finally the target test case set is generated.
[0034] In S103, the target test case set is scheduled and distributed for execution based on tester machine information, and a corresponding execution result is obtained.
[0035] In the embodiment of the application, the scheduling and distribution of execution can poll the state of the current test case, disperse the request, schedule and distribute the execution of the target test case set, and obtain the corresponding execution result. The scheduling and distribution of execution improve the efficiency of actual request calling of a large number of test cases, and at the same time avoid the influence of a large number of requests on the online service caused by simultaneous execution.
[0036] In S104, an assertion result is obtained by asserting the execution result according to the expected result corresponding to the target test case set.
[0037] For the test cases in the target test case set that meet the expectation, the parameter common part of the common part of the test cases is obtained by incrementally calculating and combining the common parameters extracted by a corresponding algorithm. The parameter common part is a part that is carried in the request header / request parameter / request body of each request; the common part of the assertion is a field that is included in the response obtained by each request, and is stored offline as an expected assertion result.
[0038] If the interface information changes (when the number of parameters / parameter types does not match the original assertion, it is possible that the interface information has changed, by extracting parameters from the response obtained after the request), the expected assertion result generated previously is automatically calculated and updated dynamically.
[0039] In the embodiment of the present application, the result obtained by scheduling execution is asserted, the expected result is pulled from the offline service, and the actual result is compared with the data type to determine whether they are consistent. If they are consistent, it is determined that the use case execution is successful, and if they are not consistent, it is determined that the use case execution fails. Then, according to the execution results of each test case, the interface test results and / or service test results are counted for the measured interface and / or measured service; the interface test results and / or service test results and the related use case execution details are saved in the form of files in the cloud, and the specified users are notified of the saved file contents in the form of notifications.
[0040] The present application provides an interface automatic continuous integration test method, collects traffic data on a line, and performs data cleaning on the collected traffic data to obtain cleaned target traffic data; a combination generation tool is called to generate a target test case set based on the target traffic data; the target test case set is used for a use case for testing a target interface or a target service; the target test case set is dispatched and executed based on test machine information, and the corresponding execution result is obtained; and the execution result is asserted according to the expected result corresponding to the target test case set to obtain an assertion result. Thus, the present application realizes automatic interface testing.
[0041] As shown in Figure 2 and Figure 3 In one embodiment provided by the present application, the target traffic data includes a plurality of parameters, and optional values and the number of optional values corresponding to the parameters, respectively. The combination generation tool is called to generate a target test case set based on the target traffic data, which includes:
[0042] S201, determining whether the number of optional values of the parameter is greater than a first preset value.
[0043] The first preset value can be set according to the number of test cases to be generated, or can be determined according to the time required to generate test cases, which is not limited in the embodiment of the present application. It can be understood that the greater the number of test cases to be generated, or the longer the time required to generate test cases, the greater the first preset value can be set.
[0044] S202, if the number of optional values of the parameter is greater than the first preset value, a fixed number of candidate cases are generated according to the target traffic data.
[0045] For example, the first preset value is 100, and if the number of parameters with more than 100 optional values in the target traffic data exceeds 5, a fixed number of candidate cases are generated according to the target traffic data, so as to select the test cases meeting the conditions from the generated candidate cases in the subsequent steps.
[0046] Specifically, the embodiment generates a fixed number of candidate test cases based on adaptive random testing (ART). It should be noted that, since the target traffic data in the embodiment contains multiple parameters, in the process of determining the number of optional values of the parameters, it is necessary to determine whether the number of optional values of the parameters of the preset parameter number is greater than the preset number, wherein the preset parameter number can be 4, 5, 6, etc., and the embodiment of the application does not make specific limitation. For example, if the number of parameters with more than 100 optional values in the target traffic data is more than 5, the target traffic data is generated into a fixed number of candidate test cases through adaptive random testing.
[0047] S203, filtering out a test case that meets a preset condition from the candidate test cases as a test case.
[0048] The preset condition can be specifically a test case that is most different from the executed test cases, so as to filter out a boundary test case that has a greater probability of covering the input domain from the candidate test cases as a test case.
[0049] S204, taking the test case as a test case in the target test case set.
[0050] In the embodiment, it is determined whether the number of optional values of the parameters is greater than a first preset value; if the number of optional values of the parameters is greater than the first preset value, a fixed number of candidate test cases are generated according to the target traffic data; and a test case that meets a preset condition is filtered out from the candidate test cases. Compared with the current traditional combination test, the application first generates a fixed number of candidate test cases when the number of optional values of the parameters is greater than the first preset value, and then filters out a preset number of test cases that meet the preset condition from the candidate test cases as test cases, so as to avoid a large amount of time occupied by the generation of test cases, reduce the number of generated test cases, and further improve the test efficiency.
[0051] S205, if the number of optional values of the parameters is less than or equal to the first preset value and greater than a second preset value, the second preset value of the optional values of the parameters whose number of optional values exceeds the second preset value is filtered out from the corresponding optional values.
[0052] The first preset value is greater than the second preset value.
[0053] In the embodiment, if the number of optional values of the parameter is less than or equal to the first preset value and greater than the second preset value, a concealed information test (CIT) is used to eliminate parameters with a large number of optional values and no influence on coverage, and then the upper limit of the number of optional values of the parameter is limited to the second preset value. Specifically, a certain number of optional values can be randomly extracted from the parameters with optional values exceeding the second preset value. For example, for the parameter with a number of optional values exceeding 50, the data exceeding the number is uniformly selected from the entire input range. If the generated test cases are still too many, the test cases are randomly discarded instead of replacing the old test cases with new test cases, so as to ensure that the test cases cover the input domain range.
[0054] In the embodiment, if the number of optional values of the parameter is less than or equal to the second preset value, the test cases are generated according to the combination test.
[0055] In S206, the test cases are generated according to the parameters and the corresponding screened optional values, and the generated test cases are used as the test cases in the target test case set.
[0056] In S207, if the generated test cases are greater than the preset number of test cases, the generated test cases are randomly discarded.
[0057] Further, if the number of optional values of the parameter is less than or equal to the second preset value, the test cases in the target test case set are determined by the combination test.
[0058] The interface automatic continuous integration test method provided in the embodiment determines the corresponding interface automatic continuous integration test method according to the number of optional values of the parameter, that is, when the number of optional values is limited, CIT is used to generate test cases, so as to ensure code coverage and error detection rate; when the number of optional values is large, optimized CIT is used to generate test cases, parameters with a large number of optional values and no influence on coverage are eliminated, the number of optional values of the parameter is limited, for the data exceeding the number, the data is uniformly selected from the entire input range, if the generated test cases are still too many, the test cases are randomly discarded instead of replacing the old with the new, so as to ensure that the test cases cover the input domain range; when the number of optional values is very large, ART is used to generate candidate test cases, and then the test cases are determined from the candidate test cases by case difference, so as to ensure the coverage of the test cases.
[0059] Referring to Figure 4 and Figure 5 , an interface automatic continuous integration test method in the embodiment is shown, the test cases meeting the preset conditions are screened from the candidate test cases, and the test cases are generated, including:
[0060] S301, calculate the parameter difference between each candidate use case in the fixed number of candidate use cases and the already executed use case.
[0061] A fixed number of candidate use cases are randomly generated before a new test use case is generated. A best candidate use case is selected as a test use case through a screening standard. The screening standards that can be selected include maxi-min, maxi-maxi, maxi-sum, etc.
[0062] maxi-min: the distance (difference, for non-numeric input) between each candidate use case and the nearest (the smallest difference, for non-numeric input) already executed use case is counted, and the candidate use case with the largest distance in the nearest use cases is selected as the selected test use case;
[0063] maxi-maxi: the distance (difference, for non-numeric input) between each candidate use case and the farthest (the largest difference, for non-numeric input) already executed use case is counted, and the candidate use case with the largest distance in the farthest use cases is selected as the selected test use case;
[0064] maxi-sum: the sum of the distance (difference, for non-numeric input) between each candidate use case and each already executed use case is counted, and the candidate use case with the largest sum is selected as the selected test use case.
[0065] The ART has little overall difference for the results of the above various screening standards. Since the range of the input domain and the data are not continuous (only discrete recorded traffic), it is more suitable to generate use cases through the election method. The ART based on maxi-min has a greater probability of covering the boundary of the input domain, and the boundary value is more prone to errors.
[0066] For the embodiment of the application, after generating candidate use cases according to the target traffic data, the candidate use case is determined from the candidate use cases based on the maxi-min standard. Since the ART based on maxi-max has a greater probability of covering the boundary of the input domain, and the boundary value is more prone to errors, the test use case selected from the candidate use cases through this standard can better guarantee the coverage rate and error detection rate of the test use case.
[0067] S302, select the candidate use case with the largest parameter difference from the already executed use case as the test use case.
[0068] S303, determine whether the number of selected test use cases reaches the preset number.
[0069] The preset number is the number of test use cases that need to be generated.
[0070] S304, if the preset number is not reached, re-randomly generating a fixed number of candidate use cases according to the target traffic data, and screening the use cases meeting the preset conditions from the candidate use cases as test cases until the number of generated test cases reaches the preset number.
[0071] The interface automatic continuous integration test method provided by the embodiment of the application first calculates the parameter difference between each candidate use case in a fixed number of candidate use cases and the already executed use case, selects the candidate use case with the largest parameter difference from the already executed use case as a test case, then judges whether the number of selected test cases reaches a preset number, if the preset number is not reached, re-randomly generates a fixed number of candidate use cases according to the target traffic data, and screens the use cases meeting the preset conditions from the candidate use cases as test cases until the number of generated test cases reaches the preset number. That is, the embodiment guarantees the coverage rate of test cases by comparing the difference of the executed use cases, thereby improving the test effect.
[0072] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiment of the application.
[0073] In an embodiment, an interface automatic continuous integration test device is provided, which corresponds to the interface automatic continuous integration test method in the above embodiment. As shown in the figure, the interface automatic continuous integration test device comprises an acquisition module 10, a generation module 20, an execution module 30 and a determination module 40. The functions of each functional module are described in detail as follows: Figure 6
[0074] The acquisition module 10 collects the traffic data on the line and performs data cleaning on the collected traffic data to obtain cleaned target traffic data;
[0075] The generation module 20 is configured to call a combination generation tool to generate a target test case set based on the target traffic data; the target test case set is used for use cases for testing a target interface or a target service;
[0076] The execution module 30 is configured to schedule and distribute the execution of the target test case set based on test machine information, and obtain the corresponding execution result;
[0077] The determination module 40 is configured to perform assertion on the execution result according to the expected result corresponding to the target test case set to obtain an assertion result.
[0078] Specifically, the target traffic data comprises a plurality of parameters, and optional values and the number of optional values corresponding to the parameters, respectively, and the generation module 20 comprises:
[0079] determining whether the number of selectable values of the parameter is greater than a first preset value;
[0080] generating a fixed number of candidate cases randomly according to the target traffic data if the number of selectable values of the parameter is greater than the first preset value;
[0081] screening a case meeting a preset condition from the candidate cases as a test case;
[0082] The generating unit is further configured to take the test case as a case in a target test case set.
[0083] The screening unit is configured to, if the number of selectable values of the parameter is less than or equal to the first preset value and greater than a second preset value, screen the second preset number of selectable values of a parameter whose number of selectable values exceeds the second preset value from the corresponding selectable values.
[0084] The generating unit is configured to generate the test case according to the parameter and the corresponding screened selectable values.
[0085] The deleting unit is configured to, if the generated test case is greater than a preset number of cases, discard the generated test case randomly.
[0086] The generating unit is configured to, if the number of selectable values of the parameter is less than or equal to the second preset value, determine a case in a target test case set by a combination test mode.
[0087] Specifically, the screening module is configured to:
[0088] calculate a parameter difference between each candidate case in the fixed number of candidate cases and a case that has been executed;
[0089] select a candidate case with a largest parameter difference from the case that has been executed as the test case;
[0090] determine whether the number of selected test cases reaches a preset number;
[0091] if the preset number is not reached, randomly generate a fixed number of candidate cases again according to the target traffic data;
[0092] screen a case meeting a preset condition from the candidate cases as a test case;
[0093] if the preset number is reached, determine that the test case is generated completely.
[0094] Further, the apparatus further comprises:
[0095] The statistical module is configured to statistically test results of interfaces and / or service test results of services for the measured interfaces and / or the measured services according to execution results of respective test cases.
[0096] The storage module is configured to save the test results of interfaces and / or the service test results and related case execution details in a file form in the cloud, and notify a specified user of the saved file content in a notification form.
[0097] The acquisition module 10 is specifically configured to, when the collected traffic data contains first type traffic data belonging to a specified service, replace a website parameter contained in the first type traffic data with a preset desensitization website parameter to obtain cleaned target traffic data.
[0098] When the collected traffic data contains second type traffic data containing specified type information, the specified type information contained in the second type traffic data is desensitized to obtain cleaned target traffic data.
[0099] The determination module 40 is specifically configured to:
[0100] Determine whether the expected result of each test case in the target test case set is consistent with the corresponding execution result;
[0101] If the expected result is consistent with the corresponding execution result, it is determined that the test case is executed successfully.
[0102] If the expected result is not consistent with the corresponding execution result, it is determined that the test case is executed unsuccessfully.
[0103] The specific definition of the device can refer to the definition of the interface automatic continuous integration test method in the foregoing, and will not be described here again. Each module in the device can be realized by software, hardware, and a combination thereof in whole or in part. Each module can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to call and execute the operation corresponding to each module by the processor.
[0104] In one embodiment, a computer device is provided, which can be a server, and an internal structure diagram of the computer device can be as shown in Figure 7 The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement an interface automatic continuous integration test method.
[0105] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implements the following steps when executing the computer program:
[0106] Collecting traffic data on a line, and performing data cleaning on the collected traffic data to obtain cleaned target traffic data;
[0107] Calling a combination generation tool to generate a target test case set based on the target traffic data; the target test case set is a use case for testing a target interface or a target service;
[0108] Scheduling and distributing execution of the target test case set based on test machine information, and obtaining corresponding execution results;
[0109] Asserting the execution results according to expected results corresponding to the target test case set to obtain assertion results.
[0110] In one embodiment, a computer readable storage medium is provided, having a computer program stored thereon, the computer program being executed by a processor to implement the following steps:
[0111] Collecting traffic data on a line, and performing data cleaning on the collected traffic data to obtain cleaned target traffic data;
[0112] Calling a combination generation tool to generate a target test case set based on the target traffic data; the target test case set is a use case for testing a target interface or a target service;
[0113] Scheduling and distributing execution of the target test case set based on test machine information, and obtaining corresponding execution results;
[0114] Asserting the execution results according to expected results corresponding to the target test case set to obtain assertion results.
[0115] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0116] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
[0117] The above embodiments are only used to illustrate the technical solutions of the present application, but not limit it. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features. The modification or replacement does not make the essence of the corresponding technical solution deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. An interface automated continuous integration testing method, characterized in that: include: Collect online traffic data and clean the collected traffic data to obtain the cleaned target traffic data; Calling a combination generation tool to generate a target test case set based on the target traffic data; The target test case set is used to test the target interface or target service; Scheduling and distributing the target test case set for execution based on the test machine information, and obtaining corresponding execution results; Asserting the execution result according to the expected result corresponding to the target test case set to obtain an assertion result; The target traffic data includes multiple parameters, and optional values and the number of optional values corresponding to the parameters respectively. The call combination generation tool generates a target test case set based on the target traffic data, including: If the number of optional values of the parameter is greater than a first preset value, generating candidate use cases according to the target traffic data by means of an adaptive random test, and screening out use cases that meet the preset conditions from the candidate use cases as use cases in the target test case set; If the number of optional values of the parameter is less than or equal to the first preset value and greater than the second preset value, filter out the second preset value of optional values from the corresponding optional values, and generate a use case in the target test case set according to the parameter and the corresponding filtered optional values; If the number of optional values of the parameter is less than or equal to the second preset value, the use cases in the target test case set are determined by a combination test method.
2. The method according to claim 1, characterized in that The call combination generation tool generates a target test case set based on the target traffic data, further comprising: If the number of use cases in the generated target test case set is greater than the preset number of use cases, the use cases in the generated target test case set are randomly discarded.
3. The method according to claim 1, characterized in that The step of selecting a use case that meets a preset condition from the candidate use cases includes: Calculate the parameter difference between each candidate use case and the executed use case; Select the candidate use case with the largest parameter difference from the previously executed use case; Determining whether the number of the selected candidate use cases reaches a preset number; If the preset number is not reached, a fixed number of candidate use cases are randomly generated again according to the target traffic data, and use cases that meet the preset conditions are screened out from the candidate use cases; If the preset number is reached, it is determined that the use case generation is completed.
4. The method according to claim 1, wherein The method further comprises: Compiling interface test results and / or service test results for the tested interface and / or the tested service according to the execution results of each test case in the target test case set; The interface test results and / or service test results and related use case execution details are saved in the cloud as files, and the saved file contents are notified to the specified user in the form of notifications.
5. The method according to claim 1, wherein The data cleaning of the collected flow data to obtain cleaned target flow data includes: When the collected traffic data includes first-category traffic data belonging to a designated business, the URL parameters included in the first-category traffic data are replaced with preset desensitized URL parameters to obtain cleaned target traffic data; When the collected traffic data contains second-type traffic data of specified type information, the specified type information contained in the second-type traffic data is desensitized to obtain cleaned target traffic data.
6. The method according to claim 1, characterized in that Asserting the execution result according to the expected result corresponding to the target test case set to obtain an assertion result includes: Determining whether the expected result of each test case in the target test case set is consistent with the corresponding execution result; If they match, it is determined that the test case is executed successfully; If not, it is determined that the test case execution fails.
7. An interface automated continuous integration testing device, characterized in that: The device comprises: The acquisition module collects the online traffic data and cleans the collected traffic data to obtain the cleaned target traffic data; A generation module is used to call a combination generation tool to generate a target test case set based on the target traffic data; the target test case set is a use case for testing a target interface or a target service; An execution module, configured to schedule and distribute the target test case set for execution based on the test machine information, and obtain corresponding execution results; A determination module, configured to assert the execution result according to the expected result corresponding to the target test case set to obtain an assertion result; The target traffic data includes multiple parameters, and optional values and the number of optional values corresponding to the parameters. The generation module is specifically used to: If the number of optional values of the parameter is greater than a first preset value, generating candidate use cases according to the target traffic data by means of an adaptive random test, and screening out use cases that meet the preset conditions from the candidate use cases as use cases in the target test case set; If the number of optional values of the parameter is less than or equal to the first preset value and greater than the second preset value, filter out the second preset value of optional values from the corresponding optional values, and generate a use case in the target test case set according to the parameter and the corresponding filtered optional values; If the number of optional values of the parameter is less than or equal to the second preset value, the use cases in the target test case set are determined by a combination test method.
8. The device according to claim 7, characterized in that The generating module is further specifically configured to: If the number of use cases in the generated target test case set is greater than the preset number of use cases, the use cases in the generated target test case set are randomly discarded.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the interface automated continuous integration testing method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the interface automated continuous integration testing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Co-diversified random testing (CAT) method
CN102629229A
Interface test method and device, computer equipment and storage medium
CN109933524A
Interface test case generation method and device, storage medium and electronic equipment
CN111625473A