Recording playback method, device and storage medium
Patent Information
- Application Number
- CN202011332457.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-24
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2040-11-24
AI Technical Summary
[0004]由于回放只是将录制过程中的操作重新执行一遍,其输入依然是多个自动化脚本,整个回放过程是与后台耦合的,无法与后台环境进行隔离,从而无法对某个场景的回放进行重复执行,实用价值较低
[0020]本发明实施例提出的录制回放方法、装置及存储介质,预先通过电子设备对测试服务器的接口进行模拟真实对象的行为(MOCK)处理,使该电子设备预先配置有模拟待测试对象后台服务功能的目标接口。在回放前,根据该测试场景信息获取基于待测试对象测试过程中的操作事件和该操作事件对应的网络请求信息进行录制得到的目标录制文件。当在测试终端上运行该待测试对象时,对该操作事件进行回放,并将操作事件在回放过程中所产生的网络请求信息,通过该目标接口发送至本地服务器,同时通过该目标接口接收本地服务器返回的,对该回放过程中所产生的网络请求信息进行处理得到的目标网络数据。由于本发明实施例中的电子设备预先配置有模拟待测试对象后台服务功能的目标接口,可以将回放过程中产生的网络请求信息通过该目标接口发送至该电子设备的本地服务器,并通过该目标接口接收本地服务器返回的目标网络数据,而无需将该网络请求信息发送至该测试服务器,实现与测试服务器的环境进行隔离和解耦,从而使得回放过程独立,达到对某个场景的回放进行重复执行的目的,进而提高回放的实用价值;再者,由于本发明实施例根据测试场景信息获取相应的目标录制文件,进而进行自动回放,可以提高场景用例的自动化测试的执行效率。
Smart Images

