Interface testing method and device, electronic equipment and readable storage medium

By automatically generating request data using information in the interface document for interface testing, the problem of low efficiency of existing interface testing is solved and efficient interface testing is achieved.

CN120045455APending Publication Date: 2025-05-27BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510106392.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

Existing interface tests mainly rely on manual writing of test data, resulting in low efficiency. How to improve the efficiency of interface tests is an urgent problem.

Method used

By obtaining information in the interface document, request data is automatically generated as test data, and interface testing is carried out, thereby improving testing efficiency.

Benefits of technology

Without manual writing of test data, interface testing can be performed automatically, significantly improving the efficiency of interface testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045455A_ABST
    Figure CN120045455A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an interface testing method and device, electronic equipment and a readable storage medium, and relates to the technical field of software test.The method comprises the steps that an interface document used for describing a to-be-tested interface is obtained; obtaining multiple items of information required for requesting the to-be-tested interface as request information according to the identifiers of the items of information recorded in the interface document; generating request data for the to-be-tested interface according to the request information to serve as test data; and testing the to-be-tested interface by using the test data to obtain a test result of the to-be-tested interface. Through the scheme, the request data for the to-be-tested interface can be automatically generated, and the interface testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular, to an interface testing method, apparatus, electronic device, and readable storage medium. Background Art

[0002] During the software program development process, as a communication bridge between different components or services of a system, the correctness of an API (Application Programming Interface) interface is crucial for the stability and reliability of the entire system. Therefore, interface testing is required.

[0003] However, current interface testing mainly relies on manually writing test data, which takes a lot of time and results in low efficiency of interface testing. Therefore, how to improve the efficiency of interface testing is an urgent problem to be solved. Summary of the Invention

[0004] The purpose of the embodiments of the present invention is to provide an interface testing method, apparatus, electronic device, and readable storage medium to improve the efficiency of interface testing. The specific technical solutions are as follows:

[0005] In one aspect of the present invention, first, an interface testing method is provided, which includes:

[0006] Obtain an interface document for describing the interface to be tested;

[0007] According to the identifiers of the various pieces of information recorded in the interface document, obtain multiple pieces of information required to request the interface to be tested as request information;

[0008] Generate request data for the interface to be tested based on the request information as test data;

[0009] Use the test data to test the interface to be tested and obtain the test result of the interface to be tested.

[0010] Optionally, the generating request data for the interface to be tested based on the request information as test data includes:

[0011] Generate request data that conforms to all the pieces of information in the request information as the first type of test data;

[0012] And / or,

[0013] Generate request data that does not conform to at least one piece of information in the request information as the second type of test data.

[0014] Optionally, the request information includes: parameter annotation; the parameter annotation represents the value range of the parameters required for requesting the interface to be tested.

[0015] Generating request data that conforms to each piece of information in the request information includes:

[0016] Generating a parameter value within the value range represented by the parameter annotation as the parameter value to be utilized.

[0017] Combining the parameter value to be utilized with other pieces of information in the request information to obtain request data that conforms to each piece of information in the request information.

[0018] Optionally, generating a parameter value within the value range represented by the parameter annotation as the parameter value to be utilized includes:

[0019] Generating boundary values of the value range represented by the parameter annotation as the parameter values to be utilized.

[0020] Optionally, before testing the interface to be tested with the test data to obtain the test result of the interface to be tested, the method further includes:

[0021] Obtaining, from the interface document, the information generated when the interface to be tested responds to correct request data as the response information corresponding to the first type of test data; and / or obtaining the information generated when the interface to be tested responds to incorrect request data as the response information corresponding to the second type of test data.

[0022] Testing the interface to be tested with the test data to obtain the test result of the interface to be tested includes:

[0023] Testing the interface to be tested based on each type of generated test data and the response information corresponding to this type of test data to obtain the test result of the interface to be tested.

