CN109522218A - Interface test method, device, computer equipment and storage medium - Google Patents

Interface test method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN109522218A
CN109522218A CN201811222329.7A CN201811222329A CN109522218A CN 109522218 A CN109522218 A CN 109522218A CN 201811222329 A CN201811222329 A CN 201811222329A CN 109522218 A CN109522218 A CN 109522218A
Authority
CN
China
Prior art keywords
interface
terminal
mock
measured
data
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
Application number
CN201811222329.7A
Other languages
Chinese (zh)
Inventor
张泽楷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811222329.7A priority Critical patent/CN109522218A/en
Publication of CN109522218A publication Critical patent/CN109522218A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

This application involves functional test, a kind of interface test method, device, computer equipment and storage medium are provided.The described method includes: receiving the Mock that terminal is sent tests instruction, Mock test instruction carries file identification;Interface data and Mock interface to be measured are obtained according to file identification;Test case, which is generated, according to interface data to be measured is sent to terminal;The request message that terminal is sent is received, request message is obtained test information by terminal from test case, is generated according to test information;Mock interface is called, Mock data are generated according to request message and return to terminal and complete interface testing.Development efficiency can be improved using this method.

Description

Interface test method, device, computer equipment and storage medium
Technical field
This application involves field of computer technology, more particularly to a kind of interface test method, device, computer equipment and Storage medium.
Background technique
Since front end and backstage are to be separated and independently performed, but front end needs to lead to after the completion of exploitation in the process of development again It crosses data-interface and obtains the product that data are used to test assessment front end from backstage.
However, front end can not then pass through when backstage development is not completed and data-interface does not write completion Data-interface obtains data from backstage and is tested, therefore the development process of front end is limited by backstage development process.In tradition In method, front end can only wait backstage exploitation just to can be carried out the interface joint debugging of front and back end after the completion, cause development efficiency low.
Summary of the invention
Based on this, it is necessary in view of the above technical problems, provide a kind of interface test method that can be improved development efficiency, Device, computer equipment and storage medium.
A kind of interface test method, which comprises
It receives the Mock that terminal is sent and tests instruction, the Mock test instruction carries file identification;
Interface data and Mock interface to be measured are obtained according to the file identification;
Test case, which is generated, according to the interface data to be measured is sent to terminal;
The request message that terminal is sent is received, the request message is obtained test letter by terminal from the test case Breath is generated according to the test information;
The Mock interface is called, Mock data are generated according to the request message and return to terminal and complete interface survey Examination.
The Mock interface is called in one of the embodiments, and Mock data are generated according to the request message and is returned Interface testing is completed back to terminal
Interface document to be measured is obtained, the interface document to be measured includes returning to field information;
The Mock interface generates Mock data according to the return field information;
If it is identical as the request message to recognize the Mock data, the Mock data are returned into terminal and are completed Interface testing.
It is described in one of the embodiments, to include: according to the interface data generation test case to be measured
Corresponding test case template is matched according to the interface data to be measured;
Test case is generated according to the test case template.
In one of the embodiments, the method also includes:
If not being matched to corresponding test case template according to the interface data to be measured, by the interface data to be measured Return to terminal;
Receive the test case template that terminal is returned according to the interface data to be measured.
In one of the embodiments, the method also includes:
Receive that terminal sends writes instruction, described to write instruction and carry critical field;
Mock pattern rule is called, corresponding correlation rule is obtained according to the critical field;
Code corresponding with the critical field is generated according to the correlation rule, Mock interface is completed according to the code It writes.
In one of the embodiments, the method also includes:
The handshake request that terminal is sent is received, carries Handshake Protocol and acquisition instruction in the handshake request;
If recognizing the Handshake Protocol is Websocket agreement, responds the handshake request and terminal is established Websocket connection;
Interface document is obtained according to the acquisition instruction, the former interface document is backed up and returns to terminal;
Receive terminal send new interface document, if recognize the new interface document with original interface document it is inconsistent, More new information is generated to be sent to terminal and the new interface document is replaced the former interface document.
It is described in one of the embodiments, to include: according to file identification acquisition interface data to be measured
Interface document to be measured is obtained according to the file identification;
Interface data to be measured is obtained according to the interface document to be measured.
A kind of interface test device, described device include:
Receiving module, for receiving the Mock test instruction of terminal transmission, the Mock test instruction carries files-designated Know;
Module is obtained, for obtaining interface data and Mock interface to be measured according to the file identification;
Generation module is sent to terminal for generating test case according to the interface data to be measured;
The receiving module is also used to receive the request message of terminal transmission, and the request message is by terminal from the test Test information is obtained in use-case, is generated according to the test information;
Calling module generates Mock data according to the request message and returns to end for calling the Mock interface Complete interface testing in end.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing Device realizes interface test method described in above-mentioned any one when executing the computer program.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor Interface test method described in above-mentioned any one is realized when row.
Above-mentioned interface test method, device, computer equipment and storage medium are tested by receiving the Mock that terminal is sent Instruction, Mock test instruction carry file identification.Interface data and Mock interface to be measured are obtained according to file identification.According to It surveys interface data generation test case and is sent to terminal, receive the request message that terminal is sent.Request message is by terminal from test Test information is obtained in use-case, is generated according to the test information.Mock interface is called, Mock data are generated according to request message And it returns to terminal and completes interface testing.The above method carries out interface testing by Mock method, improves the efficiency of exploitation.
Detailed description of the invention
Fig. 1 is the application scenario diagram of interface test method in one embodiment;
Fig. 2 is the flow diagram of interface test method in one embodiment;
Fig. 3 is the flow diagram of Mock interface write method in one embodiment;
Fig. 4 is the structural block diagram of interface test device in one embodiment;
Fig. 5 is the internal structure chart of computer equipment in one embodiment.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not For limiting the application.
Interface test method provided by the present application can be applied in application environment as shown in Figure 1.Wherein, terminal 102 It is communicated by network with server 104.Server 104 receives the Mock that terminal 102 is sent and tests instruction, and Mock test refers to File identification is carried in order.Server 104 obtains interface data and Mock interface to be measured according to file identification.Server 104 Test case is generated according to interface data to be measured and test case is sent to terminal 102.Server 104 receives terminal 102 and sends out The request message sent, request message is that terminal 102 obtains test information from the test case that server 104 returns, according to survey Try the request message that information generates.Server 104 calls Mock interface, generates Mock data according to request message and returns to end Complete interface testing in end 102.Wherein, terminal 102 can be, but not limited to be various personal computers, laptop, intelligent hand Machine, tablet computer and portable wearable device, server 104 can be formed with the either multiple servers of independent server Server cluster realize.
In one embodiment, as shown in Fig. 2, providing a kind of interface test method, it is applied in Fig. 1 in this way It is illustrated for server, comprising the following steps:
Step S202 receives the Mock that terminal is sent and tests instruction, and Mock test instruction carries file identification.
Wherein, Mock test refers to during the test, for certain objects for being not easy to construct or be not easy to obtain, The test method so as to test is created with a virtual object.Mock test instruction refer to terminal be used to indicate server into The instruction request of row test.File identification refers to the unique identification for indicating interface document to be measured and interface data to be measured.Tool Body, after developer completes front end development, Mock is entered by terminal and manages platform to server transmission Mock test Instruction, and tested in instruction by the Mock that Mock manages the transmission of platform and carry file identification.
Step S204 obtains interface data and Mock interface to be measured according to file identification.
Wherein, Mock interface is write according to the interface document that front and back end is appointed in advance, is capable of providing and data Virtual interface.Specifically, being obtained from database after server receives the file identification that terminal is sent according to file identification Corresponding interface document to be measured extracts interface data to be measured from interface document to be measured, and obtains the Mock write in advance and connect Mouth is ready for Mock test.
Step S206 generates test case according to interface data to be measured and is sent to terminal.
Wherein, test case refers to one group of test input, execution condition and the expection worked out for some special objective As a result, to test some Program path or the suitable document for whether meeting some particular demands.Specifically, server is got After interface data to be measured, corresponding test case template is got according to interface data to be measured matching.Interface data to be measured is defeated Enter and generates corresponding test case into test case template.
Step S208, receives the request message that terminal is sent, and request message is obtained test letter by terminal from test case Breath is generated according to test information.
Wherein, message is the data cell exchanged in network with transmission, is generally divided into request message and response message.Request Message, which refers to, is used for what request data exchanged by what request row, request header, null and request data formed.Test packet Include request method, request URL address (Uniform Resource Locator, uniform resource locator) and required parameter.
Specifically, after server, which will generate test case according to interface data to be measured, be sent to terminal, terminal is from reception To test case in after the test information such as acquisition request mode, the address URL of request and required parameter, by the test information It carries out packing generation request message and is sent to server.
Step S210 calls Mock interface, generates Mock data according to request message and returns to terminal and completes interface survey Examination.
After server receives the request message of terminal transmission, Mock number is generated according to the request content of request message According to the Mock data of generation are returned to terminal by Mock interface.After terminal receives Mock data, judge that Mock data are It is no consistent with the requested content of request message, if then indicating that the data returned are correct, interface testing success.If recognizing this The Mock data of return and the requested content of message are inconsistent, then collect error message feed back to related personnel continue it is corresponding Modification.Wherein, if the requested data of request message are A, the Mock data that server is returned according to request message should It is similarly A.
In above-mentioned interface test method, instruction is tested by receiving the Mock that terminal is sent, Mock test instruction carries File identification.Interface data and Mock interface to be measured are obtained according to file identification.Test case is generated according to interface data to be measured It is sent to terminal, receives the request message that terminal is sent.Request message is obtained test information by terminal from test case, according to The test information generates.Mock interface is called, Mock data are generated according to request message and return to terminal and complete interface survey Examination.The above method carries out interface testing by Mock method, improves the efficiency of exploitation.
In one embodiment, Mock interface is called, Mock data are generated according to request message and return to terminal and are completed For interface testing comprising steps of obtaining interface document to be measured, interface document to be measured includes returning to field information;Mock interface is according to returning Back Word segment information generates Mock data;If it is identical as request message to recognize Mock data, Mock data are returned into terminal Complete interface testing.
Wherein, interface document includes the request field information made an appointment, returns to field information and generate Mock data Rule etc..Returning to field information includes title, the type of field, the length of field, field definition and the data for returning to field Type etc..Mock data are stored in advance according to the return field information in the interface document made an appointment.Specifically, it takes Business device calls Mock interface, obtains interface document to be measured, the return field information made an appointment is obtained from interface document to be measured, Pre-stored Mock data are obtained according to the return field information.What the Mock data and terminal that server judgement generates were sent Whether request message is identical, if it is identical with request message to recognize Mock data, Mock data is returned to terminal completion and are connect Mouth test.For example, the Mock data that Mock interface generates are similarly " just if the field that request message request returns is " correct " Really ", then it represents that Mock data are identical as the request message that terminal is sent.
In one embodiment, interface data to be measured is obtained comprising steps of obtaining according to file identification according to file identification Interface document to be measured;Interface data to be measured is obtained according to interface document to be measured.
File identification and interface document to be measured be it is corresponding, each interface document to be measured has a fixed file identification. File identification can with number-mark, for example, number 1 it is corresponding indicate an interface document to be measured, number 2 it is corresponding indicate one it is to be measured Interface document etc..It is numbered and is storing into server in advance when writing interface document to be measured in advance.It is by file identification Corresponding interface document to be measured can be obtained.Wherein, interface document to be measured includes multiple interfaces data, such as: interface IP address, interface Title, transmission mode and interface parameters etc..Specifically, it is got from database when server according to file identification corresponding After interface document to be measured, the content of interface document to be measured is loaded, interface data to be measured is obtained from interface document to be measured.
In one embodiment, test case is generated comprising steps of according to interface data to be measured according to interface data to be measured Match corresponding test case template;Test case is generated according to test case template.
Test case template is prestored in the server by writing in advance.Server is got pair by file identification The interface document to be measured answered, after getting interface message to be measured in interface document to be measured.According to interface message to be measured from prestoring Test case template in matched and searched test case template corresponding with interface message to be measured, generated according to test case template Test case.
Wherein, interface testing use-case template includes project name, module title, use-case title, interface name, use-case mark Topic, request method, request URL address, required parameter, result verification, request message, returned packet and test result etc..Tool Body, when server is used for interface testing, the interface data information to be measured of acquisition is interface IP address, interface name, transmission mode And when interface parameters, interface testing use-case template can be matched to according to the interface data.According to the interface testing use-case mould Plate generates the corresponding test case of interface.
If generating multiple test cases, test case is packaged into test case packet and is sent to terminal, terminal is got Test case packet is parsed after test case packet first and obtains test case.If having successfully completed interface according to current test case to survey Examination, further detecting the test case in test case packet, all whether test is completed, if all test cases test completion, Terminate interface testing.If there are also the test case for not testing completion, terminal is sent to according to the Test cases technology request message Terminal carries out interface testing, until all test cases in test case packet all test completion.
It in one embodiment, will be to be measured if not being matched to corresponding test case template according to interface data to be measured Interface data returns to terminal;Receive the test case template that terminal is returned according to interface data to be measured.
If server is matched according to interface data to be measured less than corresponding interface testing use-case template, by number of ports to be measured According to being directly returned to terminal.Interface data to be measured is managed platform by Mock and shown on terminal display screen by terminal.Exploit person Member writes new test case template in Mock management platform according to interface data to be measured and returns to server.Server root Test case is generated according to the test case template, and test case template is stored to database and facilitates subsequent use.
In one embodiment, as shown in figure 3, providing a kind of Mock interface write method, specifically includes the following steps:
Step S302, receive terminal transmission writes instruction, writes instruction and carries critical field.
Wherein, writing instruction is that terminal is sent to server and is used to indicate server and carries out the instruction write of Mock interface. Critical field refers to the keyword in write code statement.Specifically, developer is flat by terminal operation Mock management Platform, selection Mock interface writes function on Mock management platform, and Mock management platform can will write region and show in terminal On display screen, and terminal writes instruction to server transmission simultaneously.Developer can be by writing code writing region Relevant critical field, the critical field is sent to server by terminal in real time while developer writes critical field.
Step S304 calls Mock pattern rule, obtains corresponding correlation rule according to critical field.
Wherein, Mock pattern rule refers to for matching corresponding correlation rule in the critical field that terminal inputs for user Series of rules, different critical fielies should match different correlation rules, and the matched rule of institute can be one or It is multiple.Correlation rule, which just refers to, has recorded code statement relevant to critical field and prompt information etc..Specifically, work as service When device receives the critical field that terminal is sent in real time, calling Mock template is that the critical field matches corresponding correlation rule. For example, critical field is B, then Mock pattern rule is called to find out the association rule containing critical field B from all correlation rules Then, which is the correlation rule of critical field B.
Step S306 generates code corresponding with critical field according to correlation rule, completes Mock interface according to code and compiles It writes.
When server calls Mock pattern rule is that critical field is matched to corresponding correlation rule, advised according to the association Then code statement and prompt information documented by the inside, complete code statement is generated centered on the critical field and returns to end End, terminal based on the received write by code statement completion Mock interface.For example, describing in correlation rule has with critical field B The code statement 1 of pass, then return to terminal for code statement 1.Wherein, according to matched correlation rule quantity, Yi Jiguan Multiple code statements can be generated in the difference of code statement data relevant to critical field documented by connection rule.It is more when generating When a code statement, i.e., code statement generated is all back to terminal, and be shown in keyword according to sequence arrangement up and down The side blank space of section.User therefrom selects suitable code statement by operating terminal, complete according to selected code statement It is write at Mock interface.
In the present embodiment, it is all directly to be write all code languages manually by staff that legacy interface, which is write, Sentence causes manpower consumption big and inefficiency.It has been generated by the Mock pattern rule in this implementation automatically according to critical field Whole code statement improves work efficiency.
In one embodiment, a kind of method of management interface document is provided, step is specifically included: receiving what terminal was sent Handshake request carries Handshake Protocol and acquisition instruction in handshake request;If recognizing Handshake Protocol is WebSocket agreement, It then responds handshake request and establishes Websocket with terminal and connect;Former interface document is obtained according to acquisition instruction, backs up former interface text Shelves return to terminal;Receive terminal send new interface document, if recognize new interface document with original interface document it is inconsistent, More new information is generated to be sent to terminal and new interface document is replaced former interface document.
Wherein, WebSocket agreement is the new network protocol of one kind based on TCP, and browser and server may be implemented Full-duplex communication allows server active transmission information to terminal.Handshake request refers to that being used to indicate server and terminal establishes Connection based on WebSocket agreement.Acquisition request refers to for obtaining the instruction for prestoring interface document in the server, In, the file identification of interface document to be obtained is carried in acquisition instruction.Former interface document refers to that server refers to according to acquisition Enable acquired interface document, new interface document refer to again return to after terminal receives the former interface document of server transmission to The interface document of server.
Specifically, when terminal need from server acquisition prestore interface document when, terminal i.e. be based on WebSocket agreement to Server sends handshake request, i.e., carries Handshake Protocol and acquisition instruction in handshake request.Server receives terminal transmission Handshake request after, if to recognize Handshake Protocol in handshake request be WebSocket agreement, directly establish connection of shaking hands And it returns to terminal and informs successful connection.Wherein, it if the Handshake Protocol recognized is not WebSocket agreement, is sent to terminal Confirmation message is confirmed whether to carry out the connection of non-WebSocket agreement.User by the determination of operating terminal and cancel button into Row selection.After successful connection, server obtains the file identification of carrying from acquisition instruction, obtains interface according to file identification Document.The interface document backup that server will acquire is stored to temporary storage area, and will be stored in the standby of temporary storage area Part interface document returns to terminal.When terminal receives the backup interface document of server return, interface document is increased Add, delete etc. modifications update operation or the interface document returned into service again after can doing nothing Device.After server receives the new interface document of terminal transmission, the backup interface text of the new interface document and temporary realm is loaded Shelves content, compare whether new interface document inconsistent with backup interface document, that is, terminal return interface document be into Went modification document.If inconsistent, generate more new information and return to the terminal notifying user interface document and modified more Newly, it and deletes the backup interface document of temporary storage area storage and the new interface document is substituted for former interface document. Also, the server can be attached with multiple terminals, after different user terminals modifies to interface document, service The more new information of generation is then sent to all terminals having connected by device, and terminal user can obtain more after receiving more new information Interface document after new.
In the present embodiment, based on WebSocket agreement carry out interface document management, once interface document have it is any Modification, related development personnel can all receive modification information, to facilitate multi-party management interface document simultaneously, improve development Efficiency.
It should be understood that although each step in the flow chart of Fig. 2-3 is successively shown according to the instruction of arrow, These steps are not that the inevitable sequence according to arrow instruction successively executes.Unless expressly stating otherwise herein, these steps Execution there is no stringent sequences to limit, these steps can execute in other order.Moreover, at least one in Fig. 2-3 Part steps may include that perhaps these sub-steps of multiple stages or stage are not necessarily in synchronization to multiple sub-steps Completion is executed, but can be executed at different times, the execution sequence in these sub-steps or stage is also not necessarily successively It carries out, but can be at least part of the sub-step or stage of other steps or other steps in turn or alternately It executes.
In one embodiment, as shown in figure 4, providing a kind of interface test device, comprising: receiving module 402 obtains Module 404, generation module 406 and calling module 408, in which:
Receiving module 402, for receiving the Mock test instruction of terminal transmission, Mock test instruction carries files-designated Know.
Module 404 is obtained, for obtaining interface data and Mock interface to be measured according to file identification.
Generation module 406 is sent to terminal for generating test case according to interface data to be measured.
Receiving module 402 is also used to receive the request message of terminal transmission, and request message is obtained from test case by terminal Test information is taken, is generated according to test information
Calling module 408 generates Mock data according to request message and returns to terminal and complete for calling Mock interface Interface testing.
In one embodiment, calling module 408 is also used to obtain interface document to be measured, and interface document to be measured includes returning Field information;Mock interface generates Mock data according to field information is returned;If it is identical as request message to recognize Mock data, Mock data are then returned into terminal and complete interface testing.
In one embodiment, module 404 is obtained to be also used to match corresponding test case mould according to interface data to be measured Plate;Test case is generated according to test case template.
In one embodiment, generation module 406 is also used to match corresponding test case mould according to interface data to be measured Plate;Test case is generated according to test case template.
If not being matched to corresponding test case template according to interface data to be measured, interface data to be measured is returned into end End;Receive the test case template that terminal is returned according to interface data to be measured.
In one embodiment, further include writing module, for receive terminal transmission write instruction, write instruction carrying There is critical field;Mock pattern rule is called, corresponding correlation rule is obtained according to critical field;According to correlation rule generate with The corresponding code of critical field is completed Mock interface according to code and is write.
In one embodiment, further include update module, for receiving the handshake request of terminal transmission, taken in handshake request With Handshake Protocol and acquisition instruction;If recognizing Handshake Protocol is WebSocket agreement, responds handshake request and built with terminal Vertical Websocket connection;Interface document is obtained according to acquisition instruction, former interface document is backed up and returns to terminal;Receive terminal hair The new interface document sent generates more new information and is sent to terminal if recognizing new interface document and former interface document is inconsistent And new interface document is replaced into former interface document.
Specific about interface test device limits the restriction that may refer to above for interface test method, herein not It repeats again.Modules in above-mentioned interface test device can be realized fully or partially through software, hardware and combinations thereof.On Stating each module can be embedded in the form of hardware or independently of in the processor in computer equipment, can also store in a software form In memory in computer equipment, the corresponding operation of the above modules is executed in order to which processor calls.
In one embodiment, a kind of computer equipment is provided, which can be server, internal junction Composition can be as shown in Figure 5.The computer equipment include by system bus connect processor, memory, network interface and Database.Wherein, the processor of the computer equipment is for providing calculating and control ability.The memory packet of the computer equipment Include non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program and data Library.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating The database of machine equipment is for storing test data.The network interface of the computer equipment is used to pass through network with external terminal Connection communication.To realize a kind of interface test method when the computer program is executed by processor.
It will be understood by those skilled in the art that structure shown in Fig. 5, only part relevant to application scheme is tied The block diagram of structure does not constitute the restriction for the computer equipment being applied thereon to application scheme, specific computer equipment It may include perhaps combining certain components or with different component layouts than more or fewer components as shown in the figure.
In one embodiment, a kind of computer equipment, including memory and processor are provided, which is stored with Computer program, the processor perform the steps of when executing computer program
It receives the Mock that terminal is sent and tests instruction, Mock test instruction carries file identification;
Interface data and Mock interface to be measured are obtained according to file identification;
Test case, which is generated, according to interface data to be measured is sent to terminal;
The request message that terminal is sent is received, request message is obtained test information by terminal from test case, according to survey Information is tried to generate;
Mock interface is called, Mock data are generated according to request message and return to terminal and complete interface testing.
In one embodiment, it is also performed the steps of when processor executes computer program
Calling module 408 is also used to obtain interface document to be measured, and interface document to be measured includes returning to field information;
Mock interface generates Mock data according to field information is returned;
If it is identical as request message to recognize Mock data, Mock data are returned into terminal and complete interface testing.
In one embodiment, it is also performed the steps of when processor executes computer program
Corresponding test case template is matched according to interface data to be measured;
Test case is generated according to test case template.
In one embodiment, it is also performed the steps of when processor executes computer program
If not being matched to corresponding test case template according to interface data to be measured, interface data to be measured is returned into end End;
Receive the test case template that terminal is returned according to interface data to be measured.
In one embodiment, it is also performed the steps of when processor executes computer program
Receive terminal transmission writes instruction, writes instruction and carries critical field;
Mock pattern rule is called, corresponding correlation rule is obtained according to critical field;
Code corresponding with critical field is generated according to correlation rule, Mock interface is completed according to code and is write.
In one embodiment, it is also performed the steps of when processor executes computer program
The handshake request that terminal is sent is received, carries Handshake Protocol and acquisition instruction in handshake request;
If recognizing Handshake Protocol is Websocket agreement, responds handshake request and terminal establishes Websocket company It connects;
Former interface document is obtained according to acquisition instruction, former interface document is backed up and returns to terminal;
Receive terminal send new interface document, if recognize new interface document with original interface document it is inconsistent, generate More new information is sent to terminal and new interface document is replaced former interface document.
In one embodiment, it is also performed the steps of when processor executes computer program
Interface document to be measured is obtained according to file identification;
Interface data to be measured is obtained according to interface document to be measured.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated Machine program performs the steps of when being executed by processor
It receives the Mock that terminal is sent and tests instruction, Mock test instruction carries file identification;
Interface data and Mock interface to be measured are obtained according to file identification;
Test case, which is generated, according to interface data to be measured is sent to terminal;
The request message that terminal is sent is received, request message is obtained test information by terminal from test case, according to survey Information is tried to generate;
Mock interface is called, Mock data are generated according to request message and return to terminal and complete interface testing.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated Machine program performs the steps of when being executed by processor
Calling module 408 is also used to obtain interface document to be measured, and interface document to be measured includes returning to field information;
Mock interface generates Mock data according to field information is returned;
If it is identical as request message to recognize Mock data, Mock data are returned into terminal and complete interface testing.
In one embodiment, it is also performed the steps of when computer program is executed by processor
Corresponding test case template is matched according to interface data to be measured;
Test case is generated according to test case template.
In one embodiment, it is also performed the steps of when computer program is executed by processor
If not being matched to corresponding test case template according to interface data to be measured, interface data to be measured is returned into end End;
Receive the test case template that terminal is returned according to interface data to be measured.
In one embodiment, it is also performed the steps of when computer program is executed by processor
Receive terminal transmission writes instruction, writes instruction and carries critical field;
Mock pattern rule is called, corresponding correlation rule is obtained according to critical field;
Code corresponding with critical field is generated according to correlation rule, Mock interface is completed according to code and is write.
In one embodiment, it is also performed the steps of when computer program is executed by processor
The handshake request that terminal is sent is received, carries Handshake Protocol and acquisition instruction in handshake request;
If recognizing Handshake Protocol is Websocket agreement, responds handshake request and terminal establishes Websocket company It connects;
Former interface document is obtained according to acquisition instruction, former interface document is backed up and returns to terminal;
Receive terminal send new interface document, if recognize new interface document with original interface document it is inconsistent, generate More new information is sent to terminal and new interface document is replaced former interface document.
In one embodiment, it is also performed the steps of when computer program is executed by processor
Interface document to be measured is obtained according to file identification;
Interface data to be measured is obtained according to interface document to be measured.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with Relevant hardware is instructed to complete by computer program, the computer program can be stored in a non-volatile computer In read/write memory medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, To any reference of memory, storage, database or other media used in each embodiment provided herein, Including non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms, Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance Shield all should be considered as described in this specification.
The several embodiments of the application above described embodiment only expresses, the description thereof is more specific and detailed, but simultaneously It cannot therefore be construed as limiting the scope of the patent.It should be pointed out that coming for those of ordinary skill in the art It says, without departing from the concept of this application, various modifications and improvements can be made, these belong to the protection of the application Range.Therefore, the scope of protection shall be subject to the appended claims for the application patent.

