Interface testing method, electronic equipment and computer readable storage medium

By parsing the parameters in the interface test data, multiple combinations of test data are generated, and the interface is comprehensively tested, which solves the problems of low efficiency and low credibility of the existing interface test methods and achieves more efficient and reliable interface testing.

CN118860880APending Publication Date: 2024-10-29NIO TECH ANHUI CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410947374.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

Existing interface testing methods have low testing efficiency and low credibility of test results, making it impossible to comprehensively test the interface.

Method used

By obtaining the test request of the interface, parsing the parameters in the test data, generating multiple replacement values ​​according to parameter types and values, generating multiple combinations of test data, and calling these data to test the interface, it improves the comprehensiveness and efficiency of the test.

Benefits of technology

It improves the credibility and efficiency of interface testing, enables more comprehensive testing of interfaces, reduces the need for users to manually enter parameter values, and reduces the probability of generating incorrect test data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118860880A_ABST
    Figure CN118860880A_ABST
Patent Text Reader

Abstract

The invention provides an interface testing method, electronic equipment and a computer readable storage medium. The interface testing method comprises the steps that a testing request for an interface is obtained, the testing request comprises first testing data, the first testing data are analyzed, one or more parameters in the first testing data are obtained, and each parameter comprises a parameter type and a parameter value; determining a plurality of replacement values corresponding to the parameter values according to the parameter types and the parameter values; generating a plurality of second test data according to the plurality of replacement values corresponding to each parameter value; and calling the first test data and the plurality of second test data to test the interface. The second test data is generated according to the plurality of replacement values corresponding to each parameter value, so that the second test data of various combinations can be generated, the test comprehensiveness is improved, the credibility of the test result is further improved, a user does not need to input the second test data after the parameter values are replaced, and the test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of software testing, and in particular, relates to an interface testing method, an electronic device, and a computer-readable storage medium. Background Art

[0002] Fuzz testing of the server interface is a software testing method. By inputting invalid or abnormal data and detecting the interface's response to the input data, the interface's ability to handle abnormal data can be detected, thereby discovering vulnerabilities or errors in the software.

[0003] The existing interface testing method generally requires testers to use test tools to update test parameters and verify the boundary values ​​and abnormal values ​​of the interface. This requires users to perform multiple operations, has low test efficiency, and has little test data. It cannot fully test the interface, and the credibility of the test results is low. Summary of the invention

[0004] In view of this, the embodiments of the present application provide an interface testing method, an electronic device and a computer-readable storage medium, which can solve the problems of low testing efficiency and low reliability of test results of existing interface testing methods.

[0005] A first aspect of an embodiment of the present application provides an interface testing method, comprising:

[0006] Obtaining a test request for an interface, wherein the test request includes first test data, and the first test data is data for accessing the interface;

[0007] Parsing the first test data to obtain one or more parameters in the first test data, each of the parameters including a parameter type and a parameter value;

[0008] Determine, according to the parameter type and the parameter value, a plurality of replacement values ​​corresponding to the parameter value;

[0009] Generate a plurality of second test data according to the plurality of replacement values ​​corresponding to each of the parameter values;

[0010] The first test data and the plurality of second test data are called to test the interface.

[0011] In one embodiment, parsing the first test data to obtain one or more parameters in the first test data includes:

[0012] Recognizing a preset character in the first test data;

[0013] Extracting one or more parameter values ​​and a parameter name corresponding to each parameter value from the first test data according to the position of the preset character;

[0014] The parameter type is determined according to the parameter name.

[0015] In one embodiment, the first test data includes a request header and a request body, the preset characters include a first character and a second character, and the identifying the preset characters in the first test data includes:

[0016] A first character in the request header is identified, and a second character in the request body is identified.

[0017] In one embodiment, generating a plurality of second test data according to the plurality of replacement values ​​corresponding to each of the parameter values ​​includes:

[0018] The first replacement value of the first parameter is combined with each replacement value of the second parameter in sequence, and the multiple second test data are obtained according to the combination results; the first parameter is one of the multiple parameters, the first replacement value is one of the multiple replacement values ​​of the first parameter, and the second parameter is a parameter of the multiple parameters except the first parameter.

