CN112306785A - Method, device, system, equipment and medium for testing micro-service application interface - Google Patents
Method, device, system, equipment and medium for testing micro-service application interface Download PDFInfo
- Publication number
- CN112306785A CN112306785A CN202011195314.3A CN202011195314A CN112306785A CN 112306785 A CN112306785 A CN 112306785A CN 202011195314 A CN202011195314 A CN 202011195314A CN 112306785 A CN112306785 A CN 112306785A
- Authority
- CN
- China
- Prior art keywords
- interface
- service
- response result
- micro
- testing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 99
- 238000000034 method Methods 0.000 title claims abstract description 31
- 230000004044 response Effects 0.000 claims abstract description 112
- 230000006870 function Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000010998 test method Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/22—Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
- G06F11/26—Functional testing
- G06F11/263—Generation of test inputs, e.g. test vectors, patterns or sequences ; with adaptation of the tested hardware for testability with external testers
Abstract
The application discloses a method, a device, a system, equipment and a medium for testing a micro-service application interface, wherein the method comprises the following steps: the testing tool end constructs an http request according to the acquired input parameters; after the http request is sent to the interface to be tested of the micro-service application end by the testing tool end, receiving an interface response result returned by the micro-service application end; the testing tool end judges whether the interface response result accords with the preset response data rule, if so, the interface response result accords with the service expectation, and if not, the interface response result does not accord with the service expectation, thereby solving the technical problems that the existing interface testing method can only test the connectivity of the application interface and can not test whether the application interface accords with the service expectation.
Description
Technical Field
The present application relates to the field of interface testing technologies, and in particular, to a method, an apparatus, a system, a device, and a medium for testing a micro-service application interface.
Background
As micro service technology matures, various application systems are being micro-serviced. In an overall application system, a business process can be split and degraded to a plurality of specific applications, and the split specific applications cooperate to complete the whole business, so that the specific applications form a relationship of mutual calling and strong dependence. In order to meet the requirement that data communication can be carried out between specific applications, an API (application programming interface) is provided for each specific application, and whether the service is normal or not can be judged through interface testing.
The conventional interface testing method is to judge whether the interface functions normally or not by sending a request to judge whether the data can be acquired, but the data return does not mean that the interface functions normally, only means that the interface functions normally technically, and does not mean that the interface functions normally in service. For example, a microservice application includes a plurality of API interfaces, and when a certain API interface is called, a certain organization name (a certain field in a return value) returned is an empty string.
Therefore, it is an urgent technical problem to provide a testing method for testing whether a microservice application interface meets a business expectation.
Disclosure of Invention
The application provides a method, a device, a system, equipment and a medium for testing a micro-service application interface, which are used for solving the technical problem that the existing interface testing method can only test the connectivity of the application interface and can not test whether the application interface meets the service expectation.
In view of the above, a first aspect of the present application provides a method for testing a micro service application interface, including:
the testing tool end constructs an http request according to the acquired input parameters, wherein the input parameters comprise a request address, a request parameter name, a request parameter value and/or a parameter type;
after the http request is sent to an interface to be tested of a micro-service application end by the testing tool end, receiving an interface response result returned by the micro-service application end;
and the test tool end judges whether the interface response result meets a preset response data rule, if so, the interface response result is judged to meet the service expectation, and if not, the interface response result is judged not to meet the service expectation.
Optionally, the testing tool end determines whether the interface response result meets a preset response data rule, if so, determines that the interface response result meets a service expectation, and if not, determines that the interface response result does not meet the service expectation, and before that, the method further includes:
and the testing tool end judges whether the response state of the interface to be tested is 200 according to the interface response result, if so, the subsequent steps are executed, and if not, the interface response result is judged to be not in accordance with the service expectation.
The second aspect of the present application provides a test tool terminal, comprising:
the building unit is used for building an http request according to the obtained input parameters, wherein the input parameters comprise request addresses, request parameter names, request parameter values and/or parameter types;
the receiving unit is used for sending the http request to an interface to be tested of the micro-service application terminal and then receiving an interface response result returned by the micro-service application terminal;
and the first judgment unit is used for judging whether the interface response result meets a preset response data rule, if so, judging that the interface response result meets the service expectation, and if not, judging that the interface response result does not meet the service expectation.
Optionally, the method further includes:
and the second judging unit is used for judging whether the response state of the interface to be tested is 200 according to the interface response result, if so, triggering the first judging unit, and if not, judging that the interface response result does not accord with the service expectation.
A third aspect of the present application provides a micro service application interface testing system, including: the test tool side and the microservice application side of any of the second aspect.
A fourth aspect of the present application provides a microservice application interface test apparatus, the apparatus comprising a processor and a memory;
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to execute the method for testing the microservice application interface according to any one of the first aspect according to instructions in the program code.
A fifth aspect of the present application provides a computer-readable storage medium for storing program code for executing the method for testing a microservice application interface of any of the first aspects.
According to the technical scheme, the method has the following advantages:
the application provides a method for testing a micro-service application interface, which comprises the following steps: the testing tool end constructs an http request according to the acquired input parameters, wherein the input parameters comprise a request address, a request parameter name, a request parameter value and/or a parameter type; after the http request is sent to the interface to be tested of the micro-service application end by the testing tool end, receiving an interface response result returned by the micro-service application end; and the test tool end judges whether the interface response result meets the preset response data rule, if so, the interface response result is judged to meet the business expectation, and if not, the interface response result is judged to not meet the business expectation.
In the application, a corresponding http request is constructed by the testing tool end according to the input parameters, and after the http request is sent to the interface to be tested of the micro-service application end, whether the interface response result meets the business expectation is judged according to the interface response result returned by the micro-service application end and the preset response data rule, so as to determine whether the micro-service application business meets the business expectation, thereby solving the technical problem that the existing interface testing method can only test the connectivity of the application interface and cannot test whether the application interface meets the business expectation.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic flowchart of a method for testing a microservice application interface according to an embodiment of the present disclosure;
fig. 2 is another schematic flow chart of a method for testing a microservice application interface according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a micro service application interface testing apparatus according to an embodiment of the present application.
Detailed Description
The application provides a method, a device, a system, equipment and a medium for testing a micro-service application interface, which are used for solving the technical problem that the existing interface testing method can only test the connectivity of the application interface and can not test whether the application interface meets the service expectation.
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
For easy understanding, referring to fig. 1, an embodiment of a method for testing a microservice application interface provided by the present application includes:
and 101, the testing tool end constructs an http request according to the acquired input parameters.
The input parameters include a request address, a request parameter name, a request parameter value and/or a parameter type, etc. And the testing tool terminal performs splicing processing on the request address, the request parameter name, the request parameter value and/or the parameter type and the like in the input parameters according to http protocol rules to obtain the http request.
And 102, after the testing tool end sends the http request to an interface to be tested of the micro-service application end, receiving an interface response result returned by the micro-service application end.
After the http request is constructed by the testing tool terminal, the http request containing the input parameters is sent to the interface to be tested of the micro-service application terminal, so that the interface to be tested of the micro-service application terminal responds to the http request to obtain an interface response result, and the micro-service application terminal returns the interface response interface to the testing tool terminal. The interface response result is an output parameter of the interface to be tested, and the output parameter may include an http request response code (e.g. 200, 304, etc.), a custom parameter (num, flag) of the interface to be tested, and the like.
It is understood that the test tool side and the microservice application side may communicate over a wireless network.
And 103, judging whether the interface response result meets a preset response data rule or not by the testing tool terminal, if so, judging that the interface response result meets the service expectation, and if not, judging that the interface response result does not meet the service expectation.
And after receiving an interface response result returned by the micro-service application end, the testing tool end reads the output parameters in the judgment interface, judges whether the output parameters in the interface response result conform to a preset response data rule, judges that the interface response result conforms to the service expectation if the output parameters in the interface response result conform to the preset response data rule, namely the micro-service application service conforms to the service expectation, and judges that the interface response result does not conform to the service expectation if the output parameters in the interface response result do not conform to the preset response data rule, namely the micro-service application service does not conform to the service.
The preset response data rule may be one or more rules, and the preset response data rule may be "a value of a certain output parameter (num) is greater than 0", or "a value of a certain output parameter (flag) is true". For example, when the preset response data rule is "a value of a certain output parameter (num) is greater than 0", the test tool reads the corresponding output parameter (num) in the interface response result, and determines whether the output parameter (num) is greater than 0, if so, it is determined that the micro service application service meets the service expectation, and if not, it is determined that the micro service application service does not meet the service expectation. It can be understood that when a certain interface to be tested has a plurality of preset response data rules, the interface response result of the interface to be tested conforms to all the preset response data rules, and then conforms to the business expectation, otherwise, does not conform to the business expectation.
In the embodiment of the application, a corresponding http request is constructed by a testing tool end according to input parameters, and after the http request is sent to an interface to be tested of a micro-service application end, whether an interface response result meets a service expectation is judged according to an interface response result returned by the micro-service application end and a preset response data rule to determine whether the micro-service application service meets the service expectation, so that the technical problem that the conventional interface testing method can only test the connectivity of an application interface and cannot test whether the application interface meets the service expectation is solved.
The foregoing is an embodiment of a method for testing a micro service application interface provided in the present application, and the following is another embodiment of a method for testing a micro service application interface provided in the present application.
For easy understanding, referring to fig. 2, another embodiment of a method for testing a microservice application interface provided by the present application includes:
The specific contents of step 201 to step 202 are the same as the specific contents of step 101 to step 102, and are not described herein again.
The testing tool end reads the http request response code in the interface response result to obtain the response state of the interface to be tested, then judges whether the response state of the interface to be tested is 200 to judge whether the http request is completed, if the response state of the interface to be tested is 200, the http request is completed, step 204 is executed, if the response state of the interface to be tested is not 200, the http request is not completed, the interface response result is directly judged to be not in line with the service expectation, namely the micro-service application service is not in line with the service expectation.
And 204, the test tool end judges whether the interface response result meets a preset response data rule, if so, the interface response result is judged to meet the service expectation, and if not, the interface response result is judged not to meet the service expectation.
The specific content of step 204 is consistent with that of step 103, and is not described herein again.
In the embodiment of the application, a corresponding http request is constructed by a testing tool end according to input parameters, and after the http request is sent to an interface to be tested of a micro-service application end, whether an interface response result meets a service expectation is judged according to an interface response result returned by the micro-service application end and a preset response data rule so as to determine whether the micro-service application service meets the service expectation, so that the technical problem that the conventional interface testing method can only test the connectivity of an application interface and cannot test whether the application interface meets the service expectation is solved;
further, the embodiment of the present application judges whether the response state of the interface to be tested is 200 according to the interface response result to test the connectivity of the interface to be tested, that is, the embodiment of the present application can test not only the connectivity of the micro service application interface, but also whether the micro service application service meets the service expectation.
The foregoing is an embodiment of a method for testing a micro service application interface provided by the present application, and the following is an embodiment of a testing tool end provided by the present application.
Referring to fig. 3, an embodiment of the present invention provides a test tool end, including:
a constructing unit 301, configured to construct an http request according to the obtained input parameters, where the input parameters include a request address, a request parameter name, a request parameter value, and/or a parameter type;
the receiving unit 302 is configured to send the http request to the interface to be tested of the microservice application terminal, and then receive an interface response result returned by the microservice application terminal;
the first determining unit 303 is configured to determine whether the interface response result meets a preset response data rule, determine that the interface response result meets a service expectation if the interface response result meets the preset response data rule, and determine that the interface response result does not meet the service expectation if the interface response result does not meet the service expectation.
As a further improvement, the test tool end in the embodiment of the present application further includes:
the second determining unit 304 is configured to determine whether a response state of the interface to be tested is 200 according to the interface response result, if so, trigger the first determining unit 303, and if not, determine that the interface response result does not meet the service expectation.
An embodiment of the present application further provides a micro service application interface test system, including: the test tool side and the microservice application side of any of the foregoing test tool side embodiments. The test tool end and the micro-service application end can communicate through a wireless network.
The embodiment of the application also provides micro-service application interface test equipment, which comprises a processor and a memory;
the memory is used for storing the program codes and transmitting the program codes to the processor;
the processor is used for executing the micro service application interface test method in the micro service application interface test method embodiment according to the instructions in the program code.
An embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium is configured to store a program code, and the program code is configured to execute the method for testing the micro service application interface in the foregoing micro service application interface testing method embodiment.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for executing all or part of the steps of the method described in the embodiments of the present application through a computer device (which may be a personal computer, a server, or a network device). And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.
Claims (7)
1. A method for testing a micro-service application interface is characterized by comprising the following steps:
the testing tool end constructs an http request according to the acquired input parameters, wherein the input parameters comprise a request address, a request parameter name, a request parameter value and/or a parameter type;
after the http request is sent to an interface to be tested of a micro-service application end by the testing tool end, receiving an interface response result returned by the micro-service application end;
and the test tool end judges whether the interface response result meets a preset response data rule, if so, the interface response result is judged to meet the service expectation, and if not, the interface response result is judged not to meet the service expectation.
2. The method for testing the micro-service application interface according to claim 1, wherein the testing tool determines whether the interface response result meets a preset response data rule, if yes, determines that the interface response result meets a service expectation, and if not, determines that the interface response result does not meet the service expectation, and before that:
and the testing tool end judges whether the response state of the interface to be tested is 200 according to the interface response result, if so, the subsequent steps are executed, and if not, the interface response result is judged to be not in accordance with the service expectation.
3. A test tool end, comprising:
the building unit is used for building an http request according to the obtained input parameters, wherein the input parameters comprise request addresses, request parameter names, request parameter values and/or parameter types;
the receiving unit is used for sending the http request to an interface to be tested of the micro-service application terminal and then receiving an interface response result returned by the micro-service application terminal;
and the first judgment unit is used for judging whether the interface response result meets a preset response data rule, if so, judging that the interface response result meets the service expectation, and if not, judging that the interface response result does not meet the service expectation.
4. The test tool tip of claim 3, further comprising:
and the second judging unit is used for judging whether the response state of the interface to be tested is 200 according to the interface response result, if so, triggering the first judging unit, and if not, judging that the interface response result does not accord with the service expectation.
5. A microservice application interface test system, comprising: the test tool side and microservice application side of any of claims 3-4.
6. A microservice application interface test device, the device comprising a processor and a memory;
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to execute the method of micro-service application interface testing of any of claims 1-2 according to instructions in the program code.
7. A computer-readable storage medium, characterized in that the computer-readable storage medium is configured to store a program code for performing the microservice application interface testing method of any of claims 1-2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011195314.3A CN112306785A (en) | 2020-10-30 | 2020-10-30 | Method, device, system, equipment and medium for testing micro-service application interface |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011195314.3A CN112306785A (en) | 2020-10-30 | 2020-10-30 | Method, device, system, equipment and medium for testing micro-service application interface |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112306785A true CN112306785A (en) | 2021-02-02 |
Family
ID=74334177
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011195314.3A Pending CN112306785A (en) | 2020-10-30 | 2020-10-30 | Method, device, system, equipment and medium for testing micro-service application interface |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112306785A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110347596A (en) * | 2019-07-02 | 2019-10-18 | 腾讯科技(深圳)有限公司 | A kind of test method, device, system, electronic equipment and medium |
CN111240955A (en) * | 2018-11-28 | 2020-06-05 | 北京京东尚科信息技术有限公司 | Automatic testing method and device for Http interface, storage medium and electronic device |
CN111813701A (en) * | 2020-09-09 | 2020-10-23 | 平安国际智慧城市科技股份有限公司 | HTTP-based interface testing method and device, computer equipment and storage medium |
-
2020
- 2020-10-30 CN CN202011195314.3A patent/CN112306785A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111240955A (en) * | 2018-11-28 | 2020-06-05 | 北京京东尚科信息技术有限公司 | Automatic testing method and device for Http interface, storage medium and electronic device |
CN110347596A (en) * | 2019-07-02 | 2019-10-18 | 腾讯科技(深圳)有限公司 | A kind of test method, device, system, electronic equipment and medium |
CN111813701A (en) * | 2020-09-09 | 2020-10-23 | 平安国际智慧城市科技股份有限公司 | HTTP-based interface testing method and device, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
"《Python自动化接口测试自学手册》", 30 June 2020, 北京:中国铁道出版社, pages: 177 - 178 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111008075B (en) | Load balancing system, method, device, equipment and medium | |
CN111045921A (en) | Automatic interface testing method and device, computer equipment and storage medium | |
CN110647490B (en) | Data transmission method, device, equipment and computer storage medium | |
CN103516851B (en) | A kind of wireless product cloud test platform system | |
CN108366098B (en) | Data interaction method and device for network nodes | |
CN103701867A (en) | Method, system and central server for processing call requests | |
CN110912805B (en) | Message reading state synchronization method, terminal, server and system | |
CN104468222A (en) | Method, device and system for reporting log information | |
US20190147443A1 (en) | Payment method based on mobile terminal and mobile terminal | |
CN109246280B (en) | Address book cloud processing method and device, computer equipment and readable storage medium | |
CN115883310A (en) | Service deployment method, service deployment system, electronic device, and storage medium | |
CN110445658B (en) | Message processing method and system | |
CN109951549B (en) | Network page access method and device and computer readable storage medium | |
CN112306785A (en) | Method, device, system, equipment and medium for testing micro-service application interface | |
CN109656791B (en) | gPC performance test method and device based on Jmeter | |
CN110933070A (en) | User identification method, system, equipment and computer readable storage medium | |
CN114666390B (en) | Page monitoring method and device of application program, electronic equipment and storage medium | |
CN108243229B (en) | Request processing method and device | |
CN105991727A (en) | Content pushing method and apparatus | |
CN105357272B (en) | A kind of OTA upgrade method and equipment | |
CN113890906A (en) | Call forwarding method and device, electronic equipment and computer readable storage medium | |
CN112651212A (en) | Method and terminal for remotely acquiring word stock | |
CN111147899A (en) | Fault early warning method and device | |
CN111178044B (en) | Method and device for determining target text elements | |
CN112487261B (en) | Data acquisition method and device, electronic equipment and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |