CN108848000B - Network request testing method and device, computer equipment and storage medium - Google Patents

Network request testing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN108848000B
CN108848000B CN201810428406.8A CN201810428406A CN108848000B CN 108848000 B CN108848000 B CN 108848000B CN 201810428406 A CN201810428406 A CN 201810428406A CN 108848000 B CN108848000 B CN 108848000B
Authority
CN
China
Prior art keywords
request
response
network request
response data
network
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.)
Active
Application number
CN201810428406.8A
Other languages
Chinese (zh)
Other versions
CN108848000A (en
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.)
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
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 OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN201810428406.8A priority Critical patent/CN108848000B/en
Publication of CN108848000A publication Critical patent/CN108848000A/en
Application granted granted Critical
Publication of CN108848000B publication Critical patent/CN108848000B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Abstract

The application relates to a network request testing method, a network request testing device, computer equipment and a storage medium. The method comprises the following steps: monitoring a first network request sent by an application program, and acquiring a first request identifier of the first network request; judging whether the first network request is an asynchronous request or not according to the first request identifier; when the first network request is an asynchronous request, searching a second request identifier associated with the first request identifier; intercepting first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, searching a preset response return sequence corresponding to the first request identifier, and returning the first response data and the second response data to the application program according to the preset response return sequence; and obtaining a first response result of the application program, and comparing the first response result with a preset response result corresponding to a preset response return sequence to obtain a test result. The coverage rate can be tested by adopting the method.

Description