[0019] In one embodiment, determining, according to the parameter type and the parameter value, a plurality of replacement values ​​corresponding to the parameter value includes:

[0020] Determining a range of replacement values ​​according to the parameter type;

[0021] A plurality of replacement values ​​corresponding to the parameter value are determined according to the range of the replacement value and the parameter value.

[0022] In one embodiment, the first test number is generated according to a historical access record of the interface.

[0023] In one embodiment, calling the first test data and the plurality of second test data to test the interface includes:

[0024] Calling the first test data and the plurality of second test data in sequence to access the interface;

[0025] Acquire multiple response results of the interface to the first test data and the multiple second test data;

[0026] A test result of the interface is determined according to the multiple response results.

[0027] In one embodiment, the method further comprises:

[0028] A plurality of executable scripts are generated according to the first test data and the plurality of second test data, and the plurality of executable scripts are output.

[0029] A second aspect of an embodiment of the present application provides an interface testing device, including:

[0030] An acquisition module, used for acquiring a test request for an interface, wherein the test request includes first test data, and the first test data is data for accessing the interface;

[0031] A parsing module, used for parsing the first test data to obtain one or more parameters in the first test data, each of the parameters including a parameter type and a parameter value;

[0032] A determination module, configured to determine a plurality of replacement values ​​corresponding to the parameter value according to the parameter type and the parameter value;

[0033] A replacement module, used for generating a plurality of second test data according to the plurality of replacement values ​​corresponding to each of the parameter values;

[0034] A testing module is used to call the first test data and the plurality of second test data to test the interface.

[0035] A third aspect of an embodiment of the present application provides an electronic 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 testing method as described in the first aspect above is implemented.

[0036] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the interface testing method as described in the first aspect above is implemented.

[0037] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the interface testing method described in any one of the first aspects above.

[0038] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by obtaining the first test data for the interface, determining one or more parameters in the first test data, determining multiple replacement values ​​corresponding to each parameter value according to the parameter type and parameter value of each parameter, generating multiple second test data according to the multiple replacement values ​​corresponding to each parameter value, and calling the first test data and the second test data to test the interface. Since the second test data is generated according to the multiple replacement values ​​corresponding to each parameter value, multiple combinations of second test data can be generated, which improves the comprehensiveness of the test, thereby improving the credibility of the test results, and does not require the user to input the second test data after the parameter value is replaced, thereby improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art.

[0040] Figure 1 This is a schematic diagram of the implementation flow of the interface testing method provided in one embodiment of the present application;

[0041] Figure 2 is a flow chart of the interface testing method provided in an embodiment of the present application;

[0042] Figure 3 is a schematic diagram of an interface testing device provided in an embodiment of the present application;

[0043] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0045] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0046] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0047] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0048] In addition, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0049] In addition to conventional functional testing, the interface test of the server also includes fuzz testing. Fuzz testing is to input random, invalid or abnormal data into the system to detect the interface's ability to handle abnormal access. Through fuzz testing, system vulnerabilities or errors can be discovered, thereby improving the stability and security of the system. In the prior art, testers are generally required to input abnormal data multiple times for interface testing, which has low test efficiency and a small number of tests. It is impossible to fully test the interface, and the credibility of the test results is low.

[0050] To this end, the present application provides an interface testing method, which determines multiple replacement values ​​corresponding to each parameter value according to the parameter type and parameter value of multiple parameters in the first test data, generates multiple second test data according to the multiple replacement values ​​corresponding to each parameter value, thereby generating multiple combinations of second test data, and then tests the interface according to the first test data and multiple second test data, so that the interface can be tested more comprehensively, and the credibility of the test results is improved. At the same time, since the user does not need to input the second test data after the parameter value is replaced, the test efficiency is improved.

[0051] The interface testing method provided by this application is described in detail below.

[0052] The interface testing method provided in the embodiment of the present application is executed on an electronic device, which may be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server.

[0053] Please see attached Figure 1 , an interface testing method provided by an embodiment of the present application includes:

[0054] S101: Obtain a test request for an interface, wherein the test request includes first test data.

[0055] Specifically, the electronic device may acquire the first test data when detecting a test request input by the user. The first test data may include one test data or multiple test data.