[0024] Optionally, testing the interface to be tested based on each type of generated test data and the response information corresponding to this type of test data to obtain the test result of the interface to be tested includes:

[0025] Sending a request to the interface to be tested using each type of generated test data to obtain the response data feedback by the interface to be tested for this type of test data as the response data corresponding to this type of test data.

[0026] For each type of test data, determine whether the response data corresponding to this type of test data conforms to all the information included in the response information corresponding to this type of test data; if there is at least one non-conformance, determine that the interface under test does not respond correctly to this type of test data.

[0027] In another aspect of the implementation of the present invention, an interface testing device is further provided. The device includes:

[0028] An interface document acquisition module, configured to acquire an interface document for describing the interface under test;

[0029] A request information acquisition module, configured to acquire multiple pieces of information required to request the interface under test as request information according to the identifiers of the information recorded in the interface document;

[0030] A test data generation module, configured to generate request data for the interface under test as test data according to the request information;

[0031] A test execution module, configured to test the interface under test by using the test data to obtain the test result of the interface under test.

[0032] In yet another aspect of the implementation of the present invention, a computer-readable storage medium is further provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the interface testing method described in any one of the above is implemented.

[0033] In yet another aspect of the implementation of the present invention, a computer program product including instructions is further provided. When it runs on a computer, it causes the computer to execute the interface testing method described in any one of the above.

[0034] The interface testing method provided by the embodiments of the present invention obtains multiple pieces of information required to request the interface under test as request information according to the identifiers of the information recorded in the interface document; then generates request data for the interface under test as test data according to the request information; and tests the interface under test by using the test data to obtain the test result of the interface under test. It can be seen that in this solution, only the interface document of the interface under test needs to be provided, and multiple pieces of information required to request the interface under test can be automatically obtained from the interface document, and then request data for the interface under test can be generated to test the interface under test and obtain the test result of the interface under test, without the need for manual writing of test data. Therefore, the efficiency of interface testing can be improved through this solution. Description of the Drawings

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art.

[0036] Figure 1 is a flowchart of the interface testing method in an embodiment of the present invention;

[0037] Figure 2 is another flowchart of the interface testing method in an embodiment of the present invention;

[0038] Figure 3 is yet another flowchart of the interface testing method in an embodiment of the present invention;

[0039] Figure 4 is a schematic structural diagram of the interface testing device in an embodiment of the present invention;

[0040] Figure 5 is a schematic structural diagram of the electronic device in an embodiment of the present invention. Detailed implementation manners

[0041] Next, the technical solutions in the embodiments of the present invention will be described with reference to the accompanying drawings in the embodiments of the present invention.

[0042] To improve the efficiency of interface testing, embodiments of the present invention provide an interface testing method, device, electronic device, and readable storage medium. Among them, the interface testing method can be applied to an electronic device with data processing capabilities. Specifically, the method can be executed by a program pre-developed and installed in the electronic device. The method may include the following steps:

[0043] Obtain an interface document for describing the interface to be tested;

[0044] According to the identifiers of the various pieces of information recorded in the interface document, obtain multiple pieces of information required to request the interface to be tested as request information;

[0045] Generate request data for the interface to be tested based on the request information as test data;

[0046] Use the test data to test the interface to be tested to obtain the test result of the interface to be tested.

[0047] In this embodiment, multiple pieces of information required to request the interface to be tested are obtained according to the identifiers of the various pieces of information recorded in the interface document as request information; then, request data for the interface to be tested is generated based on the request information as test data; and the interface to be tested is tested using the test data to obtain the test result of the interface to be tested. It can be seen that in this solution, only the interface document of the interface to be tested needs to be provided, and multiple pieces of information required to request the interface to be tested can be automatically obtained from the interface document, and then request data for the interface to be tested can be generated to test the interface to be tested and obtain the test result of the interface to be tested, without manually writing test data anymore. Therefore, the efficiency of interface testing can be improved through this solution.