Network request testing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a network request testing method, apparatus, computer device, and storage medium.
Background
In an actual application environment, when a terminal performs a network asynchronous request, when data return orders of asynchronous responses are different, different network response results may be caused, for example, some data return orders may obtain a normal response result, and some data return orders may cause an abnormal response result such as a response crash. In a test environment, when a network request is tested, a requesting party and a requested party server need to perform data interaction, and the requesting party performing the test cannot control the sequence of data returned by the server, so that all response conditions of the network request are difficult to test, and the test coverage rate is low.
Disclosure of Invention
In view of the above, it is necessary to provide a network request testing method, apparatus, computer device and storage medium capable of improving the test coverage.
A network request testing method, the method comprising:
monitoring a first network request sent by an application program, and acquiring a first request identifier of the first network request;
judging whether the first network request is an asynchronous request or not according to the first request identifier;
when the first network request is an asynchronous request, searching a second request identifier associated with the first request identifier;
intercepting first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, searching a preset response return sequence corresponding to the first request identifier, and returning the first response data and the second response data to the application program according to the preset response return sequence;
and obtaining a first response result of the application program, and comparing the first response result with a preset response result corresponding to the preset response return sequence to obtain a test result.
In one embodiment, after the first network request issued by the monitoring application, the method further includes:
intercepting the first network request;
after the second request identifier associated with the first request identifier is searched, the method further includes:
intercepting a second network request corresponding to the second request identifier;
and sending the intercepted first network request and the intercepted second network request.
In one embodiment, the method further comprises the following steps:
recording the sending time of a second network request corresponding to the second request identifier;
obtaining a first expected response time according to the sending time and a preset response time;
when a third network request which does not intercept response data exists in the second network request after the first expected response time is reached, searching historical response data corresponding to the third network request, and taking the historical response data as currently intercepted third response data corresponding to the third network request.
In one embodiment, the method further comprises the following steps:
recording a third request identifier of the third network request;
after the intercepted first response data and second response data are returned to the application program according to the preset response return sequence, the method further includes:
and when third response data corresponding to the recorded third request identification are monitored, intercepting the third response data, and adding the third response data to historical response data corresponding to the third network request.
In one embodiment, the method further comprises the following steps:
when the historical response data corresponding to the third network request cannot be searched, the third network request is sent again, and second expected response time is calculated;
and when third response data corresponding to the third network request is not intercepted when the second expected response time is reached, generating a response exception prompt according to the third network request.
In one embodiment, the method further comprises the following steps:
after generating a response exception prompt according to the third network request, the method includes:
receiving input simulation response data, and taking the simulation response data as currently intercepted third response data corresponding to the third network request;
recording the simulated response data as historical response data of the third network request
In one embodiment, the method further comprises the following steps:
when the preset response return sequence corresponding to the first request identification cannot be found, arranging and combining the return sequences of the first response data and the second response data to obtain a combined sequence;
returning the first response data and the second response data to the application program according to each combination sequence, and displaying the corresponding combination sequence in the application program;
and acquiring a second response result of the application program corresponding to each combination order, acquiring an input expected result corresponding to each combination order, and comparing the second response result with the corresponding input expected result to obtain a test result.
A network request testing apparatus, the apparatus comprising:
the first identifier acquisition module is used for monitoring a first network request sent by an application program and acquiring a first request identifier of the first network request;
the asynchronous judgment module is used for judging whether the first network request is an asynchronous request according to the first request identifier;
the association identifier acquisition module is used for searching a second request identifier associated with the first request identifier when the first network request is an asynchronous request;
a first data returning module, configured to intercept first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, search for a preset response returning sequence corresponding to the first request identifier, and return the first response data and the second response data to the application program according to the preset response returning sequence;
and the first test module is used for acquiring a first response result of the application program and comparing the first response result with a preset response result corresponding to the preset response return sequence to obtain a test result.
A computer device comprising a memory storing a computer program and a processor implementing the steps of the above method when executing the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method.
According to the network request testing method, the network request testing device, the computer equipment and the storage medium, when the asynchronous network request sent by the application program is monitored, the associated network request corresponding to the network request is searched, the network request and response data returned by the corresponding associated network request are intercepted, and the intercepted response data are returned to the application program according to the preset response return sequence corresponding to the network request, so that traversal testing can be performed on various response return conditions which a tester wants to test, automatic testing of various branch conditions is realized, and the coverage rate and the testing efficiency of the testing are improved.
Drawings
FIG. 1 is a diagram illustrating an exemplary scenario for a network request test method;
FIG. 2 is a flow diagram illustrating a method for network request testing in one embodiment;
FIG. 3 is a flowchart illustrating a network request testing method according to another embodiment;
FIG. 4 is a block diagram of an embodiment of a network request test apparatus;
FIG. 5 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The network request testing method provided by the application can be applied to the application environment shown in fig. 1. Wherein, the test terminal communicates with the server through the network. The method comprises the steps that a test terminal monitors a first network request sent by a local application program to a server, a first request identifier of the first network request is obtained, whether the first network request is an asynchronous request is judged according to the first request identifier, when the first network request is judged to be the asynchronous request, a second request identifier associated with the first request identifier is searched, response data returned to the application program by the test terminal monitoring server is intercepted, first response data corresponding to the first request identifier and second response data corresponding to the second request identifier are intercepted, after the first response data and the second response data are intercepted, the test terminal searches a preset response return sequence corresponding to the first request identifier, the first response data and the second response data are returned to the application program according to the preset response return sequence, a first response result of the application program is obtained, and the first response result is compared with the preset response result corresponding to the preset response return sequence to obtain a test knot And (5) fruit. Thereby improving the test coverage of the network request test. The test terminal may be, but is not limited to, various personal computers, notebook computers, tablet computers, and the like, and the server may be implemented by an independent server or a server cluster formed by a plurality of servers.
In an embodiment, as shown in fig. 2, a network request testing method is provided, which is described by taking the method as an example applied to the testing terminal in fig. 1, and includes the following steps:
step 210, a first network request sent by the monitoring application program is obtained, and a first request identifier of the first network request is obtained.
The application program is installed on the test terminal, and the test terminal tests a network access request sent to the server when the application program runs. The network access request sent by the application program is used for exchanging data with the server. The test terminal acquires a first request identifier of a first network request when monitoring that the application program sends the first network request to the server. The first request identifier is used for uniquely marking the first network request, and may be a code, a number, or the like, or may also be an address of an access request, a key character in a request address, or the like, and the request identifier may correspond to a request function of the network request.
Step 220, determining whether the first network request is an asynchronous request according to the first request identifier.
The test terminal obtains an asynchronous request table, and a request identifier of a network request belonging to an asynchronous request is stored in the asynchronous request table. The test terminal searches whether a request identifier consistent with the first request identifier exists in the asynchronous request table, judges that the first network request is an asynchronous request when the consistent request identifier is found, and judges that the first network request is a synchronous request when the consistent request identifier is not found.
The synchronous request means that when the application program sends a plurality of network requests to the server, the server returns response data to the application program in sequence according to the receiving sequence of the network requests. The asynchronous request means that when the application program sends a plurality of network requests to the server, the server receives the plurality of network requests first, but the order of returning response data to the application program is not necessarily according to the receiving order, and the return time of the response data corresponding to the network request received first may be later than the return time of the response data corresponding to the network request received later, that is, the return time of the response data corresponding to the network request cannot be determined, and the current network condition may also affect the return time and the return order of each asynchronous request.
When the request data of the multiple asynchronous requests have an association relationship, the return sequence of the response data corresponding to the multiple asynchronous requests is different, which may cause different response results of the application program. For example, when an application requests a server for three data, namely "drawing panel view", "painting brush", "color panel", to implement an application function of "drawing", the application may issue "drawing panel view", "painting brush", "color panel", and "three asynchronous requests to the server, and if the server receives the three asynchronous requests and returns responses to the three asynchronous requests in the order of" drawing panel view "," color panel "," painting brush ", or" color panel "," drawing panel view ", and" painting brush ", a preset function may be implemented, and if the return order is the order of" painting brush "," drawing panel view "," color panel ", or" painting brush "," color panel ", and" drawing panel view ", etc., a response failure or a crash of the application may be caused because the application receives the data" painting brush "and then performs a drawing action corresponding to" painting brush ", however, the "drawing panel view" and "color panel" are not yet prepared, so that the drawing action of the brush cannot be performed normally, which may result in a failure of the application response. It should be noted that, in practical applications, the data requested by the application program may be other types of data, and the above example is only for convenience of explanation of the asynchronous request.
In step 230, when the first network request is an asynchronous request, a second request identifier associated with the first request identifier is searched.
When the test terminal judges that the first network request is an asynchronous request, the test terminal searches for a second request identifier associated with the first request identifier, and data requested by a second network request corresponding to the second request identifier and data requested by the first network request have an association relationship. The number of the second request identifications may be one or more, and the second request identifications corresponding to the second network requests are asynchronous requests. The mapping relation between the first request identifier and the second request identifier is preset and stored in the test terminal, and the test terminal can search the second request identifier corresponding to the first request identifier by obtaining the mapping relation.
Step 240, intercepting first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, searching a preset response return sequence corresponding to the first request identifier, and returning the first response data and the second response data to the application program according to the preset response return sequence.
The terminal monitors response data returned by the server, the response data returned by the server can carry a request identifier of a corresponding network request, or the server generates a response identifier corresponding to the request identifier and carries the response identifier when returning the response data. And intercepting the first response data when the test terminal monitors the first response data corresponding to the first request identifier, and intercepting the second response data when the test terminal monitors the second response data corresponding to the second request identifier.
After the test terminal intercepts all the first response data and all the second response data, the test terminal searches for a preset response return sequence corresponding to the first request identification. The preset response returning sequence records the arrangement sequence of the first request identification corresponding to the first response data and each second request identification corresponding to the second response data, the preset response returning sequence is preset and stored by a tester in advance, the number of the preset response returning sequences corresponding to the same first request identification can be one or more, the tester may need to test the returning sequences of various response data, and therefore a plurality of preset response returning sequences can be set. And the test terminal returns the first response data and the second response data to the application program according to the sequence of the request identifications in the preset response return sequence.
Step 250, obtaining a first response result of the application program, and comparing the first response result with a preset response result corresponding to a preset response return sequence to obtain a test result.
And after the test terminal returns all the first response data and the second response data to the application program according to a preset response return sequence, acquiring a preset response result corresponding to the preset response return sequence, wherein the preset response result is stored in advance in correspondence with the preset response return sequence. The preset response result may be related information of the response page, such as a response address, a page screenshot, and the like, and the test terminal may compare the related information of the response page actually responded by the application program with the preset response result. And the test terminal compares the first response result with a preset response result, judges that the test corresponding to the preset response return sequence is successful when the first response result is consistent with the preset response result, and judges that the test corresponding to the preset response return sequence is failed if the first response result is not consistent with the preset response result.
In this embodiment, a monitoring device may be installed in the test terminal or in the application program to implement the above-described monitoring function of network request and response data, data interception and data return function of response data, and the like. The monitoring device may be, but is not limited to, an SDK (Software Development Kit) data package, or the like.
In this embodiment, when the test terminal monitors an asynchronous network request sent by the application program, the associated network request corresponding to the network request is searched, the network request and response data returned by the associated network request are intercepted, and the intercepted response data is returned to the application program according to a preset response return sequence corresponding to the network request, so that various response return conditions which a tester wants to test can be subjected to traversal test, automatic tests of various branch conditions are realized, and the test coverage and test efficiency are improved.
In one embodiment, as shown in fig. 3, after the step 210 of monitoring the first network request issued by the application, the method may further include:
step 215: a first network request is intercepted.
When the test terminal monitors a first network request sent by an application program for interception, and when the first network request is judged to be a synchronous request according to a first request identifier of the first network request, the intercepted first network request is released, and the first network request is sent to a server; and when the first network request is judged to be an asynchronous request, the first network request is continuously kept in an interception state and is not continuously sent to the server.
After the step 230 of searching for the second request identifier associated with the first request identifier, the method may further include:
step 232, intercepting the second network request corresponding to the second request identifier.
And after finding the second request identification, the test terminal continuously monitors the network requests sent by the application program, acquires the request identification of each network request sent by the application program, compares the acquired request identification with the second request identification, judges that the monitored network request is the second network request when the acquired request identification is consistent with one of the second request identifications, intercepts the second network request and does not continuously send the second network request to the server.
Step 234, sending the intercepted first network request and second network request.
After the test terminal finishes intercepting all the second network requests corresponding to the second request identifiers, the test terminal sends the first network request and the second network request to the server, and the sending sequence is not particularly limited.
In this embodiment, when the test terminal monitors a first network request that is an asynchronous request, the first network request is temporarily intercepted, and when the test terminal subsequently monitors a second network request associated with the first network request, the first network request and the second network request are sent out, so that the synchronization of sending network requests with data association is maintained, and monitoring and management are facilitated.
In one embodiment, the network request testing method may further include: recording the sending time of a second network request corresponding to the second request identifier; obtaining a first expected response time according to the sending time and a preset response time; and when a third network request which does not intercept response data exists in the second network request after the first expected response time is reached, searching historical response data corresponding to the third network request, and taking the historical response data as currently intercepted third response data corresponding to the third network request.
And after finding the associated second request identifier, the test terminal continues to monitor a second network request which is sent by the application program and corresponds to the second request identifier. Specifically, the test terminal may obtain a request identifier of each network request sent by the application program, compare the obtained request identifier with the second request identifiers, and determine that the monitored network request is the second network request when the obtained request identifier is consistent with one of the second request identifiers. And the test terminal records the sending time of each second network request or records the sending time of the last sent second network request.
The testing terminal obtains a pre-stored preset response time, the preset response time is the maximum time interval for the server to return response data to the application program after the application program sends a network request to the server, and the preset response time is preset by testing personnel according to experience and is stored in the testing terminal. And the test terminal adds preset response time length to the recorded sending time of the last sent second network request to calculate first expected response time and sets time monitoring.
When the first expected response time is reached, the test terminal judges whether all response data corresponding to the second network request are intercepted or not, and does not perform special processing when all response data are intercepted; when the third network request without intercepting corresponding response data is judged to exist in the second network request, the test terminal obtains a third request identifier of the third network request, and searches historical response data corresponding to the third request identifier, the historical response data is response results returned by a corresponding server when the third network request is sent all the time, and the test terminal carries out association recording on the response results all the time and the third request identifier. And the test terminal extracts one response data from the historical response data as the currently intercepted third response data corresponding to the third network request, and does not continue to wait for the response sequence returned by the server. It should be noted that the second network request includes a third network request, and the finally obtained second response data includes third response data. Specifically, the test terminal may randomly extract one piece of response data when extracting the response data, may also extract the last recorded response data, and may also adopt other manners, which is not particularly limited herein. After the test terminal obtains all the historical response data of the third network request which does not intercept the response data, the step of searching the preset response return sequence corresponding to the first request identifier and returning the first response data and the second response data to the application program according to the preset response return sequence can be continuously executed.
In this embodiment, when a third network request that does not intercept corresponding response data still exists in the second network request after the preset response time is reached, the test terminal directly uses historical response data of the third network request as response data of the third network request this time, and does not wait for actually returned data, so that the test time can be saved, and the test efficiency can be improved.
In one embodiment, the network request testing method may further include: recording a third request identifier of a third network request; after the intercepted first response data and second response data are returned to the application program according to the preset response return sequence, the method may further include: and when third response data corresponding to the recorded third request identification are monitored, intercepting the third response data and adding the third response data to historical response data corresponding to the third network request.
And when a third network request which does not intercept response data exists in the second network request after the first expected response time is reached, the test terminal acquires a third request identifier of the third network request and records the third request identifier. And after the test terminal returns the intercepted first response data and second response data to the application program according to a preset response return sequence, the test terminal continues to monitor third response data corresponding to the third request identifier returned by the server, and when the third response data is monitored, the test terminal intercepts the third response data and does not return to the application program any more. And the test terminal searches the historical response data corresponding to the third request identifier and adds the intercepted third response data to the searched historical response data.
In this embodiment, the test terminal records the network request with the timeout response, continues to monitor whether the server returns response data corresponding to the network request with the timeout response after returning the response data to the application program, and intercepts and adds the monitored response data to the historical response data of the network request with the timeout response when monitoring is reached, thereby avoiding abnormal response of the application program caused by repeatedly sending the response data to the application program.
In one embodiment, the network request testing method may further include: when the historical response data corresponding to the third network request cannot be searched, the third network request is sent again, and second expected response time is calculated; and when third response data corresponding to the third network request are not intercepted when the second expected response time is reached, generating a response exception prompt according to the third network request.
When the third network request which does not intercept the response data exists after the first expected response time is reached, and the test terminal cannot search the historical response data corresponding to the third network request, the test terminal sends the third network request to the server again and records the time for sending the third network request again, the test terminal obtains the preset response time, and the second expected response time is calculated according to the time for sending the third network request again and the preset response time, wherein the third network request is sent for the first time, or the historical response data corresponding to the third network request is not stored. The preset response time length of the network request for retransmission may be the same as or different from the preset response time length of the network request for retransmission.
When the third response data corresponding to the third network request is intercepted by the test terminal when the second expected response time is not reached, the step of searching the preset response return sequence corresponding to the first request identifier and returning the first response data and the second response data to the application program according to the preset response return sequence can be continuously executed; and when the third response data corresponding to the third network request is not intercepted by the test terminal after the second expected response time is reached, generating a response exception prompt by the test terminal according to the third network request, and displaying the response exception prompt, wherein the response exception prompt may include information such as a third request identifier, response timeout description and the like of the third network request. Therefore, the tester can further process according to the response abnormity prompt, and the smooth test is ensured.
In one embodiment, after the step of generating the response exception prompt according to the third network request, the method may further include: receiving input simulation response data, and taking the simulation response data as currently intercepted third response data corresponding to a third network request; the simulated response data is recorded as historical response data of the third network request.
When the test terminal generates and displays the response abnormity prompt, a data input interface can be displayed, the data input interface comprises related information of third network requests, such as request identifiers and the like, and when a plurality of third network requests exist, the third request identifiers of the third network requests are compared with the input entry in the data input interface. The tester can input or simulate response data through the data input interface, the simulated response data are used for simulating actual response data returned by the server corresponding to the third network request, and the actual response data and the simulated response data have the same data format and data structure. The test terminal receives simulation response data input by a tester through the data input interface and reads a third request identifier corresponding to each simulation response data, the simulation response data are used as currently intercepted third response data of a corresponding third network request according to the third request identifier, after the simulation response data corresponding to all the third network requests are completely obtained, the steps of searching for a preset response return sequence corresponding to the first request identifier and returning the first response data and the second response data to the application program according to the preset response return sequence can be continuously executed. And the simulation response data and the corresponding third request identification are stored in an associated mode to serve as historical response data of the corresponding third network request, and therefore the simulation response data and the corresponding third request identification can be called conveniently in the next test.
In one embodiment, the network request testing method may further include: when the preset response return sequence corresponding to the first request identification cannot be found, the return sequences of the first response data and the second response data are arranged and combined to obtain a combined sequence; returning the first response data and the second response data to the application program according to each combination sequence, and displaying the corresponding combination sequence in the application program; and acquiring a second response result of the application program corresponding to each combination sequence, acquiring an input expected result corresponding to each combination sequence, and comparing the second response result with the corresponding input expected result to obtain a test result.
And when the preset response return sequence corresponding to the first request identifier is not preset in the test terminal, the test terminal arranges and combines the return sequences of the first response data and the second response data to obtain a plurality of sequence combinations. For example, if the first response data is labeled "1", the second response data is two, and labeled "2" and "3", the three response data are arranged and combined to obtain 6 combination orders, which are "123", "132", "213", "231", "321", and "312", respectively.
And after the test terminal obtains the combination sequence, the first response data and the second response data are respectively returned to the application program according to the combination sequence, so that the traversal test is performed on the combination sequences. And when the test terminal returns the response data of various combination sequences to the application program, displaying the corresponding combination sequences in the application program. And the application program responds after receiving the response data, and the test terminal acquires a second response result of the application program under each combination sequence. The tester can also obtain the corresponding combination sequence while observing the second response result. An expected result input interface can be provided in the display interface, and a tester can input or import the expected results corresponding to the displayed combination sequence through the expected result input interface. And the test terminal channel expected result input interface receives an input expected result input by a tester, compares the input expected result with the second response result, judges whether the input expected result and the second response result are consistent and obtains a test result, and judges whether the test of each response data return sequence is normal according to the test result. In other embodiments, the tester may also determine whether the test is abnormal according to the observed response result of the application program without inputting the expected result, and input the test result into the test terminal.
In this embodiment, when the tester does not set the return sequence of the response data to be tested in advance, the test terminal can automatically perform traversal test on various possible arrangement sequences, so that the degree of automation is high, and the coverage rate of the test can be improved.
It is noted that relational terms such as first and second, and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
It should be understood that although the various steps in the flow diagrams of fig. 2-3 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-3 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 4, there is provided a network request test apparatus including: a first identifier obtaining module, an asynchronous judging module 420, an associated identifier obtaining module 430, a first data returning module 440, and a first testing module 450, wherein:
the first identifier obtaining module 410 is configured to monitor a first network request sent by an application program, and obtain a first request identifier of the first network request.
The asynchronous determining module 420 is configured to determine whether the first network request is an asynchronous request according to the first request identifier.
The association identifier obtaining module 430 is configured to, when the first network request is an asynchronous request, find a second request identifier associated with the first request identifier.
The first data returning module 440 is configured to intercept first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, search for a preset response returning sequence corresponding to the first request identifier, and return the first response data and the second response data to the application program according to the preset response returning sequence.
The first testing module 450 is configured to obtain a first response result of the application program, and compare the first response result with a preset response result corresponding to a preset response return sequence to obtain a testing result.
In one embodiment, the apparatus may further comprise:
the first interception module is used for intercepting the first network request.
And the second interception module is used for intercepting a second network request corresponding to the second request identifier.
And the first request sending module is used for sending the intercepted first network request and the intercepted second network request.
In one embodiment, the apparatus may further comprise:
and the time recording module is used for recording the sending time of the second network request corresponding to the second request identifier.
And the first estimated time obtaining module is used for obtaining first estimated response time according to the sending time and the preset response time.
And the historical data query module is used for searching historical response data corresponding to a third network request when the third network request of which the response data is not intercepted exists in the second network request after the first expected response time is reached, and taking the historical response data as currently intercepted third response data corresponding to the third network request.
In one embodiment, the apparatus may further comprise:
and the identifier recording module is used for recording a third request identifier requested by the third network.
And the third data intercepting module is used for intercepting third response data when the third response data corresponding to the recorded third request identifier is monitored, and adding the third response data to historical response data corresponding to the third network request.
In one embodiment, the apparatus may further comprise:
and the request repeating module is used for sending the third network request again and calculating a second expected response time when the historical response data corresponding to the third network request is not searched.
And the abnormal prompt module is used for generating a response abnormal prompt according to the third network request when third response data corresponding to the third network request is not intercepted when the second expected response time is reached.
In one embodiment, the apparatus may further comprise:
and the analog data receiving module is used for receiving the input analog response data and taking the analog response data as currently intercepted third response data corresponding to the third network request.
And the simulation data recording module is used for recording the simulation response data as the historical response data of the third network request.
In one embodiment, the apparatus may further comprise:
and the combined sequence obtaining module is used for arranging and combining the return sequences of the first response data and the second response data to obtain a combined sequence when the preset response return sequence corresponding to the first request identifier cannot be found.
And the sequence display module is used for returning the first response data and the second response data to the application program according to each combination sequence and displaying the corresponding combination sequence in the application program.
And the second testing module is used for acquiring a second response result of the application program corresponding to each combination sequence, acquiring an input expected result corresponding to each combination sequence, and comparing the second response result with the corresponding input expected result to obtain a testing result.
For the specific definition of the network request testing device, reference may be made to the above definition of the network request testing method, which is not described herein again. The modules in the network request testing device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 5. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a network request testing method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 5 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, there is provided a computer device comprising a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program: monitoring a first network request sent by an application program, and acquiring a first request identifier of the first network request; judging whether the first network request is an asynchronous request or not according to the first request identifier; when the first network request is an asynchronous request, searching a second request identifier associated with the first request identifier; intercepting first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, searching a preset response return sequence corresponding to the first request identifier, and returning the first response data and the second response data to the application program according to the preset response return sequence; and obtaining a first response result of the application program, and comparing the first response result with a preset response result corresponding to a preset response return sequence to obtain a test result. The coverage rate can be tested by adopting the method.
In one embodiment, the processor, when executing the computer program, further performs the steps of: intercepting a first network request; intercepting a second network request corresponding to the second request identifier; and sending the intercepted first network request and the second network request.
In one embodiment, the processor, when executing the computer program, further performs the steps of: recording the sending time of a second network request corresponding to the second request identifier; obtaining a first expected response time according to the sending time and a preset response time; and when a third network request which does not intercept response data exists in the second network request after the first expected response time is reached, searching historical response data corresponding to the third network request, and taking the historical response data as currently intercepted third response data corresponding to the third network request.
In one embodiment, the processor, when executing the computer program, further performs the steps of: recording a third request identifier of a third network request; and when third response data corresponding to the recorded third request identification are monitored, intercepting the third response data and adding the third response data to historical response data corresponding to the third network request.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when the historical response data corresponding to the third network request cannot be searched, the third network request is sent again, and second expected response time is calculated; and when third response data corresponding to the third network request are not intercepted when the second expected response time is reached, generating a response exception prompt according to the third network request.
In one embodiment, the processor, when executing the computer program, further performs the steps of: receiving input simulation response data, and taking the simulation response data as currently intercepted third response data corresponding to a third network request; the simulated response data is recorded as historical response data of the third network request.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when the preset response return sequence corresponding to the first request identification cannot be found, the return sequences of the first response data and the second response data are arranged and combined to obtain a combined sequence; returning the first response data and the second response data to the application program according to each combination sequence, and displaying the corresponding combination sequence in the application program; and acquiring a second response result of the application program corresponding to each combination sequence, acquiring an input expected result corresponding to each combination sequence, and comparing the second response result with the corresponding input expected result to obtain a test result.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: monitoring a first network request sent by an application program, and acquiring a first request identifier of the first network request; judging whether the first network request is an asynchronous request or not according to the first request identifier; when the first network request is an asynchronous request, searching a second request identifier associated with the first request identifier; intercepting first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, searching a preset response return sequence corresponding to the first request identifier, and returning the first response data and the second response data to the application program according to the preset response return sequence; and obtaining a first response result of the application program, and comparing the first response result with a preset response result corresponding to a preset response return sequence to obtain a test result. The coverage rate can be tested by adopting the method.
In one embodiment, the computer program when executed by the processor further performs the steps of: intercepting a first network request; intercepting a second network request corresponding to the second request identifier; and sending the intercepted first network request and the second network request.
In one embodiment, the computer program when executed by the processor further performs the steps of: recording the sending time of a second network request corresponding to the second request identifier; obtaining a first expected response time according to the sending time and a preset response time; and when a third network request which does not intercept response data exists in the second network request after the first expected response time is reached, searching historical response data corresponding to the third network request, and taking the historical response data as currently intercepted third response data corresponding to the third network request.
In one embodiment, the computer program when executed by the processor further performs the steps of: recording a third request identifier of a third network request; and when third response data corresponding to the recorded third request identification are monitored, intercepting the third response data and adding the third response data to historical response data corresponding to the third network request.
In one embodiment, the computer program when executed by the processor further performs the steps of: when the historical response data corresponding to the third network request cannot be searched, the third network request is sent again, and second expected response time is calculated; and when third response data corresponding to the third network request are not intercepted when the second expected response time is reached, generating a response exception prompt according to the third network request.
In one embodiment, the computer program when executed by the processor further performs the steps of: receiving input simulation response data, and taking the simulation response data as currently intercepted third response data corresponding to a third network request; the simulated response data is recorded as historical response data of the third network request.
In one embodiment, the computer program when executed by the processor further performs the steps of: when the preset response return sequence corresponding to the first request identification cannot be found, the return sequences of the first response data and the second response data are arranged and combined to obtain a combined sequence; returning the first response data and the second response data to the application program according to each combination sequence, and displaying the corresponding combination sequence in the application program; and acquiring a second response result of the application program corresponding to each combination sequence, acquiring an input expected result corresponding to each combination sequence, and comparing the second response result with the corresponding input expected result to obtain a test result.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A network request testing method, the method comprising:
monitoring a first network request sent by an application program, and acquiring a first request identifier of the first network request;
judging whether the first network request is an asynchronous request or not according to the first request identifier;
when the first network request is an asynchronous request, searching a second request identifier associated with the first request identifier;
intercepting first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, searching a preset response return sequence corresponding to the first request identifier, and returning the first response data and the second response data to the application program according to the preset response return sequence;
obtaining a first response result of the application program, and comparing the first response result with a preset response result corresponding to the preset response return sequence to obtain a test result;
recording the sending time of a second network request corresponding to the second request identifier;
obtaining a first expected response time according to the sending time and a preset response time;
when a third network request which does not intercept response data exists in the second network request after the first expected response time is reached, searching historical response data corresponding to the third network request, and taking the historical response data as currently intercepted third response data corresponding to the third network request.
2. The method of claim 1, wherein the monitoring application, after issuing the first network request, further comprises:
intercepting the first network request;
after the second request identifier associated with the first request identifier is searched, the method further includes:
intercepting a second network request corresponding to the second request identifier;
and sending the intercepted first network request and the intercepted second network request.
3. The method of claim 1, further comprising:
recording a third request identifier of the third network request;
after the returning the first response data and the second response data to the application program according to the preset response return sequence, the method further includes:
and when third response data corresponding to the recorded third request identification are monitored, intercepting the third response data, and adding the third response data to historical response data corresponding to the third network request.
4. The method of claim 1, further comprising:
when the historical response data corresponding to the third network request cannot be searched, the third network request is sent again, and second expected response time is calculated;
and when third response data corresponding to the third network request is not intercepted when the second expected response time is reached, generating a response exception prompt according to the third network request.
5. The method of claim 4, wherein after generating a response exception prompt according to the third network request, the method comprises:
receiving input simulation response data, and taking the simulation response data as currently intercepted third response data corresponding to the third network request;
recording the simulated response data as historical response data of the third network request.
6. The method of claim 1, further comprising:
when the preset response return sequence corresponding to the first request identification cannot be found, arranging and combining the return sequences of the first response data and the second response data to obtain a combined sequence;
returning the first response data and the second response data to the application program according to each combination sequence, and displaying the corresponding combination sequence in the application program;
and acquiring a second response result of the application program corresponding to each combination order, acquiring an input expected result corresponding to each combination order, and comparing the second response result with the corresponding input expected result to obtain a test result.
7. A network request testing apparatus, the apparatus comprising:
the first identifier acquisition module is used for monitoring a first network request sent by an application program and acquiring a first request identifier of the first network request;
the asynchronous judgment module is used for judging whether the first network request is an asynchronous request according to the first request identifier;
the association identifier acquisition module is used for searching a second request identifier associated with the first request identifier when the first network request is an asynchronous request;
a first data returning module, configured to intercept first response data corresponding to the first request identifier and second response data corresponding to the second request identifier, search for a preset response returning sequence corresponding to the first request identifier, and return the first response data and the second response data to the application program according to the preset response returning sequence;
the first test module is used for obtaining a first response result of the application program and comparing the first response result with a preset response result corresponding to the preset response return sequence to obtain a test result;
the time recording module is used for recording the sending time of the second network request corresponding to the second request identifier;
the first estimated time obtaining module is used for obtaining first estimated response time according to the sending time and preset response time;
and the historical data query module is used for searching historical response data corresponding to a third network request when the third network request of which the response data is not intercepted exists in the second network request after the first expected response time is reached, and taking the historical response data as currently intercepted third response data corresponding to the third network request.
8. The apparatus of claim 7, further comprising:
the first interception module is used for intercepting a first network request sent by a monitoring application program;
the second interception module is configured to intercept a second network request corresponding to the second request identifier after searching for the second request identifier associated with the first request identifier;
a first request sending module, configured to send the intercepted first network request and the intercepted second network request.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN201810428406.8A 2018-05-07 2018-05-07 Network request testing method and device, computer equipment and storage medium Active CN108848000B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810428406.8A CN108848000B (en) 2018-05-07 2018-05-07 Network request testing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810428406.8A CN108848000B (en) 2018-05-07 2018-05-07 Network request testing method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN108848000A CN108848000A (en) 2018-11-20
CN108848000B true CN108848000B (en) 2021-05-11

