Mock method and device for service internal interface request and readable storage medium
By obtaining and judging the configuration information of the Mock request and dynamically performing the Mock processing, the problem of existing Mock methods affecting each other in a multi-test environment is solved, and efficient Mock testing of internal interface requests of the service is realized.
Patent Information
- Application Number
- CN202411999556.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-02
AI Technical Summary
Existing Mock methods are prone to influence each other when multiple tests are performed simultaneously, resulting in inaccurate test results.
A Mock method for serving internal interface requests is provided. By obtaining the request configuration information of the Mock request, determining the current status of the preconfigured item, and executing the processing of the Mock request in the open state, in order to realize the dynamic interface request specified within the Mock service.
It implements dynamic mock requests on the internal interface of the service during the testing process, avoiding the impact on other tests and no need to modify the service code.
Smart Images

Figure CN119917412A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a mock method, device and readable storage medium for serving internal interface requests. Background Art
[0002] In software development and testing, mock operations usually refer to the use of mock objects (Mock objects) to replace real objects for testing. Mock objects can imitate the behavior of real objects so that there is no need to rely on real external resources or complex system environments during the testing process. The main purpose of mock operations is to improve the coverage and efficiency of tests while reducing dependence on external dependencies.
[0003] In daily testing work, it is often necessary to perform mock operations on certain interface requests in order to complete the testing of specified business scenarios.
[0004] However, when multiple tests are performed simultaneously, the existing Mock methods are prone to affect each other, thereby affecting the test results. Summary of the invention
[0005] The technical problem to be solved by the present application is to provide a Mock method, device and readable storage medium for serving internal interface requests in view of the above-mentioned deficiencies in the prior art, so as to solve the problems existing in the prior art.
[0006] In a first aspect, the present application provides a mock method for serving an internal interface request, the method comprising:
[0007] S1. In response to a Mock request for obtaining a service internal interface, obtain request configuration information corresponding to the Mock request;
[0008] S2. Determine the current state of the pre-configuration item corresponding to the requested configuration information;
[0009] S3. If the pre-configuration item corresponding to the request configuration information is currently in an enabled state, the Mock request is processed based on the pre-configuration item corresponding to the request configuration information.
[0010] In some embodiments, the request configuration information includes the application name, class name, and key methods of the Mock request;
[0011] The key method is to initiate a request to the interface that needs a mock within the service.
[0012] The class name is the class name corresponding to the key method;
[0013] The application name is the name of the application to which the key method belongs.
[0014] In some embodiments, before S1, the method further includes:
[0015] The pre-configuration item information is obtained and saved, wherein the pre-configuration item information includes different configuration information corresponding to different Mock requests, and the configuration information includes application name, class name, and key methods.
[0016] In some embodiments, obtaining pre-configuration item information includes:
[0017] Obtaining newly added configuration information, including newly added application name, class name, and key methods;
[0018] Obtaining status setting information of the newly added configuration information;
[0019] Detailed editing information of the newly added configuration information is obtained, where the detailed editing information includes conditional editing information and value assignment editing information.
[0020] In some embodiments, the detailed editing information includes parameter location, member object name, and level status;
[0021] The hierarchical status includes final and non-final.
[0022] In some embodiments, obtaining detailed editing information of the newly added configuration information includes:
[0023] When the hierarchical state is final, obtaining value attribute information of the newly added configuration information;
[0024] When the hierarchical state is non-final, the next layer of editing information of the newly added configuration information is obtained until the hierarchical state of the last layer is final.
[0025] In some embodiments, obtaining the next layer of editing information of the newly added configuration information includes:
[0026] When the hierarchical status of the next layer is non-final, obtain the name of the newly added member object and the editing information of the next layer until the hierarchical status of the last layer is final;
[0027] When the hierarchical status of the next layer is final, the newly added member object name and value attribute information are obtained.
[0028] In a second aspect, the present application provides a Mock device for serving an internal interface request, the device comprising:
[0029] An acquisition module, configured to respond to a Mock request for acquiring an internal interface of a service and acquire request configuration information corresponding to the Mock request;
[0030] A determination module, configured to determine a current state of a pre-configuration item corresponding to the requested configuration information;
[0031] The processing module is configured to execute the processing of the Mock request based on the pre-configuration item corresponding to the request configuration information if the pre-configuration item corresponding to the request configuration information is currently in an enabled state.
[0032] In a third aspect, the present application provides a Mock device for a service internal interface request, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the Mock method for the service internal interface request described in the first aspect above.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the mock method for the service internal interface request described in the first aspect above is implemented.
[0034] The present application provides a mock method, device and readable storage medium for requesting an internal interface of a service. The method includes: in response to a mock request for obtaining an internal interface of a service, obtaining request configuration information corresponding to the mock request; determining the current state of a pre-configuration item corresponding to the request configuration information; if the pre-configuration item corresponding to the request configuration information is currently in an enabled state, executing the processing of the mock request based on the pre-configuration item corresponding to the request configuration information. The present application provides a mock method for requesting an internal interface of a service. During the test, based on the pre-configuration item corresponding to the request configuration information, the test process will be mocked into the request address specified by the pre-configuration item, thereby realizing the requirements of the mock test, and will not affect other people's normal requests for the same interface. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0036] Figure 1 A mock diagram of an interface request initiated within an existing service;
[0037] Figure 2 A schematic diagram of a mock method for requesting an internal service interface provided in an embodiment of the present application;
[0038] Figure 3 A schematic diagram of obtaining pre-configuration item information in an embodiment of the present application;
[0039] Figure 4 Another schematic diagram of obtaining pre-configuration item information in an embodiment of the present application;
[0040] Figure 5 A schematic diagram of obtaining detailed editing information in an embodiment of the present application;
[0041] Fig. 6A Another schematic diagram of obtaining detailed editing information in an embodiment of the present application;
[0042] Figure 6B Another schematic diagram of obtaining detailed editing information in an embodiment of the present application;
[0043] Figure 7 A schematic diagram of obtaining the next layer of editing information in an embodiment of the present application;
[0044] Fig. 8A Another schematic diagram of obtaining newly added editing information in an embodiment of the present application;
[0045] Figure 8B Another schematic diagram of obtaining newly added editing information in an embodiment of the present application;
[0046] Fig. 9 Another schematic diagram of obtaining the next layer of editing information in an embodiment of the present application;
[0047] Fig.10 Another schematic diagram of obtaining the next layer of editing information in an embodiment of the present application;
[0048] Fig.11 A schematic diagram of the structure of a Mock device for serving internal interface requests provided in an embodiment of the present application;
[0049] Fig.12 A schematic diagram of the structure of another Mock device for serving internal interface requests provided in an embodiment of the present application.
[0050] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0051] In order to enable those skilled in the art to better understand the technical solution of the present application, the implementation mode of the present application will be further described in detail below with reference to the accompanying drawings.
[0052] It should be understood that the specific embodiments and drawings described herein are only used to explain the present application, rather than to limit the present application.
[0053] It can be understood that, in the absence of conflict, the various embodiments in the present application and the various features in the embodiments can be combined with each other.
[0054] It can be understood that, for the convenience of description, the drawings of the present application only show the parts related to the present application, while the parts unrelated to the present application are not shown in the drawings.
[0055] It can be understood that each unit and module involved in the embodiments of the present application may correspond to only one physical structure, or may be composed of multiple physical structures, or multiple units and modules may be integrated into one physical structure.
[0056] It can be understood that the terms "first", "second", etc. in the embodiments of the present application are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.
[0057] It is understandable that, in the absence of conflict, the functions and steps marked in the flowcharts and block diagrams of the present application may occur in an order different from that marked in the drawings.
[0058] It is understood that the flowcharts and block diagrams of the present application illustrate the possible architectures, functions, and operations of the systems, devices, equipment, and methods according to the various embodiments of the present application. Among them, each box in the flowchart or block diagram may represent a unit, module, program segment, code, which contains executable instructions for implementing the specified functions. Moreover, each box or combination of boxes in the block diagram and flowchart may be implemented by a hardware-based system that implements the specified functions, or by a combination of hardware and computer instructions.
[0059] It can be understood that the units and modules involved in the embodiments of the present application can be implemented by software or hardware, for example, the units and modules can be located in a processor.
[0060] In the existing mocking methods, the mocking of interface requests initiated in the client interface (such as a browser) can be implemented with the help of some existing tools, such as fiddler. In addition, the mocking of interface requests initiated within the service can usually be implemented by modifying the request address so that the request is sent to the internal mocking service.
[0061] Figure 1 A mock diagram of an interface request initiated within an existing service, such as Figure 1As shown, when user A conducts testing in this way, the development colleagues need to cooperate to modify the service code (modify the request address) before the test, and then notify the development colleagues to modify the service code again to change the request address back after the test. Therefore, this method is more troublesome; on the other hand, modifying the request address will cause all related interfaces to be requested to the specified Mock service. At this time, if there are multiple tests being tested at the same time, and they all hope that the interface is normally initiated (rather than being mocked), or hope that the address of the Mock is another address, their tests will be affected. For example, after modifying the service code (modifying the request address), user B initiates a request, but the modified service code (request address) is not what user B expects.
[0062] Based on the problems existing in the prior art, the present application provides a mock method for service internal interface requests, which can dynamically mock specified interface requests within the service without modifying the service code and will not affect other test colleagues' normal requests or mock requests for the same interface.
[0063] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0064] The present application provides a mock method for serving internal interface requests. The working process of the method can be implemented by electronic devices, such as computers, handheld smart terminals, etc. For ease of explanation, the embodiments of the present application are described with the method execution subject being a computer.
[0065] Figure 2 A schematic diagram of a mock method for requesting an internal service interface provided in an embodiment of the present application, such as Figure 2 As shown, the present application provides a Mock method for serving internal interface requests, the method includes S1-S3, which are as follows:
[0066] S1. In response to a Mock request for obtaining a service internal interface, obtain request configuration information corresponding to the Mock request;
[0067] Among them, the Mock request of the service internal interface is the request initiated by the tester when starting the business test, and the corresponding request configuration information can be obtained based on the Mock request.
[0068] In some embodiments, the request configuration information includes the application name, class name, and key methods of the Mock request;
[0069] The key method is to initiate a request to the interface that needs a mock within the service.
[0070] The class name is the class name corresponding to the key method;
[0071] The application name is the name of the application to which the key method belongs.
[0072] For example, when using the retrofit2 framework to request an interface, the key method for implementing the interface request during the flow within the framework is:
[0073] retrofit2.CallAdapter#adapt
[0074] Among them, retrofit2.CallAdapter is the class name, adapt is the method name;
[0075] In particular, the calling code of this key method is:
[0076] callAdapter.adapt(requestFactory,args,callFactory,type)
[0077] Among them, the parameter that determines the request address is the requestFactory object, in which a member object represents the address (ip, port) to which the final interface request is sent, and other parameters (such as callFactory, type) contain some information about the interface request (such as phone). In fact, in daily development, there are many similar frameworks that can be used for request interfaces (including self-developed and open source frameworks), just like the retrofit2 framework, and the parameters of key methods will include the request address, sending information, etc.
[0078] For another example, the application to which the key method of the interface to be mocked belongs is kcard-xxx.
[0079] S2. Determine the current state of the pre-configuration item corresponding to the requested configuration information;
[0080] Specifically, the present application pre-stores a variety of different types of pre-configuration items, and different pre-configuration items correspond to different Mock requests. Based on the request configuration information corresponding to the currently obtained Mock request, the corresponding pre-configuration item can be determined, and the current state corresponding to the pre-configuration item can be obtained.
[0081] The current state includes an on state and a off state.
[0082] S3. If the pre-configuration item corresponding to the request configuration information is currently in an enabled state, the Mock request is processed based on the pre-configuration item corresponding to the request configuration information.
[0083] If it is determined that the current state of the pre-configuration item corresponding to the request configuration information is an open state, it means that the pre-configuration item is currently in an available state. At this time, the processing of the Mock request can be executed through the pre-configuration item.
[0084] Specifically, during the test process, based on the pre-configuration item corresponding to the request configuration information, the test process will be mocked into the request address specified by the pre-configuration item (for example, the host is set to 130.1.11.111 and the port is set to 8866), thereby realizing the requirements of the Mock test and will not affect other people's normal requests for the same interface (key methods) (because the Mock requests initiated by others do not correspond to the pre-configuration item).
[0085] The following is a detailed description of the pre-configuration items in this application:
[0086] In some embodiments, before S1, the method further includes:
[0087] The pre-configuration item information is obtained and saved, wherein the pre-configuration item information includes different configuration information corresponding to different Mock requests, and the configuration information includes application name, class name, and key methods.
[0088] For example, Figure 3 Schematic diagram of obtaining pre-configuration item information in an embodiment of the present application, such as Figure 3 As shown, testers can Figure 3 The page shown (the interactive interface provided by this application) adds relevant configuration items, and the configuration items that need to be filled in include application name, class name, and key methods.
[0089] In some embodiments, obtaining pre-configuration item information includes:
[0090] Obtaining newly added configuration information, including newly added application name, class name, and key methods;
[0091] Obtaining status setting information of the newly added configuration information;
[0092] Detailed editing information of the newly added configuration information is obtained, where the detailed editing information includes conditional editing information and value assignment editing information.
[0093] Figure 4 Another schematic diagram of obtaining pre-configuration item information in an embodiment of the present application is shown in FIG. Figure 4 As shown, the tester clicks Figure 3 Click the Add button in the Figure 4The page shown (interactive interface provided by this application) lists all currently configured information. Each row of configuration information will have an initial status of "off", and the tester can click the on button of the row configuration to turn the status to "on".
[0094] In some embodiments, the detailed editing information includes parameter location, member object name, and level status;
[0095] The hierarchical status includes final and non-final.
[0096] Figure 5 Schematic diagram of obtaining detailed editing information in the embodiment of the present application, such as Figure 5 As shown, the tester Figure 4 After clicking the edit button of a row of configuration information, the Figure 5 The page shown (interactive interface provided by this application) lists the editing information corresponding to the row of configuration information. For the newly added configuration information, the corresponding editing information is blank at first, and the tester needs to add relevant information. The editing information consists of two parts, namely condition information and assignment information. The tester can click Figure 5 Click the Add button (both condition and assignment information have Add buttons) to add a row of editing information;
[0097] In some embodiments, obtaining detailed editing information of the newly added configuration information includes:
[0098] When the hierarchical state is final, obtaining value attribute information of the newly added configuration information;
[0099] When the hierarchical state is non-final, the next layer of editing information of the newly added configuration information is obtained until the hierarchical state of the last layer is final.
[0100] Fig. 6A as well as Figure 6B Two other schematic diagrams for obtaining detailed editing information in the embodiments of the present application are shown in FIG. Fig. 6A as well as Figure 6B As shown, the tester Figure 5 Click the Add button to open Fig. 6A In the pop-up box shown (interactive interface provided by this application), the information that the tester needs to fill in includes parameter position, member object name, and select the level status (there are two options: non-final and final); if the selected level status is final, a new filling item "value" will be added below (such as Figure 6B After filling in all the information, click the Add button and you will see Figure 5A new row of editing information is added to the page. At this time, if the level status is non-final, the position of the field value will be displayed as an "Edit Next Level" button, otherwise it will be displayed as the corresponding value.
[0101] In some embodiments, obtaining the next layer of editing information of the newly added configuration information includes:
[0102] When the hierarchical status of the next layer is non-final, obtain the name of the newly added member object and the editing information of the next layer until the hierarchical status of the last layer is final;
[0103] When the hierarchical status of the next layer is final, the newly added member object name and value attribute information are obtained.
[0104] Figure 7 Schematic diagram of obtaining the next layer of editing information in the embodiment of the present application, such as Figure 7 As shown, the tester Figure 5 Click the "Edit Next Level" button on a row of edit information to open Figure 7 The page shown (interactive interface provided by this application) will display the next layer of information of the edited information of this row; it is also empty at the beginning. The tester can click the Add button to add this layer of edited information, and multiple rows can be added.
[0105] Fig. 8A as well as Figure 8B Two other schematic diagrams for obtaining newly added editing information in the embodiments of the present application are shown in FIG. Fig. 8A as well as Figure 8B As shown, the tester clicks Figure 7 After adding the button, it will open Fig. 8A The parent object name in the pop-up box cannot be modified. The default is the previous Figure 5 In addition, when the level status is selected as non-final, a new entry "value" will be added below (such as Figure 8B shown).
[0106] Fig. 9 and Fig.10 Two other schematic diagrams of obtaining the next layer of editing information in the embodiment of the present application are shown as follows: Fig. 9 and Fig.10 As shown, in Figure 7 On the page, if the hierarchical status of a row of edit information is non-final, the "Edit Next Level" button will also be displayed in the field value position, and the tester can continue to edit the information of the next level, and so on; and when adding the edit information of the next level, the parent object name in the pop-up box cannot be modified either, and the default is the member object name of the previous level (reference Figure 5 , Fig. 9 , Fig.10 ).
[0107] After the above configurations are completed, and Figure 4 When the status on the page is turned on, it means that the specified key method has been mocked successfully. At this time, the tester can start business testing. During the test, as long as the key method is called and meets the conditions in the configuration information, it will be mocked into the specified request address (such as Fig.10 Set the host to 130.1.11.111 and the port to 8866) to meet the needs of Mock testing without affecting other people's normal requests for the same interface (key methods) (because other people will not meet the conditions).
[0108] The following is a supplementary description of the steps of this application method:
[0109] In some embodiments, obtaining the newly added configuration information, obtaining the status setting information of the newly added configuration information, and obtaining the detailed editing information of the newly added configuration information are described in detail as follows:
[0110] Tester clicks Figure 3 After clicking the Add button, a request will be triggered to service A (the service of the interactive interface provided by this application). After receiving the request, service A will save the newly added configuration information to redis, where the value of the status field defaults to closed. Figure 4 When the tester clicks the "Enable" button on a row of configuration information, a request is sent to Service A. After receiving the request, Service A executes the following logic:
[0111] 1. Determine whether the current application has been mounted and monitored (such as kcard-xxx). The judgment method is to try to read the mount mark of the application saved in redis (get monitor:kcard-xxx). If the value can be read, it means that the application has been mounted and monitored, and then execute 2 directly; if the value cannot be read, execute the remote mount command and then execute 2. The command is: . / sandbox.sh-p 1-d'service-monitor / startMonit', where 1 is the application process, which is obtained by the command ps-ef|grep-i Obtained after executing kcard-xxx|awk'{print$2}' (for example, the current application is kcard-xxx); sandbox.sh is the mount monitoring command execution script of jvm-sandbox installed in advance on the server where the application is located; jvm-sandbox is a jvm-based process monitoring tool that can monitor the java process (i.e., application process) in the jvm. Similar tools include trace, arthas, etc. Therefore, if jvm-sandbox is not used, other monitoring tools can also be used to achieve the purpose; service-monitor / startMonit is the name of the monitoring logic implementation package of the interactive interface provided by this application, and the implementation logic is as follows:
[0112] (1) Monitor the execution of each method in the current application. When a method is called, the logic in (2) is triggered before it is executed.
[0113] (2) Determine whether the method is Figure 4 A key method in the list, if yes, execute (3);
[0114] (3) Determine whether the state configured by the key method is enabled. If yes, execute (4);
[0115] (4) Set a global variable flag with an initial value of true;
[0116] (5) Read the condition information of the key method (i.e. Figure 5 ), traverse each row of conditional information, and execute the following logic for each row:
[0117] (5-1) Get the parameter object at the specified parameter position of the key method (such as the parameter object at parameter position 2), and assign it to the configured parameter object name (such as callFactory, so that the parameter object can be accessed with this parameter object name later);
[0118] (5-2) Determine whether the level status is final. If so, then determine whether the value of the parameter object is equal to the configured value (such as 01). If not, set the flag to false and end the traversal of (5). If the level status is non-final, then read the configuration information of the next level (such as Figure 7 information shown);
[0119] (5-3) Traversal Figure 7 For each line of information in the message, the following logic is executed for each line:
[0120] (5-3-1) Use reflection to obtain the value of the specified member object in the parameter object (i.e. the parent object) (for example, obtain the value of the member object phone in the callFactory object);
[0121] (5-3-2) Determine whether the level status is final. If so, then determine whether the value of the member object is equal to the configured value (such as 18600000001). If not, set the flag to false and end the traversal of (5-3) and (5). If the level status is non-final, then read the configuration information of the next level.
[0122] (5-3-3) After reading the configuration information of the next layer, recursively execute the logic of (5-3);
[0123] (6) Determine the value of flag. If it is true, it means that all the conditions traversed in (5) are met, and then execute (7);
[0124] (7) Obtain the assignment information of the key method (i.e. Figure 5 ), traverse each row of assignment information, and execute the following logic for each row:
[0125] (7-1) Get the parameter object at the specified parameter position of the key method (such as the parameter object at parameter position 1), and assign it to the configured parameter object name (such as args, so that the parameter object can be accessed with this parameter object name later);
[0126] (7-2) Determine whether the hierarchical state is final. If so, assign the configured value to the parameter object at the current specified position (such as args = [env = weixin, pv = 10002]); if the hierarchical state is non-final (such as the requestFactory line)
[0127] , then read the configuration information of the next layer (such as Fig. 9 information shown);
[0128] (7-3) Traversal Fig. 9For each line of information in the message, the following logic is executed for each line:
[0129] (7-3-1) Use reflection to obtain the value of the specified member object in the parameter object (i.e. the parent object) (for example, obtain the value of the member object baseUrl in the requestFactory object);
[0130] (7-3-2) Determine whether the hierarchical state is final. If so, assign the configured value to the current member object. If the hierarchical state is non-final, then read the configuration information of the next layer (such as Fig.10 information shown);
[0131] (7-3-3) After reading the configuration information of the next layer, recursively execute the logic of (7-3).
[0132] 2. Change the status flag of the row configuration saved in redis to "on".
[0133] In some embodiments, obtaining conditional editing information and assigning value editing information are described in detail as follows:
[0134] Figure 5 The page consists of two parts: conditions and assignment. The assignment operation will be performed only when the input parameters of the key method meet the conditions.
[0135] by Figure 5 Take the configuration in as an example. When the key method is adapt, two lines of conditions need to be configured, namely, the parameter object callFactory with the parameter position 2 and the parameter object type with the parameter position 3. Only when these two conditions are met, the key method will be assigned in the future. The satisfied condition here means that when the hierarchical state of the configuration is final, the value of the parameter object is equal to the configured value, and when the hierarchical state of the configuration is non-final, the corresponding next layer of configuration information will be taken for judgment. For example, the hierarchical state of the parameter object type line is final, so when the key method is executed, it will be judged whether the value of type in the actual parameter is 01; and the hierarchical state of the parameter object callFactory line is non-final, so when judging, the configuration information of the next layer will be taken for judgment, such as Figure 7 The information shown; only when Figure 7 Only when the conditions of the callFactory line are met, the conditions of the callFactory line are considered met; Figure 7 When the condition is met, since the hierarchical status of the member object httpUrl row is non-final, the configuration information of the next layer will continue to be determined, and so on;
[0136] When the tester clicks Figure 4After clicking the edit button of a row of configuration information (such as the row with the key method adapt), a request will be triggered to service A. After receiving the request, service A reads the configuration information saved in redis (it is empty at the beginning and will have information after configuration) and returns a response. Figure 5 Rendering display on the page.
[0137] It can be understood that the above supplementary explanation is similar in principle in the process of S3 executing the Mock request.
[0138] The present application provides a mock method for serving internal interface requests. During the test process, based on the pre-configuration item corresponding to the request configuration information, the test process will be mocked into the request address specified by the pre-configuration item, thereby realizing the needs of the mock test without affecting other people's normal requests to the same interface.
[0139] It should be understood that, although the various steps in the flowcharts in the above-described embodiments are sequentially displayed according to the indications of the arrows, these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and they can be executed in other orders. Moreover, at least a portion of the steps in the figure may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily to be carried out sequentially, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0140] Fig.11 A schematic diagram of a mock device for a service internal interface request provided in an embodiment of the present application, such as Fig.11 As shown, the present application provides a Mock device for serving internal interface requests, the device comprising:
[0141] An acquisition module 11 is configured to respond to a Mock request for acquiring a service internal interface and acquire request configuration information corresponding to the Mock request;
[0142] A determination module 12, configured to determine a current state of a pre-configuration item corresponding to the requested configuration information;
[0143] The processing module 13 is configured to execute the processing of the Mock request based on the pre-configuration item corresponding to the request configuration information if the pre-configuration item corresponding to the request configuration information is currently in an enabled state.
[0144] Regarding the limitation of the mock device for the service internal interface request, reference may be made to the limitation of the mock method for the service internal interface request in the above embodiments of the present application, which will not be repeated in this embodiment.
[0145] Fig.12 Another schematic diagram of a mock device for a service internal interface request provided in an embodiment of the present application is shown in FIG. Fig.12 As shown, the device includes a memory 22 and a processor 21, the memory stores a computer program, and the processor is configured to run the computer program to execute the methods in the above embodiments of the present application.
[0146] The memory is connected to the processor, the memory may be a flash memory or a read-only memory or other memory, and the processor may be a central processing unit or a single-chip microcomputer.
[0147] In some embodiments, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the methods in the above embodiments of the present application are implemented.
[0148] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer.
[0149] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present application, but the present application is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and substance of the present application, and these modifications and improvements are also considered to be within the scope of protection of the present application.
Claims
1. A mock method for serving internal interface requests, characterized in that: The method comprises: S1. In response to a Mock request for obtaining a service internal interface, obtain request configuration information corresponding to the Mock request; S2. Determine the current state of the pre-configuration item corresponding to the requested configuration information; S3. If the pre-configuration item corresponding to the request configuration information is currently in an enabled state, the Mock request is processed based on the pre-configuration item corresponding to the request configuration information.
2. The mock method for service internal interface request according to claim 1, characterized in that: The request configuration information includes the application name, class name, and key methods of the Mock request; The key method is to initiate a request to the interface that needs a mock within the service. The class name is the class name corresponding to the key method; The application name is the name of the application to which the key method belongs.
3. The mock method for service internal interface request according to claim 1, characterized in that: Before S1, it also included: The pre-configuration item information is obtained and saved, wherein the pre-configuration item information includes different configuration information corresponding to different Mock requests, and the configuration information includes application name, class name, and key methods.
4. The Mock method for service internal interface request according to claim 3, characterized in that: Get pre-configuration item information, including: Obtaining newly added configuration information, including newly added application name, class name, and key methods; Obtaining status setting information of the newly added configuration information; Detailed editing information of the newly added configuration information is obtained, where the detailed editing information includes conditional editing information and value assignment editing information.
5. The Mock method for service internal interface request according to claim 4, characterized in that: The detailed editing information includes parameter position, member object name, and level status; The hierarchical status includes final and non-final.
6. The Mock method for service internal interface request according to claim 5, characterized in that: Obtain detailed editing information of the newly added configuration information, including: When the hierarchical state is final, obtaining value attribute information of the newly added configuration information; When the hierarchical state is non-final, the next layer of editing information of the newly added configuration information is obtained until the hierarchical state of the last layer is final.
7. The Mock method for service internal interface request according to claim 6, characterized in that: Obtaining the next level of editing information of the newly added configuration information includes: When the hierarchical status of the next layer is non-final, obtain the name of the newly added member object and the editing information of the next layer until the hierarchical status of the last layer is final; When the hierarchical status of the next layer is final, the newly added member object name and value attribute information are obtained.
8. A mock device for serving internal interface requests, characterized in that: The device comprises: An acquisition module, configured to respond to a Mock request for acquiring an internal interface of a service and acquire request configuration information corresponding to the Mock request; A determination module, configured to determine a current state of a pre-configuration item corresponding to the requested configuration information; The processing module is configured to execute the processing of the Mock request based on the pre-configuration item corresponding to the request configuration information if the pre-configuration item corresponding to the request configuration information is currently in an enabled state.
9. A mock device for serving internal interface requests, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement a mock method for a service internal interface request as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the Mock method for the service internal interface request according to any one of claims 1 to 7 is implemented.