[0048] The embodiments of the present invention will be exemplarily introduced below with reference to the accompanying drawings. As Figure 1 shown, the method may include the following steps:

[0049] S101, obtain the interface document for describing the interface to be tested;

[0050] The interface in this embodiment is a software interface. The interface document is a document describing interface information, generally written by developers and used to guide developers in the development, testing, and maintenance of programs. The interface document has a standardized document format, such as the Swagger (specification of the Open Application Programming Interface OpenAPI) standard, the RAML (RESTful API Modeling Language, RESTful interface modeling language) standard, the WSDL (Web Services Description Language, web service description language) standard, etc.

[0051] The content of the interface document will include basic information of the interface, such as the request method, path, request parameters, response parameters, etc. of the interface. Among them, the request method usually includes add (post), modify (put), delete (delete), get (get); the request parameters are the parameters required to request the interface, which usually include the name (name), location (in), data type (style), parameter annotation (such as the value range of the annotated parameter), whether it is required (required), etc.; the response parameters usually include: status code, name of the parameter, data type, etc.

[0052] In this embodiment, when it is necessary to test the interface to be tested, the interface document of the interface to be tested can be obtained first to perform subsequent steps.

[0053] S102, obtain multiple pieces of information required to request the interface to be tested according to the identifiers of the various pieces of information recorded in the interface document as request information;

[0054] To normally call an interface, it is necessary to input request data in a specified format to the interface, and the request data needs to carry necessary information. In this embodiment, multiple pieces of information required to request the interface to be tested may include: information such as the request method, path, and request parameters of the interface to be tested. Since all these pieces of information are recorded in the interface document, and the interface document also records the identifiers of each piece of information, therefore, after obtaining the interface document of the interface to be tested, these pieces of information can be extracted from the interface document as request information. Each piece of information in the request information can be in the form of a string.

[0055] For example, the information recorded in the interface document for the path of the interface is: "paths: / user / {userId}", and "paths:" is the identifier of the path item of information. Then, search for "paths:" in the document and obtain the string " / user / {userId}" after "paths:", and thus obtain the information of the path item of the interface. Similarly, the request method, request parameters, and other information can also be obtained.

[0056] S103, generate request data for the interface to be tested according to the request information as test data;

[0057] After obtaining the request information, request data that conforms to each piece of information in the request information can be generated as the first type of test data.

[0058] For example, the request method, path, and request parameters included in the request information can be combined to obtain the first type of test data.

[0059] In one implementation manner, when the request information includes parameter annotations, and the parameter annotations indicate the value range of the parameters required to request the interface to be tested, then parameter values within the value range indicated by the parameter annotations can be generated first as the parameter values to be utilized; then, the parameter values to be utilized are combined with other pieces of information in the request information to obtain request data that conforms to each piece of information in the request information.

[0060] For example, the request method of the interface to be detected is: get method, the path is: http: / / api.example.com / user / {userId}, the parameter name of the request parameter is: userId, and the position of this parameter is in the path, and the value range indicated by the parameter annotation of this parameter is 0 - 999. Then a piece of the first type of test data can be represented by the following code:

[0061] url = "http: / / api.example.com / user / 123"

[0062] response = requests.get(url)

[0063] To improve the comprehensiveness of testing, multiple different parameter values can also be generated for the request parameters. Each time, one of the parameter values is selected for combination to obtain a test data item, and in this way, multiple different test data items can be obtained. If multiple request parameters are required to test the interface to be tested, multiple different parameter values can also be generated separately for each request parameter. In this way, multiple different parameter combinations can be obtained, and then each parameter combination can be combined with other information items respectively to also obtain multiple different test data items.

[0064] In one implementation, to make the combined request data conform to the specified format, a template for the request data can be set in advance according to the specified format. After obtaining the request information, the request method, path, names of request parameters, generated parameter values, etc. included in the request information can be filled into the corresponding positions of the template, so as to generate the first type of test data.