[0056] The first test data is the data of the access interface, including one or both of the request header and the request body. The request header is the metadata used to describe an HTTP request in the HTTP protocol, including the relevant configuration and requirements of the client. Exemplarily, the request header is generally the link address of the access interface. The request body is used in the HTTP protocol to carry the parameters, content or data required by the client to send a request to the server. For example, the request body is a lightweight data exchange format (JavaScript Object Notation, JSON) type data.

[0057] Exemplarily, when the electronic device detects that the user clicks the "fuzzy test" option, the electronic device displays an input box for the first test data on the display interface of the electronic device for the user to input the first test data.

[0058] The electronic device may obtain the first test data directly input by the user, or may display a test data list on a display interface, and use the test data selected by the user from the test data list as the first test data. Exemplarily, the test data displayed in the test data list may be generated based on the historical access records of the user access interface. For example, the electronic device pre-captures the historical access records of the access interface, uses the historical access records directly as the test data in the test data list, and combines or replaces the parameter values ​​in the historical access records to obtain the test data in the test data list.

[0059] S102: Parse the first test data to obtain one or more parameters in the first test data, each of the parameters including a parameter type and a parameter value.

[0060] In one embodiment, after obtaining the first test data, the electronic device identifies the preset characters in the first test data, extracts the parameter names and parameter values ​​of one or more parameters from the first test data according to the positions of the preset characters, determines the parameter type according to the parameter name, and thereby obtains each parameter value and the corresponding parameter type. Among them, the preset characters may be symbols such as "?", "&", ":", " / ", "=", "{}", "". The parameter type may include the parameter type in the request header and the parameter type in the request body. For example, the parameter types in the request header include user name, serial number, etc., and the parameter types in the request body include numeric type, array type, Boolean type, overlong string type, SQL statement, HTTP type, TCP protocol, empty value, and Null value, etc.

[0061] Exemplarily, the electronic device identifies the first character in the request header, and extracts the parameter value and parameter name from the request header according to the position of the first character. For example, the first character is "?", "&", and "=". The electronic device identifies the "?" in the request header, identifies the "&" after the "?", and then obtains the character string between the "?" and "&", and between two "&", each of which includes a parameter name and a corresponding parameter value. For each character string, the "=" is identified, and the character strings on both sides of the "=" are the parameter name and parameter value, respectively. According to the parameter name, the parameter type can be determined.

[0062] For example, if the string between two "&" is user_id=abc, then the parameter name is user_id, the parameter value is abc, and the parameter type is user name. For another example, if the string between two "&" is "productcode=F1", then the parameter name is productcode, the parameter value is F1, and the parameter type is serial number.

[0063] The electronic device identifies the second character in the request body, and extracts the parameter value and parameter name from the request body according to the position of the second character. For example, the second character is "{}", "":" and ":". The electronic device identifies the "{}" in the request body, and identifies the string in "":" within the "{}". For each string, the strings on both sides of ":" are the parameter name and parameter value respectively, and the parameter type can be determined based on the parameter name.

[0064] For example, if the string in "" is param:1, the parameter name is param, the parameter value is 1, and the parameter type is a numeric type.

[0065] In another embodiment, the electronic device may also extract each parameter value from the first test data, and determine the parameter type corresponding to the parameter value according to the position of each parameter value in the first test data. For example, each parameter value in the first test data is extracted in sequence and sorted, and the position of the parameter value in the first test data is determined according to the arrangement order of the parameter values.

[0066] In another embodiment, the first test data may also be input into a pre-trained parameter analysis model to obtain one or more parameters output by the parameter analysis model.

[0067] S103: Determine, according to the parameter type and the parameter value, a plurality of replacement values ​​corresponding to the parameter value.

[0068] Specifically, a range of replacement values ​​corresponding to each parameter type is preset in a plurality of parameter types. After obtaining the parameter type and the parameter value, the electronic device determines the range of replacement values ​​corresponding to the parameter type, and determines multiple replacement values ​​corresponding to the parameter value according to the range of replacement values ​​and the parameter value. Exemplarily, the values ​​within the replacement value range excluding the parameter value are used as replacement values.