Family

ID=64212729

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810428406.8A Active CN108848000B (en) 2018-05-07 2018-05-07 Network request testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN108848000B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109871251B (en) * 2019-01-17 2023-12-29 平安科技(深圳)有限公司 Response data processing method and device, storage medium and terminal equipment
CN109587013B (en) * 2019-01-18 2022-08-19 深圳壹账通智能科技有限公司 APP network compatibility testing method and device, computer equipment and storage medium
CN110069395B (en) * 2019-03-12 2023-07-25 平安科技(深圳)有限公司 Method and device for simulating asynchronous interface, storage medium and computer equipment
CN110008118B (en) * 2019-03-13 2023-03-10 深圳壹账通智能科技有限公司 Page data testing method and device, computer equipment and storage medium
CN113835912B (en) * 2020-06-24 2024-02-09 北京新氧科技有限公司 Crash information processing method and device for application program
CN113726770B (en) * 2021-08-30 2023-06-30 平安国际融资租赁有限公司 Data interception method, device, computer equipment and storage medium
CN113992543A (en) * 2021-10-29 2022-01-28 建信金融科技有限责任公司 Response message sending method, device, equipment and readable storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102833125A (en) * 2011-06-17 2012-12-19 腾讯科技(深圳)有限公司 Test server, test system adopting test server, and test method
JP2015210791A (en) * 2014-04-30 2015-11-24 富士通株式会社 Decentralized processing unit, decentralized processing system, and decentralized processing program
CN107070735B (en) * 2016-12-30 2018-04-20 上海壹账通金融科技有限公司 Method, test terminal and the system of asynchronous interface test
CN107294803A (en) * 2017-06-15 2017-10-24 北京小度信息科技有限公司 Response message conformance test method and device