[0065] In addition, current large language models already have programming capabilities. For example, models such as ChatGPT (Chat Generative Pre-trained Transformer) and Codex. Therefore, it is also possible to use a pre-trained large language model to generate request data based on the request information. That is to say, the request information is input into the large language model, and the large language model automatically combines the information items included in the request information to generate request data for testing the interface to be tested.

[0066] In one implementation, it is also possible to generate request data that does not conform to at least one piece of information in the request information as the second type of test data. For example, request data with different request methods, paths, and / or request parameters from those in the request information can be generated; request data missing necessary request parameters can also be generated. For example, a correct request data should contain the following content: GET / user / 123, where 123 is the parameter value of the request parameter userId. Deleting the parameter value can obtain the second type of test data, that is, this test data only contains "GET / user" in this part of the content.

[0067] In this embodiment, by generating the first type of test data that conforms to all the information items in the request information, it is possible to detect the response of the interface to be tested to correct request data; by generating the second type of test data that does not conform to at least one piece of information in the request information, it is possible to detect the response of the interface to be tested to incorrect request data.

[0068] Further, generating a parameter value within the value range indicated by the parameter annotation as the parameter value to be utilized includes:

[0069] Generating boundary values of the value range indicated by the parameter annotation as the parameter values to be utilized.

[0070] In this case, the parameter values included in the first type of test data generated are the boundary values of the above-mentioned value range. For example, if the value range indicated by the parameter annotation is a numerical range, such parameter values can be the maximum value of the numerical range or a value close to the maximum value, and can also be the minimum value of the numerical range or a value close to the minimum value; if the value range indicated by the parameter annotation is the length range of a string, such parameter values can be in the form of a string, and the length of the parameter value is the maximum value within the length range. Since a large number of errors are likely to occur near the boundaries of the value range in actual situations, testing the interface to be tested by generating boundary values can reduce the testing blind spots, ensure that the interface to be tested can work properly in multiple scenarios, and improve the test coverage rate.

[0071] S104, using the test data to test the interface to be tested to obtain the test result of the interface to be tested.

[0072] After obtaining the test data, the test data can be input into the interface to be tested to obtain the response data of the interface to be tested. Then, by determining whether the obtained response data meets the preset conditions, the test result of the interface to be tested can be obtained. For example, when the response data meets the preset conditions, the test result can indicate that the interface to be tested can work properly; otherwise, the test result can indicate that the interface to be tested is abnormal. In addition, the test result can also include the response time of the interface, specific response data, etc.

[0073] Further, a test report including the test result can also be generated and sent to the developers to help the developers quickly locate the problems of the interface.

[0074] In this embodiment, by obtaining multiple pieces of information required to request the interface to be tested as request information according to the identifiers of the various pieces of information recorded in the interface document; then generating request data for the interface to be tested as test data according to the request information; and using the test data to test the interface to be tested to obtain the test result of the interface to be tested. It can be seen that in this solution, only by providing the interface document of the interface to be tested, multiple pieces of information required to request the interface to be tested can be automatically obtained from the interface document, and then request data for the interface to be tested can be generated to test the interface to be tested to obtain the test result of the interface to be tested, without the need to manually write test data. Therefore, through this solution, the efficiency of interface testing can be improved.

[0075] In an embodiment of the present invention, as Figure 2 shown, before testing the interface to be tested with test data and obtaining the test result of the interface to be tested, the method further includes:

[0076] S201, obtaining, from the interface document, the information generated when the interface to be tested responds to correct request data as the response information corresponding to the first type of test data; and / or obtaining the information generated when the interface to be tested responds to incorrect request data as the response information corresponding to the second type of test data;

[0077] Since the interface document also includes: when the request data is correct, the response information corresponding to the interface to be tested. The response information may include: the status code (such as 200) in the case of a normal response, the name of the parameter, the data type, etc.; it may also include: when the request data is incorrect, the response information corresponding to the interface to be tested, such as it may include the status code (such as 404). Therefore, in this embodiment, this part of the content can be obtained from the interface document to detect whether the information feedback by the interface is correct.