[0069] For example, if the parameter type is user name and the parameter value is abc, the number of characters in the replacement value is 3, and the replacement value is a combination of letters other than abc and special characters (such as emoticons, separators, etc.). For another example, if the parameter type is factory name and the parameter value is F1, the replacement value range is F1 to F20, and the replacement value includes F2 to F20. For another example, if the parameter type is numeric type and the parameter value is 5, the replacement value range is 1 to 100, and the replacement value is an integer between 1 and 100 except 5. For another example, if the parameter type is SQL statement and the parameter value is select statement, the replacement value range is all SQL statements.

[0070] In one embodiment, a replacement value list corresponding to each parameter type may be preset and stored. After obtaining the parameter type and parameter value, the electronic device searches the replacement value list corresponding to the parameter type to obtain multiple replacement values ​​corresponding to the parameter value.

[0071] In one embodiment, the electronic device may also modify the range of replacement values ​​or the replacement value list according to the modification instruction input by the user, so as to meet the test requirements of the user.

[0072] In one embodiment, the interface testing method provided in the embodiment of the present application can test multiple interfaces, and the electronic device determines the corresponding replacement value range or replacement value list according to the interface identifier and parameter type. The interface identifier can be input by the user or determined according to the historical access record of the interface.

[0073] S104: Generate a plurality of second test data according to the plurality of replacement values ​​corresponding to each of the parameter values.

[0074] Specifically, for one of the replacement values ​​(first replacement value) of one of the parameters (first parameter), the first replacement value is sequentially combined with each replacement value of the other parameter (second parameter) to obtain new test data. The positions of the first replacement value and each replacement value of the second parameter in the new test data are the same as the positions of the corresponding parameter values ​​in the first test data, so that the new test data can be generated based on the input specification and grammar rules of the first test data, ensuring that the generated test data can access the interface.

[0075] For other replacement values ​​of the first parameter, the above method is used to obtain new test data, and all new test data are the second test data. The second test data includes test data composed of all combinations of all replacement values, that is, it includes all access requests within the range of replacement values. For example, the first test data includes 3 parameters, each parameter corresponds to 10 replacement values, and all replacement values ​​are traversed and combined. The number of second test data obtained is 10*10*10=1000, so that multiple second test data can be guaranteed to have high variability and coverage, and the interface can be tested more fully.

[0076] S105: Call the first test data and the plurality of second test data to test the interface.

[0077] Specifically, the response results of the interfaces corresponding to normal access requests and abnormal access requests are preset, and the response results are the data returned by the interfaces. For example, the interface is accessed in advance with the request data of normal access requests, and the data returned by the interface is captured. The data is the response result corresponding to the normal access request. The interface is accessed in advance with the request data of abnormal access requests, and the data returned by the interface is captured. The data is the response result corresponding to the abnormal access request. After generating multiple second test data, the first test data and multiple second test data access interfaces are called in sequence to obtain multiple response results of the interface to the first test data and the second test data, and it is determined whether the response result corresponding to each test data is consistent with the preset response result.

[0078] In one embodiment, the electronic device determines the request type of the first test data and the second test data according to the parameter values ​​in the first test data and the second test data, and the request type is a normal access request or an abnormal access request. Afterwards, the electronic device determines the corresponding response result according to the request type of the first test data and the second test data, and then determines whether the response result of the interface to the first test data or the second test data is correct according to the actual response result of the interface. For example, if there is an erroneous response result, the test result of the interface is determined to be abnormal, and if there is no erroneous response result, the test result of the interface is determined to be normal. For another example, the electronic device can count the number and proportion of correct response results and erroneous response results and output them. By testing the interface through the first test data and the second test data, a more comprehensive test can be performed on the interface to ensure the credibility of the test results.

[0079] In another embodiment, the electronic device may also output the first test data, the second test data and the corresponding response results for the tester to view, download and store the test results. For example, the electronic device may also identify erroneous response results to facilitate the tester to query.

[0080] In one embodiment, after obtaining the response result of the interface to the first test data or the second test data, the electronic device determines the response time of the interface to each test data, and outputs the response time corresponding to each test data, thereby facilitating the tester to determine the performance of the interface according to the response time corresponding to each test data.

[0081] In one embodiment, the electronic device establishes an association between first test data, a parameter value replaced in the first test data, a corresponding replacement value, second test data obtained after replacement, and a corresponding response result, and then displays the corresponding data on a display interface according to the user's instructions for viewing the data, so as to facilitate the user to view and analyze the test results.

[0082] In one embodiment, the electronic device generates multiple executable scripts (curl scripts) according to the first test data and the second test data, and outputs multiple executable scripts. The user can directly view and download the executable scripts and use the executable scripts to manually test and verify the interface.

[0083] In one embodiment, the electronic device may display the executable script and response result corresponding to each test data on the display interface, so that the user can compare the response result output by the electronic device with the response result of the manual test.

[0084] In the above embodiment, multiple parameters in the first test data are replaced to generate multiple combinations of second test data, and the first test data and the second test data are called to test the interface, so that the interface can be tested using multiple randomly changing test data, thereby improving the credibility of the test results, and there is no need for the user to input the second test data after the parameter value is replaced, so that the entire test process is free of human intervention, reducing the probability of generating erroneous test data and improving test efficiency.

[0085] In one embodiment, the interface testing method provided in the embodiment of the present application is executed by a plug-in. For example, by installing the plug-in in a browser on an electronic device, inputting the first test data and running the plug-in, the interface can be tested, thereby facilitating user use and improving user experience.

[0086] The process of the interface testing method provided by an embodiment of the present application is as follows Figure 2 shown.

[0087] When the electronic device detects that the user opens the browser, the browser page is displayed on the display interface. When the interface test instruction input by the user is detected, the input box of the test data is displayed on the display interface. After the user enters the first test data in the first input box, the electronic device parses the first test data and extracts multiple parameters from the first test data according to the parsing result. For each parameter, the electronic device determines the parameter type and parameter value, and determines multiple replacement values ​​according to the parameter type and parameter value. Afterwards, the electronic device combines the replacement values ​​corresponding to all parameter values ​​to generate a parameter group of multiple combinations, and then generates the second test data according to the position of each parameter in the parameter group in the first test data. Afterwards, the electronic device calls the first test data and the second test data access interface, obtains all the response results returned by the interface, and establishes the association relationship between the first test data, the second test data and the multiple response results. Afterwards, according to the user's instruction to view the test results, the corresponding test data and response results are displayed on the display interface.

[0088] In the above embodiment, when the user inputs the first test data, the electronic device generates multiple combinations of second test data according to multiple parameters in the first test data, and calls the first test data and the second test data to test the interface, thereby saving user operations. The user can implement interface testing through one-key operation, thereby improving testing efficiency, and using multiple different test data to test the interface can improve the credibility of the test results obtained.

[0089] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0090] Corresponding to the interface testing method described in the above embodiment, Figure 3 A structural block diagram of an interface testing device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0091] like Figure 3 As shown, the interface testing device includes the following modules.

[0092] An acquisition module 31 is used to acquire a test request for an interface, wherein the test request includes first test data, and the first test data is data for accessing the interface;

[0093] A parsing module 32, configured to parse the first test data to obtain one or more parameters in the first test data, each of the parameters including a parameter type and a parameter value;

[0094] A determination module 33, configured to determine a plurality of replacement values ​​corresponding to the parameter value according to the parameter type and the parameter value;

[0095] A replacement module 34, configured to generate a plurality of second test data according to the plurality of replacement values ​​corresponding to each of the parameter values;

[0096] The testing module 35 is used to call the first test data and the plurality of second test data to test the interface.

[0097] In one embodiment, the parsing module 32 is specifically used for:

[0098] Recognizing a preset character in the first test data;

[0099] Extracting one or more parameter values ​​and a parameter name corresponding to each parameter value from the first test data according to the position of the preset character;

[0100] The parameter type is determined according to the parameter name.

[0101] In one embodiment, the first test data includes a request header and a request body, the preset characters include a first character and a second character, and the parsing module 32 is specifically configured to:

[0102] A first character in the request header is identified, and a second character in the request body is identified.

[0103] In one embodiment, the replacement module 34 is specifically used for:

[0104] The first replacement value of the first parameter is combined with each replacement value of the second parameter in sequence, and the multiple second test data are obtained according to the combination results; the first parameter is one of the multiple parameters, the first replacement value is one of the multiple replacement values ​​of the first parameter, and the second parameter is a parameter of the multiple parameters except the first parameter.