Figure CN114546814B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer technology, and specifically relates to a recording and playback method, apparatus, and storage medium. Background Technology
[0002] User interface (UI) automation testing refers to automating testing processes by simulating user UI operations using machines. The main types of testing include automated testing of website user interfaces (WebUI) and automated testing of native application UIs.
[0003] Current UI automation testing typically involves recording events (such as clicks) and reconstructing the events based on screen coordinates during playback to achieve UI automation testing.
[0004] Since playback simply re-executes the operations during the recording process, and its input is still multiple automated scripts, the entire playback process is coupled with the backend and cannot be isolated from the backend environment. Therefore, it is impossible to repeatedly execute the playback of a certain scene, resulting in low practical value. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention proposes a recording and playback method, apparatus, and storage medium.
[0006] On one hand, this invention proposes a recording and playback method, which is applied to an electronic device. The electronic device is pre-configured with a target interface that simulates the background service function of the object under test. The method includes:
[0007] Determine the test scenario information for the object to be tested;
[0008] Obtain the target recording file corresponding to the test scenario information. The target recording file is obtained based on the recording of operation events and network request information corresponding to the operation events during the testing process of the object under test.
[0009] When the test object is run on the test terminal, the operation events in the target recording file are replayed.
[0010] The network request information generated during the playback of the operation event is sent to the local server through the target interface;
[0011] The target network data is obtained by processing the network request information generated during the playback process, which is received from the local server through the target interface.
[0012] On the other hand, embodiments of the present invention provide a recording and playback device, which is applied to an electronic device. The electronic device is pre-configured with a target interface that simulates the background service function of the object under test. The device includes:
[0013] The test scenario information determination module is used to determine the test scenario information of the object to be tested;
[0014] The target recording file acquisition module is used to acquire the target recording file corresponding to the test scenario information. The target recording file is obtained based on the recording of operation events and network request information corresponding to the operation events during the testing process of the object under test.
[0015] The playback module is used to replay the operation events in the target recording file when the test object is run on the test terminal;
[0016] The second network request information sending module is used to send the network request information generated during the playback of the operation event to the local server through the target interface;
[0017] The target network data receiving module is used to receive target network data returned by the local server through the target interface, which is obtained by processing the network request information generated during the playback process.
[0018] On the other hand, the present invention proposes an apparatus comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or at least one program being loaded and executed by the processor to implement the recording and playback method as described above.
[0019] On the other hand, the present invention proposes a computer-readable storage medium storing at least one instruction or at least one program, wherein the at least one instruction or the at least one program is loaded and executed by a processor to implement the recording and playback method as described above.
[0020] The recording and playback method, apparatus, and storage medium proposed in this invention pre-process the interface of the test server by simulating the behavior of a real object (MOCK) through an electronic device, thereby pre-configuring the electronic device with a target interface simulating the background service functions of the object under test. Before playback, a target recording file is obtained by recording operation events and corresponding network request information during the test of the object under test based on the test scenario information. When the object under test is run on the test terminal, the operation events are played back, and the network request information generated during the playback process is sent to the local server through the target interface. Simultaneously, the target network data returned by the local server through the target interface, obtained by processing the network request information generated during the playback process, is received. Because the electronic device in this embodiment of the invention is pre-configured with a target interface simulating the background service function of the object under test, the network request information generated during the playback process can be sent to the local server of the electronic device through the target interface, and the target network data returned by the local server can be received through the target interface, without having to send the network request information to the test server. This achieves isolation and decoupling from the test server environment, thereby making the playback process independent and achieving the purpose of repeatedly executing the playback of a certain scenario, thus improving the practical value of the playback. Furthermore, because this embodiment of the invention obtains the corresponding target recording file according to the test scenario information and then performs automatic playback, it can improve the execution efficiency of automated testing of scenario test cases. Attached Figure Description
[0021] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a schematic diagram of the implementation environment of a recording and playback method provided in an embodiment of the present invention.
[0023] Figure 2 This is a schematic diagram of the implementation environment for another recording and playback method provided in this embodiment of the invention.
[0024] Figure 3 This is a flowchart illustrating a recording and playback method provided in an embodiment of the present invention.
[0025] Figure 4 This is a flowchart illustrating another recording and playback method provided in an embodiment of the present invention.
[0026] Figure 5This is a flowchart illustrating another recording and playback method provided in an embodiment of the present invention.
[0027] Figure 6 This is a flowchart illustrating another recording and playback method provided in an embodiment of the present invention.
[0028] Figure 7 This is an example diagram of introducing the component library AopTest according to an embodiment of the present invention.
[0029] Figure 8 This is an example diagram of configuring a playback engine provided by an embodiment of the present invention.
[0030] Figure 9 This is an example diagram of event stream playback information generated during the playback process of an operation event provided in an embodiment of the present invention.
[0031] Figure 10 This is an example diagram of network stream playback information generated during the playback process of an operation event provided in an embodiment of the present invention.
[0032] Figure 11 This is an example diagram of playback data captured during the playback process of an operation event provided in an embodiment of the present invention.
[0033] Figure 12 This is a schematic diagram of the structure of a recording and playback device provided in an embodiment of the present invention.
[0034] Figure 13 This is a hardware structure block diagram of a server provided in an embodiment of the present invention. Detailed Implementation
[0035] Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to achieve data computing, storage, processing, and sharing.
[0036] Cloud technology is a general term encompassing network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. The backend services of cloud computing systems require substantial computing and storage resources, such as those for video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may eventually possess its own identification mark, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will require robust system support, which can only be achieved through cloud computing. Specifically, cloud technology includes technical fields such as security, big data, databases, industry applications, networking, storage, management tools, and computing.
[0037] Specifically, the embodiments of the present invention relate to the field of computer technology.
[0038] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0039] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0040] Figure 1 This is a schematic diagram illustrating the implementation environment of a recording and playback method provided in an embodiment of the present invention. For example... Figure 1 As shown, the implementation environment may include at least a playback execution terminal 01, a test terminal 02, and a test server 03. The playback execution terminal 01 is set up independently of the test terminal 02 and the test server 03. The playback execution terminal 01, the test terminal 02, and the test server 03 can be directly or indirectly connected via wired or wireless communication, which is not limited in this invention.
[0041] The test terminal 02 can be the terminal where the object under test is located, and the recording engine can also be located within the test terminal. When a tester performs tests on the object under test on this test terminal, the recording engine can record the tester's operation process. The playback execution terminal 01 can be used to open the object under test and play back the content recorded by the recording engine during the operation of the object under test. The test server 03 is used to receive various types of data generated by the playback execution terminal 01 during the playback process and to perform system verification based on the received data.
[0042] Specifically, the test terminal 02 can be a smartphone, tablet, laptop, desktop computer, smart TV, smartwatch, etc., but is not limited to these.
[0043] Specifically, test server 03 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0044] Figure 2 This is a schematic diagram illustrating the implementation environment of another recording and playback method provided in this embodiment of the invention. For example... Figure 2 As shown, the implementation environment may include at least a playback execution terminal 01, a test terminal 02, and a test server 03, with the playback execution terminal 01 located within the test terminal 02. The playback execution terminal 01, the test terminal 02, and the test server 03 may be directly or indirectly connected via wired or wireless communication, which is not limited herein.
[0045] Figure 2 The functions and roles of the playback execution terminal 01, test terminal 02, and test server 03 are all related to Figure 1 Similarities exist in other contexts, so I will not elaborate further here.
[0046] It should be noted that, Figure 1 and Figure 2 This is just one example.
[0047] Figure 3 This is a flowchart illustrating a recording and playback method provided in an embodiment of the present invention. This method can be used for... Figure 1 or Figure 2 In the implementation environment, specifically, this method is applied to an electronic device that is pre-configured with a target interface simulating the background service functions of the object under test. This electronic device can provide... Figure 1 or Figure 2 The replay execution terminal in the process. This specification provides the operational steps of the methods described in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only execution order. In actual system or server products, the methods shown in the embodiments or drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment). Specifically, as shown in the figures... Figure 3 As shown, the method may include:
[0048] S100. Pre-build the target interface that simulates the backend service functions of the object to be tested.
[0049] In this embodiment of the invention, before playback, the playback execution end (which includes a playback engine) needs to be pre-processed with a MOCK. Specifically, the playback execution end modifies the interface in the test server. MOCK refers to creating a MOCK object to simulate the behavior of objects that are difficult to construct or obtain during testing.
[0050] Specifically, such as Figure 4 As shown, S100 may include:
[0051] S1001. Obtain the configuration information of the test server's interface.
[0052] S1003. Construct the target interface based on the configuration information.
[0053] In this embodiment of the invention, a target interface is constructed based on the configuration information of the test server's interface. The constructed target interface is a MOCK object, and the behavior of the test server's interface is simulated through this MOCK object.
[0054] Because the interface in the test server is pre-built using MOCK, the playback execution end itself can process the network request information that occurs during subsequent playback and return the corresponding network data without sending the network request information to the test server for processing. This achieves isolation and decoupling from the test server environment, making the playback process independent. This allows for the repeated execution of playback of a certain scenario, thereby improving the practical value of playback.
[0055] In this embodiment of the invention, before playback, it is necessary to introduce playback triggers in the corresponding test service and configure the characteristics and functions of the playback engine.
[0056] After configuring the features and functions of the playback engine, you can open the playback execution terminal, run the playback engine, and perform subsequent playback operations.
[0057] S101. Determine the test scenario information for the object to be tested.
[0058] Specifically, such as Figure 4 As shown, S101 may include:
[0059] S10101. Obtain test task information for the object to be tested from the test server.
[0060] S10103. Determine the test scenario information based on the test task information.
[0061] In this embodiment of the invention, after the playback engine runs, when it is necessary to play back the recorded file, the electronic device (playback execution terminal) obtains test task information from the test server. The test task information carries test scenario information. After the playback execution terminal receives the test task information, it can parse the test task information and obtain the test scenario information, that is, obtain the scenario test case list.
[0062] Specifically, the test task information obtained by the replay execution terminal from the test server can be sent to the replay execution terminal periodically by the test server, or the test server can respond to a test task information retrieval request sent by the replay execution terminal and send the test task information to the replay execution terminal. This embodiment of the invention does not limit the method by which the replay execution terminal obtains the test task information.
[0063] Specifically, the test scenario information can refer to a specific task or action that occurs within a certain time and space, or a specific scene formed by certain relationships. For example, shopping on a shopping website—logging in, searching for products, submitting an order, and making payment—can be considered a functional scenario, namely, a shopping order scenario. Of course, the login process for the shopping website can also be considered a separate scenario, searching for products can be considered a separate scenario, and payment can be considered a separate scenario, etc.
[0064] It should be noted that the test scenario information parsed from the test task information by the playback execution end can be one or multiple; this embodiment of the invention does not limit the number of test scenario information. When multiple test scenario information is parsed from the test task information, they can be played back sequentially according to the scenarios during subsequent playback.
[0065] Specifically, the test object can be an object that needs to be automated tested, such as a website or application to be tested.
[0066] S103. Obtain the target recording file corresponding to the test scenario information. The target recording file is obtained by recording the operation events and network request information corresponding to the operation events during the test of the object under test.
[0067] After parsing the test scenario information at the playback execution end, the information can be further analyzed to retrieve the event stream and network stream recordings from the recording engine. For example, if the test scenario is a shopping order scenario, then the recorded events and network requests that triggered those events can be retrieved.
[0068] This operation event includes, but is not limited to, clicks, swipes, and input. There can be multiple operation events, each corresponding to at least one network request. Of course, in some scenarios, there can be only one operation event, which can correspond to at least one network request.
[0069] When there are multiple operation events, S103 may include:
[0070] The target recording file corresponding to the test scenario information is obtained from the recording engine. The target recording file includes event stream recording information and network stream recording information. The event stream recording information is obtained by the recording engine based on the recording of multiple operation events and the associated information of the multiple operation events. The associated information includes the test scenario information. The network stream recording information is obtained by the recording engine based on the recording of multiple network request information that occurs during the triggering of multiple operation events.
[0071] To obtain the target recording file corresponding to the test scene information from the recording engine, it is necessary to pre-record the corresponding recording file using the recording engine. The recording process can be as follows:
[0072] During the testing process, the tester can trigger a series of operation events (including but not limited to clicks, swipes, and inputs) on the test terminal using input devices such as keyboards and mice or directly through the touch screen on the test terminal. The recording engine will record the series of operation events triggered by the tester and the associated information, obtain the event stream recording information, and store the event stream recording information in the recording file.
[0073] Specifically, the associated information may include, but is not limited to: operation object, operation sequence number, scene information, operation time, and operation time interval between two adjacent operation events.
[0074] Since the associated information can include the operation sequence number and the operation time interval, the event stream recording information obtained by recording a series of operation events triggered by the tester is equivalent to an event chain obtained by linking a series of operation events according to the operation sequence number.
[0075] Specifically, the operation object can be the identifier of the response UI control that is operated on the UI interface by the corresponding operation event.
[0076] Specifically, scene information is used to characterize the scene to which the operation event belongs in the current operation process.
[0077] Specifically, the operation sequence number is used to characterize the execution order of a certain operation event during the recording process. For example, if the operation sequence number of operation event A is 1, the operation sequence number of operation event B is 2, and the operation sequence number of operation event C is 3, then the execution order of operation events A, B, and C is: operation event A → operation event B → operation event C.
[0078] The aforementioned click, long press, or swipe operations correspond to specific operation locations (i.e., coordinates in the test terminal's display coordinate system). For example, if a tester clicks a UI control at a location (X=300, Y=400), the corresponding operation event can be "click: X=300, Y=400". Therefore, an operation event can specifically include both the operation method and the operation location in the display coordinate system.
[0079] When a tester triggers an operation event, each operation event may generate at least one network request. The recording engine records the mapping relationship between each operation event and its corresponding network request, obtaining network stream recording information, and stores this network stream recording information in the recording file. Since the network request information corresponds to the operation event, this network request information is essentially a network chain obtained by linking the corresponding operation events according to their operation sequence numbers.
[0080] It should be noted that if the tester triggers only one operation event during the recording process, then that operation event, its corresponding operation object, operation time, scene information, etc., will be recorded to obtain the corresponding recording file.
[0081] Since the associated information of the operation event includes scene information, the playback execution end in S103 can retrieve the target recording file corresponding to the test scene information from the recording engine based on the parsed test scene information. This target recording file includes the event stream recording information and network stream recording information under the test scene information. Essentially, it retrieves the event stream recording information and network stream recording information under the test scene from the entire recording file recorded by the recording engine.
[0082] In this embodiment of the invention, during the recording engine's recording of the tester's operations on the test object, not only are the operation events (i.e., event stream recording information) recorded, but also the network request information that triggers the operation events (i.e., network stream recording information). This allows the network request information to be processed and returned as network data during subsequent playback through the playback execution terminal after being MOCKed, without having to send the network request information to the test server, thereby achieving isolation from the test server environment. Furthermore, this embodiment of the invention retrieves the event stream recording information and network stream recording information corresponding to the test scenario information, facilitating subsequent playback of the event stream recording information and network stream recording information under that test scenario information. That is, playback is scenario-based. By isolating the test server environment through MOCK technology, the problem of environment dependency during playback can be effectively solved, making the playback process independent, thus allowing the playback under that test scenario to be executed repeatedly.
[0083] S105. When the test object is run on the test terminal, the operation events in the target recording file are replayed.
[0084] In this embodiment of the invention, when the playback execution terminal retrieves the event stream recording information and network stream recording information for the test scenario, it can open and run the test object on the test terminal. Since both the event stream recording information and the network stream recording information are mapping relationships based on events, they can be accurately replayed according to events (i.e., in units of events).
[0085] In a feasible embodiment, when there is only one operation event, S105 may include: replaying the one operation event when the test object is running on the test terminal.
[0086] In another feasible embodiment, when there are multiple operation events, S105 may include:
[0087] When the test object is run on the test terminal, multiple operation events are replayed sequentially based on the operation sequence number and operation time interval.
[0088] It should be noted that the operation events, operation sequence numbers, and operation time intervals during playback are the same as those during recording. That is, these multiple operation events are played back according to a timeline.
[0089] For example, if the target recording file contains operation events A, B, and C, with operation sequence number 1 for operation event A, operation sequence number 2 for operation event B, and operation sequence number 3 for operation event C, and the time interval between operation events A and B is 2 seconds, and the time interval between operation events B and C is 3 seconds, then during the playback process, operation event A will be played back first, operation event B will be played back 2 seconds later, and operation event C will be played back 3 seconds later.
[0090] During playback, the default start event needs to be handled. The default start event refers to the first operation event during playback, which may not be a click, swipe, or input operation, but simply opening the test object. Opening the test object does not count as a real operation and does not trigger any event. Therefore, the first operation event can be specially handled by configuring an initialized event identity document (ID) for the first operation event.
[0091] In this embodiment of the invention, based on operation events, the operation events under the test scenario information are accurately replayed according to the corresponding operation sequence number and operation time interval, which can improve the automation level and execution efficiency of the automated testing of scenario test cases.
[0092] S107. Send the network request information generated during the playback of the operation event to the local server through the target interface.
[0093] S109. Receive target network data returned by the local server through the target interface, which is obtained by processing the network request information generated during the playback process.
[0094] Since at least one network request may occur during the recording process when an operation event is triggered, at least one network request will also occur during playback of the same operation event. Furthermore, because the playback execution end pre-modifies the test server's interface, the target interface built in the playback execution end can simulate the functionality of the interface on the test server. Therefore, the playback execution end can send the network requests occurring during the operation event playback to its local server through this target interface. The local server then processes the network request information to obtain the corresponding target network data, without needing to send the network request information to the test server. This achieves isolation from the test server environment, making the playback process decoupled from the test server, rather than coupled. Since playback is scenario-based, isolating the playback process from the test server environment through MOCK technology effectively solves the environmental dependency problem during playback, making the playback process independent. This allows for repeated execution of playback within the same test scenario, thereby increasing the practical value of playback.
[0095] For example, taking a shopping order scenario as the test scenario, when replaying the operation events corresponding to this test scenario, login request information, product search request information, order submission request information, payment request information, etc. may be generated. The replay execution end does not send the above network request information to the test server, but sends the above network request information to the local server of the replay execution end. The local server processes the login request information and returns network data on whether the login was successful; processes the product search request information and returns network data on the product search results; processes the order submission request information and returns network data on whether the order was submitted; processes the payment request information and returns network data on whether the payment was successful.
[0096] In a feasible embodiment, when there is only one operation event, within a preset time period (e.g., 4-5 seconds) after the operation event playback ends, a screenshot of the playback result of the operation event can be taken to obtain the playback capture data corresponding to the operation event.
[0097] In another feasible embodiment, when there are multiple operation events, the method may further include:
[0098] Use the currently playing operation event as the current operation event.
[0099] Within a preset time period after the current operation event replay ends, the replay result of the current operation event is captured to obtain the replay capture data corresponding to the current operation event.
[0100] The operation event whose operation sequence number is adjacent to the operation sequence number of the current operation event and whose operation sequence number is after the operation sequence number of the current operation event is re-designated as the current operation event.
[0101] Repeat the steps of capturing the playback result of the current operation event within a preset time period after the current operation event ends, and obtaining the playback capture data of the current operation event, until the playback capture data corresponding to multiple operation events is obtained.
[0102] Suppose the target recording file contains operation events A, B, and C, and the currently playing operation event is operation event A. Taking operation event A as the current operation event, take a screenshot of the playback result of operation event A within a preset time period (e.g., 4-5 seconds) after the playback of operation event A ends, and obtain the playback capture data of operation event A. Then take operation event B as the current operation event, take a screenshot of the playback result of operation event B within a preset time period after the playback of operation event B ends, and obtain the playback capture data of operation event B. And so on, to obtain the playback capture data of operation event C.
[0103] The replay result of this operation event can be the result data generated after the operation event has finished replaying. For example, if the operation event is a click, and a login request is generated during the triggering process, then the replay result of this operation event can include: whether the login was successful, etc. Accordingly, the replay data is the data obtained by taking a screenshot of whether the login was successful.
[0104] Taking screenshots of the replay results of this operation event and generating corresponding replay capture data is intended to facilitate subsequent verification of the replay process by the test server, thereby improving the accuracy of automated testing of the object under test. For example, after the replay execution terminal finishes, it uploads login success information to the test server. During the verification process, the test server cannot directly determine whether the login was successful based solely on this "login success information." It needs to further verify the login success based on the corresponding screenshot information, thus avoiding errors in the test server's verification caused by incorrect information reported by the replay execution terminal, and improving the accuracy of automated testing.
[0105] In this embodiment of the invention, when there are multiple operation events, after S109, the method may further include:
[0106] S1010. Record data using Aspect-Oriented Programming (AOP).
[0107] Specifically, such as Figure 5 As shown, S1010 may include:
[0108] S101001. Create event network recording information based on aspect-oriented programming.
[0109] S101003. Inject the event network record information into the corresponding raw data content of the local device.
[0110] S101005. Based on event network recording information, record event stream playback information, network stream playback information, target network data, and playback intercepted data generated during the playback of multiple operation events; the event stream playback information corresponds to the event stream recording information, and the network stream playback information corresponds to the network stream recording information.
[0111] In this embodiment of the invention, code can be written in advance using AOP to create event network recording information. Then, the event network recording information is injected into the original data content (i.e., original code) of the local device (i.e., the playback execution end). This allows for accurate and rapid recording of event stream playback information, network stream playback information, target network data, and playback intercepted data generated during the playback process without damaging the original data code of the execution end.
[0112] Among them, the event stream playback information corresponds to the event stream recording information. It is equivalent to recording multiple operation events and their associated information during the playback process, resulting in an event chain playback record. The network stream playback information corresponds to the network stream recording information. It records the network request information generated by multiple operation events during the playback process, which is equivalent to recording the network request information triggered by multiple operation events during the playback process, resulting in a network request chain playback record.
[0113] When there is only one operation event, AOP can be used to record the event stream playback information, target network data, playback intercept data, and network stream playback information generated during the playback process of that operation event.
[0114] When there are multiple operation events, after S1010, the method may further include:
[0115] Based on hook functions, event stream playback information, network stream playback information, target network data, and playback intercepted data generated during the playback of multiple operation events are uploaded to the test server. This allows the test server to verify the data uploaded by the hook functions and obtain automated test results for the object under test.
[0116] Uploading various operation data and screenshot data generated during the playback process (i.e., playback captured data) to the test server via hook functions can provide sufficient data and screenshots for the test server to perform system verification, thereby improving the accuracy of system verification and, in turn, improving the accuracy of automated testing of the test object.
[0117] When there is only one operation event, the event stream playback information, target network data, playback intercept data and network stream playback information generated during the playback of that operation event can be uploaded to the test server based on the hook function, so that the test server can verify and obtain the automated test results of the object under test.
[0118] The advantage of uploading data to the test server via hook is that, before the data is uploaded to the test server, the hook function captures the data in advance, which is equivalent to the hook function gaining control in advance. The hook function can process the captured data, continue to transmit the captured data without processing it, or forcibly terminate the transmission of data, thereby improving the accuracy, efficiency and flexibility of data processing.
[0119] The following description uses the website to be tested and Cypress as the execution end as an example to illustrate the recording and playback method provided in this embodiment of the invention. Cypress is a UI automation execution framework. Figure 6 The following is a flowchart illustrating one method of recording and playback:
[0120] 1) Introduce a replay engine for web services to reset storage and data reporting:
[0121] like Figure 7 As shown, in the index.js page of the website to be tested, the component library AopTest is imported and placed in the first initialization location. Here, index.js is the main file entry point of the component, and AopTest is an aspect-oriented test.
[0122] 2) Configure the playback engine: This mainly involves configuring the engine's features and functions.
[0123] The functionality of this configuration can include:
[0124] URL: Test server deployment link
[0125] The test server deployment link can be a pre-deployed, accessible link.
[0126] product: The name of the product introduced this time.
[0127] scene: The name of the scene being replayed.
[0128] is_screenshot: Whether to take a screenshot
[0129] The "Screenshot" setting determines whether a screenshot should be taken after the event replay ends. If configured as "yes," a screenshot will be taken after the event replay ends; otherwise, no screenshot will be taken.
[0130] table_info: The table name corresponding to the test server.
[0131] The table names corresponding to the test server refer to the pre-configured table names used to record various types of data uploaded by the Cypress execution end, such as the table name corresponding to event stream playback information, the table name corresponding to target network data, and the table name corresponding to playback intercepted data.
[0132] init_event_id: The event ID for initialization upon first opening.
[0133] Since the first operation event during recording or playback may not be a click, swipe, or input operation, but simply opening the website to be tested, opening the website to be tested does not count as a real operation and does not trigger any event. Therefore, the first operation event can be specially handled by configuring an initial event ID for it.
[0134] max_interval: The maximum interval between two events
[0135] The maximum interval between the two events refers to the maximum time interval between the two operation events.
[0136] para_cgi_info: Configuration for the same interface in multiple requests.
[0137] The configuration of the same interface for multiple requests refers to configuring the target interface through MOCK technology so that the target interface can receive multiple network request information generated during the playback process.
[0138] An example diagram of this playback engine configuration can be shown as follows: Figure 8 As shown.
[0139] 3) Start the website to be tested (i.e. start the web service) and ensure that the local environment of the website to be tested can access it normally.
[0140] 4) Open Cypress, run the playback engine, and perform the following process: obtain test task information from the test server; parse the test task information to obtain test scenario information; obtain the target recording file corresponding to the test scenario information; and replay the operation events corresponding to the target recording file.
[0141] 5) The playback engine can generate network stream playback information and event stream playback information during runtime.
[0142] 6) When the playback engine is running, it also reports information to the test server. The test server will then pass the data reported by the playback engine to the verification engine to complete functional verification. Some of the reported information can be as follows: Figure 9 , Figure 10 and Figure 11 As shown.
[0143] in, Figure 9 The image shown is an example of an event stream playback diagram generated during the playback of an operation event. For example... Figure 9 As shown, the event stream records information including event ID, scene information, product information, creation time, and update time.
[0144] Figure 10 The diagram illustrates an example of network stream playback information generated during the playback of an operation event. Although this embodiment of the invention sends network request information to the test server, the Cypress executor still records the network request information generated during the playback process, obtaining network stream record information, and sends this network stream record information to the test server for data verification. Figure 10As shown, the network stream replay information includes event ID, scene information, product information, and Uniform Resource Locator (url).
[0145] Figure 11 The image shown is an example of playback data captured during the playback process of an operation event.
[0146] During the replay process, in addition to the replay engine in the Cypress execution end reporting data to the test server, the website under test will also report corresponding data to the test server. The data reported by the website under test to the test server includes, but is not limited to: first event identification, current event identification, replay event identification, replay network reporting, etc.
[0147] The first event recognition corresponds to the "first opening initialization event ID" and "default start event handling" mentioned above. That is, when the website to be tested is opened for the first time, since opening the website is not equivalent to an operation event, the test terminal corresponding to the website to be tested needs to perform first event recognition and upload the recognized first event to the test server.
[0148] The current event identification refers to identifying the events currently being played by the playback engine and uploading the identified current events to the test server.
[0149] The replay event identification and replay network identification refer to the identification of events replayed by the replay engine and the network request information that occurs when the event is triggered, and the identification of the replay event and replay network is uploaded to the test server.
[0150] During the replay process, the website under test uploads relevant data to the test server, providing the test server with richer data and screenshots, thereby further improving the accuracy and efficiency of the test server's verification.
[0151] like Figure 12 As shown, this embodiment of the invention also provides a recording and playback device, which is applied to an electronic device. The electronic device is pre-configured with a target interface that simulates the background service function of the object under test. The device may include:
[0152] The test scenario information determination module 201 can be used to determine the test scenario information of the object to be tested.
[0153] Specifically, the test scenario information determination module 201 may include:
[0154] The test task information acquisition unit can be used to obtain test task information of the object to be tested from the test server.
[0155] The test scenario information determination unit can be used to determine test scenario information based on test task information.
[0156] The target recording file acquisition module 203 can be used to acquire the target recording file corresponding to the test scenario information. The target recording file is obtained by recording the operation events and network request information corresponding to the operation events during the test of the object under test.
[0157] The playback module 205 can be used to replay the operation events in the target recording file when the test object is run on the test terminal.
[0158] The second network request information sending module 207 can be used to send the network request information generated during the playback of the operation event to the local server through the target interface.
[0159] The target network data receiving module 209 can be used to receive target network data returned by the local server through the target interface, which is obtained by processing the network request information generated during the playback process.
[0160] Furthermore, the device may also include:
[0161] The configuration information acquisition module can be used to obtain the configuration information of the test server's interfaces.
[0162] The target interface building module can be used to build target interfaces based on configuration information.
[0163] Furthermore, since there are multiple operation events, and each operation event corresponds to at least one network request, the target recording file acquisition module 203 can be used to obtain the target recording file corresponding to the test scenario information from the recording engine. The target recording file includes event stream recording information and network stream recording information. The event stream recording information is obtained by the recording engine based on the recording of multiple operation events and the associated information corresponding to the multiple operation events. The associated information includes the test scenario information. The network stream recording information is obtained by the recording engine based on the recording of multiple network request information generated during the triggering of multiple operation events.
[0164] Furthermore, the associated information includes the operation sequence number and the operation time interval between two adjacent operation events. Then, the playback module 205 can be used to play back multiple operation events sequentially based on the operation sequence number and the operation time interval when the test object is running on the test terminal.
[0165] Furthermore, the device may also include:
[0166] The current operation event determination module can be used to determine the currently replayed operation event as the current operation event.
[0167] The current playback data acquisition module can be used to capture the playback result of the current operation event within a preset time period after the current operation event ends, and obtain the playback data corresponding to the current operation event.
[0168] The re-determining module can be used to re-designate an operation event whose operation sequence number is adjacent to the operation sequence number of the current operation event and whose operation sequence number is after the operation sequence number of the current operation event as the current operation event.
[0169] The repeat module can be used to repeat the steps of capturing the playback result of the current operation event within a preset time period after the current operation event has finished playing back, and obtaining the playback capture data of the current operation event, until the playback capture data corresponding to multiple operation events is obtained.
[0170] Furthermore, the device may also include:
[0171] The creation module can be used to create event network logging information based on aspect-oriented programming.
[0172] The injection module can be used to inject event network record information into the corresponding raw data content of the local device.
[0173] The recording module can be used to record event stream playback information, network stream playback information, target network data, and playback intercepted data generated during the playback of multiple operation events based on event network recording information; the event stream playback information corresponds to the event stream recording information, and the network stream playback information corresponds to the network stream recording information.
[0174] Furthermore, the device may also include:
[0175] The upload module can be used to upload event stream playback information, network stream playback information, target network data, and playback intercepted data generated during the playback of multiple operation events to the test server based on hook functions. This allows the test server to verify the data uploaded by the hook functions and obtain automated test results for the object under test.
[0176] It should be noted that the device embodiments provided in this invention are based on the same inventive concept as the method embodiments described above.
[0177] This invention also provides a recording and playback device, which includes a processor and a memory. The memory stores at least one instruction or at least one program. The processor loads and executes the at least one instruction or at least one program to implement the recording and playback method provided in the above method embodiments.
[0178] Embodiments of the present invention also provide a computer-readable storage medium that can be disposed in a terminal to store at least one instruction or at least one program related to implementing a recording and playback method in the method embodiments. The at least one instruction or at least one program is loaded and executed by a processor to implement the recording and playback method provided in the above method embodiments.
[0179] Optionally, in the embodiments of this specification, the storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0180] The memory described in this specification can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may primarily include a program storage area and a data storage area. The program storage area may store the operating system, applications required for functions, etc.; the data storage area may store data created based on the use of the device, etc. Furthermore, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.
[0181] The recording and playback method, apparatus, and storage medium provided in this invention have the following beneficial effects:
[0182] 1) Since the electronic device in this embodiment of the invention is pre-configured with a target interface that simulates the background service function of the test object, the network request information generated during the playback process can be sent to the local server of the electronic device through the target interface, and the target network data obtained by the local server after processing the network request information can be received through the target interface, without having to send the network request information to the test server. This achieves isolation and decoupling from the test server environment, making the playback process independent, thereby achieving the purpose of repeatedly executing the playback of a certain scenario, and thus improving the practical value of the playback.
[0183] 2) Based on operation events, this embodiment of the invention accurately replays operation events under test scenario information according to the corresponding operation sequence number and operation time interval, thereby improving the automation level and execution efficiency of automated testing of scenario test cases.
[0184] 3) In this embodiment of the invention, various operation data and screenshot data (i.e., playback capture data) generated during the playback process are accurately and quickly uploaded to the test server through the hook function (HOOK). This can provide sufficient data and screenshots for the test server to perform system verification, thereby improving the accuracy of system verification and thus improving the accuracy and efficiency of automated testing of the test object.
[0185] This invention also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the recording and playback method provided in the above-described method embodiments.
[0186] The recording and playback method embodiments provided in this invention can be executed on a terminal, computer terminal, server, or similar computing device. Taking running on a server as an example, Figure 13 This is a hardware structure block diagram of a server for a recording and playback method provided in an embodiment of the present invention. For example... Figure 13 As shown, the server 300 can vary significantly depending on its configuration or performance. It may include one or more Central Processing Units (CPUs) 310 (CPUs 310 may include, but are not limited to, microprocessors (MCUs) or programmable logic devices (FPGAs), a memory 330 for storing data, and one or more storage media 320 (e.g., one or more mass storage devices) for storing application programs 323 or data 322. The memory 330 and storage media 320 may be temporary or persistent storage. The program stored in the storage media 320 may include one or more modules, each module including a series of instruction operations on the server. Furthermore, the CPU 310 may be configured to communicate with the storage media 320 and execute a series of instruction operations stored in the storage media 320 on the server 300. The server 300 may also include one or more power supplies 360, one or more wired or wireless network interfaces 350, one or more input / output interfaces 340, and / or one or more operating systems 321, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0187] The input / output interface 340 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of server 300. In one example, the input / output interface 340 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the input / output interface 340 may be a radio frequency (RF) module for wireless communication with the Internet.
[0188] Those skilled in the art will understand that Figure 13 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, server 300 may also include... Figure 13 The more or fewer components shown, or having the same Figure 13 The different configurations shown.
[0189] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0190] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and server embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0191] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0192] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A recording and playback method, characterized in that, The method is applied to an electronic device, which is pre-configured with a target interface simulating the background service function of the object under test. The method includes: Determine the test scenario information for the object to be tested; Obtain the target recording file corresponding to the test scenario information. The target recording file includes event stream recording information and network stream recording information. The event stream recording information is obtained by the recording engine based on recording multiple operation events and the associated information corresponding to the multiple operation events. The associated information includes the operation sequence number and the operation time interval between two adjacent operation events. The network stream recording information is obtained by the recording engine based on recording multiple network request information generated during the triggering of the multiple operation events. When the test object is run on the test terminal, multiple operation events in the target recording file are replayed sequentially based on the operation sequence number and the operation time interval; The network request information generated during the playback of the operation event is sent to the local server of the electronic device through the target interface; The target network data is obtained by processing the network request information generated during the playback process and receiving the local server's response through the target interface. The event stream playback information, network stream playback information, target network data, and playback capture data generated during the playback of the multiple operation events are uploaded to the test server to obtain the UI automated test results of the object under test; the playback capture data is obtained by taking screenshots of the playback results of the operation events.
2. The method according to claim 1, characterized in that, The method includes: Obtain the configuration information of the test server's interface; Based on the configuration information, the target interface is constructed.
3. The method according to claim 1, characterized in that, Each operation event corresponds to at least one network request message, and the method further includes: The target recording file corresponding to the test scene information is obtained from the recording engine, and the associated information includes the test scene information.
4. The method according to claim 1, characterized in that, The method further includes: Use the currently replayed operation event as the current operation event; Within a preset time period after the current operation event playback ends, the playback result of the current operation event is captured to obtain the playback capture data corresponding to the current operation event; The operation event whose operation sequence number is adjacent to the operation sequence number of the current operation event and whose operation sequence number is after the operation sequence number of the current operation event is re-designated as the current operation event; The process of repeatedly capturing the playback result of the current operation event within a preset time period after the current operation event playback ends, and obtaining the playback capture data of the current operation event, is repeated until the playback capture data corresponding to the multiple operation events is obtained.
5. The method according to claim 4, characterized in that, The method further includes: Event network recording information is created using aspect-oriented programming. The event network record information is injected into the corresponding original data content of the local device; Based on the event network recording information, the event stream playback information, network stream playback information, target network data, and playback intercepted data generated during the playback of the multiple operation events are recorded; the event stream playback information corresponds to the event stream recording information, and the network stream playback information corresponds to the network stream recording information.
6. The method according to claim 5, characterized in that, The method further includes: Based on the hook function, the event stream playback information, network stream playback information, target network data, and playback intercept data generated during the playback of the multiple operation events are uploaded to the test server, so that the test server can verify the data uploaded by the hook function and obtain the automated test results of the object under test.
7. The method according to claim 1, characterized in that, The test scenario information for determining the object to be tested includes: Obtain the test task information of the object to be tested from the test server; Based on the test task information, the test scenario information is determined.
8. A recording and playback device, characterized in that, The device is applied to an electronic device, which is pre-configured with a target interface simulating the background service function of the object under test. The device includes: The test scenario information determination module is used to determine the test scenario information of the object to be tested; The target recording file acquisition module is used to acquire the target recording file corresponding to the test scenario information. The target recording file includes event stream recording information and network stream recording information. The event stream recording information is obtained by the recording engine based on recording multiple operation events and the associated information corresponding to the multiple operation events. The associated information includes the operation sequence number and the operation time interval between two adjacent operation events. The network stream recording information is obtained by the recording engine based on recording multiple network request information generated during the triggering of the multiple operation events. The playback module is used to sequentially play back multiple operation events in the target recording file based on the operation sequence number and the operation time interval when the test object is run on the test terminal. The second network request information sending module is used to send the network request information generated during the playback of the operation event to the local server of the electronic device through the target interface; The target network data receiving module is used to receive target network data returned by the local server through the target interface, which is obtained by processing the network request information generated during the playback process; The upload module is used to upload the event stream playback information, network stream playback information, target network data, and playback capture data generated during the playback of the multiple operation events to the test server to obtain the UI automated test results of the object under test; the playback capture data is obtained by taking screenshots of the playback results of the operation events.
9. The apparatus according to claim 8, characterized in that, The device further includes: The configuration information acquisition module is used to acquire the configuration information of the test server's interfaces; The target interface construction module is used to construct the target interface based on the configuration information.
10. The apparatus according to claim 8, characterized in that, Each operation event corresponds to at least one network request; the target recording file acquisition module is also used to obtain the target recording file corresponding to the test scenario information from the recording engine, and the associated information includes the test scenario information.
11. The apparatus according to claim 8, characterized in that, The device further includes: The current operation event determination module is used to determine the currently replayed operation event as the current operation event; The current playback intercept data acquisition module is used to intercept the playback result of the current operation event within a preset time period after the end of the current operation event playback, and obtain the playback intercept data corresponding to the current operation event; The re-determination module is used to re-designate an operation event whose operation sequence number is adjacent to the operation sequence number of the current operation event and whose operation sequence number is located after the operation sequence number of the current operation event as the current operation event. The repeat module is used to repeat the steps of extracting the playback result of the current operation event within a preset time period after the current operation event ends, and obtaining the playback extracted data of the current operation event, until the playback extracted data corresponding to the multiple operation events is obtained.
12. The apparatus according to claim 11, characterized in that, The device further includes: Create a module for creating event network logging information using aspect-oriented programming. An injection module is used to inject the event network record information into the corresponding original data content of the local device. The recording module is used to record, based on the event network recording information, event stream playback information, network stream playback information, target network data, and playback intercepted data generated during the playback of the multiple operation events; the event stream playback information corresponds to the event stream recording information, and the network stream playback information corresponds to the network stream recording information.
13. The apparatus according to claim 12, characterized in that, The upload module is also used to: based on the hook function, upload the event stream playback information, network stream playback information, target network data and playback intercepted data generated during the playback of the multiple operation events to the test server, so that the test server can verify the data uploaded by the hook function and obtain the automated test results of the object to be tested.
14. The apparatus according to claim 8, characterized in that, The test scenario information determination module includes: The test task information acquisition unit is used to acquire the test task information of the object to be tested from the test server. The test scenario information determination unit is used to determine the test scenario information based on the test task information.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the recording and playback method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Remote mock testing method and device
CN104899142A
Webpage operation playback and collection method, computing device, storage medium and system
CN111274105A