[0078] In this case, the above-mentioned testing the interface to be tested with test data and obtaining the test result of the interface to be tested includes:

[0079] Based on each type of generated test data and the response information corresponding to this type of test data, testing the interface to be tested to obtain the test result of the interface to be tested;

[0080] In one implementation, this process includes the following steps:

[0081] S1041, using each type of generated test data to send a request to the interface to be tested to obtain the response data feedback by the interface to be tested for this type of test data as the response data corresponding to this type of test data;

[0082] That is, inputting the test data into the interface to be tested to obtain the response data feedback by the interface to be tested for this test data.

[0083] S1042, for each type of test data, determining whether the response data corresponding to this type of test data conforms to all the information included in the response information corresponding to this type of test data; if there is at least one non-conformity, it is determined that the interface to be tested does not respond correctly for this type of test data.

[0084] Specifically, when the test data is the first type of test data, it can be determined whether the status code included in the response data is the status code in the case of a normal response (such as 200), whether the name of the response parameter is the name in the case of a normal response, whether the data type of the response parameter is the data type in the case of a normal response, and so on. If at least one does not conform, it is determined that the interface under test does not respond correctly to this type of test data, that is, it is determined that the interface under test is abnormal.

[0085] Correspondingly, when the test data is the second type of test data, it can be determined whether the status code included in the response data is the status code in the case of a request data error (such as 404). If not, it can be determined that the interface under test does not respond correctly to this type of test data, that is, it is determined that the interface under test is abnormal.

[0086] In one implementation, after obtaining the request information and response information from the interface document, multiple request data are first generated. For example, the multiple request data can include the first type of test data and the second type of test data. Then, each test data is combined with the corresponding response information to obtain test cases. In this way, normal cases (the request data included is the first type of test data), abnormal cases (the request data included is the second type of test data), and boundary cases (the parameter values in the request data are boundary values) can be obtained.

[0087] After that, each test case can be input into an automated testing framework such as Postman, Junit (a unit testing framework for the Java language), TestNG (Test Next Generation, the next-generation automated testing framework), or Pytest (a unit framework for the Python language). The automated testing framework can then test the interface under test based on each test case, monitor the response data, and generate a test report. Using an automated testing framework to execute and monitor interface calls can reduce human intervention in the testing process and improve testing quality and consistency.

[0088] Taking the automated testing framework as Pytest as an example, if the request method of the interface to be detected is: get method, the path is: http: / / api.example.com / user / {userId}, the parameter name of the request parameter is: userId, and the position of this parameter is in the path, and the value range represented by the parameter annotation of this parameter is 0 - 999. The information generated when the interface to be detected responds to the correct request data includes: status code: 200; the parameter name of response parameter 1 is: id; the parameter name of response parameter 2 is: name. Then the generated test case can be represented by the following code:

[0089] import requests

[0090] def test_get_user():

[0091] url = "http: / / api.example.com / user / 123"

[0092] response = requests.get(url)

[0093] assert response.status_code == 200

[0094] data = response.json()

[0095] assert 'id' in data

[0096] assert 'name' in data

[0097] In addition, by replacing the "123" in the above code with other characters, other test cases can be quickly generated. For example, by replacing "123" with a boundary value, such as "0", a boundary test case may be obtained; by replacing it with other non-boundary values within the value range represented by the parameter annotation, normal test cases can be obtained. By replacing it with a parameter value not within the value range represented by the parameter annotation (or directly deleting "123"), modifying "code == 200" to "code == 404", and deleting the following three lines of code (data = response.json(), assert 'id' in data, assert 'name' in data), exception test cases can be obtained.

[0098] In one implementation, as Figure 3 shown, this embodiment can be executed by four modules, namely:

[0099] The interface document parsing module is used to read the interface document, parse and obtain the key information of the interface to be tested from the interface document, that is, multiple pieces of information required to request the interface to be tested, as well as the information generated when the interface to be tested responds to correct request data and the information generated when the interface to be tested responds to incorrect request data.

[0100] The test generation module is used to generate multiple test cases, including normal test cases, exception test cases, and boundary test cases.

[0101] The automated execution framework execution module is used to utilize the automated execution framework to perform interface testing based on the test cases and monitor the response results.

[0102] A recording and analyzing result module, which is used to record the entire test process, including test results such as response data, response time, and whether the response data is correct, and generate a test report.

[0103] In this embodiment, only the interface document of the interface to be tested needs to be provided, and multiple pieces of information required to request the interface to be tested can be automatically obtained from the interface document, and then request data for the interface to be tested can be generated to test the interface to be tested and obtain the test result of the interface to be tested, without manually writing test data anymore. Therefore, the efficiency of interface testing can be improved through this solution.

[0104] Based on the same inventive concept, an embodiment of the present invention further provides an interface testing device, as Figure 4 shown, the device includes:

[0105] An interface document acquisition unit 401, which is used to acquire an interface document for describing the interface to be tested;

[0106] A request information acquisition unit 402, which is used to acquire multiple pieces of information required to request the interface to be tested as request information according to the identifiers of the information recorded in the interface document;

[0107] A test data generation unit 403, which is used to generate request data for the interface to be tested as test data according to the request information;

[0108] A test execution unit 404, which is used to test the interface to be tested by using the test data to obtain the test result of the interface to be tested.

[0109] Optionally, the test data generation unit 403 is specifically used to generate request data that conforms to each piece of information in the request information as the first type of test data;

[0110] And / or,

[0111] Generate request data that does not conform to at least one piece of information in the request information as the second type of test data.

[0112] Optionally, the request information includes: parameter annotation; the parameter annotation represents the value range of the parameters required to request the interface to be tested;

[0113] The test data generation unit 403 includes: a parameter value generation unit, which is used to generate parameter values within the value range represented by the parameter annotation as the parameter values to be used;

[0114] A combination unit, which is used to combine the parameter values to be used with other pieces of information in the request information to obtain request data that conforms to each piece of information in the request information.

[0115] Optionally, the parameter value generation unit is specifically configured to generate boundary values of the value range represented by the parameter annotation as the parameter values to be utilized.

[0116] Optionally, the apparatus further includes:

[0117] A response information acquisition unit, configured to, before the test execution unit 404 uses the test data to test the interface to be tested and obtain the test result of the interface to be tested, acquire, from the interface document, information generated when the interface to be tested responds to correct request data as the response information corresponding to the first type of test data; and / or acquire information generated when the interface to be tested responds to incorrect request data as the response information corresponding to the second type of test data;

[0118] The test execution unit 404 is specifically configured to:

[0119] Based on each type of generated test data and the response information corresponding to this type of test data, test the interface to be tested to obtain the test result of the interface to be tested.

[0120] Optionally, the test execution unit 404 includes:

[0121] A request subunit, configured to use each type of generated test data to request the interface to be tested to obtain response data fed back by the interface to be tested for this type of test data as the response data corresponding to this type of test data;

[0122] A test result determination subunit, configured to, for each type of test data, determine whether the response data corresponding to this type of test data conforms to each item of information included in the response information corresponding to this type of test data; if there is at least one non-conformity, determine that the interface to be tested does not respond correctly to this type of test data.

[0123] In this embodiment, by acquiring, according to the identifiers of the information items recorded in the interface document, multiple items of information required to request the interface to be tested as request information; then generating request data for the interface to be tested based on the request information as test data; and using the test data to test the interface to be tested to obtain the test result of the interface to be tested. It can be seen that in this solution, only the interface document of the interface to be tested needs to be provided, and multiple items of information required to request the interface to be tested can be automatically acquired from the interface document, and then request data for the interface to be tested can be generated to test the interface to be tested to obtain the test result of the interface to be tested, without the need for manual writing of test data. Therefore, the efficiency of interface testing can be improved through this solution.

