Data processing method, testing method, device, equipment, storage medium and product
By acquiring and generating the correlation between network request and response information of gesture operations during the recording phase, the problem of inconsistent network environment in automated testing is solved, achieving higher testing accuracy and efficiency.
Patent Information
- Application Number
- CN202410911071.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2026-01-13
AI Technical Summary
In existing automated testing solutions, the test results are not accurate enough during the recording and playback process, and it is difficult to guarantee the consistency of the network environment.
During the recording phase, network request and response information triggered by gesture operations received by the application under test is acquired, and target relationship data is generated, including the association between gesture operations, request information and response information. During the playback phase, a virtual network response is constructed based on the target relationship data to replace real network communication.
It improved the accuracy of automated testing, ensured the consistency of the network environment, and enhanced the accuracy and efficiency of testing.
Smart Images

Figure CN121326720A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the technical field of computer, and particularly, to a data processing method, a test method, an apparatus, a device, a storage medium and a product. BACKGROUND
[0002] With the rapid development of computer technology and Internet technology, the functions in software are becoming more and more rich. After the development of new functions is completed, related tests need to be performed to discover problems in time before the new functions are put into use. With the increasing frequency of new function release, an automatic test scheme is widely applied.
[0003] In the automatic test scheme, recording and playback is an important test link, which can improve the test efficiency in the software test process. Generally, recording and playback includes a recording process and a playback process. The recording process can include recording related information when a page is operated by a touch action on a first device, and saving the information as a test case; the playback process can include running the test case on a second device to restore the corresponding touch action.
[0004] However, in the current recording and playback scheme, there is still a problem that the test result is not accurate enough, which needs to be improved. SUMMARY
[0005] Embodiments of the present disclosure provide a data processing method, an apparatus, a device, a storage medium and a product, which can optimize the existing automatic test scheme.
[0006] In a first aspect, embodiments of the present disclosure provide a data processing method applied to a first device, and the method comprises:
[0007] In response to a first gesture operation received by a to-be-tested application program, first request information in a first network request triggered by the first gesture operation is acquired, wherein operation data of the first gesture operation is used to generate a test case, and the number of the first gesture operation used to generate the test case is at least two;
[0008] First response information in a first network response corresponding to the first network request is acquired, wherein the first network response is sent by a preset server corresponding to the to-be-tested application program;
[0009] Target relationship data is generated, wherein the target relationship data includes an association relationship between a first gesture identifier of the first gesture operation, the first request information and the first response information.
[0010] In a second aspect, embodiments of the present disclosure further provide a test method applied to a second device, and the method comprises:
[0011] In a running process of the to-be-tested application program, second request information in a second network request triggered by a second gesture operation triggered by a test case is acquired, wherein the test case is generated according to operation data of a first gesture operation received by the to-be-tested application program in the first device, and the number of the first gesture operations is at least two.
[0012] Second response information corresponding to the second gesture operation is matched from the target relationship data according to a second gesture identifier of the second gesture operation and the second request information, wherein the target relationship data includes an association relationship of a first gesture identifier of the first gesture operation, first request information and first response information, the first request information is request information in a first network request triggered by the first gesture operation, and the first response information is response information in a first network response corresponding to the first network request and sent by a preset server corresponding to the to-be-tested application program and acquired by the first device.
[0013] A virtual second network response is constructed according to the second response information, so as to respond to the second network request by using the second network response.
[0014] In a third aspect, the embodiments of the present disclosure further provide a data processing apparatus configured in a first device, and the apparatus comprises:
[0015] A first request information acquisition module is configured to acquire first request information in a first network request triggered by a first gesture operation in response to that the to-be-tested application program receives the first gesture operation, wherein operation data of the first gesture operation is used to generate a test case, and the number of the first gesture operations used to generate the test case is at least two.
[0016] A first response information acquisition module is configured to acquire first response information in a first network response corresponding to the first network request, wherein the first network response is sent by a preset server corresponding to the to-be-tested application program.
[0017] A target relationship data generation module is configured to generate target relationship data, wherein the target relationship data includes an association relationship of a first gesture identifier of the first gesture operation, the first request information and the first response information, so as to determine the target relationship data.
[0018] In a fourth aspect, the embodiments of the present disclosure further provide a test apparatus configured in a second device, and the apparatus comprises:
[0019] The second request information acquisition module is configured to acquire second request information in a second network request triggered by a second gesture operation in response to the second gesture operation triggered by the test case during running of the application under test, wherein the test case is generated according to operation data of a first gesture operation received by the application under test in the first device, and the number of the first gesture operation is at least two.
[0020] The second response information matching module is configured to match corresponding second response information from the target relationship data according to the second gesture identifier of the second gesture operation and the second request information, wherein the target relationship data includes an association relationship among a first gesture identifier of the first gesture operation, first request information and first response information, the first request information is request information in a first network request triggered by the first gesture operation, and the first response information is response information in a first network response corresponding to the first network request sent by a preset server corresponding to the application under test and acquired by the first device.
[0021] The response module is configured to construct a virtual second network response according to the second response information, and to respond to the second network request by using the second network response.
[0022] In a fifth aspect, the embodiments of the present disclosure further provide an electronic device, and the electronic device includes:
[0023] one or more processors;
[0024] a storage device configured to store one or more programs,
[0025] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the embodiments of the present disclosure.
[0026] In a sixth aspect, the embodiments of the present disclosure further provide a storage medium containing computer executable instructions, which are used to execute the method provided by the embodiments of the present disclosure when executed by a computer processor.
[0027] In a seventh aspect, the embodiments of the present disclosure further provide a computer program product, including a computer program, which is executed by a processor to implement the method provided by the embodiments of the present disclosure.
[0028] The data processing scheme provided by the embodiments of the present disclosure, in the first device, in response to the first gesture operation received by the to-be-tested application program, first request information in a first network request triggered by the first gesture operation is acquired, wherein operation data of the first gesture operation is used to generate a test case, the number of the first gesture operation used to generate the test case is at least two, first response information in a first network response corresponding to the first network request is acquired, the first network response is sent by a preset server corresponding to the to-be-tested application program, target relationship data is generated, wherein the target relationship data includes an association relationship among a first gesture identifier of the first gesture operation, the first request information and the first response information. By adopting the above technical scheme, the accuracy of the automatic test can be improved.
[0029] The test scheme provided by the embodiments of the present disclosure, in the second device, in the running process of the to-be-tested application program, in response to a second gesture operation triggered by a test case, second request information in a second network request triggered by the second gesture operation is acquired, wherein the test case is generated according to operation data of a first gesture operation received by the to-be-tested application program in the first device, the number of the first gesture operation is at least two, corresponding second response information is matched from target relationship data according to a second gesture identifier of the second gesture operation and the second request information, the target relationship data includes an association relationship among a first gesture identifier of the first gesture operation, the first request information and the first response information, the first request information is request information in a first network request triggered by the first gesture operation, the first response information is response information in a first network response corresponding to the first network request sent by a preset server corresponding to the to-be-tested application program and acquired by the first device, a virtual second network response is constructed according to the second response information, so as to respond to the second network request by using the second network response. By adopting the above technical scheme, the accuracy of the automatic test can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0030] The above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent by referring to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals indicate the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale.
[0031] Figure 1 An application scenario diagram provided by the embodiments of the present disclosure;
[0032] Figure 2 Another application scenario diagram provided by the embodiments of the present disclosure
[0033] Figure 3 A flow diagram of a data processing method provided by the embodiments of the present disclosure;
[0034] Figure 4 A flowchart of another data processing method provided by an embodiment of the present disclosure;
[0035] Figure 5 A flowchart of a test method provided by an embodiment of the present disclosure;
[0036] Figure 6 A structural diagram of a data processing apparatus provided by an embodiment of the present disclosure;
[0037] Figure 7 A structural diagram of a test apparatus provided by an embodiment of the present disclosure;
[0038] Figure 8 A structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0039] Embodiments of the present disclosure will be described in more detail by referring to the drawings. Although certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather these embodiments are provided so as to more completely and thoroughly understand the present disclosure. It is understood that the drawings and embodiments of the present disclosure are for exemplary purposes only and are not intended to limit the scope of protection of the present disclosure.
[0040] It should be understood that each of the steps recited in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.
[0041] The term “comprising” and variations thereof as used herein are open-ended, that is, “including but not limited to”. The term “based on” is “based, at least in part, on”. The term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one additional embodiment”; the term “some embodiments” means “at least some embodiments”. Related definitions are given below in the description of the terms.
[0042] It should be noted that the concepts of “first”, “second”, etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0043] It should be noted that the modification of “one”, “multiple” mentioned in the present disclosure is illustrative and not limiting, and those skilled in the art should understand that, unless otherwise explicitly indicated in the context, it should be understood as “one or more”.
[0044] The first device and the second device in the embodiments of the present disclosure can be electronic devices, for example, mobile terminals such as mobile phones, smart watches, tablet computers, and personal digital assistants, and the device types and device models of the first device and the second device can be the same or different, and the specific device types and device models are not limited. Generally, the first device can be one, and the second device can be one or more, and when the second device is multiple, batch automated testing can be implemented.
[0045] Figure 1 An application scenario diagram provided by the embodiments of the present disclosure can be specifically an application scenario diagram of the data processing scheme and the test scheme provided by the embodiments of the present disclosure. As shown in Figure 1 The application scenario includes a first device 101 (also referred to as a recording device) and a second device 102 (also referred to as a playback device), and the first device 101 and the second device 102 can be communicatively connected or can not be communicatively connected. The communication connection can be wired or wireless to perform data interaction. In the case where there is no communication connection, a mobile storage device can be used as an intermediary to perform data transmission. The first device 101 can perform any data processing method provided by the embodiments of the present disclosure, and the second device 102 can perform any test method provided by the embodiments of the present disclosure. Optionally, the first device 101 can send the generated test case and / or target relationship data to the second device 102 through the communication connection. Optionally, the test case and / or target relationship data generated by the first device 101 are stored in the mobile storage device, and the test case and / or target relationship data are copied to the second device 102.
[0046] Figure 2 Another application scenario diagram provided by the embodiments of the present disclosure can be specifically an application scenario diagram of the data processing scheme and the test scheme provided by the embodiments of the present disclosure. As shown in Figure 2As shown, the application scenario includes a first device 201, a second device 202, and a test terminal 203. The test terminal 203 can be a personal computer (PC) terminal or a target server. The first device 201 can be in communication connection with the test terminal 203, or can not be in communication connection. The test terminal 203 can be in communication connection with the first device 201, or can not be in communication connection. The communication connection can be a wired connection or a wireless connection for data interaction. In the case where there is no communication connection, a mobile storage device can be used as an intermediary for data transmission. The first device 201 can execute any data processing method provided by the embodiments of the present disclosure, and the second device 202 can execute any test method provided by the embodiments of the present disclosure. Optionally, the first device 201 can send the generated test case and / or target relationship data to the test terminal 203, and the test terminal 203 forwards the test case and / or target relationship data to the second device 202. Optionally, the test case and / or target relationship data generated by the first device 201 are stored in the mobile storage device, and the test case and / or target relationship data are copied to the second device 202. After executing the test method, the second device 202 can send the execution result of the test method as test result data to the test terminal 203, so as to visually display and analyze the test result by the test terminal 203.
[0047] Figure 3 A flowchart of a data processing method provided by the embodiments of the present disclosure is shown. The embodiments of the present disclosure are applicable to the case of processing the related data of the network request triggered by the gesture operation in the recording stage of the automation test. The method can be executed by a data processing apparatus, which can be implemented in the form of software and / or hardware, and can be implemented by an electronic device configured as a first device.
[0048] As shown in Figure 3 The method includes the following steps.
[0049] In step 301, in response to the first gesture operation received by the application under test, first request information in a first network request triggered by the first gesture operation is acquired. The operation data of the first gesture operation is used to generate a test case, and the number of the first gesture operations used to generate the test case is at least two.
[0050] Exemplarily, the automated test in the embodiments of the present disclosure can be applied to a scenario of automated testing for a user interface (UI), for example, a scenario of automated testing for a page function in an application. A preset application to be tested (denoted as a to-be-tested application) is installed in both the first device and the second device. In the first device, a recording can be performed on a page (denoted as a first page) in response to a recording request for the page. During the recording, a user (for example, a tester) can input a gesture operation (for example, a touch operation) through a screen of the first device, so that the first device can detect the gesture operation and further obtain operation data (for example, parameter information) corresponding to the gesture operation. In response to an end recording request for the first page, a recording file is generated based on the obtained operation data. The recording file can be referred to as a test case. The first page refers to a page in the to-be-tested application installed in the first device. The number of the first page is not limited and can be dynamically changed. For example, when the recording is started, the first page can be a home page of the application. After a page switching operation is performed, the first page can be changed to another page. The recording request can be triggered by the first device in response to a start recording request. The start recording request can be input by a user on the first device, for example, the user clicks a start recording button on the first device to input the recording request. The first device performs recording on the first page in response to the recording request. The recording on the first page refers to that operation data corresponding to a gesture operation for the first page is continuously obtained during the recording. It should be understood that the gesture operation for the first page can be initiated by the user. For example, a click, a swipe, a double-click, a long press, and the like performed by the user on the first page can be understood as gesture operations. Of course, in addition to the above operations, the gesture operation can also include other operations, such as a three-finger operation and the like. Here, the end recording request can be input by the user on the first device, for example, the user clicks an end recording button on the first device to input the end recording request. The first device receives the end recording request, indicating that the recording is ended, and then generates the test case based on the operation data of the gesture operation obtained during the recording. The test case can be a script file, for example, a Json file.
[0051] In the automated testing process, the to-be-tested application program and the corresponding preset server exist network communication. In the related art, in the recording stage and the playback stage, the to-be-tested application program and the preset server perform real network communication. However, since the recording stage is before the playback stage, it is difficult to ensure that the preset server returns the same network data, which leads to different page display contents in the playback stage and the recording stage, and causes inaccurate test results. For example, assuming that the to-be-tested application program is an application program for playing a video stream, when the to-be-tested application program requests the video content to be played at different times from the preset server, it is difficult to ensure that the preset server returns the same video content. Different video contents may be different in the associated UI control or UI layout in the page, which may cause data interaction abnormity, such as that the gesture operation triggered by the test case and the gesture operation triggered in the recording stage trigger different controls, or play an incorrect video, and the like.
[0052] In the recording stage, when the to-be-tested application program receives the first gesture operation, the first device not only acquires the operation data of the gesture operation, but also acquires the first request information in the first network request triggered by the first gesture operation, so as to subsequently continue to acquire the corresponding first response information. In the playback stage, the first response information is used to respond to the network request, the real network communication performed by the second device and the preset server is reduced, the consistency of the network data is ensured, and then the consistency of the network environment in the automated testing process is ensured, and the accuracy of the automated testing can be improved.
[0053] For example, the first gesture operation can be any one gesture operation received by the to-be-tested application program, the network request triggered by the first gesture operation is denoted as the first network request, and the first gesture operation can trigger one or more network requests, that is, the number of the first network request can be one or more.
[0054] For example, the request information is contained in the network request, and the request information can include information such as a request path (path) or a request resource type. The first request information is the request information contained in the first network request.
[0055] Exemplarily, the network request can be detected at an application layer and the request information can be acquired therefrom; or the network request can be detected in a network request underlying framework and the request information can be acquired therefrom. Optionally, the first request information in the first network request triggered by the first gesture operation is acquired by using a preset function in the first device, wherein the preset function is a function in the network request underlying framework that is called when the first network request is triggered. In this way, the request information is acquired by using the underlying function, without the need to set the network request detection mode for different functions of the application layer, and the omission in the detection at the application layer can be avoided, the accuracy of the request information acquisition is improved, the accuracy of the target relationship data is ensured, the correct response information cannot be matched in the playback stage, the virtual network response cannot be constructed, and the test progress is affected. Taking an Android operating system as an example, the network request underlying framework can be OkHttp, and the preset function can be a public Response intercept(Chain chain) function, wherein the chain is a class provided by OkHttp and contains a chain call of the request and the response.
[0056] In step 302, first response information in a first network response corresponding to the first network request is acquired, wherein the first network response is sent by a preset server corresponding to the application under test.
[0057] Exemplarily, the response information is contained in the network response, the network response is sent by the preset server corresponding to the application under test to the first device, and the response information can include information such as a response body. The first response information is the response information contained in the first network response, and the first network response is a network response sent by the preset server after receiving the first network request in response to the first network request. The corresponding first network request and the first network response contain the same uniform resource locator (URL).
[0058] Exemplarily, the network response can be detected at an application layer and the response information can be acquired therefrom; or the network response can be detected in a network request underlying framework and the response information can be acquired therefrom. Optionally, the first response information in the first network response corresponding to the first network request is acquired by using the preset function, wherein the preset function is called when the first network response is received. Taking an Android operating system as an example, the public Response intercept(Chain chain) function is also called when the network response is received, and therefore, the network response can be detected by using the function.
[0059] In step 303, target relationship data is generated, wherein the target relationship data comprises an association relationship among a first gesture identifier of the first gesture operation, the first request information, and the first response information.
[0060] The target relationship data is used for the second device to match corresponding second response information from the target relationship data according to a second gesture identifier of a second gesture operation triggered by the test case and second request information of a second network request triggered by the second gesture operation in a process of running the to-be-tested application program, and to construct a virtual second network response according to the second response information, so as to respond to the second network request by using the second network response.
[0061] For example, the gesture identifier can be information for uniquely representing the identity of the gesture operation, for example, can be a gesture id, and the first gesture identifier is the gesture identifier of the first gesture operation. If the number of the first network requests is one, the association relationship among the first gesture identifier, the first request information, and the first response information can be a one-to-one relationship (i.e., a one-to-one-to-one relationship). If the number of the first network requests is multiple, the first gesture identifier corresponds to multiple first request information, and the first request information and the first response information are in a one-to-one relationship, that is, different first request information corresponds to different first response information.
[0062] For example, the target relationship data can be cached by the first device, and after the recording stage ends, all target relationship data corresponding to the gesture operation is packaged, so as to directly or indirectly send the packaged target relationship data to the second device. For example, the target relationship data is uploaded to a target server, and when the to-be-tested application program in the second device starts, the target relationship data is issued to the second device by the target server. Optionally, the target relationship data can be included in the test case, or can exist independently outside the test case, and the specific implementation is not limited.
[0063] For example, in the process of running the to-be-tested application program in the second device, a test case is started, a gesture operation is triggered by the test case, the gesture operation triggered by the test case in the second device is recorded as a second gesture operation, and a gesture identifier of the second gesture operation is recorded as a second gesture identifier. Since the purpose of the playback stage is to simulate the gesture operation in the recording stage so as to perform the automated test, the second gesture identifier and the first gesture identifier are in one-to-one correspondence, for example, gesture ids are the same or gesture ids have a mapping relationship. A network request triggered by the second gesture operation is recorded as a second network request, request information in the second network request is recorded as second request information, and the second request information can be acquired in the same or similar manner as the first request information, which will not be described here. After the second request information is acquired, the second device can match the first gesture identifier that is the same as or has a mapping relationship with the second gesture identifier from the target relationship data, find the first request information that matches the second request information from the first request information corresponding to the first gesture identifier, and take the first response information corresponding to the matched first request information as the second response information. A virtual network response constructed according to the second response information is recorded as a second network response. The second network response is used to respond to the second network request, so as to reduce the network interaction between the second device and the real preset server, and the second device can use the second network response for subsequent testing, so as to ensure the consistency of the network data and the network environment and improve the test accuracy.
[0064] The data processing method provided in the embodiments of the present disclosure is used in the first device. In response to a to-be-tested application program receiving a first gesture operation, first request information in a first network request triggered by the first gesture operation is acquired, wherein operation data of the first gesture operation is used to generate a test case, the number of the first gesture operations used to generate the test case is at least two, first response information in a first network response corresponding to the first network request is acquired, the first network response is sent by a preset server corresponding to the to-be-tested application program, and target relationship data is generated, wherein the target relationship data includes an association relationship among a first gesture identifier of the first gesture operation, the first request information, and the first response information. By using the technical solution, real network data can be acquired in the test case generation stage (recording stage) of the automated test, and in the running stage (playback stage) of the test case, the real network response acquired in advance is used to construct a virtual network response for testing, so as to ensure the consistency of the network environment in the automated test process and improve the accuracy of the automated test.
[0065] In some embodiments, the first request information in the first network request triggered by the first gesture operation is acquired in response to the first gesture operation being received by the application under test, including: first candidate request information in a first candidate network request triggered by the first gesture operation is acquired in response to the first gesture operation being received by the application under test, wherein the first candidate request information includes a candidate request path; it is judged whether the candidate request path is in a preset path set, wherein the preset path set includes preset paths corresponding to heartbeat requests and / or long connection requests; if not, the first candidate network request is determined as the first network request, and the first candidate request information is determined as corresponding first request information. Thus, the response information can be selectively acquired, the operation is reduced, the data processing efficiency in the recording stage is improved, and the data amount of the target relationship data is reduced.
[0066] For example, any network request triggered by the first gesture operation can be recorded as a candidate network request, and the first candidate network request is the currently triggered candidate network request. If the first candidate network request is a heartbeat request or a long connection request, the network response generally does not affect the content displayed in the page of the application under test. Therefore, the response information can be avoided to be acquired for the heartbeat request and / or the long connection request.
[0067] Specifically, the request path included in the heartbeat request and / or the long connection request sent by the application under test can be determined by experiments or the like, and the determined request path is stored in the preset path set as a preset path. If the candidate request path included in the first candidate request information is not in the preset path set, it can be determined that the first candidate network request is not a heartbeat request or a long connection request, and the first candidate network request can be determined as the first network request. Optionally, if the candidate request path is in the preset path set, it can be determined that the first candidate network request is a heartbeat request or a long connection request, so that the response information corresponding to the first candidate network request does not need to be acquired, that is, the first candidate network request is allowed to be sent to the preset server.
[0068] In some embodiments, the first device stores a preset file set, and files in the preset file set are pushed into the memory of the first device by a preset push command during installation of the application under test on the first device. In response to the application under test receiving the first gesture operation, the first request information in the first network request triggered by the first gesture operation is obtained, including: in response to the application under test receiving the first gesture operation, the second candidate request information in the second candidate network request triggered by the first gesture operation is obtained, wherein the second candidate request information includes a request resource type; it is determined whether the request resource type is a file type (file); if it is not a file type, the second candidate network request is determined as the first network request, and the second candidate request information is determined as the corresponding first request information. Thus, the response information can be selectively obtained, the operation is reduced, the data processing efficiency in the recording stage is improved, and the data amount of the target relationship data is reduced.
[0069] For example, during the running of the application under test, a network request for downloading a file can also be triggered, and the size of the file is usually large, such as a picture file or a binary file, and the process of downloading the file is usually time-consuming. If the downloaded file is included in the target relationship data, the data amount of the target relationship data will also be greatly increased. Therefore, in the embodiments of the present disclosure, the target file that can be downloaded during the running of the application under test can be determined in advance by experiment or the like, the target file is downloaded in advance, and is packaged into a compressed package such as a zip package. The compressed package is placed in the installation file of the application under test, and when the application under test is installed in the first device, the compressed package is extracted from the installation file and pushed into the disk corresponding to the application under test in the first device by a preset push command (such as an adb push command) and decompressed into the memory to obtain a preset file set. The preset file set includes the target file downloaded in advance. Thus, when a certain function in the application under test needs to use a certain file due to receiving the first gesture operation, there is a high probability that the file can be directly obtained from the local preset file set, without triggering a network request for response, reducing the interaction with the preset server. Since the preset file set meets most of the file usage requirements, the number of times of triggering a network request for downloading a file is greatly reduced, and when downloading a file by triggering a network request, the corresponding response information does not need to be obtained. The second device stores a preset file set, and files in the preset file set are pushed into the memory of the second device by a preset push command during installation of the application under test on the second device. In the playback stage, the application under test is allowed to request a file download from the preset server through a network request.
[0070] Optionally, the preset file set can be different for different versions of the application under test, that is, different versions can need different target files to be downloaded in advance.
[0071] For example, if the request resource type is a preset type other than a file type, such as a json data type, the second candidate network request is determined as the first network request, and the second candidate request information is determined as the corresponding first request information. If the request resource type is not a preset type, the response information corresponding to the second candidate network request can also be obtained.
[0072] For example, the first candidate network request and the second candidate network request can be the same or different candidate network requests.
[0073] Figure 4 For another data processing method provided by the embodiment of the present disclosure, the embodiment of the present disclosure is optimized based on the various optional schemes in the above embodiments, and specifically, the method includes the following steps:
[0074] Step 401, in response to the first gesture operation received by the application under test, obtaining the first candidate request information of the first candidate network request triggered by the first gesture operation, wherein the first candidate request information includes the candidate request path and the request resource type.
[0075] The operation data of the first gesture operation is used to generate a test case.
[0076] For example, the first candidate request information of the first candidate network request triggered by the first gesture operation is obtained by using a preset function in the first device. For example, the preset function is a public Response intercept(Chain chain) function, and when the public Response intercept(Chain chain) function is called, the first candidate request information is obtained from the input parameters thereof.
[0077] Step 402, determining whether the candidate request path is in a preset path set, if yes, ending the flow; otherwise, performing step 403.
[0078] The preset path set includes preset paths corresponding to heartbeat requests and long connection requests.
[0079] For example, if it is in the preset path set, the next candidate network request can be continuously detected, if there is no next candidate network request, the flow can be ended, or the next gesture operation can be continuously detected, if it is detected that the recording is stopped, the flow is ended.
[0080] Step 403, judging whether the requested resource type is a file type, if yes, ending the flow; otherwise, executing step 404.
[0081] In the first device, a preset file set is stored, and the files in the preset file set are pushed into the memory of the first device through a preset push command in the process of installing the application under test in the first device. For example, if the requested resource type is a json data type, step 404 can be executed.
[0082] For example, if the type is a file type, the next candidate network request can be continuously detected, if there is no next candidate network request, the flow can be ended, or the next gesture operation can be continuously detected, if the recording is stopped, the flow is ended.
[0083] Step 404, determining the first candidate network request as the first network request, and determining the first candidate request information as the corresponding first request information.
[0084] For example, if the first candidate network request is not a heartbeat request, nor a long connection request, and the requested resource type is also not a file type, the first candidate network request can be determined as the first network request which needs to obtain the corresponding response information.
[0085] Step 405, obtaining the first response information in the first network response corresponding to the first network request, wherein the first network response is sent by a preset server corresponding to the application under test.
[0086] For example, the first response information in the first network response corresponding to the first network request is obtained by using a preset function. For example, the preset function is a public Response intercept(Chain chain) function, when the public Response intercept(Chain chain) function is called, the first response information is obtained from the input parameters thereof.
[0087] Step 406, generating target relationship data, the target relationship data including the association relationship between the first gesture identifier of the first gesture operation, the first request information and the first response information.
[0088] Optionally, according to the association relationship between the first gesture identifier of the first gesture operation, the first request information and the first response information, initial relationship data is generated, and the initial relationship data is encrypted by using a preset encryption algorithm to obtain the target relationship data. The initial relationship data can be binary data, and some special characters such as "-" or " / " can exist in the binary data. The initial relationship data can be encrypted by using a Base64 algorithm or other encryption algorithm to prevent data leakage.
[0089] The data processing method provided by the embodiments of the present disclosure filters the network request triggered by the gesture operation in the test case generation stage of the automated test, and in the case that the network request is not a heartbeat request, is not a long connection request, and the request resource type is not a file type, the real network response is further acquired, that is, the response information can be selectively acquired, the operation is reduced, the data processing efficiency of the test case generation stage is improved, and the data amount of the target relational data is reduced. In the running stage of the test case, the real response information acquired before is used to construct a virtual network response and perform testing, ensuring the consistency of the network environment in the automated test process, effectively improving the accuracy and efficiency of the automated test.
[0090] Figure 5 The flowchart of the test method provided by the embodiments of the present disclosure is applicable to the case of processing the network request triggered by the gesture operation in the playback stage of the automated test. The method can be executed by a test device, which can be implemented in the form of software and / or hardware, and can be implemented by an electronic device configured as a second device. As shown in Figure 5 The method comprises the following steps.
[0091] In step 501, in the running process of the application under test, the second request information in the second network request triggered by the second gesture operation is acquired in response to the test case triggered second gesture operation, wherein the test case is generated according to the operation data of the first gesture operation received by the application under test in the first device, and the number of the first gesture operation is at least two.
[0092] In the embodiments of the present disclosure, the second gesture operation is triggered by the test case, rather than by the real user, which can be understood as a virtual gesture operation. When generating the test case, the second gesture operation corresponding to the first gesture operation can be constructed, and the second gesture operation is triggered when the test case is run. Alternatively, after generating the initial test case, the second gesture operation can be constructed and added to the initial test case to update the initial test case and obtain the test case for running in the second device. Alternatively, when running the test case, the second gesture operation can be constructed and triggered by acquiring the data of the touch position and touch duration of the first gesture operation from the test case, without limitation.
[0093] For example, the network request triggered by the second gesture operation is referred to as the second network request, and the request information in the second network request is referred to as the second request information.
[0094] Optionally, the second request information in the second network request triggered by the second gesture operation is obtained by using a preset function in the second device, the preset function being a function in a network request underlying framework that is called when the second network request is triggered, such as the public Response intercept(Chain chain) function mentioned above.
[0095] Optionally, before the step is performed, the following step can also be included: before starting the preset application, performing a cleaning operation on the cache to avoid interference of cache data generated by other applications with the automatic test of the preset application.
[0096] In step 502, the second response information is matched from the target relationship data according to the second gesture identifier of the second gesture operation and the second request information; the target relationship data includes an association relationship among the first gesture identifier, the first request information, and the first response information of the first gesture operation, the first request information being request information in a first network request triggered by the first gesture operation, and the first response information being response information in a first network response corresponding to the first network request sent by a preset server corresponding to the application under test and obtained by the first device.
[0097] For example, the gesture identifier of the second gesture operation is recorded as the second gesture identifier. The second gesture operation has a corresponding relationship with the first gesture operation, and therefore the second gesture identifier and the first gesture identifier are in one-to-one correspondence, for example, the gesture ids are the same or the gesture ids have a mapping relationship. After the second request information is obtained, the first gesture identifier that is the same as or has a mapping relationship with the second gesture identifier is matched from the target relationship data, the first request information that matches the second request information is searched from the first request information corresponding to the first gesture identifier, and the first response information corresponding to the matched first request information is taken as the second response information.
[0098] In step 503, a virtual second network response is constructed according to the second response information, so as to respond to the second network request by using the second network response.
[0099] For example, the virtual network response constructed according to the second response information is recorded as the second network response, the second network request is responded to by using the second network response, the network interaction between the second device and the real preset server is reduced, and the second device can use the second network response for subsequent testing, ensuring the consistency of network data and network environment and improving the test accuracy.
[0100] Optionally, the second response information includes a response body, the virtual second network response is constructed according to the response body, the second network response is taken as the input of the preset function by calling the preset function, and the second network request is responded to.
[0101] The test scheme provided by the embodiments of the present disclosure, in the second device, in the running process of the to-be-tested application program, second request information in a second network request triggered by a second gesture operation triggered by a test case is acquired, wherein the test case is generated according to operation data of a first gesture operation received by the to-be-tested application program in the first device, second response information corresponding to the second gesture operation is matched from target relationship data according to a second gesture identifier of the second gesture operation and the second request information, the target relationship data includes an association relationship of a first gesture identifier of the first gesture operation, first request information and first response information, the first request information is request information in a first network request triggered by the first gesture operation, and the first response information is response information in a first network response corresponding to the first network request sent by a preset server corresponding to the to-be-tested application program and acquired by the first device, and a virtual second network response is constructed according to the second response information, so as to respond to the second network request by using the second network response. By using the above technical scheme, real network data can be acquired in the test case generation stage of the automatic test, and the real network data acquired before is used for testing in the running stage of the test case, so that the consistency of the network environment in the automatic test process is ensured, and the accuracy of the automatic test can be improved.
[0102] In some embodiments, the acquiring, in the running process of the to-be-tested application program, second request information in a second network request triggered by a second gesture operation triggered by a test case, comprises: acquiring first alternative request information of a first alternative network request triggered by the second gesture operation in the running process of the to-be-tested application program in response to the second gesture operation triggered by the test case, wherein the first alternative request information includes an alternative request path; determining whether the alternative request path is in a preset path set, wherein the preset path set includes preset paths corresponding to heartbeat requests and / or long connection requests; if not, determining the first alternative network request as the second network request and the first alternative request information as corresponding second request information. In this way, when the second gesture operation triggers a heartbeat request and / or a long connection request, since the corresponding response information is not stored in the recording stage, in the playback stage, the matching of the response information is not needed, and the test efficiency is improved. Optionally, if the alternative request path is in the preset path set, the first alternative network request is allowed to be sent to the preset server.
[0103] Exemplarily, any network request triggered by the second gesture operation can be recorded as an alternative network request, and the first alternative network request is the currently triggered alternative network request. If the alternative request path in the first alternative network request is not in the preset path set, it is indicated that the first alternative network request is not a heartbeat request or a long connection request, and the first alternative network request can be determined as the second network request, and then subsequent matching of response information is performed. If the alternative request path in the first alternative network request is in the preset path set, it is indicated that the first alternative network request is a heartbeat request or a long connection request, and the first alternative network request is allowed to be sent to the preset server.
[0104] In some embodiments, the second device stores a preset file set, and a file in the preset file set is pushed into the memory of the second device through a preset push command in the process in which the second device installs the to-be-tested application; wherein the obtaining, in the running process of the to-be-tested application, second request information in a second network request triggered by a second gesture operation triggered by a test case, includes: obtaining, in the running process of the to-be-tested application, second alternative request information of a second alternative network request triggered by the second gesture operation triggered by the test case, wherein the second alternative request information includes a request resource type; determining whether the request resource type in the second alternative request information is a file type; if not, determining the second alternative network request as the second network request, and determining the second alternative request information as the corresponding second request information. Thus, when the second gesture operation triggers a network request for requesting a file, since the corresponding response information is not stored in the recording stage, in the playback stage, matching of the response information is not needed, and the test efficiency is improved. Optionally, if the request resource type is the file type, the second alternative network request is allowed to be sent to the preset server.
[0105] In the embodiments of the present disclosure, the network requests are distinguished according to the request paths contained in the network requests. If the first gesture operation triggers a plurality of first network requests containing different request paths, the plurality of first network requests are bound to the first gesture identifier, and in the playback stage, the unique response information can be matched according to the gesture identifier and the request path.
[0106] Exemplarily, the first gesture operation can also trigger a plurality of first network requests with the same request path, and when matched, a plurality of response information can be matched. In some embodiments, the first request information includes a first request path, and the second request information includes a second request path. Wherein, the matching of the corresponding second response information from the target relationship data according to the second gesture identifier of the second gesture operation and the second request information includes: if a plurality of first request paths same as the second request path are matched from the target relationship data according to the second gesture identifier of the second gesture operation and the second request path, the request sequence number of the current second network request is determined, wherein the request sequence number is the sequence number of the current second network request in the trigger sequence of the plurality of second network requests triggered by the second gesture operation; the corresponding target first response information is obtained from the target relationship data according to the request sequence number, wherein in the target relationship data, the first response information corresponding to the plurality of first network requests triggered by the first gesture operation is one-to-one corresponding to a plurality of preset sequence numbers, and the preset sequence number is used to represent the sequence number of the corresponding first network request in the trigger sequence of the plurality of first network requests; and the target first response information is determined as the matched second response information. Thus, the test accuracy can be improved.
[0107] Exemplarily, for the case that the first gesture operation triggers a plurality of first network requests with the same request path, the corresponding response information can be matched according to the request sequence. For example, the first gesture trigger operation triggers 3 first network requests with the same path1, and for each first network request, 3 first response information are obtained in the recording stage, and the trigger sequence is body1, body2 and body3 in turn, and the corresponding relationship is path1-body1, path1-body2 and path1-body3. In the playback stage, if the second request path is path1, 3 first response information can be matched, the target first response information matched by the first triggered second network request is body1, the target first response information matched by the second triggered second network request is body2, and the target first response information matched by the third triggered second network request is body3.
[0108] In some embodiments, obtaining the corresponding target first response information from the target relationship data according to the request sequence number includes: if the request sequence number is less than or equal to the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the first target preset sequence number is determined as the target first response information, wherein the first target preset sequence number is equal to the request sequence number; if the request sequence number is greater than the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the second target preset sequence number is determined as the target first response information, wherein the second target preset sequence number is the largest preset sequence number. Therefore, for situations where there are more network requests triggered by gesture operations during the playback phase than the same gesture operation triggered during the recording phase, corresponding virtual network responses can be successfully constructed, ensuring the continuation of the test, avoiding test interruption due to the failure to match the corresponding response information, and improving test efficiency.
[0109] For example, as described above, suppose the second gesture operation triggers four second network requests with the request path 'path1'. If the request number 4 of the fourth triggered second network request is greater than the maximum value 3 among multiple preset numbers in the target relation data, then the preset number 3 is determined as the second target preset number, that is, the first response information corresponding to the preset number 3, body3, is determined as the target first response information.
[0110] Optionally, if the target relationship data is encrypted using a preset encryption algorithm (such as Base64 algorithm), the target relationship data is decrypted, and the corresponding second response information is matched from the decrypted target relationship data based on the second gesture identifier and the second request information of the second gesture operation.
[0111] Figure 6 This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of the present disclosure, as shown below. Figure 6 As shown, the device includes:
[0112] The first request information acquisition module 601 is used to acquire the first request information in the first network request triggered by the first gesture operation in response to the application under test receiving the first gesture operation, wherein the operation data of the first gesture operation is used to generate test cases.
[0113] The first response information acquisition module 602 is used to acquire the first response information in the first network response corresponding to the first network request, wherein the first network response is sent by a preset server corresponding to the application under test.
[0114] The target relationship data generation module 603 is used to generate target relationship data, wherein the target relationship data includes the association between the first gesture identifier of the first gesture operation, the first request information, and the first response information.
[0115] The data processing apparatus provided in this disclosure can acquire real network data during the test case generation phase of automated testing, and construct virtual network responses using the previously acquired real network responses during the test case execution phase, thereby ensuring the consistency of the network environment during automated testing and improving the accuracy of automated testing.
[0116] Optionally, the first request information acquisition module includes:
[0117] The first candidate request information acquisition unit is configured to, in response to the application under test receiving a first gesture operation, acquire first candidate request information of a first candidate network request triggered by the first gesture operation, wherein the first candidate request information includes a candidate request path;
[0118] A path determination unit is used to determine whether the candidate request path is in a preset path set, wherein the preset path set includes preset paths corresponding to heartbeat requests and / or long connection requests;
[0119] The first request information determination unit is used to determine the first candidate network request as the first network request and the first candidate request information as the corresponding first request information when the candidate request path is not in the preset path set.
[0120] Optionally, the first device stores a preset file set, and the files in the preset file set are pushed into the memory of the first device through a preset push command during the installation of the application to be tested on the first device;
[0121] The first request information acquisition module includes:
[0122] The second candidate request information acquisition unit is configured to, in response to the application under test receiving a first gesture operation, acquire second candidate request information of a second candidate network request triggered by the first gesture operation, wherein the second candidate request information includes the request resource type;
[0123] A type determination unit is used to determine whether the requested resource type is a file type;
[0124] The second request information determining unit is configured to determine the second candidate network request as the first network request and the second candidate request information as the corresponding first request information when the requested resource type is not a file type.
[0125] Optionally, obtaining the first request information in the first network request triggered by the first gesture operation includes: obtaining the first request information in the first network request triggered by the first gesture operation using a preset function in the first device, wherein the preset function is a function in the underlying network request framework that is called when the first network request is triggered;
[0126] The step of obtaining the first response information in the first network response corresponding to the first network request includes: using the preset function to obtain the first response information in the first network response corresponding to the first network request, wherein the preset function is called when the first network response is received.
[0127] Figure 7 This is a schematic diagram of the structure of a testing device provided in an embodiment of this disclosure, as shown below. Figure 7 As shown, the device includes:
[0128] The second request information acquisition module 701 is used to acquire second request information in a second network request triggered by a second gesture operation triggered by a test case during the operation of the application under test. The test case is generated based on the operation data of the first gesture operation received by the application under test in the first device, and the number of the first gesture operation is at least two.
[0129] The second response information matching module 702 is used to match the corresponding second response information from the target relationship data according to the second gesture identifier of the second gesture operation and the second request information; wherein, the target relationship data includes the association relationship between the first gesture identifier, the first request information and the first response information of the first gesture operation, the first request information is the request information in the first network request triggered by the first gesture operation, and the first response information is the response information in the first network response corresponding to the first network request sent by the preset server corresponding to the application under test, obtained by the first device;
[0130] The response module 703 is used to construct a virtual second network response based on the second response information, so as to respond to the second network request using the second network response.
[0131] The testing apparatus provided in this disclosure can acquire real network data during the test case generation phase of automated testing, and construct virtual network responses using the previously acquired real network responses during the test case execution phase, thereby ensuring the consistency of the network environment during automated testing and improving the accuracy of automated testing.
[0132] Optionally, the first request information includes a first request path, and the second request information includes a second request path;
[0133] The second response information matching module includes:
[0134] The request sequence number determination unit is used to determine the request sequence number of the current second network request if multiple first request paths identical to the second request path are matched from the target relationship data based on the second gesture identifier of the second gesture operation and the second request path, wherein the request sequence number is the sequence number of the current second network request in the triggering order of multiple second network requests triggered by the second gesture operation;
[0135] The target first response information acquisition unit is used to acquire the corresponding target first response information from the target relationship data according to the request sequence number. In the target relationship data, the first response information corresponding to the multiple first network requests triggered by the first gesture operation corresponds one-to-one with multiple preset sequence numbers. The preset sequence number is used to indicate the sequence number of the corresponding first network request in the triggering order of the multiple first network requests.
[0136] The second response information determination unit is used to determine the target first response information as the matched second response information.
[0137] Optionally, the target first response information acquisition unit is used for:
[0138] If the request sequence number is less than or equal to the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the first target preset sequence number is determined as the target first response information, wherein the first target preset sequence number is equal to the request sequence number;
[0139] If the request sequence number is greater than the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the second target preset sequence number is determined as the target first response information, wherein the second target preset sequence number is the largest preset sequence number.
[0140] The data processing apparatus provided in this disclosure can execute the data processing method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects for executing the method. The testing apparatus provided in this disclosure can execute the testing method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects for executing the method.
[0141] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.
[0142] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Reference is made below. Figure 8 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 8 The diagram below shows the structure of the terminal device or server 800. The terminal device in this embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and vehicle terminals (e.g., vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0143] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the electronic device 800. The processing device 801, ROM 802, and RAM 803 are interconnected via a bus 804. An edit / output (I / O) interface 805 is also connected to the bus 804.
[0144] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 807 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 808 including, for example, magnetic tapes, hard disks, etc.; and communication devices 809. Communication device 809 allows electronic device 800 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 An electronic device 800 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0145] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by a processing device 801, it performs the functions defined in the methods of embodiments of this disclosure.
[0146] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0147] The electronic device provided in this embodiment and the data processing method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0148] This disclosure provides a computer storage medium storing a computer program that, when executed by a processor, implements the data processing method provided in the above embodiments.
[0149] This disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the data processing method provided in the above embodiments.
[0150] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0151] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0152] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0153] The aforementioned computer-readable medium carries one or more programs. When the electronic device executes the one or more programs, the electronic device causes the following actions: In response to the application under test receiving a first gesture operation, the electronic device acquires first request information from a first network request triggered by the first gesture operation, wherein the operation data of the first gesture operation is used to generate test cases, and the number of first gesture operations used to generate the test cases is at least two; acquires first response information from a first network response corresponding to the first network request, wherein the first network response is sent by a preset server corresponding to the application under test; and generates target relationship data, wherein the target relationship data includes the association between the first gesture identifier of the first gesture operation, the first request information, and the first response information to determine the target relationship data.
[0154] Alternatively, the aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: during the operation of the application under test, in response to a second gesture operation triggered by a test case, acquire second request information from a second network request triggered by the second gesture operation, wherein the test case is generated based on operation data of a first gesture operation received by the application under test in the first device, and the number of the first gesture operations is at least two; match corresponding second response information from the target relationship data based on the second gesture identifier of the second gesture operation and the second request information; wherein the target relationship data includes the association relationship between the first gesture identifier, the first request information, and the first response information of the first gesture operation, the first request information being the request information in the first network request triggered by the first gesture operation, and the first response information being the response information in the first network response corresponding to the first network request sent by a preset server corresponding to the application under test, acquired by the first device; and construct a virtual second network response based on the second response information to respond to the second network request using the second network response.
[0155] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0157] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The names of modules do not necessarily limit the module itself; for example, the first request information acquisition module can also be described as "a module that, in response to the application under test receiving a first gesture operation, acquires the first request information in a first network request triggered by the first gesture operation."
[0158] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0159] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0160] According to one or more embodiments of this disclosure, a data processing method is provided, comprising:
[0161] In response to the application under test receiving a first gesture operation, the first request information in the first network request triggered by the first gesture operation is obtained, wherein the operation data of the first gesture operation is used to generate test cases, and the number of the first gesture operations used to generate the test cases is at least two.
[0162] Obtain the first response information from the first network response corresponding to the first network request, wherein the first network response is sent by a preset server corresponding to the application under test;
[0163] Generate target relationship data, wherein the target relationship data includes the association between the first gesture identifier of the first gesture operation, the first request information, and the first response information.
[0164] According to one or more embodiments of this disclosure, the step of obtaining first request information from a first network request triggered by the first gesture operation in response to the application under test receiving a first gesture operation includes:
[0165] In response to the application under test receiving a first gesture operation, the first candidate request information of the first candidate network request triggered by the first gesture operation is obtained, wherein the first candidate request information includes a candidate request path;
[0166] Determine whether the candidate request path is in a preset path set, wherein the preset path set includes preset paths corresponding to heartbeat requests and / or long connection requests;
[0167] If not, the first candidate network request is determined as the first network request, and the first candidate request information is determined as the corresponding first request information.
[0168] According to one or more embodiments of this disclosure, the first device stores a preset file set, and the files in the preset file set are pushed into the memory of the first device through a preset push command during the installation of the application to be tested on the first device;
[0169] The step of responding to the application under test receiving a first gesture operation and obtaining the first request information in the first network request triggered by the first gesture operation includes:
[0170] In response to the application under test receiving a first gesture operation, the second candidate request information of the second candidate network request triggered by the first gesture operation is obtained, wherein the second candidate request information includes the requested resource type;
[0171] Determine whether the requested resource type is a file type;
[0172] If it is not a file type, the second candidate network request is determined as the first network request, and the second candidate request information is determined as the corresponding first request information.
[0173] According to one or more embodiments of this disclosure, obtaining the first request information in the first network request triggered by the first gesture operation includes:
[0174] The first request information in the first network request triggered by the first gesture operation is obtained by using a preset function in the first device, wherein the preset function is a function in the underlying framework of the network request that is called when the first network request is triggered;
[0175] Wherein, obtaining the first response information in the first network response corresponding to the first network request includes:
[0176] The preset function is used to obtain the first response information in the first network response corresponding to the first network request, wherein the preset function is called when the first network response is received.
[0177] According to one or more embodiments of this disclosure, a testing method is provided, applied to a second device, the method comprising:
[0178] During the operation of the application under test, in response to the second gesture operation triggered by the test case, the second request information in the second network request triggered by the second gesture operation is obtained, wherein the test case is generated based on the operation data of the first gesture operation received by the application under test in the first device, and the number of the first gesture operation is at least two;
[0179] Based on the second gesture identifier of the second gesture operation and the second request information, the corresponding second response information is matched from the target relationship data; wherein, the target relationship data includes the association relationship between the first gesture identifier, the first request information and the first response information of the first gesture operation, the first request information is the request information in the first network request triggered by the first gesture operation, and the first response information is the response information in the first network response corresponding to the first network request sent by the preset server corresponding to the application under test, obtained by the first device;
[0180] A virtual second network response is constructed based on the second response information to respond to the second network request.
[0181] According to one or more embodiments of this disclosure, the first request information includes a first request path, and the second request information includes a second request path;
[0182] The step of matching the corresponding second response information from the target relationship data based on the second gesture identifier of the second gesture operation and the second request information includes:
[0183] If, based on the second gesture identifier of the second gesture operation and the second request path, multiple first request paths identical to the second request path are matched from the target relationship data, then the request sequence number of the current second network request is determined, wherein the request sequence number is the sequence number of the current second network request in the triggering order of multiple second network requests triggered by the second gesture operation;
[0184] According to the request sequence number, the corresponding target first response information is obtained from the target relationship data. In the target relationship data, the first response information corresponding to the multiple first network requests triggered by the first gesture operation corresponds one-to-one with multiple preset sequence numbers. The preset sequence number is used to indicate the sequence number of the corresponding first network request in the triggering order of the multiple first network requests.
[0185] The target first response information is determined as the matched second response information.
[0186] According to one or more embodiments of this disclosure, obtaining the corresponding target first response information from the target relationship data based on the request sequence number includes:
[0187] If the request sequence number is less than or equal to the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the first target preset sequence number is determined as the target first response information, wherein the first target preset sequence number is equal to the request sequence number;
[0188] If the request sequence number is greater than the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the second target preset sequence number is determined as the target first response information, wherein the second target preset sequence number is the largest preset sequence number.
[0189] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0190] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0191] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A data processing method, characterized in that, Applied to a first device, the method includes: In response to the application under test receiving a first gesture operation, the first request information in the first network request triggered by the first gesture operation is obtained, wherein the operation data of the first gesture operation is used to generate test cases, and the number of the first gesture operations used to generate the test cases is at least two. Obtain the first response information from the first network response corresponding to the first network request, wherein the first network response is sent by a preset server corresponding to the application under test; Generate target relationship data, wherein the target relationship data includes the association between the first gesture identifier of the first gesture operation, the first request information, and the first response information.
2. The method according to claim 1, characterized in that, The step of responding to the application under test receiving a first gesture operation and obtaining the first request information in the first network request triggered by the first gesture operation includes: In response to the application under test receiving a first gesture operation, the first candidate request information of the first candidate network request triggered by the first gesture operation is obtained, wherein the first candidate request information includes a candidate request path; Determine whether the candidate request path is in a preset path set, wherein the preset path set includes preset paths corresponding to heartbeat requests and / or long connection requests; If not, the first candidate network request is determined as the first network request, and the first candidate request information is determined as the corresponding first request information.
3. The method according to claim 1, characterized in that, The first device stores a preset file set, and the files in the preset file set are pushed into the memory of the first device through a preset push command during the installation of the application to be tested on the first device. The step of responding to the application under test receiving a first gesture operation and obtaining the first request information in the first network request triggered by the first gesture operation includes: In response to the application under test receiving a first gesture operation, the second candidate request information of the second candidate network request triggered by the first gesture operation is obtained, wherein the second candidate request information includes the requested resource type; Determine whether the requested resource type is a file type; If it is not a file type, the second candidate network request is determined as the first network request, and the second candidate request information is determined as the corresponding first request information.
4. The method according to any one of claims 1-3, characterized in that, in, The step of obtaining the first request information in the first network request triggered by the first gesture operation includes: The first request information in the first network request triggered by the first gesture operation is obtained by using a preset function in the first device, wherein the preset function is a function in the underlying framework of the network request that is called when the first network request is triggered; Wherein, obtaining the first response information in the first network response corresponding to the first network request includes: The preset function is used to obtain the first response information in the first network response corresponding to the first network request, wherein the preset function is called when the first network response is received.
5. A testing method, characterized in that, Applied to a second device, the method includes: During the operation of the application under test, in response to the second gesture operation triggered by the test case, the second request information in the second network request triggered by the second gesture operation is obtained, wherein the test case is generated based on the operation data of the first gesture operation received by the application under test in the first device, and the number of the first gesture operation is at least two; Based on the second gesture identifier of the second gesture operation and the second request information, the corresponding second response information is matched from the target relationship data; wherein, the target relationship data includes the association relationship between the first gesture identifier, the first request information and the first response information of the first gesture operation, the first request information is the request information in the first network request triggered by the first gesture operation, and the first response information is the response information in the first network response corresponding to the first network request sent by the preset server corresponding to the application under test, obtained by the first device; A virtual second network response is constructed based on the second response information to respond to the second network request.
6. The method according to claim 5, characterized in that, The first request information includes a first request path, and the second request information includes a second request path; The step of matching the corresponding second response information from the target relationship data based on the second gesture identifier of the second gesture operation and the second request information includes: If, based on the second gesture identifier of the second gesture operation and the second request path, multiple first request paths identical to the second request path are matched from the target relationship data, then the request sequence number of the current second network request is determined, wherein the request sequence number is the sequence number of the current second network request in the triggering order of multiple second network requests triggered by the second gesture operation; According to the request sequence number, the corresponding target first response information is obtained from the target relationship data. In the target relationship data, the first response information corresponding to the multiple first network requests triggered by the first gesture operation corresponds one-to-one with multiple preset sequence numbers. The preset sequence number is used to indicate the sequence number of the corresponding first network request in the triggering order of the multiple first network requests. The target first response information is determined as the matched second response information.
7. The method according to claim 6, characterized in that, The step of obtaining the corresponding target first response information from the target relationship data according to the request sequence number includes: If the request sequence number is less than or equal to the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the first target preset sequence number is determined as the target first response information, wherein the first target preset sequence number is equal to the request sequence number; If the request sequence number is greater than the maximum value among the plurality of preset sequence numbers in the target relationship data, then the first response information corresponding to the second target preset sequence number is determined as the target first response information, wherein the second target preset sequence number is the largest preset sequence number.
8. A data processing apparatus, characterized in that, Configured in a first device, the device includes: The first request information acquisition module is used to acquire the first request information in the first network request triggered by the first gesture operation in response to the application under test receiving the first gesture operation, wherein the operation data of the first gesture operation is used to generate test cases, and the number of the first gesture operations used to generate the test cases is at least two. The first response information acquisition module is used to acquire the first response information in the first network response corresponding to the first network request, wherein the first network response is sent by a preset server corresponding to the application under test. The target relationship data generation module is used to generate target relationship data, wherein the target relationship data includes the association between the first gesture identifier of the first gesture operation, the first request information and the first response information, so as to determine the target relationship data.
9. A testing device, characterized in that, Configured in a second device, the device includes: The second request information acquisition module is used to acquire second request information in a second network request triggered by a second gesture operation triggered by a test case during the operation of the application under test. The test case is generated based on the operation data of the first gesture operation received by the application under test in the first device, and the number of the first gesture operation is at least two. The second response information matching module is used to match the corresponding second response information from the target relationship data based on the second gesture identifier of the second gesture operation and the second request information; wherein, the target relationship data includes the association relationship between the first gesture identifier, the first request information and the first response information of the first gesture operation, the first request information being the request information in the first network request triggered by the first gesture operation, and the first response information being the response information in the first network response corresponding to the first network request sent by the preset server corresponding to the application under test, obtained by the first device; The response module is used to construct a virtual second network response based on the second response information, so as to respond to the second network request using the second network response.
10. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
11. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the method as described in any one of claims 1-7.
12. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method as described in any one of claims 1-7.