Claims (10)

1. a kind of interface test method, which comprises
It receives the Mock that terminal is sent and tests instruction, the Mock test instruction carries file identification;
Interface data and Mock interface to be measured are obtained according to the file identification;
Test case, which is generated, according to the interface data to be measured is sent to terminal;
The request message that terminal is sent is received, the request message is obtained test information, root by terminal from the test case It is generated according to the test information;
The Mock interface is called, Mock data are generated according to the request message and return to terminal and complete interface testing.
2. being reported the method according to claim 1, wherein described call the Mock interface according to the request Text, which generates Mock data and returns to terminal, completes interface testing
Interface document to be measured is obtained, the interface document to be measured includes returning to field information;
The Mock interface generates Mock data according to the return field information;
If it is identical as the request message to recognize the Mock data, the Mock data are returned into terminal and complete interface Test.
3. the method according to claim 1, wherein described generate test case according to the interface data to be measured Include:
Corresponding test case template is matched according to the interface data to be measured;
Test case is generated according to the test case template.
4. according to the method described in claim 3, it is characterized in that, the method also includes:
If not being matched to corresponding test case template according to the interface data to be measured, the interface data to be measured is returned To terminal;
Receive the test case template that terminal is returned according to the interface data to be measured.
5. the method according to claim 1, wherein the method also includes:
Receive that terminal sends writes instruction, described to write instruction and carry critical field;
Mock pattern rule is called, corresponding correlation rule is obtained according to the critical field;
Code corresponding with the critical field is generated according to the correlation rule, Mock interface is completed according to the code and is compiled It writes.
6. the method according to claim 1, wherein the method also includes:
The handshake request that terminal is sent is received, carries Handshake Protocol and acquisition instruction in the handshake request;
If recognizing the Handshake Protocol is Websocket agreement, responds the handshake request and terminal establishes Websocket Connection;
Former interface document is obtained according to the acquisition instruction, the former interface document is backed up and returns to terminal;
Receive terminal send new interface document, if recognize the new interface document with original interface document it is inconsistent, generate More new information is sent to terminal and the new interface document is replaced the former interface document.
7. the method according to claim 1, wherein described obtain interface data to be measured according to the file identification It include: that interface document to be measured is obtained according to the file identification;
Interface data to be measured is obtained according to the interface document to be measured.
8. a kind of interface test device, which is characterized in that described device includes:
Receiving module, for receiving the Mock test instruction of terminal transmission, the Mock test instruction carries file identification;
Module is obtained, for obtaining interface data and Mock interface to be measured according to the file identification;
Generation module is sent to terminal for generating test case according to the interface data to be measured;
The receiving module is also used to receive the request message of terminal transmission, and the request message is by terminal from the test case Information is tested in middle acquisition, is generated according to the test information;
Calling module generates Mock data according to the request message and to return to terminal complete for calling the Mock interface At interface testing.
9. a kind of computer equipment, including memory and processor, the memory are stored with computer program, feature exists In the step of processor realizes any one of claims 1 to 7 the method when executing the computer program.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program The step of method described in any one of claims 1 to 7 is realized when being executed by processor.
CN201811222329.7A 2018-10-19 2018-10-19 Interface test method, device, computer equipment and storage medium Pending CN109522218A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811222329.7A CN109522218A (en) 2018-10-19 2018-10-19 Interface test method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811222329.7A CN109522218A (en) 2018-10-19 2018-10-19 Interface test method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN109522218A true CN109522218A (en) 2019-03-26