[0124] An embodiment of the present invention further provides an electronic device, such as Figure 5 shown, which includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504. Among them, the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.

[0125] The memory 503 is used to store a computer program.

[0126] When the processor 501 is used to execute the program stored on the memory 503, the steps of the interface test method described in any one of the above are implemented.

[0127] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0128] The communication interface is used for communication between the above terminal and other devices.

[0129] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0130] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0131] In another embodiment provided by the present invention, there is also provided a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the interface testing method described in any of the above embodiments is implemented.

[0132] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions, and when it runs on a computer, the computer is caused to execute the interface testing method described in any of the above embodiments.

[0133] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center integrating one or more available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).

[0134] It should be noted that in this document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of additional identical elements in the process, method, article, or device comprising the element.

[0135] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the device, electronic device, and readable storage medium, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant parts, reference can be made to the partial description of the method embodiments.

[0136] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. An interface testing method, characterized in that: The method comprises: Get the interface document used to describe the interface to be tested; According to the identifiers of the various information recorded in the interface document, obtaining multiple pieces of information required for requesting the interface to be tested as request information; Generate request data for the interface to be tested according to the request information as test data; The interface to be tested is tested using the test data to obtain a test result of the interface to be tested.

2. The method according to claim 1, characterized in that The step of generating request data for the interface to be tested according to the request information as test data includes: Generate request data that is consistent with all information in the request information as the first type of test data; and / or, Generate request data that does not conform to at least one item of information in the request information as the second type of test data.

3. The method according to claim 2, characterized in that The request information includes: parameter annotation; the parameter annotation indicates the value range of the parameter required for requesting the interface to be tested; The generating of request data that is consistent with each item of information in the request information includes: Generate a parameter value within the value range represented by the parameter annotation as the parameter value to be used; The parameter value to be used is combined with other information in the request information to obtain request data that is consistent with all information in the request information.

4. The method according to claim 2, characterized in that: The generating a parameter value within the value range represented by the parameter annotation as the parameter value to be used includes: Generate a boundary value of the value range represented by the parameter annotation as the parameter value to be used.

5. The method according to any one of claims 2 to 4, characterized in that: Before testing the interface to be tested by using the test data to obtain a test result of the interface to be tested, the method further includes: From the interface document, obtain information generated when the interface to be tested responds to correct request data as response information corresponding to the first type of test data; and / or obtain information generated when the interface to be tested responds to incorrect request data as response information corresponding to the second type of test data; The testing the interface to be tested by using the test data to obtain a test result of the interface to be tested includes: Based on each type of generated test data and the response information corresponding to the type of test data, the interface to be tested is tested to obtain a test result of the interface to be tested.

6. The method according to claim 5, characterized in that The step of testing the interface to be tested based on each type of test data generated and the response information corresponding to the type of test data to obtain a test result of the interface to be tested includes: Using each type of test data generated, requesting the interface to be tested, obtaining response data fed back by the interface to be tested for the type of test data as response data corresponding to the type of test data; For each type of test data, determine whether the response data corresponding to this type of test data is consistent with all the information contained in the response information corresponding to this type of test data; if there is at least one item that does not match, it is determined that the interface test to be tested does not respond correctly to this type of test data.

7. An interface testing device, characterized in that: The device comprises: An interface document acquisition unit, used to acquire an interface document describing the interface to be tested; A request information acquisition unit, used to acquire multiple pieces of information required to request the interface to be tested as request information according to the identifiers of the various pieces of information recorded in the interface document; A test data generating unit, configured to generate request data for the interface to be tested according to the request information as test data; The test execution unit is used to test the interface to be tested using the test data to obtain a test result of the interface to be tested.

8. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 6 when executing a program stored in a memory.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is run on a computer, the computer is enabled to implement the method steps of any one of claims 1 to 6.