[ summary of the invention ]
Aspects of the present invention provide a method and an apparatus for operating a Web interface, so as to improve flexibility, efficiency and reliability of interface operation.
One aspect of the present invention provides an operating method for a Web interface, including:
receiving description information of a Web interface to be registered;
and registering the Web interface by using the description information to generate registration information, wherein the registration information comprises interface request type information, interface address information, interface parameter information and interface return information.
The foregoing aspect and any possible implementation manner further provide an implementation manner, where after the registering the Web interface by using the description information to generate registration information, the method further includes:
and updating the registration information.
The above-described aspect and any possible implementation manner further provide an implementation manner, where the registration information further includes an operator related to the Web interface; after the registering the Web interface by using the description information to generate registration information, the method further includes:
detecting the registration information;
and if the registration information is updated, sending an update notification to the operator included in the registration information according to the registration information.
The foregoing aspect and any possible implementation manner further provide an implementation manner, where after the registering the Web interface by using the description information to generate registration information, the method further includes:
generating a test case of the Web interface according to the registration information;
randomly generating input data, wherein the input data comprises structural data and/or business data;
running the test case by using the input data to obtain return data;
and verifying the Web interface according to the returned data and the interface returned information.
The above-described aspect and any possible implementation further provides an implementation in which the randomly generating input data includes:
randomly generating the structural data meeting the limiting conditions according to the pre-configured limiting conditions; and/or
And randomly extracting the pre-configured reference data to obtain the service data.
In another aspect of the present invention, an operating apparatus of a Web interface includes:
the receiving unit is used for receiving the description information of the Web interface to be registered;
and the registration unit is used for registering the Web interface by using the description information to generate registration information, wherein the registration information comprises interface request type information, interface address information, interface parameter information and interface return information.
The above-mentioned aspect and any possible implementation manner further provide an implementation manner, where the registration unit is further configured to
And updating the registration information.
The above-described aspect and any possible implementation manner further provide an implementation manner, where the registration information further includes an operator related to the Web interface; the device further comprises:
a detection unit configured to detect the registration information;
and the notification unit is used for sending an update notification to the operator included in the registration information according to the registration information if the test unit detects that the registration information is updated.
There is further provided in accordance with the above-mentioned aspect and any possible implementation form, an implementation form, wherein the apparatus further comprises a test unit for testing the device
Generating a test case of the Web interface according to the registration information; randomly generating input data, wherein the input data comprises structural data and/or business data; running the test case by using the input data to obtain return data; and verifying the Web interface according to the return data and the interface return information.
The above aspects and any possible implementations further provide an implementation of the test unit, which is specifically configured to
Randomly generating the structural data meeting the limiting conditions according to the pre-configured limiting conditions; and/or
And randomly extracting the pre-configured reference data to obtain the service data.
According to the technical scheme, the description information of the Web interface to be registered is received, so that the Web interface can be registered by utilizing the description information to generate the registration information, and the registration information comprises the interface request type information, the interface address information, the interface parameter information and the interface return information.
In addition, according to the technical scheme provided by the invention, the registration information is automatically generated according to the description information of the Web interface, so that an operator does not need to refer to the interface description document to execute subsequent work, and automatically executes subsequent operation according to the registration information, thereby further improving the flexibility of operation and the automation of operation.
In addition, by adopting the technical scheme provided by the invention, because the description information of the Web interface is the processing basis of the subsequent operation, if the description information needs to be modified, the modified description information only needs to be registered again, namely the registration information is updated, and the whole operation flow and the test case do not need to be modified, thereby further improving the flexibility of the operation and the automation of the operation.
In addition, by adopting the technical scheme provided by the invention, because the description information of the Web interface is the processing basis of the subsequent operation, the description information does not need to be considered by the test case, thereby further improving the flexibility of the test and the automation of the test.
[ detailed description ] embodiments
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In addition, the term "and/or" herein is only one kind of association relationship describing an associated object, and means that there may be three kinds of relationships, for example, a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
Fig. 1 is a schematic flowchart of an operation method of a Web interface according to an embodiment of the present invention, as shown in fig. 1.
101. And receiving the description information of the Web interface to be registered.
It is understood that the description information of the Web interface may be used to describe some relevant information of the Web interface, for example, information such as a request type of the interface, an address and a port of the interface, and a parameter name and a parameter type of the interface. Specifically, as shown in fig. 2 and 3, the input description information may be received through a User Interface (UI) shown in fig. 2 and 3.
102. And registering the Web interface by using the description information to generate registration information, wherein the registration information comprises interface request type information, interface address information, interface parameter information and interface return information.
The Web interface may include, but is not limited to, an interface based on HyperText Transfer Protocol (HTTP), an interface based on Telnet Protocol (Telnet), an interface based on File Transfer Protocol (FTP), an interface based on Domain Name System (DNS), an interface based on Simple Network Management Protocol (SNMP), or an interface based on Simple Mail Transfer Protocol (SMTP), which is not limited in this embodiment.
It should be noted that the execution main bodies of 101 and 102 may be operation devices.
Therefore, the description information of the Web interface to be registered is received, so that the Web interface can be registered by using the description information to generate the registration information, and the registration information comprises the interface request type information, the interface address information, the interface parameter information and the interface return information.
Specifically, taking an HTTP-based interface as an example, in the registration information,
the interface request type information may include, but is not limited to, information indicating a get (get) type, information indicating a push (post), information indicating a header method (head), information indicating an update (put), or information indicating a delete (delete), which is not limited in this embodiment;
the interface address information may include, but is not limited to, an address, a port, an entry function, a parameter name, and a parameter value, for example, http:// www.baidu.com/s;
the interface parameter information may include, but is not limited to, a parameter name and a parameter type, which is not limited in this embodiment;
the interface return information may be a character string, which is not limited in this embodiment.
It is understood that the parameter type may include, but is not limited to, at least one of boolean (bool), array (array), integer (int), and enumeration (enum), which is not limited by the embodiment.
Optionally, in a possible implementation manner of this embodiment, after 102, the operating device may further update the registration information, that is, register the modified description information again.
Optionally, in a possible implementation manner of this embodiment, the registration information may further include an operator related to the Web interface.
Accordingly, after 102, the operating device may further detect the registration information. If the registration information is updated, the operating device may send an update notification to the operator included in the registration information according to the registration information.
It will be appreciated that the manner in which the operating means sends the update notification may be determined by the available contact details of the operator. If the contact way is a mail address, an update notice can be sent to an operator through a mail; if the contact way is a fixed telephone, an update notice can be sent to an operator through voice communication; if the contact way is a mobile phone, an update notification may be sent to the operator through a voice call, a short message, or a multimedia message, which is not limited in this embodiment.
Therefore, after the registration information changes, operators at each stage, such as developers and testers, can timely acquire the update notification, and can perform subsequent interface operations, such as management operations and test operations, according to the updated registration information, so that the reliability of the interface operations is improved.
Further, the registration information may further include interface status information for identifying the status of the Web interface, such as development completed, enabled for automated testing, and enabled for simulation (Mock).
Optionally, in a possible implementation manner of this embodiment, after 102, the operating device may further generate a test case of the Web interface according to the registration information. Furthermore, the operating device randomly generates input data, which includes structural data and/or business data. Then, the operating device may run the test case by using the input data to obtain the return data. In this way, the operating device can verify the Web interface according to the return data and the interface return information. It will be appreciated that only the return data corresponding to the interface return information can pass the authentication.
In this way, because the registration information is automatically generated according to the description information of the Web interface, the operator does not need to refer to the interface description document to execute subsequent work, but automatically executes subsequent operation according to the registration information, thereby further improving the flexibility of operation and the automation of operation.
In addition, because the description information of the Web interface is the processing basis of the subsequent operation, the description information does not need to be considered by a test case, thereby further improving the flexibility of the test and the automation of the test.
Specifically, the operating device may randomly generate the configuration data satisfying a preset restriction condition according to the restriction condition. For example, if the parameter type is integer, the pre-configured limiting condition may be 1-100, or may also be some fixed value 1, 5, 60, etc. Alternatively, for another example, if the parameter type is enumerated, the preconfigured limit may be an allowed value.
Or, the operating device may further perform random extraction on pre-configured reference data to obtain the service data. The reference data may be acquired real service data, or may also be associated service data obtained according to other data, for example, return data of other upstream interfaces, and the like.
In this embodiment, the description information of the Web interface to be registered is received, so that the Web interface can be registered by using the description information to generate registration information, where the registration information includes interface request type information, interface address information, interface parameter information, and interface return information.
In addition, according to the technical scheme provided by the invention, the registration information is automatically generated according to the description information of the Web interface, so that an operator does not need to refer to the interface description document to execute subsequent work, and automatically executes subsequent operation according to the registration information, thereby further improving the flexibility of operation and the automation of operation.
In addition, by adopting the technical scheme provided by the invention, because the description information of the Web interface is the processing basis of the subsequent operation, if the description information needs to be modified, the modified description information only needs to be registered again, namely the registration information is updated, and the whole operation flow and the test case do not need to be modified, thereby further improving the flexibility of the operation and the automation of the operation.
In addition, by adopting the technical scheme provided by the invention, because the description information of the Web interface is the processing basis of the subsequent operation, the description information does not need to be considered by the test case, thereby further improving the flexibility of the test and the automation of the test.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
Fig. 4 is a schematic structural diagram of an operation device of a Web interface according to another embodiment of the present invention, as shown in fig. 4. The operation means of the Web interface of the present embodiment may include a reception unit 41 and a registration unit 42. The receiving unit 41 is configured to receive description information of a Web interface to be registered; and a registering unit 42, configured to register the Web interface by using the description information to generate registration information, where the registration information includes interface request type information, interface address information, interface parameter information, and interface return information.
It is understood that the description information of the Web interface may be used to describe some relevant information of the Web interface, for example, information such as a request type of the interface, an address and a port of the interface, and a parameter name and a parameter type of the interface. Specifically, as shown in fig. 2 and 3, the input description information may be received through a User Interface (UI) shown in fig. 2 and 3.
The Web interface may include, but is not limited to, an interface based on HyperText Transfer Protocol (HTTP), an interface based on Telnet Protocol (Telnet), an interface based on File Transfer Protocol (FTP), an interface based on Domain Name System (DNS), an interface based on Simple Network Management Protocol (SNMP), or an interface based on Simple Mail Transfer Protocol (SMTP), which is not limited in this embodiment.
Therefore, the receiving unit receives the description information of the Web interface to be registered, so that the registering unit can register the Web interface by using the description information to generate the registration information, wherein the registration information comprises interface request type information, interface address information, interface parameter information and interface return information.
Specifically, taking an HTTP-based interface as an example, in the registration information,
the interface request type information may include, but is not limited to, information indicating a get (get) type, information indicating a push (post), information indicating a header method (head), information indicating an update (put), or information indicating a delete (delete), which is not limited in this embodiment;
the interface address information may include, but is not limited to, an address, a port, an entry function, a parameter name, and a parameter value, for example, http:// www.baidu.com/s;
the interface parameter information may include, but is not limited to, a parameter name and a parameter type, which is not limited in this embodiment;
the interface return information may be a character string, which is not limited in this embodiment.
It is understood that the parameter type may include, but is not limited to, at least one of boolean (bool), array (array), integer (int), and enumeration (enum), which is not limited by the embodiment.
Optionally, in a possible implementation manner of this embodiment, the registering unit 42 may be further configured to update the registration information.
Optionally, in a possible implementation manner of this embodiment, the registration information may further include an operator related to the Web interface.
Accordingly, as shown in fig. 5, the operation device of the Web interface provided in this embodiment may further include:
a detecting unit 51 configured to detect the registration information;
a notification unit 52, configured to, if the detection unit 51 detects that the registration information is updated, send an update notification to the operator included in the registration information according to the registration information.
It will be appreciated that the manner in which the notification unit 52 sends the update notification may be determined based on the available contact details of the operator. If the contact way is a mail address, an update notice can be sent to an operator through a mail; if the contact way is a fixed telephone, an update notice can be sent to an operator through voice communication; if the contact way is a mobile phone, an update notification may be sent to the operator through a voice call, a short message, or a multimedia message, which is not limited in this embodiment.
Therefore, after the registration information changes, operators at each stage, such as developers and testers, can timely acquire the update notification, and can perform subsequent interface operations, such as management operations and test operations, according to the updated registration information, so that the reliability of the interface operations is improved.
Further, the registration information may further include interface status information for identifying the status of the Web interface, such as development completed, enabled for automated testing, and enabled for simulation (Mock).
Optionally, in a possible implementation manner of this embodiment, as shown in fig. 6, the operating device of the Web interface provided in this embodiment may further include a testing unit 61, configured to generate a test case of the Web interface according to the registration information; further, randomly generating input data, wherein the input data comprises structural data and/or business data; then, running the test case by using the input data to obtain return data; in this way, the Web interface can be verified according to the return data and the interface return information. It will be appreciated that only the return data corresponding to the interface return information can pass the authentication.
In this way, because the registration information is automatically generated according to the description information of the Web interface, the operator does not need to refer to the interface description document to execute subsequent work, but automatically executes subsequent operation according to the registration information, thereby further improving the flexibility of operation and the automation of operation.
In addition, because the description information of the Web interface is the processing basis of the subsequent operation, the description information does not need to be considered by a test case, thereby further improving the flexibility of the test and the automation of the test.
Specifically, the test unit 61 may be specifically configured to randomly generate the structural data meeting the constraint condition according to a constraint condition configured in advance. For example, if the parameter type is integer, the pre-configured limiting condition may be 1-100, or may also be some fixed value 1, 5, 60, etc. Alternatively, for another example, if the parameter type is enumerated, the preconfigured limit may be an allowed value.
Or, the testing unit 61 may specifically perform random extraction on pre-configured reference data to obtain the service data. The reference data may be acquired real service data, or may also be associated service data obtained according to other data, for example, return data of other upstream interfaces, and the like.
In this embodiment, the receiving unit receives the description information of the Web interface to be registered, so that the registering unit can register the Web interface by using the description information to generate registration information, where the registration information includes interface request type information, interface address information, interface parameter information, and interface return information.
In addition, according to the technical scheme provided by the invention, the registration information is automatically generated according to the description information of the Web interface, so that an operator does not need to refer to the interface description document to execute subsequent work, and automatically executes subsequent operation according to the registration information, thereby further improving the flexibility of operation and the automation of operation.
In addition, by adopting the technical scheme provided by the invention, because the description information of the Web interface is the processing basis of the subsequent operation, if the description information needs to be modified, the modified description information only needs to be registered again, namely the registration information is updated, and the whole operation flow and the test case do not need to be modified, thereby further improving the flexibility of the operation and the automation of the operation.
In addition, by adopting the technical scheme provided by the invention, because the description information of the Web interface is the processing basis of the subsequent operation, the description information does not need to be considered by the test case, thereby further improving the flexibility of the test and the automation of the test.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.