CN116112377B - Interface simulation method, device, equipment and storage medium - Google Patents

Interface simulation method, device, equipment and storage medium Download PDF

Info

Publication number
CN116112377B
CN116112377B CN202211737738.7A CN202211737738A CN116112377B CN 116112377 B CN116112377 B CN 116112377B CN 202211737738 A CN202211737738 A CN 202211737738A CN 116112377 B CN116112377 B CN 116112377B
Authority
CN
China
Prior art keywords
simulation
interface
information
target
parameter value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211737738.7A
Other languages
Chinese (zh)
Other versions
CN116112377A (en
Inventor
胡鹏强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202211737738.7A priority Critical patent/CN116112377B/en
Publication of CN116112377A publication Critical patent/CN116112377A/en
Application granted granted Critical
Publication of CN116112377B publication Critical patent/CN116112377B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The disclosure provides an interface simulation method, device, equipment and storage medium, relates to the technical field of computer software testing, and aims to simulate an interface based on a simulation task edited by a user, and can directly simulate a specified interface without modifying codes, so that the accuracy and efficiency of interface simulation are improved. The method comprises the following steps: displaying a first display interface, wherein the first display interface is used for displaying a simulation task list to a user, and the simulation task list is used for indicating a simulated target interface and an operation key for editing a simulation task of the target interface; responding to the operation of the user on the operation key based on the first display interface, and triggering a monitoring event for editing the simulation task; editing the simulation task based on the monitoring event; simulating the target interface based on the edited target simulation task; the target simulation task includes simulation information indicating target response parameters of the target interface when called by the target call parameters.

Description

Interface simulation method, device, equipment and storage medium
Technical Field
The disclosure relates to the technical field of computer software testing, and in particular relates to an interface simulation method, an interface simulation device, interface simulation equipment and a storage medium.
Background
The mock test is to simulate the return content of the interface provided by the service and return the return content to the interface caller instead of the real content. Currently, in testing activities, for some relatively complex data/scenarios that are not easily constructed or easily available, a virtual simulation object is used to create a test method for testing.
At present, a tester can directly simulate a client interface by using a client agent, but when the method is adopted for simulation, the tester can only simulate an interface initiated from the front end and cannot simulate an interface in the server. The developer directly modifies the internal interface code of the server side to enable the internal interface of the server side to return to a certain fixed value, namely, the simulation of the internal interface of the server is realized, but the method requires the developer to manually modify the code and then redeploy the modified code, and the problems of manual modification errors and large workload in the code modification and deployment process exist, so that the efficiency and the accuracy cannot be effectively ensured.
Disclosure of Invention
In order to solve the problem that an internal interface cannot be directly simulated in the prior art, the present disclosure provides an interface simulation method, device, equipment and storage medium, wherein a user edits a simulation task first, and then simulates an interface based on the simulation task edited by the user, and the specified interface can be directly simulated without modifying a code, so that the accuracy and efficiency of interface simulation are improved.
In order to achieve the above purpose, the present disclosure adopts the following technical scheme:
in a first aspect, an interface simulation method is provided, where the method includes:
displaying a first display interface, wherein the first display interface is used for displaying a simulation task list to a user, and the simulation task list is used for indicating a simulated target interface and an operation key for editing a simulation task of the target interface;
Responding to the operation of the user on the operation key based on the first display interface, and triggering a monitoring event for editing the simulation task;
Editing the simulation task based on the monitoring event;
Simulating the target interface based on the edited target simulation task; the target simulation task includes simulation information for indicating a target response parameter of the target interface when the target interface is called by a target call parameter.
With reference to the first aspect, in one possible implementation manner, simulating the target interface based on the edited target simulation task includes:
judging whether the called object is a target interface in the simulation task list;
responding to the called object as a target interface in the simulation task list, and reading a plurality of simulation tasks of the target interface;
and simulating the target interface based on the simulation tasks.
With reference to the first aspect, in a possible implementation manner, each piece of simulation information includes a simulation input parameter value and a simulation response value;
simulating the target interface based on the plurality of simulation information, including:
acquiring an actual input parameter value corresponding to the target interface;
Traversing all simulation information, and determining target simulation information based on the actual input parameter value, wherein the actual input parameter value comprises all fields in the simulation input parameter value in the target simulation information;
And determining a call response value of the target interface based on the simulation response value in the target simulation information.
With reference to the first aspect, in one possible implementation manner, traversing all simulation information and determining target simulation information based on the actual parameter value includes:
obtaining a matching variable, wherein the matching variable comprises matching information and a matching value;
determining current simulation information, and judging whether each field in the simulation parameter value of the current simulation information is included in the actual parameter value;
responding to each field in the simulation input parameter value including the current simulation information in the actual input parameter value, and acquiring the number of fields in the simulation input parameter value in the current simulation information;
In response to the number of fields in the simulated parameter value in the current simulation information being greater than the matching variable, replacing the matching value in the matching variable with the number of fields in the simulated parameter value in the current simulation information, replacing the matching information in the matching variable with the simulated parameter value in the current simulation information, and returning to the step of determining the current simulation information;
Responding to the fact that the number of fields in the simulated parameter value in the current simulation information is smaller than or equal to the matching variable, and returning to the step of determining the current simulation information;
and determining the matching information in the matching variables as target simulation information.
With reference to the first aspect, in a possible implementation manner, the method further includes:
Receiving a simulation instruction of the user on the target interface, wherein the simulation instruction is used for indicating the simulated target interface, and the simulation instruction comprises interface information of the target interface;
And in response to the simulation instruction, configuring the interface information of the target interface into the simulation task list.
With reference to the first aspect, in one possible implementation manner, receiving a simulation instruction of the user to the target interface includes:
displaying a second display interface, wherein the second display interface is used for displaying input items of interface information to a user;
And receiving interface information of the target interface input by the user based on the second display interface and the simulation instruction sent by the user operation monitoring key.
With reference to the first aspect, in a possible implementation manner, the operation key includes an edit key, where the edit key is used to trigger a listening event for editing the interface information;
Editing the simulation task based on the monitoring event, including:
changing a text box in the simulation task list into a changeable state, and displaying a submit button corresponding to the text box; the text box corresponds to interface information for indicating the monitored target interface;
And responding to the clicking operation of the user on the submitting button, saving the interface information of the current text in the text box as the monitored target interface, and changing the text box into an unchangeable state.
In a second aspect, there is provided an interface simulation apparatus, the apparatus comprising:
The first display module is used for displaying a first display interface, the first display interface is used for displaying a simulation task list to a user, and the simulation task list is used for indicating a simulated target interface and operation keys for editing simulation tasks of the target interface;
the monitoring event triggering module is used for responding to the operation of the user on the operation key based on the first display interface and triggering a monitoring event for editing the simulation task;
The simulation task editing module is used for editing the simulation task based on the monitoring event;
The simulation module is used for simulating the target interface based on the edited target simulation task; the target simulation task includes simulation information for indicating a target response parameter of the target interface when the target interface is called by a target call parameter.
With reference to the second aspect, in one possible implementation manner, the analog module includes:
The called object judging unit is used for judging whether the called object is a target interface in the simulation task list or not;
the simulation task reading unit is used for responding to the called object as a target interface in the simulation task list and reading a plurality of simulation information of the target interface;
And the simulation unit is used for simulating the target interface based on the plurality of simulation information.
With reference to the second aspect, in a possible implementation manner, each analog information includes an analog input parameter value and an analog response value;
The simulation unit includes:
An actual parameter obtaining subunit, configured to obtain an actual parameter value corresponding to the target interface;
The target task determining subunit is used for traversing all simulation information and determining target simulation information based on the actual input parameter value, wherein the actual input parameter value comprises all fields in the simulation input parameter value in the target simulation information;
And the call response value determining subunit is used for determining the call response value of the target interface based on the simulation response value in the target simulation information.
With reference to the second aspect, in one possible implementation manner, the target task determining subunit includes:
a matching variable obtaining subunit, configured to obtain a matching variable, where the matching variable includes matching information and a matching value;
the current simulation information judging subunit is used for determining current simulation information and judging whether the actual input parameter value comprises each field in the simulation input parameter value of the current simulation information;
A field number obtaining subunit, configured to obtain, in response to each field in the analog input parameter value that includes the current analog information in the actual input parameter value, a field number in the analog input parameter value in the current analog information;
A matching variable updating subunit, configured to replace a matching value in the matching variable with a field number in the analog input parameter in the current analog information, and replace the matching information in the matching variable with the analog input parameter in the current analog information, in response to the field number in the analog input parameter in the current analog information being greater than the matching variable, and return to the step of determining the current analog information;
Responding to the fact that the number of fields in the simulated parameter value in the current simulation information is smaller than or equal to the matching variable, and returning to the step that the current simulation information judging subunit determines the current simulation information;
And the target simulation information determining subunit is used for determining the matching information in the matching variables as target simulation information.
With reference to the second aspect, in one possible implementation manner, the apparatus further includes:
The simulation instruction receiving module is used for receiving a simulation instruction of the user on the target interface, wherein the simulation instruction is used for indicating the simulated target interface, and the simulation instruction comprises interface information of the target interface;
And the simulation task list configuration module is used for responding to the simulation instruction and configuring the interface information of the target interface into the simulation task list.
With reference to the second aspect, in one possible implementation manner, the analog instruction receiving module includes:
the second display unit is used for displaying a second display interface, and the second display interface is used for displaying input items of interface information to a user;
And the simulation instruction receiving unit is used for receiving the interface information of the target interface input by the user based on the second display interface and the simulation instruction sent by the user operation monitoring key.
With reference to the second aspect, in one possible implementation manner, the operation key includes an edit key, where the edit key is used to trigger a listening event for editing the interface information;
The simulation task editing module comprises:
a text box display unit for changing the text box in the simulation task list to a changeable state and displaying a submit button corresponding to the text box; the text box corresponds to interface information for indicating the monitored target interface;
and the interface information storage unit is used for responding to the clicking operation of the user on the submitting button, storing the interface information of which the current text in the text box is the monitored target interface, and changing the text box into an unchangeable state.
In a third aspect, there is provided an interface simulation apparatus comprising: a processor and a memory; wherein the memory is configured to store computer-executable instructions that, when the interface simulation device is operating, the processor executes the computer-executable instructions stored by the memory to cause the interface simulation device to perform the interface simulation method as described in any one of the possible implementations of the first aspect and the first aspect.
In a fourth aspect, the present disclosure provides a computer readable storage medium having instructions stored therein which, when executed by a processor of an interface simulation device, enable the interface simulation device to perform the interface simulation method as described in any one of the possible implementations of the first aspect and the first aspect.
In the present disclosure, the names of the above-mentioned interface simulation devices do not constitute limitations on the devices or function modules themselves, and in actual implementations, these devices or function modules may appear under other names. Insofar as the function of each device or function module is similar to the present disclosure, it is within the scope of the claims of the present disclosure and the equivalents thereof.
These and other aspects of the disclosure will be more readily apparent from the following description.
The technical scheme provided by the disclosure at least brings the following beneficial effects: the interface simulation method provided by the disclosure comprises the following steps: displaying a first display interface, wherein the first display interface is used for displaying a simulation task list to a user, and the simulation task list is used for indicating a simulated target interface and an operation key for editing a simulation task of the target interface; responding to the operation of the user on the operation key based on the first display interface, and triggering a monitoring event for editing the simulation task; editing the simulation task based on the monitoring event; simulating the target interface based on the edited target simulation task; the target simulation task includes simulation information for indicating a target response parameter of the target interface when the target interface is called by a target call parameter. The method enables the user to edit the simulation task, and then simulate the interface based on the simulation task edited by the user, so that the simulation of the appointed interface and the appointed scene data can be realized on the premise of hardly consuming extra manpower time. And because the simulation data included in the simulation task corresponding to each target interface can be multiple, the simultaneous simulation of the data of the same target interface in different scenes can be realized without modifying and redeploying the back-end service or the monitoring service, thereby improving the testing efficiency and reducing the risk of manual errors.
Drawings
Fig. 1 is a schematic flow chart of an interface simulation method provided in the present disclosure;
FIG. 2 is a schematic illustration of a first display interface provided by the present disclosure;
FIG. 3 is a schematic diagram of a front end page provided by the present disclosure;
FIG. 4 is a schematic diagram of an analog information augmentation operation page provided by the present disclosure;
FIG. 5 is a schematic diagram of an internal flow of an interface simulation method provided by the present disclosure;
FIG. 6 is a schematic diagram of a second display interface provided by the present disclosure;
FIG. 7 is a schematic illustration of another first display interface provided by the present disclosure;
fig. 8 is a schematic structural diagram of an interface simulation device provided in the present disclosure;
fig. 9 is a schematic hardware structure of an interface simulation device provided in the present disclosure.
Detailed Description
The following describes in detail an interface simulation method, an apparatus and a storage medium provided by embodiments of the present disclosure with reference to the accompanying drawings.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone.
The terms "first" and "second" and the like in the description and in the drawings of the present disclosure are used for distinguishing between different objects or for distinguishing between different processes of the same object and not for describing a particular sequential order of objects.
Furthermore, references in the description of this disclosure to the terms "comprise" and "have," and any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed but may optionally include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It should be noted that in the embodiments of the present disclosure, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g." in the examples of this disclosure should not be taken as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
Simulation testing refers to simulating the returned content of the interface provided by the service and returning the simulated returned content to the interface caller instead of the real content. At present, there are several ways to perform simulation test, for example, a tester may use a client agent tool, such as fiddler, through which a tester can directly simulate an interface of a client, however, the tester can only simulate an interface initiated from a front end of the client through the client agent tool, but cannot simulate an interface inside a server, and for example, assuming that the front end of the client invokes an interface a and the interior of the interface a invokes an interface B, the client agent tool can only simulate an interface a and cannot simulate an interface B. In order to simulate the interface inside the server, the developer may also directly modify the interface code on the server, so that the interface on the server returns a fixed certain value. However, when the simulation of the interface is realized by changing the code, the code is modified each time when different contents corresponding to different scenes are simulated, and the modified code is redeployed, so that a great amount of manpower and time are required to be consumed, and the risk of certain manual errors is provided, for example, if the simulated code is not changed back to the code of the formal release version after the code is modified for a certain time, the simulated code is wrongly released to the formal environment, and the normal call of the service interface cannot be ensured.
In order to solve the above technical problems, the present application provides an interface simulation method, please refer to fig. 1, fig. 1 is a flow chart of an interface simulation method provided by the present disclosure, the method includes the following steps:
Step S110: and displaying the first display interface.
Referring to fig. 2, fig. 2 is a schematic diagram of a first display interface, where the first display interface is used to display a simulation task list to a user, and the simulation task list is used to indicate a target interface to be simulated and operation keys for editing a simulation task of the target interface. The first row of the table in the first display interface shown in fig. 2 represents a name of each data in each simulation task, for example, the second row of the table represents a service name kcard-Auth, a package name kcard.src.java.controller, a class name Auth, and a method name logic of the target interface, the state of the target interface is normal, and the operation keys performed on the simulation task corresponding to the target interface include an edit key, a suspend key, a delete key, and a data key. The state of the target interface is used for indicating the state of simulating the target interface, specifically, if the state of the target interface corresponding to the first line of simulation task is normal, the state of simulating the target interface is in a normal simulation state, and if the state of the target interface corresponding to the second line of simulation task is suspended, the state of simulating the target interface is not performed, but the simulation task of the target interface still exists in the simulation task list. As shown in fig. 2, the operation keys for editing the simulation task of the target interface include two cases, when the state of the target interface is normal, the corresponding operation keys include an editing key, a suspension key, a delete key and a data key, and when the state of the target interface is suspended, the corresponding operation keys include an editing key, a loading key, a delete key and a data key.
Step S120: and responding to the operation of the user on the operation key based on the first display interface, and triggering a monitoring event for editing the simulation task.
When the user operates the operation key on the first display interface, the monitoring time for editing the simulation task can be triggered, as shown in fig. 2, the user can click any key in the operation bar, so as to trigger a monitoring event for editing the simulation task. A snoop event is a response to an event that occurs after waiting for the event to occur. For example, after the user operates the edit key in fig. 2, a new page is opened in response to the operation of the edit key, which is a listening event.
Step S130: editing the simulation task based on the monitoring event.
Based on the listening time triggered by the user's operation, the simulation task may be edited, for example, the user clicks the data button in fig. 2, that is, opens the front-end page shown in fig. 3, and when the front-end page is opened, triggers a request for querying data from the cache, so as to read the simulation information of the method information stored in the cache, and returns the simulation information to the front-end page, where all the simulation information read from the cache is displayed by the front-end page shown in fig. 3. If the simulation information corresponding to the target interface is not read in the cache, the front page only comprises one row of empty data, and the operation column only displays one newly added key. If the simulation information corresponding to the target interface is read in the cache, displaying each row of simulation information in the list shown in fig. 3, and displaying two keys in each row of operation columns: edit keys and delete keys. And a row of blank data is reserved in the last row, and an operation column displays a new key so as to facilitate the addition of new simulation information by a tester. After clicking the editing key, the user sets the text boxes corresponding to the two columns of the input text and the response text of the editing key to be in an editable state, and changes the editing key into a submitting key. At this time, the user can change the related value in the text box in the editable state, and after the modification is completed, the user clicks the submit button to update and save the simulation information of the modified line in the cache, so that the simulation information of the line in the cache is modified into the latest content. The text box in the page is again placed in a non-editable state while the user clicks the submit button. After clicking the delete key, the user deletes the line of analog information corresponding to the delete key in the cache and the front page. After clicking the newly added key, the user opens a new flick frame, as shown in fig. 4, and inputs the simulation information required to be newly added, namely, the input parameter and response, and click the determination key in the page shown in fig. 4, so that the input parameter and response input by the user can be newly added to fig. 3 as the new simulation information, and meanwhile, the new simulation information is saved in the cache. When the user clicks the determining key in fig. 4, the interface shown in fig. 4 is closed, and the page in fig. 3 is returned again, at this time, all the simulation information of the target interface is obtained again from the cache, and all the simulation information is displayed in the page shown in fig. 3, so that the simulation information shown in fig. 3 is ensured to be changed in real time according to the editing of the user. It can be understood that after the user clicks the new key, the input of the analog information may be directly performed in fig. 3, for example, the entering of the last line shown in fig. 3 and the response of the corresponding blank text input box may be changed to an editable state, so that the user may input the analog information in the response text input box, and at the same time, the submit key is displayed at the operation field where the new key is displayed. After the user inputs the parameter entering and responding in the text input box, clicking the submitting key, and then keeping the parameter entering and responding input in the text input box by the user, and simultaneously changing the submitting key displayed in the original operation column into an editing key and a deleting key.
Step S140: and simulating the target interface based on the edited target simulation task.
The target simulation task includes simulation information for indicating a target response parameter of the target interface when the target interface is called by a target call parameter. As shown in FIG. 3, when the reference is "phone" 131XXXX3335, "response is" code "10000", "result" logic_success "," id "123123," the actual reference in the call request of the target interface is "phone" 131XXXX3335", the target interface is simulated, and" code "10000", "result" logic_success "," id "123123 are returned. "it can be understood that when the actual call-in parameter in the call request of the target interface is" phone "131XXXX3334", since the simulation information in the target simulation task has no target call parameter matched with the actual call-in parameter, i.e. the set call-in parameter value, the real response of the target interface is returned to the caller.
The method enables the user to edit the simulation task, and then simulate the interface based on the simulation task edited by the user, so that the simulation of the appointed interface and the appointed scene data can be realized on the premise of hardly consuming extra manpower time. And because the simulation data included in the simulation task corresponding to each target interface can be multiple, the simultaneous simulation of the data of the same target interface in different scenes can be realized without modifying and redeploying the back-end service or the monitoring service, thereby improving the testing efficiency and reducing the risk of manual errors.
In a possible implementation manner, step S140 of simulating the target interface based on the edited target simulation task includes the following steps S141-S143, please refer to fig. 5:
step S141: and judging whether the called object is a target interface in the simulation task list.
When your called object is the target interface, it needs to monitor all methods under the current service, and before a certain method is called and executed, it determines whether the called method is the target interface in the simulation task list as shown in fig. 2, specifically, it can query from the cache whether the information of the method is saved, for example, the service, package, class, method and the like saved in the cache are consistent with the called method, and then it indicates that the called method is the target interface.
Step S142: and responding to the called object as the target interface in the simulation task list, and reading a plurality of simulation information of the target interface.
The analog information includes analog input parameter values and analog response values. It can be understood that after judging that the called object is the target interface in the simulation task list, the state corresponding to the target interface can be also judged, and when the state of the target interface is normal, a plurality of simulation information of the target interface is read to simulate the target interface. If the state of the target interface is suspended, the target interface is not simulated, and suspension can be realized in a mode of not reading any simulation information corresponding to the target interface.
Step S143: and simulating the target interface based on the plurality of simulation information.
The step S143 of simulating the target interface based on the multiple simulation information includes the following three steps:
and step 1, acquiring an actual input parameter value corresponding to the target interface.
And step 2, traversing all simulation information, and determining target simulation information based on the actual input parameter value.
The actual input parameter value comprises all fields in the simulation input parameter value in the target simulation information.
And step 3, determining the call response value of the target interface based on the simulation response value in the target simulation information.
The method comprises the following six steps of traversing all simulation information and determining target simulation information based on the actual input parameter values:
Step 1: and obtaining a matching variable, wherein the matching variable comprises matching information and a matching value.
Step 2: and determining the current simulation information, and judging whether each field in the simulation parameter value of the current simulation information is included in the actual parameter value.
Step 3: and responding to each field in the simulation input parameter value including the current simulation information in the actual input parameter value, and acquiring the number of fields in the simulation input parameter value in the current simulation information.
Step 4: and 2, replacing the matching value in the matching variable with the field number in the analog input parameter value in the current analog information and replacing the matching information in the matching variable with the analog input parameter value in the current analog information in response to the field number in the analog input parameter value in the current analog information being larger than the matching variable, and returning to the step for determining the current analog information.
Step 5: and 2, returning to the step of determining the current simulation information in response to the fact that the number of fields in the simulation parameter value in the current simulation information is smaller than or equal to the matching variable.
Step 6: and determining the matching information in the matching variables as target simulation information.
When judging whether the actual input parameter value includes each field in the simulation input parameter value of the current simulation information, performing regular matching operation by using each field of the simulation input parameter value configured in the simulation information and the actual input parameter value corresponding to the target interface, and if the actual input parameter value is true, namely, when each field in the simulation input parameter value including the current simulation information in the actual input parameter value, performing next processing. For example, assume that the configured analog entry value is { "phone": "131XXXX3335" }, while the actual entry value is { "phone": "131XXXX3335", "channel": "wx", "timestamp": "1662866446869", "usertype": "newUser" }, then match to true. Assuming that the configured analog input parameter value is { "phone": "131XXXX3335", "channel": "st" }, the corresponding actual input parameter value is still { "phone": "131XXXX3335", "channel": "wx", "timestamp": "1662866446869", "usertype": "newUser" }, the matching is false.
And in response to each field in the simulation input parameter value including the current simulation information in the actual input parameter value, acquiring the number of fields in the simulation input parameter value in the current simulation information, for example, the simulation input parameter value in the simulation input parameter value is { "phone": "131XXXX3335" }, and the acquired number of fields is 1 if each field in the simulation input parameter value is included in the simulation input parameter value. For another example, the analog input parameter value in the analog input parameter values is { "phone": "131XXXX3335", "channel": "wx" }, and the analog input parameter value includes each field in the analog input parameter value, then the number of acquired fields is 2.
And in response to the number of fields in the simulated parameter value in the current simulation information being greater than the matching variable, replacing the matching value in the matching variable with the number of fields in the simulated parameter value in the current simulation information, and replacing the matching information in the matching variable with the simulated parameter value in the current simulation information. For example, the match variable is TMPPARAMS, and the match variable TMPPARAMS includes the match information param and the match value cnt. The simulated parameter value and the field number can be respectively stored in the matching information param and the matching value cnt in the variable TMPPARAMS. For example, if the analog input parameter value is { "phone": "131XXXX3335" } matches true, then the value saved to variable TMPPARAMS is { "param": "{" phone ":"131XXXX3335"}", "cnt": "1" }.
And continuing traversing the simulation information, namely continuing returning to the step of determining the current simulation information, performing regular matching operation on the simulation input parameter value of the simulation information of the next row and the corresponding actual input parameter value, and if the matching is true and the field number of the simulation input parameter value in the current simulation information is larger than the cnt currently stored in the variable TMPPARAMS, storing the simulation input parameter value and the field number in the current simulation information into the variable TMPPARAMS to cover the previously stored value. By way of example, assuming that the simulated parameter value in the simulated information of the current traversal is { "phone": "131XX 3335", "channel": "wx" }, the actual parameter value is { "phone": "131XXXX3335", "channel": "wx", "timestamp": "1662866446869", "usertype": "newUser" }, then the matching is successful, then the values saved to TMPPARAMS are { "param": "{" phone ":"131XXXX3335"," channel ":" wx "}," cnt ":"2"}.
After all the analog information has been traversed, the variable TMPPARAMS holds the analog input parameter that matches the actual input parameter to the highest degree. At this time, the value of the param in TMPPARAMS is read, and the value is used as a key to query the response value of the analog data stored in the cache. As in the example above, the final param value is { "phone": "131XXXX3335", "channel": "wx" }, and then the corresponding response value is { "code": "3XXXX", "result": "logic_failed", "id": "456456" }, which can be queried in the analog information as shown in the configuration of FIG. 3. And taking the queried response value as the response content of the target interface, and returning the response content to the caller instead of the real response content.
It can be understood that in the above process, if the value TMPPARAMS is read and found to be null, it is indicated that all the analog information and the actual parameter entry fail to match, and at this time, the target interface is directly executed without additional processing, and the actual response value after the execution of the target interface is returned to the caller.
In one possible implementation manner, the method further includes the following processes: firstly, receiving a simulation instruction of the user on the target interface, wherein the simulation instruction is used for indicating the simulated target interface, the simulation instruction comprises interface information of the target interface, and then, responding to the simulation instruction, configuring the interface information of the target interface into the simulation task list.
Illustratively, when receiving the simulation instruction of the user to the target interface, a second display interface is displayed, as shown in fig. 6, where the second display interface is used to display the input item of the interface information to the user. And receiving interface information of the target interface input by the user based on the second display interface and the simulation instruction sent by the user operation monitoring key.
After the user inputs interface information of the interface on the second display interface, clicking a 'newly added' button, the interface information input by the user is stored in a cache redis, and the interface information contains a state field, wherein the state field is automatically assigned and is assigned to be 1, that is, the validity of the newly added interface information is normally in a simulation state. When the user has manipulated a piece of configuration information to be suspended in the page shown in fig. 2, the status field information is assigned a value of 0, which represents a suspended state, i.e., the target interface is not emulated. With continued reference to fig. 2, the operation keys include an edit key for triggering a listening event for editing the interface information;
When editing the simulation task based on the monitoring event, a text box in the simulation task list can be changed into a changeable state, and a submit button corresponding to the text box is displayed; the text box corresponds to interface information indicating the monitored target interface. For example, after clicking the edit key of the second row operation bar in the first display interface in fig. 2, the first display interface becomes as shown in fig. 7, at this time, the second row changes the text box of the corresponding row of four columns of service, package, class, and method to the modifiable state, and the edit key in the operation bar becomes the submit key. The user can make text modification in the text box in the changeable state in fig. 7, and after the user completes the modification, the user clicks the submit button. And responding to clicking operation of a user on a submit button, saving interface information of which the current text in the text box is the monitored target interface, and changing the text box into an unchangeable state. At the same time, the submit button changes back to the edit button as shown in FIG. 2.
After the user clicks the suspend button, the state field of the corresponding target interface is updated in the cache, the normal state is changed to be suspended, and the state field of the corresponding row in the first display interface is displayed as suspended. After the user clicks the load button, the state field of the corresponding target interface is updated in the cache, the suspension is changed to be normal, and the state field of the corresponding row in the first display interface is displayed to be normal.
After clicking the delete key, the user deletes the interface information of the corresponding target interface in the cache, and the data of the corresponding row in the first display interface is deleted and is not displayed any more.
After clicking the data key, the user opens the front-end interface as shown in fig. 3, for allowing analog information to be input in the interface.
It can be seen that the foregoing description has mainly been presented with respect to a method of providing a technical solution according to an embodiment of the present disclosure. To achieve the above functions, it includes corresponding hardware structures and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the various illustrative modules and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The embodiment of the disclosure may divide the functional modules of the interface simulation device according to the above method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated in one processing module. The integrated modules may be implemented in hardware or in software functional modules. Optionally, the division of the modules in the embodiments of the present disclosure is schematic, which is merely a logic function division, and other division manners may be actually implemented.
As shown in fig. 8, an interface simulation apparatus 800 according to an embodiment of the disclosure includes:
The first display module 810 is configured to display a first display interface, where the first display interface is configured to display a simulation task list to a user, where the simulation task list is configured to indicate a target interface to be simulated and an operation key for editing a simulation task of the target interface;
A monitor event triggering module 820, configured to trigger a monitor event for editing the simulation task in response to an operation of the operation key by the user based on the first display interface;
The simulation task editing module 830 is configured to edit the simulation task based on the listening event;
The simulation module 840 is configured to simulate the target interface based on the edited target simulation task; the target simulation task includes simulation information for indicating a target response parameter of the target interface when the target interface is called by a target call parameter.
Optionally, in one possible implementation manner, the above simulation module includes:
The called object judging unit is used for judging whether the called object is a target interface in the simulation task list or not;
The simulation information reading unit is used for responding to the called object as a target interface in the simulation task list and reading a plurality of simulation information of the target interface;
And the simulation unit is used for simulating the target interface based on the simulation information.
Optionally, in one possible implementation, each analog information includes an analog input parameter value and an analog response value;
The simulation unit includes:
An actual parameter obtaining subunit, configured to obtain an actual parameter value corresponding to the target interface;
The target task determining subunit is used for traversing all simulation information and determining target simulation information based on the actual input parameter value, wherein the actual input parameter value comprises all fields in the simulation input parameter value in the target simulation information;
And the call response value determining subunit is used for determining the call response value of the target interface based on the simulation response value in the target simulation information.
Optionally, in one possible implementation manner, the target task determining subunit includes:
a matching variable obtaining subunit, configured to obtain a matching variable, where the matching variable includes matching information and a matching value;
the current simulation information judging subunit is used for determining current simulation information and judging whether the actual input parameter value comprises each field in the simulation input parameter value of the current simulation information;
A field number obtaining subunit, configured to obtain, in response to each field in the analog input parameter value that includes the current analog information in the actual input parameter value, a field number in the analog input parameter value in the current analog information;
A matching variable updating subunit, configured to replace a matching value in the matching variable with a field number in the analog input parameter in the current analog information, and replace the matching information in the matching variable with the analog input parameter in the current analog information, in response to the field number in the analog input parameter in the current analog information being greater than the matching variable, and return to the step of determining the current analog information;
Responding to the fact that the number of fields in the simulated parameter value in the current simulation information is smaller than or equal to the matching variable, and returning to the step that the current simulation information judging subunit determines the current simulation information;
And the target simulation information determining subunit is used for determining the matching information in the matching variables as target simulation information.
Optionally, in one possible implementation manner, the apparatus further includes:
The simulation instruction receiving module is used for receiving a simulation instruction of the user on the target interface, wherein the simulation instruction is used for indicating the simulated target interface, and the simulation instruction comprises interface information of the target interface;
And the simulation task list configuration module is used for responding to the simulation instruction and configuring the interface information of the target interface into the simulation task list.
Optionally, in one possible implementation, the analog instruction receiving module includes:
the second display unit is used for displaying a second display interface, and the second display interface is used for displaying input items of interface information to a user;
And the simulation instruction receiving unit is used for receiving the interface information of the target interface input by the user based on the second display interface and the simulation instruction sent by the user operation monitoring key.
Optionally, in a possible implementation manner, the operation key includes an edit key, where the edit key is used to trigger a listening event for editing the interface information;
The simulation task editing module comprises:
a text box display unit for changing the text box in the simulation task list to a changeable state and displaying a submit button corresponding to the text box; the text box corresponds to interface information for indicating the monitored target interface;
and the interface information storage unit is used for responding to the clicking operation of the user on the submitting button, storing the interface information of which the current text in the text box is the monitored target interface, and changing the text box into an unchangeable state.
The embodiment of the disclosure provides an interface simulation device for executing a method required to be executed by any device in the data integrity determination system. The interface simulation device may be an interface simulation device referred to in the present disclosure, or a module in an interface simulation apparatus; or a chip in the interface simulation device, or other devices for performing the interface simulation method, which is not limited in this disclosure.
When implemented in hardware, the specific implementation manner of the interface simulation device in the embodiment of the present application is shown in fig. 9, and fig. 9 is a schematic structural diagram of an interface simulation device provided in an embodiment of the present disclosure, where the interface simulation device 900 includes at least one processor 901, a communication line 902, at least one communication interface 904, and may further include a memory 903. The processor 901, the memory 903, and the communication interface 904 may be connected by a communication line 902.
Processor 901 may be a central processing unit (central processing unit, CPU), an Application SPECIFIC INTEGRATED Circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present disclosure, such as: one or more digital signal processors (DIGITAL SIGNAL processors, DSPs), or one or more field programmable gate arrays (field programmable GATE ARRAY, FPGAs).
Communication line 902 may include a path for communicating information between the components described above.
The communication interface 904, for communicating with other devices or communication networks, may use any transceiver-like device, such as ethernet, radio access network (radio access network, RAN), wireless local area network (wireless local area networks, WLAN), etc.
The memory 903 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (ELECTRICALLY ERASABLE PROGRAMMABLE RE AD-only memory, EEPROM), a compact disc (compact disc read-only memor y, CD-ROM) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to contain or store the desired program code in the form of instructions or data structures and that can be accessed by a computer.
In a possible design, the memory 903 may exist independent of the processor 901, i.e., the memory 903 may be a memory external to the processor 901, where the memory 903 may be connected to the processor 901 through a communication line 902, for storing execution instructions or application program codes, and the execution is controlled by the processor 901 to implement an interface simulation method provided in the embodiments of the present disclosure described below. In yet another possible design, the memory 903 may be integrated with the processor 901, i.e., the memory 903 may be an internal memory of the processor 901, e.g., the memory 903 may be a cache, and may be used to temporarily store some data and instruction information, etc.
As one implementation, processor 901 may include one or more CPUs, such as CPU0 and CPU1 in fig. 9. As another implementation, interface simulation device 900 may include multiple processors, such as processor 901 and processor 907 in fig. 9. As yet another implementation, the interface simulation device 900 may also include an output device 905 and an input device 906.
From the foregoing description of the embodiments, it will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of functional modules is illustrated, and in practical application, the above-described functional allocation may be implemented by different functional modules according to needs, i.e. the internal structure of the network node is divided into different functional modules to implement all or part of the functions described above. The specific working processes of the above-described system, module and network node may refer to the corresponding processes in the foregoing method embodiments, which are not described herein.
The present disclosure also provides a computer-readable storage medium having instructions stored therein, which when executed by a computer, perform the steps of the method flow shown in the method embodiments described above.
The computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: electrical connections having one or more wires, portable computer diskette, hard disk. Random access Memory (Random Access Memory, RAM), read-Only Memory (ROM), erasable programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), registers, hard disk, optical fiber, portable compact disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any other form of computer-readable storage medium suitable for use by a person or in combination with any other form of data in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an Application SPECIFIC INTEG RATED Circuit (ASIC). In the disclosed embodiments, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
Embodiments of the present disclosure provide a chip comprising a processor and a communication interface coupled to the processor for running a computer program or instructions to implement an interface simulation method as in the method embodiments described above. Since the apparatus, device, computer readable storage medium, and computer program product in the embodiments of the present disclosure may be applied to the above-mentioned method, the technical effects that may be obtained by the apparatus, device, computer readable storage medium, and computer program product may also refer to the above-mentioned method embodiments, and the embodiments of the present disclosure are not repeated herein.
In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the above-described device embodiments are merely illustrative, e.g., the division of the above-described elements is merely a logical functional division, and may be implemented in other ways, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, indirect coupling or communication connection of devices or units, electrical, mechanical, or other form.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The foregoing is merely a specific embodiment of the disclosure, but the protection scope of the disclosure is not limited thereto, and any changes or substitutions within the technical scope of the disclosure should be covered by the protection scope of the disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims (7)

1. An interface simulation method, the method comprising:
Displaying a first display interface, wherein the first display interface is used for displaying a simulation task list to a user, and the simulation task list is used for indicating a simulated target interface and an operation key for editing a simulation task of the target interface;
responding to the operation of the user on the operation key based on the first display interface, and triggering a monitoring event for editing the simulation task;
Editing the simulation task based on the monitoring event;
Judging whether the called object is a target interface in the simulation task list;
Responding to the called object as a target interface in the simulation task list, and reading a plurality of simulation information of the target interface;
acquiring an actual input parameter value corresponding to the target interface;
obtaining a matching variable, wherein the matching variable comprises matching information and a matching value;
determining current simulation information, and judging whether each field in the simulation parameter value of the current simulation information is included in the actual parameter value;
Responding to each field in the simulation input parameter value including the current simulation information in the actual input parameter value, and acquiring the number of fields in the simulation input parameter value in the current simulation information;
responding to the fact that the field number in the analog input parameter value in the current analog information is larger than the matching variable, replacing the matching value in the matching variable with the field number in the analog input parameter value in the current analog information, replacing the matching information in the matching variable with the analog input parameter value in the current analog information, and returning to the step of determining the current analog information;
responding to the fact that the number of fields in the simulated parameter value in the current simulation information is smaller than or equal to the matching variable, and returning to the step of determining the current simulation information;
Determining the matching information in the matching variable as target simulation information;
And determining a call response value of the target interface based on the simulation response value in the target simulation information.
2. The method according to claim 1, wherein the method further comprises:
receiving a simulation instruction of the user on the target interface, wherein the simulation instruction is used for indicating the simulated target interface, and the simulation instruction comprises interface information of the target interface;
And responding to the simulation instruction, and configuring interface information of the target interface into the simulation task list.
3. The method of claim 2, wherein receiving the user's simulation instructions for the target interface comprises:
Displaying a second display interface, wherein the second display interface is used for displaying input items of interface information to a user;
and receiving interface information of the target interface input by the user based on the second display interface and the simulation instruction sent by the user operation monitoring key.
4. The method of claim 1, wherein the operation keys comprise an edit key for triggering a listening event for editing interface information;
editing the simulation task based on the monitoring event, including:
Changing a text box in the simulation task list into a changeable state, and displaying a submit button corresponding to the text box; the text box corresponds to interface information for indicating a monitored target interface;
and responding to clicking operation of the user on the submitting button, saving interface information of which the current text in the text box is the monitored target interface, and changing the text box into an unchangeable state.
5. An interface simulation apparatus, the apparatus comprising:
The first display module is used for displaying a first display interface, the first display interface is used for displaying a simulation task list to a user, and the simulation task list is used for indicating a simulated target interface and operation keys for editing simulation tasks of the target interface;
the monitoring event triggering module is used for responding to the operation of the user on the operation key based on the first display interface and triggering a monitoring event for editing the simulation task;
The simulation task editing module is used for editing the simulation task based on the monitoring event;
the simulation module is used for judging whether the called object is a target interface in the simulation task list;
Responding to the called object as a target interface in the simulation task list, and reading a plurality of simulation information of the target interface;
acquiring an actual input parameter value corresponding to the target interface;
obtaining a matching variable, wherein the matching variable comprises matching information and a matching value;
determining current simulation information, and judging whether each field in the simulation parameter value of the current simulation information is included in the actual parameter value;
Responding to each field in the simulation input parameter value including the current simulation information in the actual input parameter value, and acquiring the number of fields in the simulation input parameter value in the current simulation information;
responding to the fact that the field number in the analog input parameter value in the current analog information is larger than the matching variable, replacing the matching value in the matching variable with the field number in the analog input parameter value in the current analog information, replacing the matching information in the matching variable with the analog input parameter value in the current analog information, and returning to the step of determining the current analog information;
responding to the fact that the number of fields in the simulated parameter value in the current simulation information is smaller than or equal to the matching variable, and returning to the step of determining the current simulation information;
Determining the matching information in the matching variable as target simulation information;
And determining a call response value of the target interface based on the simulation response value in the target simulation information.
6. An interface simulation apparatus, comprising: a processor and a memory; wherein the memory is configured to store computer-executable instructions that, when executed by the interface simulation device, cause the interface simulation device to perform the interface simulation method of any of claims 1-4.
7. A computer readable storage medium having instructions stored therein, which when executed by a processor of an interface simulation device, cause the interface simulation device to perform the interface simulation method of any of claims 1-4.
CN202211737738.7A 2022-12-30 Interface simulation method, device, equipment and storage medium Active CN116112377B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211737738.7A CN116112377B (en) 2022-12-30 Interface simulation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211737738.7A CN116112377B (en) 2022-12-30 Interface simulation method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116112377A CN116112377A (en) 2023-05-12
CN116112377B true CN116112377B (en) 2024-07-12

Family

ID=

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108446225A (en) * 2018-03-06 2018-08-24 平安科技(深圳)有限公司 Creating device, method and the computer readable storage medium of analog interface
CN108897691A (en) * 2018-06-29 2018-11-27 百度在线网络技术(北京)有限公司 Data processing method, device, server and medium based on interface analog service

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108446225A (en) * 2018-03-06 2018-08-24 平安科技(深圳)有限公司 Creating device, method and the computer readable storage medium of analog interface
CN108897691A (en) * 2018-06-29 2018-11-27 百度在线网络技术(北京)有限公司 Data processing method, device, server and medium based on interface analog service

Similar Documents

Publication Publication Date Title
CN108459962A (en) Code specification detection method, device, terminal device and storage medium
US20200104246A1 (en) Continuous automation with test suite engine
CN115794641A (en) Method, device and equipment for making number based on business process and storage medium
CN114185874A (en) Big data based modeling method and device, development framework and equipment
JP2023553220A (en) Process mining for multi-instance processes
CN116467975B (en) Data processing method, device, electronic equipment and storage medium
CN116112377B (en) Interface simulation method, device, equipment and storage medium
CN112947907A (en) Method for creating code branch
CN114328062B (en) Method, device and storage medium for checking cache consistency
CN116112377A (en) Interface simulation method, device, equipment and storage medium
CN115827636A (en) Method for storing and reading simulation data of logic system design from waveform database
CN113127099B (en) Server configuration method, device, equipment and storage medium
CN115599401A (en) Publishing method, device, equipment and medium of user-defined model
CN111228815B (en) Method, apparatus, storage medium and system for processing configuration table of game
CN113641628A (en) Data quality detection method, device, equipment and storage medium
CN113254332A (en) Multi-scenario testing method, system, terminal and storage medium for storage system
CN113220586A (en) Automatic interface pressure test execution method, device and system
CN113238901A (en) Multi-device automatic testing method and device, storage medium and computer device
US8069193B2 (en) Method and system for utilizing a generic scalar function to allow a column function to operate on row data
US20230057746A1 (en) User constrained process mining
CN112711247B (en) Interface display method, interface display device and electronic equipment
US20230054774A1 (en) User constrained process mining
CN115982035A (en) Interface data simulation method, device, equipment and storage medium
CN117435185A (en) Code generation method, device, computer equipment and storage medium
US20050288913A1 (en) Circuit design simulation

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant