[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN107797911A - Method and apparatus for testing HTTP interface - Google Patents

Method and apparatus for testing HTTP interface Download PDF

Info

Publication number
CN107797911A
CN107797911A CN201610800785.XA CN201610800785A CN107797911A CN 107797911 A CN107797911 A CN 107797911A CN 201610800785 A CN201610800785 A CN 201610800785A CN 107797911 A CN107797911 A CN 107797911A
Authority
CN
China
Prior art keywords
test
data
testing procedure
http
tested
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
CN201610800785.XA
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201610800785.XA priority Critical patent/CN107797911A/en
Publication of CN107797911A publication Critical patent/CN107797911A/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/3668Software testing
    • G06F11/3696Methods or tools to render software testable

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)
  • Information Transfer Between Computers (AREA)

Abstract

This application discloses the method and apparatus for testing HTTP interface.One embodiment of methods described includes:Obtain the test case for HTTP HTTP interface to be tested of user's input;Using first testing procedure in the test case as current testing procedure, and perform following HTTP interface testing procedure:The test operation of the current testing procedure and test data are packaged into HTTP test requests bag and are sent to the HTTP interface to be tested;Judge whether the response data that the HTTP interface to be tested returns is identical with the expected result data of the current testing procedure, if it is different, then the result of generation test crash;If identical, determine whether the current testing procedure is last step of the test case, if it is, generating the result being successfully tested;If it is not, then using next testing procedure as current testing procedure, the HTTP interface testing procedure is continued executing with.This embodiment improves the testing efficiency of HTTP interface.

Description

Method and apparatus for testing HTTP interface
Technical field
The application is related to field of computer technology, and in particular to Internet technical field, more particularly, to tests HTTP The method and apparatus of interface.
Background technology
The conventional scheme of webpage automatic test is to open webpage by testing tool (for example, Selenuim) at present, etc. After the page elements of operation to be specified have loaded, then modelling customer behavior operation is carried out (for example, accessing, inputting, clicking on, file The operation such as selection), page elements are obtained by operating result and judge operating result, it is final to determine whether test case succeeds.
However, there can be problems with by the operation of testing tool simulation browser:(1) it is silent either in internal memory to beat Open or call user interface to open, all loading efficiency problem can occur because of waiting some scripted code of the page to perform;(2) Being changed for some page elements needs frequent maintenance test script, increases testing cost;(3) it is higher to develop script cost, needs Analyze page elements;(4) modularization effect is poor, because testing tool is to realize automation based on page elements, therefore calls Module also has to loading page element and could used, and when using or safeguarding, efficiency is low.Such as accessing a multilayer link When, testing tool needs to go to operate in layer, and similar user clicks on by hand.This for HTTP interface verify, above Page operation is nonsensical.
The content of the invention
The purpose of the application is to propose a kind of improved method and apparatus for testing HTTP interface, more than solving The technical problem that background section is mentioned.
In a first aspect, this application provides a kind of method for testing HTTP interface, methods described includes:Obtain user The test for HTTP to be tested (Hyper Text Transfer Protocol, HTTP) interface of input is used Example, the HTTP interface to be tested include uniform resource position mark URL, and the test case includes at least one of order execution Testing procedure, the testing procedure include test operation, test data and expected result data, and the test operation includes GET Operation and POST operation, the test data include URL, the URL of the test data and the HTTP interface to be tested URL It is identical;Using first testing procedure in the test case as current testing procedure, and perform following HTTP interface test Step:The test operation of the current testing procedure and test data are packaged into HTTP test request bags;The HTTP is surveyed Examination request bag is sent to the HTTP interface to be tested;The response data that the HTTP interface to be tested returns is received, judges institute Whether identical with the expected result data of the current testing procedure response data is stated, if it is different, then according to the current survey Try suddenly and the response data, generates the result of test crash;If identical, the current testing procedure is determined whether Whether it is last step of the test case, if it is, generating the result being successfully tested;If it is not, then by institute Next testing procedure of current testing procedure in test case is stated as current testing procedure, the HTTP interface is continued executing with and surveys Try is rapid.
Second aspect, it is used to test HTTP interface device this application provides one kind, described device includes:Acquiring unit, It is configured to obtain the test case for HTTP interface to be tested of user's input, the HTTP interface to be tested includes unified URLs URL, the test case include at least one testing procedure that order performs, and the testing procedure includes test Operation, test data and expected result data, the test operation include GET operations and POST operation, the test data bag URL is included, the URL of the test data is identical with the URL of the HTTP interface to be tested;Execution unit, being configured to will be described First testing procedure in test case performs following HTTP interface testing procedure as current testing procedure:By described in The test operation and test data of current testing procedure are packaged into HTTP test request bags;The HTTP test requests bag is sent To the HTTP interface to be tested;The response data that the HTTP interface to be tested returns is received, judges that the response data is It is no identical with the expected result data of the current testing procedure, if it is different, then according to the current testing procedure and described Response data, generate the result of test crash;Judging unit, if being configured to identical, determine whether described current survey Whether try is last step of the test case suddenly, if it is, generating the result being successfully tested;If it is not, Then using next testing procedure of current testing procedure in the test case as current testing procedure, the HTTP is continued executing with Interface testing step.
What the application provided is used to test HTTP interface method and apparatus, to be tested by obtaining being directed to for user's input The test case of HTTP interface, then to each testing procedure in test case, by the test operation of the testing procedure and survey Examination data are packaged into HTTP test request bags, and the HTTP test request bags are sent into HTTP interface to be tested, last basis The response data received from HTTP interface to be tested, generate test result.That is, simulation browser sends GET to HTTP interface Or POST request, directly submit data to give HTTP interface to be tested, trigger HTTP interface corresponding function service to be tested and make sound Should, obtain returned data and judge whether response succeeds, and all load without waiting for all page elements and successfully simulated again Test, it is achieved thereby that the independence of test operation and test data, accelerate the speed of test script exploitation, reduce maintenance into This, improves testing efficiency.
Brief description of the drawings
By reading the detailed description made to non-limiting example made with reference to the following drawings, present application it is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that the application can apply to exemplary system architecture figure therein;
Fig. 2 is the flow chart for being used to test one embodiment of the method for HTTP interface according to the application;
Fig. 3 is the flow chart according to one embodiment for establishing test case of the application;
Fig. 4 is the structural representation for being used to test one embodiment of the device of HTTP interface according to the application;
Fig. 5 is adapted for the structural representation for realizing the terminal device of the embodiment of the present application or the computer system of server Figure.
Embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Be easy to describe, illustrate only in accompanying drawing to about the related part of invention.
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase Mutually combination.Describe the application in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 shows the method for being used to test HTTP interface that can apply the application or the dress for testing HTTP interface The exemplary system architecture 100 for the embodiment put.
As shown in figure 1, system architecture 100 can include terminal device 101,102,103, network 104 and server 105. Network 104 between terminal device 101,102,103 and server 105 provide communication link medium.Network 104 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User (for example, Test Engineer) can pass through network 104 and server with using terminal equipment 101,102,103 105 interactions, to receive or send message etc..Various client applications can be installed on terminal device 101,102,103, such as Webpage test class application, web browser applications etc..
Terminal device 101,102,103 can have a display screen and a various electronic equipments that supported web page browses, bag Include but be not limited to smart mobile phone, tablet personal computer, pocket computer on knee and desktop computer etc..
Server 105 can be to provide the server of various services, such as to being shown on terminal device 101,102,103 Webpage provides the backstage web page server supported.Backstage web page server can be to Webpage request (such as the GET that receives Request or POST request) etc. data carry out the processing such as analyzing, and result (such as webpage data) is fed back into terminal Equipment.
It should be noted that the method for being used to test HTTP interface that the embodiment of the present application is provided is typically by terminal device 101st, 102,103 perform, correspondingly, the device for testing HTTP interface is generally positioned in terminal device 101,102,103.
It should be understood that the number of the terminal device, network and server in Fig. 1 is only schematical.According to realizing need Will, can have any number of terminal device, network and server.
With continued reference to Fig. 2, it illustrates one embodiment for being used to test the method for HTTP interface according to the application Flow 200.The described method for testing HTTP interface, comprises the following steps:
Step 201, the test case for HTTP interface to be tested of user's input is obtained.
In the present embodiment, electronic equipment thereon is run (such as shown in Fig. 1 for testing the method for HTTP interface Terminal device 101,102,103) can locally or remotely obtain user input the test for HTTP interface to be tested Use-case.Wherein, above-mentioned HTTP interface to be tested includes URL (Uniform Resource Locator, URL), For example, http://www.xxxxx.com/index.html.Above-mentioned test case includes at least one test step that order performs Suddenly, each testing procedure includes test operation, test data and expected result data, and test operation includes GET operations and POST Operation, test data include URL, and the URL of above-mentioned test data is identical with the URL of above-mentioned HTTP interface to be tested.
HTTP is a kind of procotol being most widely used on internet.HTTP is that a client and server end please The standard of summation response.The different operating mode of several request resource defined in http protocol, including POST, GET, DELETE etc..In the present embodiment, it is contemplated that GET modes and POST modes are two kinds of the most frequently used modes of operation, therefore will be surveyed Examination operation is divided into GET operations and POST operation.GET operations refer to from HTTP interface request data to be tested;POST operation refers to Data to be processed is submitted to HTTP interface to be tested.
In some optional implementations of the present embodiment, the test data of testing procedure may be used also corresponding to GET operations With including at least one of following:HTTP request head, data to be obtained, browser rs cache.Wherein, HTTP request head is that HTTP please The core asked, it is carried on server etc. corresponding to user terminal browser, the resource of client request and HTTP interface Related information.Such as HTTP request head can include:" User-Agent " shows that the browser version of client and operation are System, the browser of Tell server client can also be carried out including " Accept-Encoding " can receive the pressure of which type Contracting output etc..Data to be obtained are the data messages that user end to server is asked.Browser rs cache (also cry Cookie or Cookies) refer to some websites in order to distinguish user identity, conversate and (be also session) tracking and be stored in user's sheet Data (generally going through encryption) in ground terminal.
In some optional implementations of the present embodiment, the test data of testing procedure corresponding to POST operation may be used also With including at least one of following:HTTP request head, data to be committed, browser rs cache, the store path letter of file to be uploaded Breath.
Step 202, using first testing procedure in test case as current testing procedure.
In the present embodiment, above-mentioned electronic equipment can be after test case be got, by first in test case Testing procedure is as current testing procedure.
Step 203, the test operation of current testing procedure and test data are packaged into HTTP test request bags.
In the present embodiment, the test operation of current testing procedure and test data can be packaged into by above-mentioned electronic equipment HTTP test request bags.Here, above-mentioned electronic equipment can be according to the type of test operation GET operation or POST operation, Encapsulate different HTTP test request bags.
As an example, for the test operation of GET types, myGet (url, data, header, cookies) can be used Test operation and test data are packaged into HTTP test request bags, the url in bracket is mandatory parameter, is in test data URL, while be also HTTP interface to be tested URL;Data in bracket is optional parameters, is to be obtained in test data Data;Header in bracket is optional parameters, is the HTTP request head in test data;Cookies in bracket is can Parameter is selected, is the browser caching data in test data.
MyGet (url, data, header, cookies) can submit to the HTTP test requests of HTTP interface to be tested In bag following request row (being also Request Line) is added before HTTP request head:" GET path Protocol ", its In:" GET " represents that the type of HTTP request is acquisition type (GET types);What " path " embodied is the path after main frame.Example Such as, client request " http:During //www.xxxxxx.com/tutorials/others/ ", " path " will be "/ tutorials/others/”;" Protocol " represents client and the agreement of server communication and the version number of agreement, example If " Protocol " can be " HTTP/1.1 " or " HTTP/1.X ".
MyGet can also enclose HTTP request head after request row, naturally it is also possible to be not provided with HTTP request head.
MyGet can also enclose browser rs cache after HTTP request head, and certain browser caching data is optional.
MyGet can also enclose client requested resource after Cookie, and client requested resource can be with It is the word in webpage, CSS and picture etc..
As an example, for the test operation of POST types, can use myPost (url, data, header, Cookies, File) test operation and test data be packaged into HTTP test request bags, the url in bracket is essential ginseng Number, is the URL in test data, while is also the URL of HTTP interface to be tested;Dara in bracket is optional parameters, is to survey Try data to be committed in data;Header in bracket is optional parameters, is the HTTP request head in test data;Bracket In cookies be optional parameters, be the browser caching data in test data;File in bracket is optional parameters, is The store path information of file to be uploaded in test data.
MyPost can be added before the HTTP request head in submitting to the HTTP test request bags of HTTP interface to be tested Following request row (being also Request Line) " POST path Protocol ", wherein:" POST " represents HTTP request Type is submission type (POST types);What " path " embodied is the path after main frame.For example, client request to “http:When //www.xxxxxx.com/submit.php " submits data, " path " will be "/submit.php "; " Protocol " represents that client and the agreement of server communication and the version number of agreement, such as " Protocol " can be " HTTP/1.1 " or " HTTP/1.X ".
MyPost can also enclose HTTP request head after request row, can also currently be not provided with HTTP request head.
MyPost can also enclose browser rs cache after HTTP request head, certain browser caching data be it is optional, Such as browser caching data can be " Cookie:PHPSESSID=r2t5uvjq435r4q7ib3vtdjq120 ".
MyPost can also be enclosed after browser caching data it is data to be committed, for example, data to be committed can To be
" first_name=John&last_name=Doe&action=Submit ".
Certainly, myPost can also enclose the store path information of file to be uploaded after data to be committed.
Step 204, HTTP test request bags are sent to HTTP interface to be tested.
In the present embodiment, the HTTP test request bags encapsulated in step 203 can be sent to and treat by above-mentioned electronic equipment Test HTTP interface.Here, if what is encapsulated in the HTTP test request bags encapsulated in step 203 is GET operations, by HTTP Test request bag be sent to HTTP interface to be tested that is, to HTTP interface to be tested have sent GET types request ( It is Request);, please by HTTP tests if what is encapsulated in the HTTP test request bags encapsulated in step 203 is POST operation Bag is asked to be sent to HTTP interface to be tested that is, have sent the request of POST types to HTTP interface to be tested.
Step 205, the response data that HTTP interface to be tested returns is received.
After HTTP test request bags are sent to HTTP interface to be tested by above-mentioned electronic equipment, HTTP interface to be tested Data in the HTTP test request bags that receive can be handled, and return to response data (that is, Response), so, Above-mentioned electronic equipment can receive the response data that HTTP interface to be tested returns.
One http response data (HTTP Response) generally includes statusline, and statusline includes HTTP version numbers With HTTP conditional codes, such as statusline can be " HTTP/1.1200OK ";Some heads can also be included in response data to believe Breath, such as produce Response time, the type of coding and length of body matter;It can also include in response data in main body Hold (being also Body), deposit the data returned to client, these data can be text type, HTML (Hyper Text Markup Language, HTML) and type or XML (Extensible Markup Language, it is expansible Markup language) type data.
Step 206, judge whether response data is identical with the expected result data of current testing procedure, if it is, going to Step 207, if not, going to step 208.
In the present embodiment, above-mentioned electronic equipment can receive response data that HTTP interface to be tested returns it Afterwards, judge whether response data is identical with the expected result data of current testing procedure, if it is, step 207 is gone to, if It is no, go to step 208.
In some optional implementations of the present embodiment, it is above-mentioned judge response data whether with current testing procedure Expected result data are identical to be carried out in the following way:First, above-mentioned electronic equipment can be obtained in response data HTTP conditional codes, for example, shown in above-mentioned steps 205 " " 200 " in HTTP/1.1200 OK " are HTTP conditional codes; Then, above-mentioned electronic equipment may determine that whether HTTP conditional codes are identical with the expected result data of current testing procedure.
Step 207, judge current testing procedure whether be test case last step, if it is, going to step 209, if not, going to step 210.
In the present embodiment, above-mentioned electronic equipment can be in response data and the expected result data phase of current testing procedure With in the case of, determine whether current testing procedure is last step of test case, if it is, showing to test All testing procedures in use-case are all successfully tested, then step 209 are gone to generate the result being successfully tested, if not, showing Current testing procedure and testing procedure before are all successfully tested, but also have other testing procedures etc. to be tested, then go to step Rapid 210, to continue to test follow-up test step.
Step 208, according to current testing procedure and response data, the result of test crash is generated.
In the present embodiment, in the case where the expected result data of response data and current testing procedure differ, card Bright current testing procedure test crash, above-mentioned electronic equipment can generate test and lose according to current testing procedure and response data The result lost.
In some optional implementations of the present embodiment, above-mentioned electronic equipment can be according to the current testing procedure With the HTTP conditional codes in response data, the result of test crash is generated.Here, the result of test crash can be test crash Flag bit or the flag bit of test crash, HTTP conditional codes and HTTP states representated by meaning.
As an example, table 1 lists several frequently seen HTTP conditional codes, and the result representated by different conditional codes is Success or failure, and the reason for success or failure.
HTTP conditional codes Success/failure Meaning
200 Success Success
404 Failure Do not find (Not Found)
401 Failure (Unauthorized) without permission
403 Failure It is prohibited (Forbidden)
500 Failure Server mistake (Internal Server Error)
Table 1
For example, when the HTTP conditional codes in response data are 404, the result for generating test crash can be " failure -404- Do not find ".
Step 209, the result being successfully tested is generated.
In the present embodiment, it is identical with the expected result data of current testing procedure in response data and work as preamble Suddenly be test case last step in the case of, show that all testing procedures in test case are successfully tested, then Above-mentioned electronic equipment can generate the result being successfully tested.
Step 210, using next testing procedure of current testing procedure in test case as current testing procedure.
In the present embodiment, it is identical with the expected result data of current testing procedure in response data and work as preamble It is rapid be not test case last step in the case of, show that current testing procedure and testing procedure before are tested Success, but the step of not yet testing in test case also be present, therefore, above-mentioned electronic equipment can will be current in test case Next testing procedure of testing procedure continues to the survey that step 203 carries out next testing procedure as current testing procedure Examination.
In some optional implementations of the present embodiment, before step 201 obtains test case, it can also include The step of establishing test case, the idiographic flow on establishing test case can see below the explanation of the embodiment on Fig. 3 Part.
The method that above-described embodiment of the application provides sends GET or POST by simulation browser to HTTP interface please Ask, and directly submit data to give HTTP interface to be tested, trigger HTTP interface corresponding function service to be tested and respond, obtain The response data of return simultaneously judges whether response succeeds, it is achieved thereby that the independence of test operation and test data, accelerates survey The speed of this exploitation of training, reduces maintenance cost, improves testing efficiency.
With further reference to Fig. 3, it illustrates the flow 300 of one embodiment for establishing test case according to the application. This establishes the flow 300 of test case, comprises the following steps:
Step 301, the functional test use-case of HTTP interface to be tested is obtained.
In the present embodiment, to establish test case, the functional test use-case of HTTP interface to be tested can be obtained first. Wherein, functional test use-case is the test case for being tested item by item each function of HTTP interface to be tested.Function is surveyed The data required for the function of each step of HTTP interface to be tested, each step and each step are described in example on probation Between logical relation.
For example, for an electronic business transaction website, the first step is registered user;Second step is then that input is correctly used Name in an account book and password are logged in;3rd step is then that the link of user's click merchandise news browses merchandise news;4th step user will Merchandise news adds order;5th step user pay invoice completes whole shopping process.
Step 302, functional test use-case is resolved into at least one step.
In the present embodiment, the functional test use-case obtained in step 301 can be resolved at least one step, its In, step includes:Input paramete information, expected result data and function type.Input paramete information can include input parameter Number, the data type and span of each input parameter.For example, for the input parameter age, data type can only It is nonnegative integer, and span can be the integer between 0 to 200.Function type can be obtain type operation or Submit the operation of type.
Step 303, to each step at least one step, according to the function type and input paramete information of the step Test operation and test data are generated, testing procedure is generated for the step, by the expectation of test operation, test data and the step Result data is respectively as the test operation of the testing procedure of the step, test data and expected result data.
In the present embodiment, can be surveyed in the following way according to the function type of the step and input paramete information generation Examination operation and test data:
If to obtain type, the test operation of GET types is generated for the step for the function type of the step, if should The function type of step then generates the test operation of POST types to submit type for the step;
Test data is generated according to the input paramete information of the step.
Step 304, the testing procedure of each step at least one step is combined, forms test case.
In the present embodiment, the logic between each step in the functional test use-case that can be obtained based on step 301 Relation, the testing procedure for each step that combination step 303 generates, so as to form test case.
With further reference to Fig. 4, as the realization to method shown in above-mentioned each figure, it is used to test this application provides one kind One embodiment of the device of HTTP interface, the device embodiment is corresponding with the embodiment of the method shown in Fig. 2, and the device is specific It can apply in various electronic equipments.
As shown in figure 4, the device 400 for being used to test HTTP interface described in the present embodiment includes:Acquiring unit 401, hold Row unit 402 and judging unit 403.Wherein, acquiring unit 401, be configured to acquisition user's input is directed to HTTP to be tested The test case of interface, above-mentioned HTTP interface to be tested include uniform resource position mark URL, and above-mentioned test case includes order and held Capable at least one testing procedure, above-mentioned testing procedure include test operation, test data and expected result data, above-mentioned test Operation includes that GET is operated and POST operation, above-mentioned test data include URL, the URL of above-mentioned test data with it is above-mentioned to be tested The URL of HTTP interface is identical;Execution unit 402, be configured to using first testing procedure in above-mentioned test case as work as Preamble is rapid, and performs following HTTP interface testing procedure:By the test operation and test data of above-mentioned current testing procedure It is packaged into HTTP test request bags;Above-mentioned HTTP test requests bag is sent to above-mentioned HTTP interface to be tested;Receive above-mentioned treat Test the response data that HTTP interface returns, judge above-mentioned response data whether the expected result number with above-mentioned current testing procedure According to identical, if it is different, then according to above-mentioned current testing procedure and above-mentioned response data, the result of test crash is generated;Judge Unit 403, if being configured to identical, determine whether above-mentioned current testing procedure is the last of above-mentioned test case One step, if it is, the result that generation is successfully tested;If it is not, then by current testing procedure in above-mentioned test case Next testing procedure as current testing procedure, continue executing with above-mentioned HTTP interface testing procedure.
In the present embodiment, for acquiring unit 401, execution unit 402 and the judgement of the device 400 for testing HTTP interface The specific processing of unit 403 can respectively with reference to step 201 in the corresponding embodiment of figure 2, step 202- steps 206 and step 208 and The related description of step 207 and step 209- steps 210, will not be repeated here.
In some optional implementations of the present embodiment, the test data of testing procedure corresponding to above-mentioned GET operations It can also include at least one of following:HTTP request head, data to be obtained, browser rs cache, corresponding to above-mentioned POST operation The test data of testing procedure also includes at least one of following:HTTP request head, data to be committed, browser rs cache, treat The store path information of transmitting file.
In some optional implementations of the present embodiment, above-mentioned execution unit 402 can be further configured to:Obtain Take the HTTP conditional codes in above-mentioned response data;Judge above-mentioned HTTP conditional codes whether the expectation knot with above-mentioned current testing procedure Fruit data are identical.
In some optional implementations of the present embodiment, above-mentioned execution unit 402 can also be further configured to: According to above-mentioned current testing procedure and above-mentioned HTTP conditional codes, the result of test crash is generated.
In some optional implementations of the present embodiment, the above-mentioned device 400 for being used to test HTTP interface can be with Unit 404 is established including test case, above-mentioned test case, which establishes unit, to be included:Acquisition module 4041, it is configured to obtain Take the functional test use-case of above-mentioned HTTP interface to be tested;Decomposing module 4042, it is configured to above-mentioned functional test use-case point Solution includes at least one step, above-mentioned steps:Input paramete information, expected result data and function type;Generation module 4043, it is configured to each step in above-mentioned at least one step, is believed according to the function type of the step and input parameter Breath generation test operation and test data, testing procedure is generated for the step, by above-mentioned test operation, above-mentioned test data and be somebody's turn to do The expected result data of step are respectively as the test operation of the testing procedure of the step, test data and expected result data; Composite module 4044, it is configured to combine the testing procedure of each step in above-mentioned at least one step, forms test case.Obtain Modulus block 4041, decomposing module 4042, generation module 4043 and composite module 4044 specific processing can be respectively with reference to the correspondence of figure 3 Step 301 in embodiment, step 302, the related description of step 303 and step 304, will not be repeated here.
In some optional implementations of the present embodiment, above-mentioned generation module 4043 can be further configured to: If the function type of the step to obtain type, the test operation of GET types is generated for the step, if the work(of the step Energy type is then the test operation that the step generates POST types to submit type;Given birth to according to the input paramete information of the step Into test data.
Below with reference to Fig. 5, it illustrates suitable for for realizing the calculating of the terminal device of the embodiment of the present application or server The structural representation of machine system 500.
As shown in figure 5, computer system 500 includes CPU (CPU) 501, it can be read-only according to being stored in Program in memory (ROM) 502 or be loaded into program in random access storage device (RAM) 503 from storage part 508 and Perform various appropriate actions and processing.In RAM 503, also it is stored with system 500 and operates required various programs and data. CPU 501, ROM 502 and RAM 503 are connected with each other by bus 504.Input/output (I/O) interface 505 is also connected to always Line 504.
I/O interfaces 505 are connected to lower component:Importation 506 including keyboard, mouse etc.;Penetrated including such as negative electrode The output par, c 507 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage part 508 including hard disk etc.; And the communications portion 509 of the NIC including LAN card, modem etc..Communications portion 509 via such as because The network of spy's net performs communication process.Driver 510 is also according to needing to be connected to I/O interfaces 505.Detachable media 511, such as Disk, CD, magneto-optic disk, semiconductor memory etc., it is arranged on as needed on driver 510, in order to read from it Computer program be mounted into as needed storage part 508.
Especially, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product, it includes being tangibly embodied in machine readable Computer program on medium, the computer program include the program code for being used for the method shown in execution flow chart.At this In the embodiment of sample, the computer program can be downloaded and installed by communications portion 509 from network, and/or from removable Medium 511 is unloaded to be mounted.When the computer program is performed by CPU (CPU) 501, perform in the present processes The above-mentioned function of limiting.
Flow chart and block diagram in accompanying drawing, it is illustrated that according to the system of the various embodiments of the application, method and computer journey Architectural framework in the cards, function and the operation of sequence product.At this point, each square frame in flow chart or block diagram can generation The part of one module of table, program segment or code, a part for the module, program segment or code include one or more For realizing the executable instruction of defined logic function.It should also be noted that some as replace realization in, institute in square frame The function of mark can also be with different from the order marked in accompanying drawing generation.For example, two square frames succeedingly represented are actual On can perform substantially in parallel, they can also be performed in the opposite order sometimes, and this is depending on involved function.Also It is noted that the combination of each square frame and block diagram in block diagram and/or flow chart and/or the square frame in flow chart, Ke Yiyong Function as defined in execution or the special hardware based system of operation are realized, or can be referred to specialized hardware and computer The combination of order is realized.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit can also be set within a processor, for example, can be described as:A kind of processor bag Include acquiring unit, execution unit and judging unit.Wherein, the title of these units is not formed to the unit under certain conditions The restriction of itself, for example, acquiring unit is also described as " unit for obtaining test case ".
As on the other hand, present invention also provides a kind of nonvolatile computer storage media, the non-volatile calculating Machine storage medium can be the nonvolatile computer storage media included in device described in above-described embodiment;Can also be Individualism, without the nonvolatile computer storage media in supplying terminal.Above-mentioned nonvolatile computer storage media is deposited One or more program is contained, when one or more of programs are performed by an equipment so that the equipment:Obtain The test case for HTTP interface to be tested of user's input, above-mentioned HTTP interface to be tested include URL URL, above-mentioned test case include at least one testing procedure that order performs, and above-mentioned testing procedure includes test operation, test Data and expected result data, above-mentioned test operation include GET operations and POST operation, and above-mentioned test data includes URL, above-mentioned The URL of test data is identical with the URL of above-mentioned HTTP interface to be tested;First testing procedure in above-mentioned test case is made For current testing procedure, and perform following HTTP interface testing procedure:By the test operation of above-mentioned current testing procedure and test Data are packaged into HTTP test request bags;Above-mentioned HTTP test requests bag is sent to above-mentioned HTTP interface to be tested;In reception State the response data that HTTP interface to be tested returns, judge above-mentioned response data whether the expectation knot with above-mentioned current testing procedure Fruit data are identical, if it is different, then according to above-mentioned current testing procedure and above-mentioned response data, generate the result of test crash; If identical, determine whether above-mentioned current testing procedure whether be above-mentioned test case last step, if it is, Then generate the result being successfully tested;If it is not, then next testing procedure of current testing procedure in above-mentioned test case is made For current testing procedure, above-mentioned HTTP interface testing procedure is continued executing with.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.People in the art Member should be appreciated that invention scope involved in the application, however it is not limited to the technology that the particular combination of above-mentioned technical characteristic forms Scheme, while should also cover in the case where not departing from the inventive concept, carried out by above-mentioned technical characteristic or its equivalent feature The other technical schemes for being combined and being formed.Such as features described above has similar work(with (but not limited to) disclosed herein The technical scheme that the technical characteristic of energy is replaced mutually and formed.

Claims (12)

  1. A kind of 1. method for testing HTTP interface, it is characterised in that methods described includes:
    The test case for HTTP HTTP interface to be tested of user's input is obtained, the HTTP to be tested connects Mouth includes uniform resource position mark URL, and the test case includes at least one testing procedure that order performs, the test step Rapid to include test operation, test data and expected result data, the test operation includes GET operations and POST operation, described Test data includes URL, and the URL of the test data is identical with the URL of the HTTP interface to be tested;
    Using first testing procedure in the test case as current testing procedure, and perform following HTTP interface test step Suddenly:The test operation of the current testing procedure and test data are packaged into HTTP test request bags;The HTTP is tested Request bag is sent to the HTTP interface to be tested;The response data that the HTTP interface to be tested returns is received, described in judgement Whether response data is identical with the expected result data of the current testing procedure, if it is different, then according to the current test Step and the response data, generate the result of test crash;
    If identical, determine whether the current testing procedure whether be the test case last step, such as Fruit is then to generate the result being successfully tested;If it is not, then next test step by current testing procedure in the test case Suddenly current testing procedure is used as, continues executing with the HTTP interface testing procedure.
  2. 2. according to the method for claim 1, it is characterised in that the test data of testing procedure corresponding to the GET operations Also include at least one of following:HTTP request head, data to be obtained, browser rs cache, test corresponding to the POST operation The test data of step also includes at least one of following:HTTP request head, data to be committed, browser rs cache, text to be uploaded The store path information of part.
  3. 3. according to the method for claim 1, it is characterised in that described to judge whether the response data is currently surveyed with described The rapid expected result data of try are identical, including:
    Obtain the HTTP conditional codes in the response data;
    Judge whether the HTTP conditional codes are identical with the expected result data of the current testing procedure.
  4. 4. according to the method for claim 3, it is characterised in that described according to the current testing procedure and the number of responses According to, the result of test crash is generated, including:
    According to the current testing procedure and the HTTP conditional codes, the result of test crash is generated.
  5. 5. according to the method for claim 1, it is characterised in that the step of methods described also includes establishing test case, institute Stating the step of establishing test case includes:
    Obtain the functional test use-case of the HTTP interface to be tested;
    The functional test use-case is resolved into at least one step, the step includes:Input paramete information, expected result number According to and function type;
    To each step at least one step, according to the function type of the step and input paramete information generation test Operation and test data, testing procedure is generated for the step, by the expectation of the test operation, the test data and the step Result data is respectively as the test operation of the testing procedure of the step, test data and expected result data;
    The testing procedure of each step at least one step is combined, forms test case.
  6. 6. according to the method for claim 5, it is characterised in that described to be believed according to the function type and input parameter of the step Breath generation test operation and test data, including:
    If the function type of the step to obtain type, the test operation of GET types is generated for the step, if the step Function type for submit type, then be the step generation POST types test operation;
    Test data is generated according to the input paramete information of the step.
  7. 7. a kind of device for being used to test HTTP interface, it is characterised in that described device includes:
    Acquiring unit, the test for HTTP HTTP interface to be tested for being configured to obtain user's input are used Example, the HTTP interface to be tested include uniform resource position mark URL, and the test case includes at least one of order execution Testing procedure, the testing procedure include test operation, test data and expected result data, and the test operation includes GET Operation and POST operation, the test data include URL, the URL of the test data and the HTTP interface to be tested URL It is identical;
    Execution unit, it is configured to using first testing procedure in the test case as current testing procedure, and performs Following HTTP interface testing procedure:The test operation of the current testing procedure and test data are packaged into HTTP test requests Bag;The HTTP test requests bag is sent to the HTTP interface to be tested;Receive what the HTTP interface to be tested returned Response data, judge whether the response data is identical with the expected result data of the current testing procedure, if it is different, then According to the current testing procedure and the response data, the result of test crash is generated;
    Judging unit, if being configured to identical, determine whether the current testing procedure is the test case Last step, if it is, the result that is successfully tested of generation;If it is not, then will currently it be surveyed in the test case The rapid next testing procedure of try continues executing with the HTTP interface testing procedure as current testing procedure.
  8. 8. device according to claim 7, it is characterised in that the test data of testing procedure corresponding to the GET operations Also include at least one of following:HTTP request head, data to be obtained, browser rs cache, test corresponding to the POST operation The test data of step also includes at least one of following:HTTP request head, data to be committed, browser rs cache, text to be uploaded The store path information of part.
  9. 9. device according to claim 7, it is characterised in that the execution unit is further configured to:
    Obtain the HTTP conditional codes in the response data;
    Judge whether the HTTP conditional codes are identical with the expected result data of the current testing procedure.
  10. 10. device according to claim 9, it is characterised in that the execution unit is further configured to:
    According to the current testing procedure and the HTTP conditional codes, the result of test crash is generated.
  11. 11. device according to claim 7, it is characterised in that described device also establishes unit including test case, described Test case, which establishes unit, to be included:
    Acquisition module, it is configured to obtain the functional test use-case of the HTTP interface to be tested;
    Decomposing module, it is configured to the functional test use-case resolving at least one step, the step includes:Input ginseng Number information, expected result data and function type;
    Generation module, it is configured to each step at least one step, according to the function type of the step and defeated Enter parameter information generation test operation and test data, testing procedure is generated for the step, by the test operation, the test The expected result data of data and the step are respectively as the test operation of the testing procedure of the step, test data and it is expected to tie Fruit data;
    Composite module, it is configured to combine the testing procedure of each step at least one step, forms test case.
  12. 12. device according to claim 11, it is characterised in that generation module is further configured to:
    If the function type of the step to obtain type, the test operation of GET types is generated for the step, if the step Function type for submit type, then be the step generation POST types test operation;
    Test data is generated according to the input paramete information of the step.
CN201610800785.XA 2016-09-02 2016-09-02 Method and apparatus for testing HTTP interface Pending CN107797911A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610800785.XA CN107797911A (en) 2016-09-02 2016-09-02 Method and apparatus for testing HTTP interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610800785.XA CN107797911A (en) 2016-09-02 2016-09-02 Method and apparatus for testing HTTP interface

Publications (1)

Publication Number Publication Date
CN107797911A true CN107797911A (en) 2018-03-13

Family

ID=61529734

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610800785.XA Pending CN107797911A (en) 2016-09-02 2016-09-02 Method and apparatus for testing HTTP interface

Country Status (1)

Country Link
CN (1) CN107797911A (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108600048A (en) * 2018-04-12 2018-09-28 平安科技(深圳)有限公司 Interface testing method, device, equipment and computer readable storage medium
CN108595339A (en) * 2018-05-09 2018-09-28 成都致云科技有限公司 Automated testing method, apparatus and system
CN109032956A (en) * 2018-09-11 2018-12-18 郑州云海信息技术有限公司 A kind of interface test method and device
CN109117290A (en) * 2018-08-20 2019-01-01 郑州云海信息技术有限公司 A kind of analogy method and device of interface
CN110471842A (en) * 2019-07-12 2019-11-19 平安普惠企业管理有限公司 A kind of test method, device and computer readable storage medium
CN110716844A (en) * 2019-09-23 2020-01-21 上海游族信息技术有限公司 Pressurizing method for server performance pressure test
CN111198821A (en) * 2020-01-06 2020-05-26 瑞庭网络技术(上海)有限公司 Interface abnormity judgment method and device and readable storage medium
CN111427797A (en) * 2020-04-12 2020-07-17 广州通达汽车电气股份有限公司 Automatic interface testing method and device, electronic equipment and storage medium
CN111464594A (en) * 2020-03-13 2020-07-28 平安国际智慧城市科技股份有限公司 Http interface connection method, apparatus and storage medium
CN111562490A (en) * 2019-02-14 2020-08-21 深圳市汇顶科技股份有限公司 Test method and system
CN112015483A (en) * 2020-08-07 2020-12-01 北京浪潮数据技术有限公司 POST request parameter automatic processing method and device and readable storage medium
CN112162923A (en) * 2020-09-25 2021-01-01 中诚信征信有限公司 Interface testing method and device
CN112383661A (en) * 2020-11-20 2021-02-19 北京达佳互联信息技术有限公司 Mobile terminal automation test method and device, electronic equipment and storage medium
CN113704080A (en) * 2020-05-22 2021-11-26 北京沃东天骏信息技术有限公司 Automatic testing method and device
CN116708215A (en) * 2023-06-15 2023-09-05 重庆智铸达讯通信有限公司 Automatic test method, device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101246448A (en) * 2008-03-17 2008-08-20 中兴通讯股份有限公司 Automatized script implementing method
WO2011054024A1 (en) * 2009-11-06 2011-05-12 Toby Biddle A usability testing tool
CN104268082A (en) * 2014-09-26 2015-01-07 北京国双科技有限公司 Pressure test method and pressure test device for browser
CN104820640A (en) * 2015-05-19 2015-08-05 广州华多网络科技有限公司 Webpage testing method and device
CN104866422A (en) * 2015-05-20 2015-08-26 中国互联网络信息中心 Web Service automatic test system and method
CN104978261A (en) * 2014-04-03 2015-10-14 腾讯科技(深圳)有限公司 Test method, device and system of application program

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101246448A (en) * 2008-03-17 2008-08-20 中兴通讯股份有限公司 Automatized script implementing method
WO2011054024A1 (en) * 2009-11-06 2011-05-12 Toby Biddle A usability testing tool
CN104978261A (en) * 2014-04-03 2015-10-14 腾讯科技(深圳)有限公司 Test method, device and system of application program
CN104268082A (en) * 2014-09-26 2015-01-07 北京国双科技有限公司 Pressure test method and pressure test device for browser
CN104820640A (en) * 2015-05-19 2015-08-05 广州华多网络科技有限公司 Webpage testing method and device
CN104866422A (en) * 2015-05-20 2015-08-26 中国互联网络信息中心 Web Service automatic test system and method

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108600048A (en) * 2018-04-12 2018-09-28 平安科技(深圳)有限公司 Interface testing method, device, equipment and computer readable storage medium
WO2019196213A1 (en) * 2018-04-12 2019-10-17 平安科技(深圳)有限公司 Interface test method, apparatus and device, and computer-readable storage medium
CN108595339A (en) * 2018-05-09 2018-09-28 成都致云科技有限公司 Automated testing method, apparatus and system
CN109117290A (en) * 2018-08-20 2019-01-01 郑州云海信息技术有限公司 A kind of analogy method and device of interface
CN109117290B (en) * 2018-08-20 2021-10-01 郑州云海信息技术有限公司 Interface simulation method and device
CN109032956A (en) * 2018-09-11 2018-12-18 郑州云海信息技术有限公司 A kind of interface test method and device
CN111562490A (en) * 2019-02-14 2020-08-21 深圳市汇顶科技股份有限公司 Test method and system
CN111562490B (en) * 2019-02-14 2023-01-20 深圳市汇顶科技股份有限公司 Test method and system
CN110471842A (en) * 2019-07-12 2019-11-19 平安普惠企业管理有限公司 A kind of test method, device and computer readable storage medium
CN110716844A (en) * 2019-09-23 2020-01-21 上海游族信息技术有限公司 Pressurizing method for server performance pressure test
CN111198821A (en) * 2020-01-06 2020-05-26 瑞庭网络技术(上海)有限公司 Interface abnormity judgment method and device and readable storage medium
CN111198821B (en) * 2020-01-06 2021-07-16 瑞庭网络技术(上海)有限公司 Interface abnormity judgment method and device and readable storage medium
CN111464594A (en) * 2020-03-13 2020-07-28 平安国际智慧城市科技股份有限公司 Http interface connection method, apparatus and storage medium
CN111464594B (en) * 2020-03-13 2024-07-05 平安国际智慧城市科技股份有限公司 Http interface connection method, http interface connection device and storage medium
CN111427797A (en) * 2020-04-12 2020-07-17 广州通达汽车电气股份有限公司 Automatic interface testing method and device, electronic equipment and storage medium
CN111427797B (en) * 2020-04-12 2023-12-05 广州通达汽车电气股份有限公司 Automatic interface testing method and device, electronic equipment and storage medium
CN113704080A (en) * 2020-05-22 2021-11-26 北京沃东天骏信息技术有限公司 Automatic testing method and device
CN112015483A (en) * 2020-08-07 2020-12-01 北京浪潮数据技术有限公司 POST request parameter automatic processing method and device and readable storage medium
CN112015483B (en) * 2020-08-07 2021-12-03 北京浪潮数据技术有限公司 POST request parameter automatic processing method and device and readable storage medium
CN112162923A (en) * 2020-09-25 2021-01-01 中诚信征信有限公司 Interface testing method and device
CN112383661B (en) * 2020-11-20 2023-05-02 北京达佳互联信息技术有限公司 Mobile terminal automatic test method and device, electronic equipment and storage medium
CN112383661A (en) * 2020-11-20 2021-02-19 北京达佳互联信息技术有限公司 Mobile terminal automation test method and device, electronic equipment and storage medium
CN116708215A (en) * 2023-06-15 2023-09-05 重庆智铸达讯通信有限公司 Automatic test method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107797911A (en) Method and apparatus for testing HTTP interface
US8281401B2 (en) System for detecting vulnerabilities in web applications using client-side application interfaces
US6589290B1 (en) Method and apparatus for populating a form with data
US7992127B2 (en) Method and system of encapsulating web site transactions for computer-aided generation of web services
US7783723B2 (en) Systems and methods for submitting data from a WML-based browser
US8365188B2 (en) Content management
US9459888B2 (en) Implementing browser based hypertext transfer protocol session storage
US11068385B2 (en) Behavior driven development test framework for application programming interfaces and webservices
CN108268635B (en) Method and apparatus for acquiring data
US10084847B1 (en) Methods and systems for dynamically generating and reusing dynamic web content
US9971636B2 (en) Methods for implementing web services and devices thereof
CN108268332A (en) Webpage abnormality monitoring method, equipment and system
CN107634947A (en) Limitation malice logs in or the method and apparatus of registration
US6862620B2 (en) Web page monitoring system and methods therefor
US20210392144A1 (en) Automated and adaptive validation of a user interface
CN110414989A (en) Method for detecting abnormality and device, electronic equipment and computer readable storage medium
CN107436843A (en) Webpage performance test methods and device
CN109428877A (en) A kind of method and apparatus for by user equipment access operation system
CN107203576A (en) Information synchronization method and device
CN107656910A (en) Method and apparatus for generating list
US6535916B1 (en) Systems, methods and computer program products for linking transactions by multiple web site servers to web site visitors
CN110333866B (en) Method and device for generating receiving page and electronic equipment
CN103198062A (en) Method for monitoring page dead link and JS error
CN113362173A (en) Anti-duplication mechanism verification method, anti-duplication mechanism verification system, electronic equipment and storage medium
CN115643054A (en) Identity information verification method, device, server, medium and product

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