[0105] In one embodiment, the determination module 33 is specifically used for:

[0106] Determining a range of replacement values ​​according to the parameter type;

[0107] A plurality of replacement values ​​corresponding to the parameter value are determined according to the range of the replacement value and the parameter value.

[0108] In one embodiment, the first test number is generated according to a historical access record of the interface.

[0109] In one embodiment, the testing module 35 is specifically used for:

[0110] Calling the first test data and the plurality of second test data in sequence to access the interface;

[0111] Acquire multiple response results of the interface to the first test data and the multiple second test data;

[0112] A test result of the interface is determined according to the multiple response results.

[0113] In one embodiment, the testing module 35 is further configured to:

[0114] A plurality of executable scripts are generated according to the first test data and the plurality of second test data, and the plurality of executable scripts are output.

[0115] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0116] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0117] like Figure 4 As shown, the electronic device of this embodiment includes: a processor 41, a memory 42, and a computer program 43 stored in the memory 42 and executable on the processor 41. When the processor 41 executes the computer program 43, the steps in the above interface test method embodiment are implemented, for example Figure 1 Alternatively, when the processor 41 executes the computer program 43, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 3 The functions of the acquisition module 31 to the testing module 35 are shown.

[0118] Exemplarily, the computer program 43 may be divided into one or more modules / units, which are stored in the memory 42 and executed by the processor 41 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 43 in the electronic device.

[0119] Those skilled in the art will understand that Figure 4 These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0120] The processor 41 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0121] The memory 42 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 42 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 42 may also include both an internal storage unit of the electronic device and an external storage device. The memory 42 is used to store the computer program and other programs and data required by the electronic device. The memory 42 may also be used to temporarily store data that has been output or is to be output.

[0122] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0123] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0124] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0126] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0127] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0128] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. An interface testing method, characterized in that: include: Obtaining a test request for an interface, wherein the test request includes first test data, and the first test data is data for accessing the interface; Parsing the first test data to obtain one or more parameters in the first test data, each of the parameters including a parameter type and a parameter value; Determine, according to the parameter type and the parameter value, a plurality of replacement values ​​corresponding to the parameter value; Generate a plurality of second test data according to the plurality of replacement values ​​corresponding to each of the parameter values; The first test data and the plurality of second test data are called to test the interface.

2. The method according to claim 1, characterized in that The parsing the first test data to obtain one or more parameters in the first test data includes: Recognizing a preset character in the first test data; Extracting one or more parameter values ​​and a parameter name corresponding to each parameter value from the first test data according to the position of the preset character; The parameter type is determined according to the parameter name.

3. The method according to claim 2, characterized in that The first test data includes a request header and a request body, the preset characters include a first character and a second character, and the identifying the preset characters in the first test data includes: A first character in the request header is identified, and a second character in the request body is identified.

4. The method according to claim 1, characterized in that: Generating a plurality of second test data according to the plurality of replacement values ​​corresponding to each of the parameter values ​​comprises: The first replacement value of the first parameter is combined with each replacement value of the second parameter in sequence, and the multiple second test data are obtained according to the combination results; the first parameter is one of the multiple parameters, the first replacement value is one of the multiple replacement values ​​of the first parameter, and the second parameter is a parameter of the multiple parameters except the first parameter.

5. The method according to claim 1, characterized in that The determining, according to the parameter type and the parameter value, a plurality of replacement values ​​corresponding to the parameter value comprises: Determining a range of replacement values ​​according to the parameter type; A plurality of replacement values ​​corresponding to the parameter value are determined according to the range of the replacement value and the parameter value.

6. The method according to claim 1, characterized in that The first test number is generated according to the historical access record of the interface.

7. The method according to claim 1, characterized in that The calling the first test data and the plurality of second test data to test the interface includes: Calling the first test data and the plurality of second test data in sequence to access the interface; Acquire multiple response results of the interface to the first test data and the multiple second test data; A test result of the interface is determined according to the multiple response results.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: A plurality of executable scripts are generated according to the first test data and the plurality of second test data, and the plurality of executable scripts are output.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 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 method according to any one of claims 1 to 8 is implemented.