Analog data processing method, apparatus, device and medium
By intercepting data requests from target applications on mobile terminals, generating singleton global object data and displaying the interface operation interface, users can perform simulated data processing on the interface. This solves the problem of cumbersome operation caused by the need for PCs and proxy certificates in existing technologies, and improves test development efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2026-04-07
AI Technical Summary
In existing technologies, data testing requires the use of PCs and proxy certificates during software development and testing, which makes the process cumbersome and prevents data testing from being conducted anytime, anywhere.
By installing an application interceptor on a mobile terminal, data requests from the target application are intercepted, Uniform Resource Locator (URL) parameters are extracted, target interface information is determined, and data fusion processing is performed to generate singleton global object data. The interface operation interface is then displayed, allowing users to perform simulated data processing and generate simulated data results.
It enables data testing on mobile devices without the need for a PC or proxy certificate, improving test development efficiency and saving time and costs.
Smart Images

Figure CN115495372B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a simulation data processing method and device, equipment and medium. BACKGROUND
[0002] At present, in the process of software development and testing, it is often necessary for developers to troubleshoot whether the request and interface return data are correct. The existing technology generally uses mock data for data testing. Specifically, developers and testers generally need to use Charles or Fiddler to analyze data packet capture and perform mock data testing. However, these operations all depend on a personal computer (PC), and the tester must connect the PC and configure proxy certificates and other related steps when performing data troubleshooting, resulting in very tedious data testing steps and making it impossible to test data anytime and anywhere. SUMMARY
[0003] The present application provides a simulation data processing method, device, equipment and medium to get rid of PC dependence and proxy certificate dependence, solve the problem of tedious operation caused by the necessity of connecting the PC for existing test data troubleshooting, and improve the test development efficiency.
[0004] In a first aspect, the present application provides a simulation data processing method, comprising:
[0005] determining target interface information according to a test data request of a target application program;
[0006] performing data fusion processing on the test data in the test data request, the test response data corresponding to the target interface information, and the test data in the test data request according to the target interface information and the test response data corresponding to the target interface information, to obtain a singleton global object data corresponding to the test data request;
[0007] displaying an interface operation interface according to the singleton global object data;
[0008] performing simulation data processing according to an interface selection operation submitted by a user in the interface operation interface, to obtain a simulation data result corresponding to the test data request.
[0009] Optionally, the mobile terminal is installed with an application interceptor, and the determining of the target interface information according to the test data request of the target application program comprises:
[0010] intercepting the data request of the target application program through the application interceptor to obtain the test data request;
[0011] extracting a uniform resource locator parameter from the test data request;
[0012] Determine target interface information based on the uniform resource locator parameter.
[0013] Optionally, the data fusion processing of the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request obtains a singleton global object data corresponding to the test data request, including:
[0014] Determine the test response data corresponding to the target interface information.
[0015] Extract the test data from the test data request, and determine the test request time corresponding to the test data.
[0016] According to the preset singleton mode, the target interface information, the test response data, the request time and the test data are encapsulated to obtain the singleton global object data.
[0017] Optionally, the determination of the test response data corresponding to the target interface information includes:
[0018] When the uniform resource locator parameter matches the interface parameter in the cache simulation data set, the cache simulation data corresponding to the interface parameter is determined as the original response data, and the test response data is determined based on the original response data, wherein the cache simulation data set is a set generated by the mobile terminal based on the cache data obtained when the application interceptor is started.
[0019] When the uniform resource locator parameter does not match the interface parameter in the cache simulation data set, the test response data is created based on the target interface information.
[0020] Optionally, the determination of the test response data based on the original response data includes: taking the original response data as the test response data; or, based on the original response data, the copy data is obtained by copying processing, and the copy data is determined as the test response data.
[0021] Optionally, the simulation data processing according to the interface selection operation submitted by the user on the interface operation interface obtains the simulation data result corresponding to the test data request, including:
[0022] When the interface selection operation is a modification selection operation, determine a target editing interface based on the modification selection operation.
[0023] Display the response data corresponding to the target editing interface.
[0024] According to the response editing operation submitted by the user, the response data is modified to obtain response modification data.
[0025] perform format checking according to the response modification data, to obtain a format checking result;
[0026] If the format checking result is a format checking pass result, the simulation data result is generated based on the response modification data.
[0027] Optionally, before the target interface information is determined according to the test data request of the target application program, the method further includes: when the application interceptor is started, obtaining cache data, the cache data including cache simulation data and interface parameters corresponding to the cache simulation data; and generating a cache simulation data set according to the cache simulation data and the interface parameters corresponding to the cache simulation data.
[0028] After the simulation data result is generated based on the response modification data, the method further includes:
[0029] The cache simulation data set is updated based on the simulation data result.
[0030] Optionally, the interface operation interface is displayed according to the singleton global object data, including:
[0031] The test request time is extracted from the singleton global object data;
[0032] The interface is sorted based on the test request time, to obtain a target interface list;
[0033] The interface operation interface is displayed based on the target interface list.
[0034] Optionally, the simulation data result corresponding to the test data request is obtained by performing simulation data processing according to an interface selection operation submitted by a user on the interface operation interface, including:
[0035] When the interface selection operation is a preset selection operation, a target interface selected by the preset selection operation is determined;
[0036] The request response parameters corresponding to the target interface are extracted from the target interface list;
[0037] The simulation data result is generated based on the request response parameters.
[0038] In a second aspect, the application provides a simulation data processing apparatus, including:
[0039] A target interface information determination module is configured to determine target interface information according to a test data request of a target application program;
[0040] The single global object data determination module is configured to perform data fusion processing on the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request, to obtain single global object data corresponding to the test data request.
[0041] The display module is configured to display an interface operation interface according to the single global object data.
[0042] The simulation data processing module is configured to perform simulation data processing according to an interface selection operation submitted by a user on the interface operation interface, to obtain simulation data results corresponding to the test data request.
[0043] In a third aspect, the present application provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus.
[0044] The memory is configured to store a computer program.
[0045] The processor is configured to execute the program stored on the memory, to implement the steps of the simulation data processing method according to any one of the embodiments of the first aspect.
[0046] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the simulation data processing method according to any one of the embodiments of the first aspect.
[0047] In summary, the embodiments of the present application determine target interface information according to a test data request of a target application program, perform data fusion processing on the target interface information, test response data corresponding to the target interface information, and test data in the test data request, to obtain single global object data corresponding to the test data request, display an interface operation interface according to the single global object data, perform simulation data processing according to an interface selection operation submitted by a user on the interface operation interface, to obtain simulation data results corresponding to the test data request, thereby solving the problem of complicated operation caused by the necessity of connecting a PC in the prior art test troubleshooting data, and improving the test development efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0048] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate one embodiment consistent with the present application and, together with the specification, serve to explain the principles of the application.
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those of ordinary skill in the art, the other drawings can be obtained based on these drawings without any creative effort.
[0050] Figure 1 A flowchart of a simulation data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0051] Figure 2 A step flowchart of a simulation data processing method provided by an optional embodiment of the present application is shown in FIG. 2.
[0052] Figure 3 A simulation data processing flowchart provided by an optional embodiment of the present application is shown in FIG. 3.
[0053] Figure 4 A structural block diagram of a simulation data processing device provided by an embodiment of the present application is shown in FIG. 4.
[0054] Figure 5 A structural diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 5. DETAILED DESCRIPTION
[0055] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by those of ordinary skill in the art without any creative effort fall within the scope of protection of the present application.
[0056] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by those of ordinary skill in the art without any creative effort fall within the scope of protection of the present application.
[0057] Figure 1 A flowchart of a simulation data processing method provided by an embodiment of the present application is shown in FIG. 1. Figure 1 The simulation data processing method provided by the embodiment of the present application can specifically include the following steps.
[0058] In step 110, target interface information is determined according to a test data request of a target application program.
[0059] Specifically, the target application can be an application (App) installed on the mobile terminal, and the embodiments of the present application do not limit this; the test data request can contain a data request of the target application, and the target application can determine the data request when mock data needs to be obtained, and the embodiments of the present application do not limit this; the target interface information can be an interface for obtaining response data, such as the target interface information can contain a uniform resource locator (URL), and the embodiments of the present application do not limit this. Specifically, the embodiments of the present application can obtain the test data request of the target application, and can determine the target interface information according to the test data request of the target application.
[0060] In a specific implementation, the simulation data processing method provided by the embodiments of the present application can be applied to a mobile terminal, such as an Android terminal and an IOS terminal, and the embodiments of the present application do not limit the mobile terminal. For example, when the mobile terminal is an Android terminal, the target application can be an App installed on the Android terminal, and when the back-end interface is not fully developed and the developer or tester needs to troubleshoot the data of the App, the data request of the target application can be intercepted as a test data request, and then the URL can be extracted from the test data request as target interface information.
[0061] Step 120, according to the target interface information, the test response data corresponding to the target interface information and the test data in the test data request, data fusion processing is performed to obtain a singleton global object data corresponding to the test data request.
[0062] Specifically, the test response data can be divided into mock data and user pre-defined data, and the embodiments of the present application do not limit this; the test data can contain a request parameter, which can be used to determine a request form object (FormBody), wherein the request form object can be used to implement identity authentication, and the embodiments of the present application do not limit this. Specifically, after the embodiments of the present application determine the target interface information, the test response data can be obtained for the target interface information, and the test data can be extracted from the test data request, and then the target interface information, the test response data and the test data can be subjected to data fusion processing, such as the target interface information can be used as a key in a key-value pair, and the test response data and the test data can be used as a value in the key-value pair for data fusion, to obtain a singleton global object data.
[0063] In a specific implementation, embodiments of the present application can intercept both the data request and data response stages of the target application. Specifically, after intercepting the data request stage of the target application, the test data request is determined, and based on the URL corresponding to the test data request, the mock data corresponding to the URL is attempted to be obtained. Subsequently, it is determined whether the mock data corresponding to the URL is obtained, if it is determined that the mock data corresponding to the URL is obtained, the original response data is determined based on the mock data, if it is determined that the mock data corresponding to the URL is not obtained, the data defined by the user in advance is taken as the original response data, and then the target interface information, the test response data corresponding to the target interface information and the test data in the test data request are subjected to data fusion processing to obtain the singleton global object data corresponding to the test data request. By intercepting the request stage and the response stage of the target application, the data in the request stage and the data in the response stage are obtained, the acquisition of the request response log is implemented, the specific information of the interface request and response data can be quickly browsed and viewed on the mobile terminal, and the functions of analyzing and replacing the mock data of the intercepted request response log are implemented.
[0064] Step 130, displaying an interface operation interface according to the singleton global object data.
[0065] Specifically, after determining the singleton global object data, embodiments of the present application can design a user interface (User Interface, UI) according to the singleton global object data, for example, the target interface information in the singleton global object data can be used to generate an interface list, and then the interface list can be taken as an interface operation interface, and the interface operation interface is displayed through the mobile terminal, so that the user can subsequently perform simulated data replacement on the test response data corresponding to the target interface information, that is, step 140 is executed.
[0066] Step 140, performing simulated data processing according to the interface selection operation submitted by the user in the interface operation interface to obtain simulated data results corresponding to the test data request.
[0067] Specifically, the user can select the target interface information to be simulated in the interface operation interface, and then the user can perform simulation data processing on the target interface information, such as modifying the test response data corresponding to the target interface information, replacing the test response data with mock data set by the user, obtaining the simulation data result corresponding to the test data request, and implementing mock operation. When the backend is not released, the mock data can be used in advance to ensure the normal development of the front end without waiting for the release of the backend. When performing data mock and request response data analysis, there is no need to connect a PC or perform relatively cumbersome operations such as proxy hanging, which breaks the time and space restrictions and greatly saves the time cost, thereby solving the problem of cumbersome operation caused by the necessity of connecting a PC for existing test data troubleshooting and improving the test development efficiency.
[0068] In a specific implementation, in addition to replacing the test response data corresponding to the target interface information, the user can also replace the test data corresponding to the target interface information, and simulate data processing on the request parameters in the test data, such as adding, modifying, and deleting the content of the request parameters on the basis of the original request parameters, to control the response of different content data by simulating data processing on the request parameters.
[0069] It can be seen that the embodiments of the present application determine the target interface information according to the test data request of the target application program, perform data fusion processing on the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request to obtain the singleton global object data corresponding to the test data request, display the interface operation interface according to the singleton global object data, perform simulation data processing according to the interface selection operation submitted by the user in the interface operation interface, and obtain the simulation data result corresponding to the test data request, thereby solving the problem of cumbersome operation caused by the necessity of connecting a PC for existing test data troubleshooting and improving the test development efficiency.
[0070] Referring to Figure 2 , a step flowchart of a simulation data processing method provided by an optional embodiment of the present application is shown. The simulation data processing method can specifically include the following steps:
[0071] Step 210, determining the target interface information according to the test data request of the target application program.
[0072] In its specific implementation, this application embodiment can intercept the request and response phases of an App using interceptors included in the OkHttp network request framework. Specifically, OkHttp supports various interceptors, which can be divided into two main categories: application interceptors, which can be the first interceptor to execute in the interception chain; and network interceptors, which can be the sixth interceptor in the interception chain and are typically used to observe data transmission over the network.
[0073] As an example, a request-response log analysis interceptor and a mock data interceptor can be implemented using application interceptors. The request-response log analysis interceptor intercepts both the data request and response phases, while the mock data interceptor uses the mock data corresponding to the data request as the response data. Since application interceptors are typically called only once, there's no need to worry about intermediate responses such as redirects and retries, and the `chain.proceed()` method can be called to determine whether to execute other interceptions. Of course, request-response log analysis interceptors and mock data interceptors can also be implemented using network interceptors; this example does not restrict the implementation method of the interceptors.
[0074] In an optional embodiment, when an application interceptor is installed on the mobile terminal, the step of determining the target interface information based on the test data request of the target application may specifically include: intercepting the data request of the target application through the application interceptor to obtain the test data request; extracting the Uniform Resource Locator (URL) parameter from the test data request; and determining the target interface information based on the URL parameter.
[0075] As an example, refer to Figure 3 You can use an application request interceptor to intercept data requests and obtain test data requests. Then you can call chain.request() to get the URL of the current test data request, which can be used as the target interface information.
[0076] In practical applications, OkHttp can have a built-in network connection pool and support file compression programs from GNU free software (GNU-zip, gzip). Specifically, OkHttp's interceptors can include retry and redirection interceptors (RetryAndFollowUpInterceptor) and bridging interceptors.
[0077] OkHttp employs various interceptors, including BridgeInterceptor, CacheInterceptor, ConnectInterceptor, and CallServerInterceptor. Each interceptor can handle intercepted requests. Specifically, OkHttp uses the Chain of Responsibility pattern to link each object to its next corresponding object, forming a chain. Interceptors can be applied to different nodes in this chain, each with its own responsibility to handle requests. Each chain can decide whether to process an intercepted request. OkHttp also allows users to add custom interceptors to implement their own logic, enabling features such as request log analysis and mock data replacement of response data.
[0078] In an optional embodiment, before determining the target interface information based on the test data request of the target application, this embodiment may further include: when the application interceptor starts, obtaining cached data, the cached data including cached mock data and interface parameters corresponding to the cached mock data; and generating a cached mock data set based on the cached mock data and the interface parameters corresponding to the cached mock data. Here, the interface parameters are interface URLs, and the cached mock data may include mock data; this embodiment does not impose any limitations on this.
[0079] Specifically, a mock data interceptor can be implemented using an application interceptor. This mock data interceptor starts when the application interceptor begins, and then retrieves cached data. Based on the cached mock data and interface parameters contained within the cached data, a cached mock data set is generated. This set can be stored in key-value pairs; for example, the interface parameter (interface URL) can be used as the key, and the corresponding cached mock data can be used as the value. This allows for the determination of the test response data corresponding to the target interface information later.
[0080] Step 220: Determine the test response data corresponding to the target interface information.
[0081] Specifically, embodiments of this application can determine the test response data corresponding to the target interface information. For example, when the mock data interceptor is activated, the mock data interceptor can obtain the URL corresponding to the target interface information and determine whether the URL matches the locally cached mock interface list. This can be done by determining whether the URL belongs to the mock interface list. If the URL belongs to the mock interface list, it can be determined that the URL matches the locally cached mock interface list. Subsequently, mock data corresponding to the URL can be extracted from the locally cached mock data, and this mock data is used as the original response data. The test response data is then determined based on the original response data. If the URL does not belong to the mock interface list, it can be determined that the URL does not match the locally cached mock interface list. Subsequently, user-defined data can be obtained, which can be in JavaScript Object Notation (JSON) format. This user-defined JSON data is used as the original response data, thereby determining the test response data. Even when the mock data interceptor is not activated, user-defined JSON data can still be used as the original response data to determine the test response data.
[0082] In one optional embodiment, determining the test response data corresponding to the target interface information may specifically include: when the Uniform Resource Locator (URL) parameter matches the interface parameter in the cached simulation data set, determining the cached simulation data corresponding to the interface parameter as the original response data, and determining the test response data based on the original response data. The cached simulation data set is a set generated by the mobile terminal based on the cached data obtained when the application interceptor starts; when the URL parameter does not match the interface parameter in the cached simulation data set, creating the test response data based on the target interface information.
[0083] In practical implementation, to avoid state anomalies, such as in OkHttp request callbacks where the response.body().string() method is typically used to retrieve response information, the data stream may be closed after calling the response. In this case, calling response.body().string() to retrieve the response information will throw an exception. Therefore, in this embodiment, after obtaining the original response data, the original response data can be copied to obtain copied data. This copied data can then be used as test response data to avoid state anomalies and other issues.
[0084] In one optional embodiment, the present application embodiment determines the test response data based on the original response data, which may specifically include: using the original response data as the test response data; or, performing a copying process based on the original response data to obtain copied data, and determining the copied data as the test response data.
[0085] As an example, refer to Figure 3 The original response information (i.e., the original response data, ResponseBody) can be obtained through the chain.response() method. Then, the original response data can be copied to obtain a new ResponseBody (i.e., the test response data).
[0086] Step 230: Extract the test data from the test data request and determine the test request time corresponding to the test data.
[0087] Specifically, in this application embodiment, test data can be extracted from the test data request, and then the test request time corresponding to the test data can be determined. The test request time may include the request time corresponding to the test data request, and this application embodiment does not limit this.
[0088] As an example, refer to Figure 3 Test data (RequestBody) can be obtained using the `request.body()` method. For example, the `RequestBody` can be extracted from the test data request using `request.body()`, and this example does not restrict this. Then, based on the obtained `RequestBody`, the `FormBody` can be determined, and key-value pairs can be constructed. For example, the URL can be used as the key and the `FormBody` as the value to construct key-value pairs, which can then be stored in memory and on disk for persistence. This data can be used after the app restarts.
[0089] Step 240: According to the preset singleton pattern, the target interface information, the test response data, the request time, and the test data are encapsulated to obtain the singleton global object data.
[0090] Specifically, in this application embodiment, the obtained target interface information, current test response data request time, and test data can be encapsulated according to the singleton pattern. For example, the target interface information, current test response data request time, and test data can be encapsulated into an object to obtain singleton global object data. This singleton global object data represents all the information contained in the current target interface information. Subsequently, all the corresponding information of the current target interface information, such as test response data, request time, and test data, can be obtained based on the target interface information.
[0091] As an example, refer to Figure 3 It allows storing the URL, response content (ResponseBody), and request key-value pairs (key-value information) separately for local persistence. Subsequently, a singleton can be used to perform data fusion processing on the key-value pairs and response content to obtain the singleton global object data, enabling the retrieval of request and response logs.
[0092] Step 250: Operate the interface based on the singleton global object data display interface.
[0093] Optionally, the above-described operation interface for displaying the singleton global object data may specifically include the following sub-steps:
[0094] Sub-step 2501: Extract the test request time from the singleton global object data.
[0095] Specifically, in this embodiment of the application, the test request time can be extracted from the singleton global object data so that it can be sorted according to the test request time later.
[0096] Sub-step 2502: Sort the interfaces based on the test request time to obtain a list of target interfaces.
[0097] Specifically, the embodiments of this application can sort the interfaces based on the test request time. For example, the target interface information can be sorted according to the order of the test request time to obtain a target interface list.
[0098] Sub-step 2503: Display the interface operation interface based on the target interface list.
[0099] Specifically, the target interface list can be rendered through UI design to obtain the interface operation interface, which can then be displayed.
[0100] As an example, refer to Figure 3 After obtaining the singleton global object data, it can be stored in the singleton global storage for local persistence. Then, each singleton global object data item can be retrieved from the singleton global storage, and the target interface information can be sorted according to the test request time corresponding to the singleton global object data to obtain an interface list (i.e., the target interface list). This interface list can be displayed on the interface operation interface through the UI.
[0101] Step 260: When the interface selection operation is a modification selection operation, determine the target editing interface based on the modification selection operation.
[0102] Specifically, in embodiments of this application, when the interface selection operation is a modification selection operation, the target interface information selected by the user can be determined based on the modification selection operation, and used as the target editing interface.
[0103] As an example, the modification selection operation can be set as a click operation. This example does not restrict this; that is, when the user clicks on the selected target interface information, the interface selection operation can be determined as a modification selection operation, and the target interface information selected by the user can then be used as the target editing interface. For example, refer to... Figure 3 After a user clicks on a URL in the interface list, that URL can be designated as the target editing interface. Subsequently, the user can obtain the singleton global object data corresponding to the target editing interface and display and format the test response data in the singleton global object data, such as formatting the test response data into JSON, making the structure of the test response data clearer and easier to understand, making it easier for users to browse the test response data, and making the modification of the test response data more accurate and faster, thereby improving the user experience.
[0104] Furthermore, refer to Figure 3 In addition to clicking on URLs in the API list, users can also long-press on them. By long-pressing, the selected URL becomes the target editing API. The user can then retrieve the current API request parameters, which are test data from the singleton global object data corresponding to the target editing API. This test data is then displayed in JSON format, allowing the user to modify or replace the API request parameters. This includes adding, modifying, or deleting parameters, thus controlling the response content.
[0105] In an optional embodiment, when the interface selection operation is a preset selection operation, the step of performing simulated data processing based on the interface selection operation submitted by the user on the interface operation interface to obtain the simulated data result corresponding to the test data request may specifically include: when the interface selection operation is a preset selection operation, determining the target interface selected by the preset selection operation; extracting the request-response parameters corresponding to the target interface from the target interface list; and generating the simulated data result based on the request-response parameters. The request-response parameters may be test data, and this embodiment does not limit their use.
[0106] Step 270: Display the response data corresponding to the target editing interface.
[0107] Specifically, the interface operation interface can display the response data corresponding to the target editing interface selected by the user. The response data may include test response data, but this application embodiment does not limit this.
[0108] Step 280: Modify the response data according to the response editing operation submitted by the user to obtain the modified response data.
[0109] Specifically, the response modification data may include user-defined mock data, and this application embodiment does not impose any limitations on this. Specifically, the user can modify the response data, such as by replacing the response data with mock data to obtain the modified response data. Subsequently, the modified response data can be format-validated to obtain the format validation result.
[0110] Step 290: Modify the data according to the response and perform format verification to obtain the format verification result.
[0111] Specifically, the format verification result includes a format verification pass result and a format verification fail result, and this application embodiment does not limit this. Specifically, this application embodiment can perform format verification based on the response modified data, so that when the format verification passes, the format verification pass result is determined as the format verification result; when the format verification fails, the format verification fail result is determined as the format verification result.
[0112] In a specific implementation, the embodiments of this application can preset a target format. After determining the response modification data, the format of the response modification data can be validated. For example, it can be determined whether the format corresponding to the response modification data is the target format. If the format corresponding to the response modification data is the target format, the format validation is determined to be successful, and a format validation success result can be obtained. If the format corresponding to the response modification data is not the target format, the format validation is determined to be unsuccessful, and a format validation failure result can be obtained.
[0113] For example, refer to Figure 3 Users can edit the API response content (i.e., response data) and modify the data source (mock data) to obtain the modified response data. The modified response data can then be validated to determine if it is in JSON format. If it is confirmed to be JSON, the validation is successful (validation passed), and the mock data modification is complete. This data can then be persisted locally using the URL as the key and the mock data as the value. If the validation fails (validation fails), the mock data modification fails. In this case, the user should be notified that the mock data is not in JSON format and advised to modify it again to conform to JSON format.
[0114] Step 300: If the format verification result is a format verification pass result, then the simulated data result is generated based on the response modified data.
[0115] Specifically, this application embodiment can generate simulated data results based on the modified response data when the format validation result is a passed result. This allows users to quickly browse and view interface request and response data on the App, achieving mocking through the App without relying on a PC.
[0116] In an optional embodiment, after generating the simulated data result based on the response modification data, this application embodiment may further include: updating the cached simulated data set based on the simulated data result. Specifically, this application embodiment may update the cached simulated data set based on the URL and mock data included in the simulated data result. Subsequently, the user-modified URL and mock data may be persisted to local storage, such as storing the cached simulated data set in memory and on the hard drive, so that the mock process can still be performed normally after the App restarts, ensuring the stability of the mock.
[0117] As an example, refer to Figure 4 After successfully validating the mock data format, the URL and mock data can be persisted to local storage using the URL as the key and the mock data as the value. This allows for updating the mock Map collection (i.e., the cached mock data collection) based on the URL and mock data. Upon receiving a subsequent test data request, with the mock data interceptor running, it can be determined whether the URL corresponding to the test data request matches the cached mock URL. If a match is found, the URL can be used as the key to extract the corresponding value from the cached mock data collection—that is, to extract the mock data corresponding to the URL—and this mock data can be used as the new ResponseBody to complete the mocking process. If the URL corresponding to the test data request does not match the cached mock URL, the process can be terminated.
[0118] In practice, once the backend interfaces are developed, users can modify the cached mock data set. For example, the cached mock data set can be displayed as an interface list. After selecting a URL from the list (the backend interface corresponding to the URL may have already been developed), users can choose to delete the URL and its corresponding mock data. Furthermore, the interceptor can be set not to intercept the URL, allowing the App to use the backend interface data normally without affecting the mock process.
[0119] Furthermore, once all backend interfaces have been developed, users can use a pre-defined one-click clear button to delete all data contained in the cached simulation data set, achieving batch unified management.
[0120] In summary, this application embodiment determines the target interface information and the corresponding test response data based on the test data request of the target application. Test data is extracted from the test data request, and the corresponding test request time is determined. Then, according to a preset singleton pattern, the target interface information, test response data, request time, and test data are encapsulated to obtain singleton global object data. The interface operation interface is displayed based on the singleton global object data. When the interface selection operation is a modification selection operation, the target editing interface is determined based on the modification selection operation, and the response data corresponding to the target editing interface is displayed. The response data is modified according to the user-submitted response editing operation to obtain modified response data. Format validation is performed on the modified response data to obtain the format validation result. When the format validation result is a passed result, simulated data results are generated based on the modified response data. This allows mock data to be provided to the frontend even before the backend is released, ensuring that normal frontend development does not require waiting for backend release. Interface request and response data can be quickly viewed on the App without relying on PCs or proxies, thus solving the cumbersome operation problem caused by the requirement to connect to a PC for existing test data analysis, saving time and improving test development efficiency.
[0121] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should know that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps may be performed in other orders or simultaneously.
[0122] like Figure 5 As shown in the illustration, this application also provides an analog data processing apparatus 400, comprising:
[0123] The target interface information determination module 410 is used to determine the target interface information based on the test data request of the target application.
[0124] The singleton global object data determination module 420 is used to perform data fusion processing based on the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request to obtain the singleton global object data corresponding to the test data request.
[0125] Display module 430 is used to operate the interface based on the singleton global object data display interface;
[0126] The simulation data processing module 440 is used to perform simulation data processing based on the interface selection operation submitted by the user on the interface operation interface, and obtain the simulation data result corresponding to the test data request.
[0127] Optionally, the target interface information determination module includes:
[0128] The interception submodule is used to intercept the data requests of the target application through the application interceptor to obtain the test data requests;
[0129] An extraction submodule is used to extract Uniform Resource Locator (URL) parameters from the test data request.
[0130] The target interface information determination submodule is used to determine the target interface information based on the Uniform Resource Locator (URL) parameters.
[0131] Optionally, the singleton global object data determination module includes:
[0132] The test response data determination submodule is used to determine the test response data corresponding to the target interface information;
[0133] The test request time determination submodule is used to extract the test data from the test data request and determine the test request time corresponding to the test data;
[0134] The encapsulation submodule is used to encapsulate the target interface information, the test response data, the request time, and the test data according to a preset singleton pattern to obtain the singleton global object data.
[0135] Optionally, the test response data determination submodule includes:
[0136] The test response data determination unit is configured to, when the Uniform Resource Locator (URL) parameter matches the interface parameter in the cached simulation data set, determine the cached simulation data corresponding to the interface parameter as the original response data, and determine the test response data based on the original response data, wherein the cached simulation data set is a set generated by the mobile terminal based on the cached data obtained when the application interceptor is started; and when the URL parameter does not match the interface parameter in the cached simulation data set, create the test response data based on the target interface information.
[0137] Optionally, the test response data determination unit is specifically used to use the original response data as the test response data; or, to perform copying processing based on the original response data to obtain copied data, and to determine the copied data as the test response data.
[0138] Optionally, the simulation data processing module includes:
[0139] The target editing interface determination submodule is used to determine the target editing interface based on the modification selection operation when the interface selection operation is a modification selection operation.
[0140] The display submodule is used to display the response data corresponding to the target editing interface;
[0141] The modification submodule is used to modify the response data based on the response editing operation submitted by the user, and obtain the modified response data;
[0142] The format verification submodule is used to perform format verification based on the data modified in the response, and obtain the format verification result.
[0143] The simulated data result generation submodule is used to generate the simulated data result based on the response modified data when the format verification result is a format verification pass result.
[0144] Optionally, the analog data processing device further includes:
[0145] A cached simulation data set generation submodule is used to obtain cached data when the application interceptor starts. The cached data includes cached simulation data and the interface parameters corresponding to the cached simulation data. A cached simulation data set is generated based on the cached simulation data and the interface parameters corresponding to the cached simulation data.
[0146] An update module is used to update the cached simulation data set based on the simulation data results.
[0147] Optionally, the display module includes:
[0148] The test request time extraction submodule is used to extract the test request time from the singleton global object data;
[0149] The sorting submodule is used to sort the interfaces based on the test request time to obtain a list of target interfaces.
[0150] The display submodule is used to display the interface operation interface based on the target interface list.
[0151] Optionally, the simulation data processing module is specifically used to determine the target interface selected by the preset selection operation when the interface selection operation is a preset selection operation; extract the request-response parameters corresponding to the target interface from the target interface list; and generate the simulation data result based on the request-response parameters.
[0152] It should be noted that the simulation data processing apparatus provided in the embodiments of this application can execute the simulation data processing method provided in any embodiment of this application, and has the corresponding functions and beneficial effects of executing the simulation data processing method.
[0153] In a specific implementation, the aforementioned simulation data processing device can be integrated into the device, enabling the device to perform simulation data processing based on test data requests and obtain simulation data processing results. As an electronic device, it enables simulation data processing on a mobile terminal. This electronic device can consist of two or more physical entities, or it can consist of a single physical entity. For example, an electronic device can be a personal computer (PC), a computer, a server, etc. This application does not impose specific limitations on this.
[0154] like As shown, this application embodiment provides an electronic device including a processor 111, a communication interface 112, a memory 113, and a communication bus 114. The processor 111, communication interface 112, and memory 113 communicate with each other via the communication bus 114. The memory 113 stores computer programs. The processor 111, when executing the program stored in the memory 113, implements the steps of the simulated data processing method provided in any of the aforementioned method embodiments. For example, the steps of the simulated data processing method may include the following: determining target interface information based on a test data request from a target application; performing data fusion processing based on the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request to obtain singleton global object data corresponding to the test data request; displaying an interface operation interface based on the singleton global object data; and performing simulated data processing based on the interface selection operation submitted by the user on the interface operation interface to obtain the simulated data result corresponding to the test data request.
[0155] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the simulated data processing method provided in any of the foregoing method embodiments.
[0156] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0157] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for processing analog data, characterized in that, Applied to mobile terminals, including: Based on the test data requests from the target application, determine the target interface information; Based on the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request, data fusion processing is performed to obtain the singleton global object data corresponding to the test data request; The interface for displaying the singleton global object data is based on the provided description. Based on the interface selection operation submitted by the user on the interface operation interface, simulated data processing is performed to obtain the simulated data result corresponding to the test data request, including: when the interface selection operation is a modification selection operation, determining the target editing interface based on the modification selection operation; displaying the response data corresponding to the target editing interface; modifying the response data according to the response editing operation submitted by the user to obtain modified response data; performing format validation on the modified response data to obtain a format validation result; if the format validation result is a format validation pass result, then generating the simulated data result based on the modified response data.
2. The method according to claim 1, characterized in that, The mobile terminal is equipped with an application interceptor. The step of determining the target interface information based on the test data request of the target application includes: The test data request is obtained by intercepting the data request of the target application through the application interceptor. Extract the Uniform Resource Locator (URL) parameter from the test data request; The target interface information is determined based on the Uniform Resource Locator (URL) parameters.
3. The method according to claim 2, characterized in that, The data fusion process, based on the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request, yields the singleton global object data corresponding to the test data request, including: Determine the test response data corresponding to the target interface information; Extract the test data from the test data request and determine the test request time corresponding to the test data; According to the preset singleton pattern, the target interface information, the test response data, the request time, and the test data are encapsulated to obtain the singleton global object data.
4. The method according to claim 3, characterized in that, The step of determining the test response data corresponding to the target interface information includes: When the Uniform Resource Locator parameter matches the interface parameter in the cached simulation data set, the cached simulation data corresponding to the interface parameter is determined as the original response data, and the test response data is determined based on the original response data. The cached simulation data set is a set generated by the mobile terminal based on the cached data obtained when the application interceptor is started. When the Uniform Resource Locator (URL) parameter does not match the interface parameter in the cached mock dataset, the test response data is created based on the target interface information.
5. The method according to claim 4, characterized in that, Determining the test response data based on the original response data includes: using the original response data as the test response data; or, performing a copying process on the original response data to obtain copied data, and determining the copied data as the test response data.
6. The method according to claim 1, characterized in that, Before determining the target interface information based on the test data request of the target application, the method further includes: obtaining cached data when the application interceptor starts, wherein the cached data includes cached simulation data and interface parameters corresponding to the cached simulation data; and generating a cached simulation data set based on the cached simulation data and the interface parameters corresponding to the cached simulation data. After generating the simulated data result based on the modified response data, the method further includes: The cached simulation data set is updated based on the simulation data results.
7. The method according to claim 1, characterized in that, The interface for displaying data based on the singleton global object includes: Extract the test request time from the singleton global object data; The interfaces are sorted based on the test request time to obtain a list of target interfaces; The interface operation interface is displayed based on the target interface list.
8. The method according to claim 7, characterized in that, The step of performing simulated data processing based on the interface selection operation submitted by the user on the interface operation interface to obtain the simulated data result corresponding to the test data request includes: When the interface selection operation is a preset selection operation, the target interface selected by the preset selection operation is determined; Extract the request and response parameters corresponding to the target interfaces from the list of target interfaces; The simulated data results are generated based on the request and response parameters.
9. An analog data processing device, characterized in that, include: The target interface information determination module is used to determine the target interface information based on the test data request of the target application. The singleton global object data determination module is used to perform data fusion processing based on the target interface information, the test response data corresponding to the target interface information, and the test data in the test data request to obtain the singleton global object data corresponding to the test data request. The display module is used to operate the interface based on the singleton global object data display interface. The simulated data processing module is used to perform simulated data processing based on the interface selection operation submitted by the user on the interface operation interface, and to obtain the simulated data result corresponding to the test data request. Specifically, it is used to: when the interface selection operation is a modification selection operation, determine the target editing interface based on the modification selection operation; and display the response data corresponding to the target editing interface. The response data is modified based on the user-submitted response editing operation to obtain the modified response data; Based on the response, modify the data and perform format validation to obtain the format validation result; If the format verification result is a passed format verification result, then the simulated data result is generated based on the response modified data.
10. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the analog data processing method according to any one of claims 1-8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the analog data processing method as described in any one of claims 1-8.
Citation Information
Patent Citations
Safety test method and device, computer equipment and storage medium
CN112783798A
Data testing method and device and storage medium
CN113220572A