Family

ID=65772128

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811222329.7A Pending CN109522218A (en) 2018-10-19 2018-10-19 Interface test method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109522218A (en)

Cited By (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110209575A (en) * 2019-05-20 2019-09-06 深圳壹账通智能科技有限公司 Test document generation method, device, electronic equipment and storage medium
CN110262978A (en) * 2019-06-24 2019-09-20 四川新网银行股份有限公司 It is a kind of based on long process automation test interface retry method and data flow
CN110287109A (en) * 2019-06-18 2019-09-27 广州华多网络科技有限公司 Test method, device, computer equipment and its storage medium of protocol interface
CN110287099A (en) * 2019-05-21 2019-09-27 平安银行股份有限公司 Simplify Loadrunner performance test methods, server and computer readable storage medium
CN110337076A (en) * 2019-07-09 2019-10-15 深圳壹账通智能科技有限公司 SMS platform interface test method, device, computer equipment and storage medium
CN110347604A (en) * 2019-07-11 2019-10-18 中国工商银行股份有限公司 Programming interface test method and equipment, electronic equipment and readable storage medium storing program for executing
CN110399294A (en) * 2019-06-26 2019-11-01 平安科技(深圳)有限公司 Method for generating test case, device, computer equipment and storage medium
CN110413507A (en) * 2019-06-21 2019-11-05 平安科技(深圳)有限公司 System detection method, device, computer equipment and storage medium
CN110457228A (en) * 2019-08-22 2019-11-15 携程计算机技术(上海)有限公司 The comparison method and system of interface returned packet
CN110554956A (en) * 2019-07-31 2019-12-10 交控科技股份有限公司 BDMS automatic testing method
CN110597706A (en) * 2019-08-02 2019-12-20 贝壳技术有限公司 Method and device for testing application program interface data abnormity
CN110716919A (en) * 2019-09-23 2020-01-21 贝壳技术有限公司 Mock testing method, Mock testing device and storage medium
CN110825431A (en) * 2019-11-14 2020-02-21 京东数字科技控股有限公司 Interface document processing method, device, system, storage medium and electronic equipment
CN110990205A (en) * 2019-11-28 2020-04-10 腾讯科技(深圳)有限公司 Interface call testing method, device and computer readable storage medium
CN111045756A (en) * 2019-12-10 2020-04-21 中国工商银行股份有限公司 Method, apparatus, computing device, and medium for generating interface service
CN111078477A (en) * 2019-11-13 2020-04-28 航天信息股份有限公司 Interface test method and device, storage medium and electronic equipment
CN111078562A (en) * 2019-12-18 2020-04-28 广州唯品会研究院有限公司 Interface test method, terminal device and computer readable storage medium
CN111143224A (en) * 2019-12-30 2020-05-12 广州酷狗计算机科技有限公司 Pile service implementation method, device, equipment and computer storage medium
CN111181805A (en) * 2019-12-25 2020-05-19 航天信息股份有限公司 Micro-service test baffle generation method and system based on test case
CN111190596A (en) * 2019-12-24 2020-05-22 平安普惠企业管理有限公司 Joint debugging method and device, computer equipment and readable storage medium
CN111290951A (en) * 2020-01-22 2020-06-16 京东数字科技控股有限公司 Test method, terminal, server, system and storage medium
CN111478969A (en) * 2020-04-09 2020-07-31 吉林亿联银行股份有限公司 Interface checking method and device
WO2020211360A1 (en) * 2019-04-19 2020-10-22 平安普惠企业管理有限公司 Mock test method and system, electronic device, and computer non-volatile readable storage medium
CN111858296A (en) * 2019-12-31 2020-10-30 北京嘀嘀无限科技发展有限公司 Interface test method, device, equipment and storage medium
CN112100079A (en) * 2020-11-02 2020-12-18 北京淇瑀信息科技有限公司 Test method and system based on simulation data calling and electronic equipment
CN112181824A (en) * 2020-09-25 2021-01-05 中国建设银行股份有限公司 System development auxiliary platform and method
CN112910741A (en) * 2021-02-26 2021-06-04 平安普惠企业管理有限公司 Interface testing method and device, computer equipment and storage medium
CN113176993A (en) * 2021-04-28 2021-07-27 平安银行股份有限公司 Case testing method and device, electronic equipment and storage medium
CN113204496A (en) * 2021-06-03 2021-08-03 上海中通吉网络技术有限公司 Fiddler-based security override problem batch test method and device
CN113220595A (en) * 2021-06-11 2021-08-06 中国农业银行股份有限公司 Test method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104102480A (en) * 2013-04-11 2014-10-15 腾讯科技(深圳)有限公司 Method and device for generating configuration file
US20160246706A1 (en) * 2015-02-20 2016-08-25 Vmware, Inc. Generating test cases
CN106326121A (en) * 2016-08-22 2017-01-11 上海亿账通互联网科技有限公司 Method for automatically generating test script and terminal
CN106528400A (en) * 2016-09-22 2017-03-22 深圳峰创智诚科技有限公司 MOCK testing method and device
CN107592238A (en) * 2017-08-07 2018-01-16 千寻位置网络有限公司 Automatic test approach and system, service terminal, the memory of interface
CN107844421A (en) * 2017-10-31 2018-03-27 平安科技(深圳)有限公司 Interface test method, device, computer equipment and storage medium
CN108446225A (en) * 2018-03-06 2018-08-24 平安科技(深圳)有限公司 Creating device, method and the computer readable storage medium of analog interface

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104102480A (en) * 2013-04-11 2014-10-15 腾讯科技(深圳)有限公司 Method and device for generating configuration file
US20160246706A1 (en) * 2015-02-20 2016-08-25 Vmware, Inc. Generating test cases
CN106326121A (en) * 2016-08-22 2017-01-11 上海亿账通互联网科技有限公司 Method for automatically generating test script and terminal
CN106528400A (en) * 2016-09-22 2017-03-22 深圳峰创智诚科技有限公司 MOCK testing method and device
CN107592238A (en) * 2017-08-07 2018-01-16 千寻位置网络有限公司 Automatic test approach and system, service terminal, the memory of interface
CN107844421A (en) * 2017-10-31 2018-03-27 平安科技(深圳)有限公司 Interface test method, device, computer equipment and storage medium
CN108446225A (en) * 2018-03-06 2018-08-24 平安科技(深圳)有限公司 Creating device, method and the computer readable storage medium of analog interface

Cited By (43)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020211360A1 (en) * 2019-04-19 2020-10-22 平安普惠企业管理有限公司 Mock test method and system, electronic device, and computer non-volatile readable storage medium
CN110209575A (en) * 2019-05-20 2019-09-06 深圳壹账通智能科技有限公司 Test document generation method, device, electronic equipment and storage medium
CN110287099B (en) * 2019-05-21 2023-11-21 平安银行股份有限公司 Simplified Loadrunner performance test method, server and computer readable storage medium
CN110287099A (en) * 2019-05-21 2019-09-27 平安银行股份有限公司 Simplify Loadrunner performance test methods, server and computer readable storage medium
CN110287109B (en) * 2019-06-18 2023-09-19 广州华多网络科技有限公司 Protocol interface testing method and device, computer equipment and storage medium thereof
CN110287109A (en) * 2019-06-18 2019-09-27 广州华多网络科技有限公司 Test method, device, computer equipment and its storage medium of protocol interface
CN110413507B (en) * 2019-06-21 2024-05-03 平安科技(深圳)有限公司 System test method, device, computer equipment and storage medium
CN110413507A (en) * 2019-06-21 2019-11-05 平安科技(深圳)有限公司 System detection method, device, computer equipment and storage medium
CN110262978B (en) * 2019-06-24 2022-12-09 四川新网银行股份有限公司 Interface retry method and device based on long-flow automatic test
CN110262978A (en) * 2019-06-24 2019-09-20 四川新网银行股份有限公司 It is a kind of based on long process automation test interface retry method and data flow
CN110399294A (en) * 2019-06-26 2019-11-01 平安科技(深圳)有限公司 Method for generating test case, device, computer equipment and storage medium
CN110337076A (en) * 2019-07-09 2019-10-15 深圳壹账通智能科技有限公司 SMS platform interface test method, device, computer equipment and storage medium
CN110347604A (en) * 2019-07-11 2019-10-18 中国工商银行股份有限公司 Programming interface test method and equipment, electronic equipment and readable storage medium storing program for executing
CN110554956A (en) * 2019-07-31 2019-12-10 交控科技股份有限公司 BDMS automatic testing method
CN110554956B (en) * 2019-07-31 2023-05-23 交控科技股份有限公司 BDMS automatic test method
CN110597706A (en) * 2019-08-02 2019-12-20 贝壳技术有限公司 Method and device for testing application program interface data abnormity
CN110457228B (en) * 2019-08-22 2022-12-20 携程计算机技术(上海)有限公司 Method and system for comparing interface return messages
CN110457228A (en) * 2019-08-22 2019-11-15 携程计算机技术(上海)有限公司 The comparison method and system of interface returned packet
CN110716919A (en) * 2019-09-23 2020-01-21 贝壳技术有限公司 Mock testing method, Mock testing device and storage medium
CN111078477A (en) * 2019-11-13 2020-04-28 航天信息股份有限公司 Interface test method and device, storage medium and electronic equipment
CN110825431A (en) * 2019-11-14 2020-02-21 京东数字科技控股有限公司 Interface document processing method, device, system, storage medium and electronic equipment
CN110825431B (en) * 2019-11-14 2021-07-20 京东数字科技控股有限公司 Interface document processing method, device, system, storage medium and electronic equipment
CN110990205B (en) * 2019-11-28 2022-09-02 腾讯科技(深圳)有限公司 Interface call testing method, device and computer readable storage medium
CN110990205A (en) * 2019-11-28 2020-04-10 腾讯科技(深圳)有限公司 Interface call testing method, device and computer readable storage medium
CN111045756A (en) * 2019-12-10 2020-04-21 中国工商银行股份有限公司 Method, apparatus, computing device, and medium for generating interface service
CN111045756B (en) * 2019-12-10 2024-01-09 中国工商银行股份有限公司 Method, apparatus, computing device and medium for generating interface service
CN111078562A (en) * 2019-12-18 2020-04-28 广州唯品会研究院有限公司 Interface test method, terminal device and computer readable storage medium
CN111078562B (en) * 2019-12-18 2024-01-16 广州品唯软件有限公司 Interface test method, terminal device and computer readable storage medium
CN111190596A (en) * 2019-12-24 2020-05-22 平安普惠企业管理有限公司 Joint debugging method and device, computer equipment and readable storage medium
CN111181805A (en) * 2019-12-25 2020-05-19 航天信息股份有限公司 Micro-service test baffle generation method and system based on test case
CN111181805B (en) * 2019-12-25 2022-04-29 航天信息股份有限公司 Micro-service test baffle generation method and system based on test case
CN111143224A (en) * 2019-12-30 2020-05-12 广州酷狗计算机科技有限公司 Pile service implementation method, device, equipment and computer storage medium
CN111858296A (en) * 2019-12-31 2020-10-30 北京嘀嘀无限科技发展有限公司 Interface test method, device, equipment and storage medium
CN111290951A (en) * 2020-01-22 2020-06-16 京东数字科技控股有限公司 Test method, terminal, server, system and storage medium
CN111290951B (en) * 2020-01-22 2023-09-26 京东科技控股股份有限公司 Test method, terminal, server, system and storage medium
CN111478969A (en) * 2020-04-09 2020-07-31 吉林亿联银行股份有限公司 Interface checking method and device
CN112181824A (en) * 2020-09-25 2021-01-05 中国建设银行股份有限公司 System development auxiliary platform and method
CN112100079A (en) * 2020-11-02 2020-12-18 北京淇瑀信息科技有限公司 Test method and system based on simulation data calling and electronic equipment
CN112910741A (en) * 2021-02-26 2021-06-04 平安普惠企业管理有限公司 Interface testing method and device, computer equipment and storage medium
CN113176993A (en) * 2021-04-28 2021-07-27 平安银行股份有限公司 Case testing method and device, electronic equipment and storage medium
CN113204496A (en) * 2021-06-03 2021-08-03 上海中通吉网络技术有限公司 Fiddler-based security override problem batch test method and device
CN113220595A (en) * 2021-06-11 2021-08-06 中国农业银行股份有限公司 Test method and device
CN113220595B (en) * 2021-06-11 2023-10-03 中国农业银行股份有限公司 Test method and test equipment

Similar Documents

Publication Publication Date Title
CN109522218A (en) Interface test method, device, computer equipment and storage medium
CN109783342A (en) Script debugging method, equipment and computer storage medium
CN109460527A (en) Product data configuration method, device, computer equipment and storage medium
CN110377336A (en) Interface document generation method, device, computer equipment and storage medium
CN110209652A (en) Tables of data moving method, device, computer equipment and storage medium
CN108573371A (en) The data measures and procedures for the examination and approval, device, computer equipment and storage medium
CN109726134B (en) Interface test method and system
CN110008118A (en) Page data test method, device, computer equipment and storage medium
CN108446116A (en) Generation method, device, computer equipment and the storage medium of the application program page
CN109739552A (en) Micro services gray scale dissemination method, device, computer equipment and storage medium
CN109766263A (en) Automatic test analysis and processing method, device, computer equipment and storage medium
CN109816399A (en) Complain management method, device, computer equipment and the storage medium of part
CN108446362A (en) Data cleansing processing method, device, computer equipment and storage medium
CN110765001B (en) Modularized automatic test method and device for application system
CN109710677A (en) Processing for Data Analysis in Physics, device, computer equipment and storage medium
CN110750222A (en) Printing method, printing device, computer equipment and storage medium
CN112491659B (en) Flow playback test method and device, computer equipment and storage medium
CN108874661A (en) Test mapping relations library generating method, device, computer equipment and storage medium
CN110221967A (en) Test data building method, device, computer equipment and storage medium
CN110955600A (en) Interface test method and device
CN108833265A (en) Message treatment method, device, server and storage medium
CN110471838A (en) Method of calibration, device, computer equipment and the storage medium of test case
CN110471585A (en) Function of application icon methods of exhibiting, device and computer equipment
CN109408372A (en) Common component test method, device, computer equipment and storage medium
CN109446772A (en) Accrediting amount calculation method, device, computer equipment and storage 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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190326