Also Published As

Publication number Publication date
CN108848000A (en) 2018-11-20

Similar Documents

Publication Publication Date Title
CN108848000B (en) Network request testing method and device, computer equipment and storage medium
CN109672741B (en) Micro-service monitoring method and device, computer equipment and storage medium
CN110008118B (en) Page data testing method and device, computer equipment and storage medium
CN109766256B (en) Method and device for testing H5 page performance in application program and computer equipment
CN110162453B (en) Test method, test device, computer readable storage medium and computer equipment
CN109726134B (en) Interface test method and system
CN111475376A (en) Method and device for processing test data, computer equipment and storage medium
CN112637008B (en) Link simulation test method, device, system, computer equipment and storage medium
CN108052440B (en) Method, device, equipment and storage medium for correcting operation logic of business system
CN111026647B (en) Method and device for acquiring code coverage rate, computer equipment and storage medium
CN110941555A (en) Test case recommendation method and device, computer equipment and storage medium
CN110781070A (en) Big data test verification method and device, computer equipment and storage medium
CN110798376A (en) Interface testing method and device, computer equipment and storage medium
CN112000903A (en) Data query method and device, computer equipment and storage medium
CN114328243A (en) Abnormal operation data processing method, device, equipment and storage medium
CN111431767B (en) Multi-browser resource synchronization method and device, computer equipment and storage medium
CN112506758A (en) Firmware refreshing method and device, computer equipment and storage medium
CN111414309A (en) Automatic test method of application program, computer equipment and storage medium
WO2019153978A1 (en) Terminal fingerprint test method, apparatus, computer device, and storage medium
CN112612706A (en) Automated testing method, computer device and storage medium
CN103838651A (en) Mainboard function test management and control system and method
CN113419968B (en) Application testing method and device, electronic equipment and storage medium
CN111176986A (en) Thread script debugging method and device, computer equipment and storage medium
CN112817816B (en) Embedded point processing method and device, computer equipment and storage medium
CN111625835B (en) Program vulnerability path tracking 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
GR01 Patent grant
GR01 Patent grant