CN115292205A - Method and device for generating relational topological graph of interface, electronic equipment and storage medium - Google Patents
Method and device for generating relational topological graph of interface, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN115292205A CN115292205A CN202211219775.9A CN202211219775A CN115292205A CN 115292205 A CN115292205 A CN 115292205A CN 202211219775 A CN202211219775 A CN 202211219775A CN 115292205 A CN115292205 A CN 115292205A
- Authority
- CN
- China
- Prior art keywords
- interface
- parameter
- extraction
- interfaces
- response
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/048—Interaction techniques based on graphical user interfaces [GUI]
- G06F3/0484—Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
- G06F3/0486—Drag-and-drop
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Human Computer Interaction (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
The invention relates to a method, a device, electronic equipment and a storage medium for generating a relation topological graph of interfaces, wherein the method comprises the steps of recording parameter extraction rule information of a first interface when at least one first interface in a plurality of interfaces is subjected to parameter extraction; in the process of parameter configuration of a second interface in the plurality of interfaces, a parameter variable list is displayed based on parameter extraction rule information, and a first interface is a front interface of the second interface; responding to the selection operation of a user on the parameter variable list, and determining a target parameter variable; determining a dependency relationship of at least one first interface and a second interface based on the parameter extraction rule information and the parameter variables; and repeatedly executing the steps until the dependency relationship among the interfaces in the plurality of interfaces is obtained, and generating a relationship topological graph based on the dependency relationship among the interfaces in the plurality of interfaces. The method and the device can improve the generation efficiency of the relationship topological graph among the interfaces.
Description
Technical Field
The present disclosure relates to the field of testing technologies, and in particular, to a method and an apparatus for generating a relational topology of an interface, an electronic device, and a storage medium.
Background
The API interface test is an important part in software test, compared with a GUI user graphical interface, the API interface is easier to realize automatic batch test, a large amount of labor and time cost can be saved in a repeated regression test process, and the test period is shortened.
At present, a traditional testing mode such as unit testing mainly aims at the testing of a single interface, however, with the increasing complexity of system functions, the API interfaces cannot be isolated, but have an intricate and complex dependency relationship, and the API interfaces need to be arranged according to service scenes to carry out service testing; the existing testing mode is difficult to effectively determine the dependency relationship between interfaces, and the business scene test can only be performed by manual hard coding and requires familiarity with the relationship between the interfaces.
Disclosure of Invention
In order to overcome the problems in the related art, the present disclosure provides a method and an apparatus for generating a relational topology of an interface, an electronic device, and a storage medium.
According to a first aspect of the embodiments of the present disclosure, a method for generating a relationship topology diagram of an interface is provided, including:
when at least one first interface in a plurality of interfaces carries out parameter extraction, recording parameter extraction rule information of the first interface, wherein the parameter extraction rule information comprises a parameter name, a matching expression, an affiliated interface and an extraction mode of a parameter extraction rule;
in the process of parameter configuration of a second interface in the plurality of interfaces, a parameter variable list is displayed based on the parameter extraction rule information, wherein the parameter variable list comprises parameter variables provided by the at least one first interface, and the first interface is a front interface of the second interface;
responding to the selection operation of the user on the parameter variable list, and determining a target parameter variable;
determining a dependency relationship of the at least one first interface and the second interface based on the parameter extraction rule information and the reference relationship of the target parameter variable;
when the parameter extraction is repeatedly executed on at least one first interface in the multiple interfaces, the parameter extraction rule information of the first interface is recorded to the reference relation based on the parameter extraction rule information and the target parameter variable, the dependency relation between the at least one first interface and the second interface is determined until the dependency relation between the multiple interfaces is obtained, and a relation topological graph is generated based on the dependency relation between the multiple interfaces.
Optionally, the method further comprises:
and determining the extraction mode of the first interface in response to the configuration operation of the first interface by a user, wherein the extraction mode information is used for the first interface to extract response head data and response body data.
Optionally, the extraction manner of the response header data includes an extraction manner based on a K-V key value pair.
Optionally, the extraction manner of the response volume data includes at least one of an extraction manner based on json path, an extraction manner based on xPath, an extraction manner based on regular expression, and an extraction manner based on character string interception.
Optionally, the determining the extraction manner of the first interface in response to the configuration operation of the first interface by the user includes:
displaying an extraction configuration interface of the response volume data, wherein the extraction configuration interface comprises a jsonnPath expression input box;
and determining the extraction mode of the response volume data of the first interface in response to the input expression of the user in the jsonPath expression input box.
Optionally, the extracting manner of the response volume data is an extracting manner based on jsonPath, and determining the extracting manner of the first interface in response to the configuration operation of the first interface by the user includes:
displaying an extraction configuration interface of response volume data of the first interface, wherein the extraction configuration interface comprises a visualized tree structure formed by a plurality of json format data keys;
generating a json Path parameter extraction expression in response to a drag operation of a user on a key of json format data in the tree structure;
and determining the extraction mode of the first interface based on the jsonPath parameter extraction expression.
Optionally, after the generating the relationship topology, the method further includes:
and determining the sequential execution relation of the plurality of interfaces and a cyclic dependence detection result among the plurality of interfaces based on the relation topological graph.
According to a second aspect of the embodiments of the present disclosure, there is provided an apparatus for generating a relational topology of an interface, the apparatus including:
the device comprises a recording module, a parameter extracting module and a parameter extracting module, wherein the recording module is used for recording parameter extracting rule information of at least one first interface in a plurality of interfaces when the first interface carries out parameter extraction, and the parameter extracting rule information comprises a parameter name, a matching expression, an affiliated interface and an extracting mode of a parameter extracting rule;
a parameter variable list display module, configured to display a parameter variable list based on the parameter extraction rule information in a process of performing parameter configuration on a second interface of the multiple interfaces, where the parameter variable list includes parameter variables provided by the at least one first interface, and the first interface is a front interface of the second interface;
the parameter variable selection module is used for responding to the selection operation of the user on the parameter variable list and determining a target parameter variable;
a dependency relationship determination module, configured to determine a dependency relationship between the at least one first interface and the second interface based on the parameter extraction rule information and a reference relationship between the target parameter variable;
and the topological graph generating module is used for recording parameter extraction rule information of the first interface to the reference relation based on the parameter extraction rule information and the target parameter variable when the parameter extraction is repeatedly executed on at least one first interface in the plurality of interfaces, determining the dependency relation between the at least one first interface and the second interface until the dependency relation between the interfaces in the plurality of interfaces is obtained, and generating a relational topological graph based on the dependency relation between the interfaces in the plurality of interfaces.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of the first aspect.
According to the technical scheme provided by the embodiment of the disclosure, when parameter extraction is carried out on at least one first interface in a plurality of interfaces, parameter extraction rule information of the first interface is recorded, wherein the parameter extraction rule information comprises a parameter name, a matching expression, an affiliated interface and an extraction mode of the parameter extraction rule; in the process of parameter configuration of a second interface in the plurality of interfaces, a parameter variable list is displayed based on parameter extraction rule information, wherein the parameter variable list comprises at least one parameter variable provided by a first interface, and the first interface is a front interface of the second interface; responding to the selection operation of a user on the parameter variable list, and determining a target parameter variable; determining a dependency relationship of at least one first interface and a second interface based on the parameter extraction rule information and the parameter variables; when the parameter extraction is repeatedly executed on at least one first interface in the plurality of interfaces, the parameter extraction rule information of the first interface is recorded to the parameter extraction rule information and the parameter variables, the dependency relationship between the at least one first interface and the second interface is determined until the dependency relationship between the interfaces in the plurality of interfaces is obtained, and a relationship topological graph is generated on the basis of the dependency relationship between the interfaces in the plurality of interfaces. Therefore, the rear interface can quote the parameters of the front interface by selecting a simple operation mode of parameter variables to form the dependence and depended relation between the interfaces, and then the relation topological graph among the interfaces can be quickly and effectively obtained by traversing each interface in the plurality of interfaces in the mode, so that the dependence relation among the interfaces can be observed clearly from the topological graph, and whether cyclic dependence exists or not can be judged through the direction of an arrow, and further, the testing of the plurality of interfaces by a tester is facilitated. Compared with the traditional interface dependence, the dependence relationship between the interfaces is only deduced according to the calling sequence, the scheme can accurately deduce the dependence relationship of the interfaces, and accurately deduce the dependence condition and the dependence direction of the interfaces.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure, but do not constitute a limitation of the disclosure. In the drawings:
FIG. 1 is a flowchart illustrating a method for generating a relational topology of an interface in accordance with an exemplary embodiment.
Fig. 2 is a table structure diagram of a parameter extraction rule record table according to the embodiment shown in fig. 1.
Fig. 3 is a schematic structural diagram of an HTTP response message according to the embodiment of fig. 1.
FIG. 4 is a configuration sub-interface of a request header according to the embodiment shown in FIG. 1.
FIG. 5 is a configuration sub-interface for a requestor shown according to the embodiment of FIG. 1.
Fig. 6 is a relational topology diagram of interfaces shown according to the embodiment of fig. 1.
FIG. 7 is a flowchart illustrating a method for relational topology generation of an interface in accordance with another exemplary embodiment.
Fig. 8 is an extraction parameter setting interface according to the embodiment shown in fig. 7.
Fig. 9 is an interface for extracting configuration in response to volume data according to the embodiment of fig. 7.
Fig. 10 is another extraction configuration interface for response volume data according to the embodiment of fig. 7.
FIG. 11 is a process diagram illustrating interface use case maintenance in accordance with an illustrative embodiment.
Fig. 12 is a block diagram illustrating a relational topology generation apparatus of an interface according to an example embodiment.
FIG. 13 is a functional block diagram illustration of an electronic device shown in an exemplary embodiment.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
The API interface test is very important in software test, compared with a GUI user graphical interface, the API interface is easier to realize automatic batch test, a large amount of labor and time cost can be saved in a repeated regression test process, and the test period is shortened.
The test mode in the related art, such as unit test, is mainly a test for a single interface, but nowadays, as the system function becomes more and more complex, the API interfaces cannot be isolated, but have an intricate and complex dependency relationship. This dependency is mainly reflected in multi-interface testing, and testing of one interface often requires relying on return data successfully requested by another or multiple interfaces. For example: the interfaces which can be requested only after logging in need to obtain corresponding authentication vouchers, such as token, from the logging interfaces; the common functions of adding, modifying and deleting must add data through the added interface and return the unique identifier ID, so as to be used by the interface modifying and deleting request. Similar to the login interface and the newly added interface, the interfaces which rely on the token or the unique identifier ID returned by the newly added interface as the request parameter are collectively called as front-end interfaces. Obviously, the front interface and the back interface are only a relative concept, and for only two interfaces generating dependency relationship, the execution of the front interface and the back interface is sequential, and the design of the test tool must support recording the response data of the front interface, so as to facilitate the request use of the back interface.
In the related art, a typical professional API interface testing tool such as postman records parameters to be referred to by an interface request mainly by setting a global environment variable key value pair, which requires a user to manually write a script to extract a unique identifier ID from response volume data of a newly added interface, and then write a global environment variable for subsequent interface modification and deletion. Usually, the name of the unique identifier ID field stored in the database is fixed, but the data is dynamic, and the global environment variable is still very limited in use, and the value of the environment variable needs to be continuously modified according to the pre-interface real-time request response body data.
The interface pressure test tool jmeter then introduces the concept of a post processor, enabling more advanced automated batch testing than postman. The post processor is provided with extractors such as json Path expression, xPath expression and regular expression, and the principle of the extractors is to extract parameter data from a response head or a response body through pattern matching. The HTTP response header data is text data in a key-value pair expression form, so that parameter extraction can be carried out in a K-V key-value pair-based mode. The response volume data is mainly in a centralized format of json character strings, xml documents, text transfer character strings and the like, the response volume data of the json character strings which are most frequently used can be extracted by using a json Path expression, the json character strings are also data in a key value expression form, keys are relatively fixed, values are dynamic, and the data of the values can be obtained by matching the keys through the json Path expression. The jmeter uses various expression extractors provided by such a post-processor to be more flexible than the global environment variables of postman, but needs to learn the syntax of the jsonPath expression, manually create the jsonPath expression extractor on the pre-interface and write various expressions, which is too high for the user and is prone to error.
In addition, no matter the automatic batch test of the interfaces is carried out by using postman or jmeter, the user needs to clear the calling sequence of the interfaces, and the programming must be strictly organized according to the sequence of the front and back dependency relationships of the interfaces. When the dependency relationship between interfaces is too complex, even a loop dependency condition may occur, which may cause a call chain loop to occur when the interface test is automatically executed in batch, for example: the interface A depends on the interface B, the interface B depends on the interface C, and the interface C depends on the interface A.
In summary, the existing mainstream automatic batch interface testing tools are not very friendly to users, and have high learning cost and great use difficulty. Particularly, increasingly large interface function systems and complicated interface dependency relationships require a lot of time and effort to clean the relationships, and the existing interface test tools do not provide any technical solutions for how to solve the interface cyclic dependency detection.
In view of the foregoing problems, the present embodiment provides a method and an apparatus for generating a topological relational graph of an interface, an electronic device, and a storage medium, which can reduce the difficulty in generating a topological relational graph of multiple interfaces and improve the generation efficiency of the topological relational graph.
Fig. 1 is a flowchart illustrating a method for generating a relational topology diagram of an interface according to an exemplary embodiment, where the method may include the following steps, as shown in fig. 1:
110. when at least one first interface in a plurality of interfaces carries out parameter extraction, the parameter extraction rule information of the first interface is recorded, and the parameter extraction rule information comprises the parameter name, the matching expression, the affiliated interface and the extraction mode of the parameter extraction rule.
Illustratively, the method for generating the relationship topological graph of the interface may be applied to an electronic device with a display function, optionally, the electronic device includes, but is not limited to, a computer, a notebook computer, a tablet computer, a smartphone, and the like. The following description will be made by taking a computer as an example.
Wherein the parameter extraction rule information can be used to extract parameter variables.
In some embodiments, the parameter extraction rule information of each of the plurality of interfaces is preset, and when the interface performs parameter extraction, the parameter extraction may be performed according to the set parameter extraction rule. When the first interface uses the set parameter extraction rule to extract the parameters, the parameter name, the matching expression, the affiliated interface and the extraction mode of the parameter extraction rule can be recorded and stored, and the information of the parameter extraction rule is stored in a parameter extraction rule recording table, wherein the parameter name must be a unique character string. And in the maintenance process of the interface use case, the parameter variable is provided for the post interface of the first interface to use. Illustratively, the table structure of the parameter extraction rule record table may be as shown in fig. 2, where the data of the parameter extraction record includes an extraction record ID, a parameter name, an extraction expression, an affiliated interface ID, an extraction manner, and the like.
It should be noted that the interface in this embodiment is an API application programming interface based on the HTTP protocol, and is characterized by being based on the standard HTTP protocol, and including elements such as a request header, a request body, a response header, and a response body. Illustratively, the parameter to be extracted by the interface is an HTTP response packet, which may be specifically as shown in fig. 3, and the HTTP response packet may be composed of three parts:
the response line consists of: (1) message protocol and version, and (2) status code and description.
The response head: consisting of response header attributes.
A responder: the server returns the text information to the client.
120. In the process of configuring parameters for a second interface of the plurality of interfaces, a parameter variable list is displayed based on the parameter extraction rule information, wherein the parameter variable list includes parameter variables provided by the at least one first interface, and the first interface is a front interface of the second interface.
In some embodiments, after saving the parameter extraction rule of the first interface (hereinafter, referred to as a front interface), the user may perform parameter configuration on the back interface through a configuration interface of a second interface (hereinafter, referred to as a back interface) provided by the computer, where the parameters required to be configured by the back interface include a request header parameter and a request body parameter.
For example, the configuration interface may be as shown in fig. 4, and the user may select the option of "request header" and then enter the configuration sub-interface of the request header, in which the user may select all the parameter variables provided by the pre-interface in real time from the parameter variable list data expanded by the drop-down.
For example, referring to fig. 5, after the parameter setting of the request header is completed, the user may further select an option in the configuration interface for configuring the request body, such as selecting the "request parameter" option in fig. 5, and then enter a configuration sub-interface of the request body as shown in fig. 5, in which the user may also select parameter variables provided by all pre-interfaces in real time from a parameter variable list expanded by a pull-down method. Wherein the parameter variable is generated based on the parameter extraction rule information of all the prepositive interfaces.
130. And determining a target parameter variable in response to the selection operation of the user on the parameter variable list.
Following the above example, please refer to fig. 4 and 5 again, the user may select one of the parameter variables by clicking on the parameter variable list expanded by the pull-down process, so as to determine the selected parameter variable as the target parameter variable.
140. And determining the dependency relationship between the at least one first interface and the second interface based on the reference relationship between the parameter extraction rule information and the target parameter variable.
After the parameter variables of the rear interface are set, the rear interface can be quoted to the front interface, and the dependency relationship between the first interface and the second interface can be determined by combining the parameter extraction rule information in the parameter extraction rule record table. In particular, parameters can be referenced on demand by way of parameter reference "$ (parameter name)" placeholder. The post-side interface forms a dependency and a depended relationship between the interfaces by referring to the parameters of the pre-side interface, and can determine that the dependency relationship between the first interface and the second interface is determined, for example, the first interface includes an interface a, an interface b and an interface c, the second interface includes an interface d, and the interface d refers to the parameter variable corresponding to the interface a when the parameters are configured, so that the interface d can be determined to depend on the interface a.
150. When the parameter extraction is repeatedly executed on at least one first interface in the plurality of interfaces, the parameter extraction rule information of the first interface is recorded to the reference relationship based on the parameter extraction rule information and the target parameter variable, the dependency relationship between the at least one first interface and the second interface is determined until the dependency relationship between each interface in the plurality of interfaces is obtained, and a relationship topological graph is generated based on the dependency relationship between each interface in the plurality of interfaces.
By repeating the steps 110 to 140 until each interface is traversed, the dependency relationship between the interfaces in the multiple interfaces, that is, the parameter reference relationship between the interfaces, can be obtained, and after the parameter reference relationship exists, the automatic derivation and generation of the visualized interface dependency relationship topological graph can be realized. The implementation principle of the method is mainly that interface records are traversed, a regular expression is used for matching and identifying parameter reference placeholders from request head data and request body data of an interface, referenced parameter names are obtained, and then the parameter names are used for inquiring the preposed interfaces of the interface from a parameter extraction record table, so that the dependency relationship among the interfaces is deduced in sequence. The front interface is embodied on the topological graph to be the target node pointed by the arrow, and the back interface is embodied on the topological graph to be the arrow source node. Illustratively, the generated relationship topological graph of the interface can be as shown in fig. 6, and it can be clearly observed from fig. 6 that the interface 2 depends on the interface 1, the interface three depends on the interface 2 and the interface 1, and the test interface test1 depends on the interface 1 and is depended on by the interface 3.
It can be seen that, in this embodiment, when parameter extraction is performed on at least one first interface of the multiple interfaces, parameter extraction rule information of the first interface is recorded, where the parameter extraction rule information includes a parameter name, a matching expression, an affiliated interface, and an extraction manner of the parameter extraction rule; in the process of parameter configuration of a second interface in the plurality of interfaces, a parameter variable list is displayed based on parameter extraction rule information, wherein the parameter variable list comprises at least one parameter variable provided by a first interface, and the first interface is a front interface of the second interface; responding to the selection operation of a user on the parameter variable list, and determining a target parameter variable; determining a dependency relationship of at least one first interface and a second interface based on the parameter extraction rule information and the parameter variables; when the parameter extraction is repeatedly executed on at least one first interface in the plurality of interfaces, the parameter extraction rule information of the first interface is recorded to the parameter extraction rule information and the parameter variables, the dependency relationship between the at least one first interface and the second interface is determined until the dependency relationship between the interfaces in the plurality of interfaces is obtained, and a relationship topological graph is generated on the basis of the dependency relationship between the interfaces in the plurality of interfaces. Therefore, the rear interface can quote the parameters of the front interface by selecting a simple operation mode of parameter variables to form the dependence and depended relation between the interfaces, and then the relation topological graph among the interfaces can be quickly and effectively obtained by traversing each interface in the plurality of interfaces in the mode, so that the dependence relation among the interfaces can be observed clearly from the topological graph, and whether cyclic dependence exists or not can be judged through the direction of an arrow, and further, the testing of the plurality of interfaces by a tester is facilitated.
FIG. 7 is a flowchart illustrating a method for generating a relational topology of an interface according to an exemplary embodiment, which may include the following steps, as shown in FIG. 7:
210. and determining the extraction mode of the first interface in response to the configuration operation of the first interface by a user, wherein the extraction mode information is used for the first interface to extract response head data and response volume data.
In some embodiments, the response header data is extracted based on a K-V key value pair.
For example, the computer may display an extraction parameter setting interface of the first interface as shown in fig. 8, and when the user selects an option of "response header" in the extraction parameter setting interface, a setting sub-interface of response header data may be entered, and in the interface, the user may perform a selection operation on the extracted parameter name list presented by the pull-down to select a required parameter name to be extracted from the parameter name list, thereby setting the response header data.
In some embodiments, the extraction method of the response volume data includes at least one of a jsonPath-based extraction method, an xPath-based extraction method, a regular expression-based extraction method, and a string extraction-based extraction method.
For example, in this embodiment, the parameter extraction of the first interface includes parameter extraction of response header and response volume data, and specifically, the idea of various expression extractors in the jmeter post processor may be used for reference. Wherein, the response head can extract parameters by using a mode based on K-V key value pairs. The parameter extraction mode of the response volume data comprises extraction based on jsonPath (applicable to json format response data), xPath (applicable to xml format response data), regular expression (applicable to all format response data) and character string interception (applicable to all format response data).
In some embodiments, specific embodiments of step 210 may include:
211a, displaying an extraction configuration interface of the response volume data, wherein the extraction configuration interface comprises a jsonPath expression input box.
212a, determining the extraction mode of the response volume data of the first interface in response to the expression input by the user in the jsonPath expression input box.
Illustratively, following the above example, in the extraction parameter setting interface of the first interface shown in fig. 8, when the user selects the option of "response data" in the extraction parameter setting interface, the configuration interface of response volume data shown in fig. 9 may be entered, the configuration interface includes a drop-down list of selection of extraction manners, the extraction manner required by the user may be selected in the list, after selecting the extraction manner, a corresponding expression input box may be displayed, as shown in fig. 9, after selecting the json path extraction manner, an input box of the json path expression may be displayed, and then the user may input a specific expression in the input box, thereby completing the setting of the extraction manner of the response volume data.
In other embodiments, the extracting manner of the response volume data is based on a json path, and the specific implementation of step 210 may include:
211b, displaying an extraction configuration interface of the response volume data of the first interface, wherein the extraction configuration interface comprises a visual tree structure formed by a plurality of json format data keys.
212b, generating a json Path parameter extraction expression in response to the drag operation of the user on the key of the json format data in the tree structure.
213b, determining the extraction mode of the first interface based on the jsonPath parameter extraction expression.
Illustratively, when the user selects the option of "response data (i.e. response volume data)" in the above-mentioned extraction parameter setting interface, the extraction configuration interface of response volume data as shown in fig. 10 may be entered, on the left side of the extraction configuration interface, a visualized tree structure formed by a plurality of keys of json format data is displayed, and the user may move a certain key in the tree structure on the left side into the right window area by means of dragging, thereby automatically generating the extraction expression.
It can be seen that, in the embodiment, the parameter extraction method of the json path expression mainly used for the json format response volume data supports the parameter extraction of the traditional handwritten json path expression in the aspect of implementing the visualized extraction of the front-end page interface parameters. And simultaneously, a dragging type parameter extraction mode is provided, the principle is that keys of response body json format data are processed into a visual tree structure to be displayed, then an expression is automatically generated according to the json Path expression writing rule by selecting a mode of dragging a certain key to a right window area, and a user only needs to define a unique json Path expression name in an input box. The use threshold of the user is reduced, the user can use the mobile phone more simply and conveniently, and the use efficiency of the user is improved.
220. When at least one first interface in the plurality of interfaces carries out parameter extraction, the parameter extraction rule information of the first interface is recorded. The parameter extraction rule information comprises a parameter name, a matching expression, an affiliated interface and an extraction mode of the parameter extraction rule.
230. And in the process of configuring parameters of a second interface in the plurality of interfaces, displaying a parameter variable list based on the parameter extraction rule information. The parameter variable list includes parameter variables provided by the at least one first interface, where the first interface is a front interface of the second interface.
240. And determining a target parameter variable in response to the selection operation of the user on the parameter variable list.
250. And determining the dependency relationship between the at least one first interface and the second interface based on the reference relationship between the parameter extraction rule information and the target parameter variable.
260. And repeating the steps 220 to 250 until the dependency relationship among the interfaces in the plurality of interfaces is obtained, and generating a relationship topological graph based on the dependency relationship among the interfaces in the plurality of interfaces.
The detailed implementation of steps 220 to 260 can refer to steps 110 to 150, and therefore will not be described herein.
270. And determining the sequential execution relation of the plurality of interfaces and a cyclic dependence detection result among the plurality of interfaces based on the relation topological graph.
In some embodiments, the computer may display the relationship topological graph through a display, so that the dependency relationship between the interfaces can be clearly observed from the topological graph, and whether the cyclic dependency exists can be judged through the arrow direction. Certainly, in the processing process of the program logic, whether the interfaces forming the closed loop have circular dependence or not is automatically judged according to the graph theory traversal algorithm, and a marking prompt is given in the process of drawing the topological graph. After the interface depends on the topological graph, in the process of executing the automatic batch interface test, the executed initial interface nodes can be calculated according to a graph theory traversal algorithm, and the execution sequence among the interfaces is sequentially traversed and calculated, so that the real-time response data can be extracted from the returned results after all the front interfaces are executed by using the corresponding parameter extraction rules and used as the request input parameters of the rear interfaces to replace the parameter reference placeholders.
In some embodiments, the method includes recording parameter extraction rule information for extracting a parameter variable of at least one interface (i.e., the first interface in the above embodiment) of the plurality of interfaces when the parameter variable is extracted; in the process of parameter configuration of the subsequent other interface (i.e. the second interface in the above embodiment), based on the parameter extraction rule information, a parameter variable list that can be referred to is shown, and the interface to which the extracted variable is referred is a front interface of the interface that refers to the variable; then, under the condition that the selection operation of the user on the parameter variable list is received, the target parameter variable is determined in response to the selection operation of the user on the parameter variable list; based on the reference relationship between the parameter variable extraction rule information and the target parameter variable, recursively deducing the dependency relationship of the interface; and then, repeatedly executing the steps until the dependency relationship among the interfaces in the plurality of interfaces is obtained, and generating a relationship topological graph based on the dependency relationship among the interfaces in the plurality of interfaces.
As an example, in practical applications, a process of performing interface use case maintenance on an interface by using the relationship topological graph generation method of the interface may be as shown in fig. 11:
and starting interface use case maintenance.
In step 100a, a response body jsonPath parameter extraction expression can be automatically generated by adopting a drag-and-drop mode, and in step 100b, a response head K-V key value pair parameter extraction expression or a response body jsonPath/xPath/regular expression/character string interception parameter extraction expression can be manually set.
In step 101, the parameter extraction expression may be stored in a parameter extraction rule record table.
In step 102, when the interface request header or the request body is set, parameter variables can be selected and placeholders for the parameter variables can be automatically generated through pull-down.
In step 103, an interface dependency topology map (i.e. the above-mentioned relationship topology map) is derived and generated according to the parameter extraction record table and the interface parameter variable reference.
In step 104, a graph-theoretic traversal algorithm is used to detect cyclic dependencies between interfaces according to the interface dependency topology.
And (6) ending.
As can be seen, compared with the related art, the method for generating the relationship topological graph of the interface provided by the embodiment provides solutions for three technical problems that a json Path expression is difficult to learn, interface dependence relationship is difficult to clear, and interface cyclic dependence is difficult to detect. In the related technology, basically, a user needs to learn various parameter extraction expression grammars by himself and manually write expressions for parameter extraction, and meanwhile, an interface needs to manually write parameter variable placeholders instead of automatically generating after selection when parameters are applied.
In addition, besides the fact that various parameter extraction expressions are manually input, a dragging type parameter extraction mode is provided for a more common jsonPath expression extractor, the jsonPath parameter extraction expressions are automatically generated from response volume data of a tree structure in a dragging interaction mode and recorded into parameter extraction rules, and the learning cost and the error probability of manual input are reduced.
In addition, when the interface use case is maintained, a user does not need to spend time on clearing the sequence among the interfaces, only needs to select parameter variables provided by all the front interfaces from the drop-down list, even if other front interfaces which are currently depended on are not maintained, the user can return to re-edit the interfaces and set parameter variable reference afterwards, and the system can automatically generate parameter reference placeholders according to the selected parameter variables.
In addition, the dependency relationship among the interfaces is processed into an image and visual topological graph for displaying, the interfaces are all represented by topological graph nodes, and the dependency relationship is represented by arrow directions, so that a user can conveniently clear the relationship among a plurality of interfaces.
In addition, whether the closed-loop topological graph has circular dependence or not and the precedence relationship of automatic interface execution are reversely deduced through the traversal principle of graph theory, so that the probability of errors in automatic batch execution of interface regression testing is avoided.
Fig. 12 is a block diagram illustrating a relationship topology generation apparatus of an interface according to an exemplary embodiment, as shown in fig. 12, the relationship topology generation apparatus 30 of the interface may include:
the recording module 31 is configured to record parameter extraction rule information of at least one first interface of the multiple interfaces when the first interface performs parameter extraction, where the parameter extraction rule information includes a parameter name, a matching expression, an interface to which the parameter extraction rule belongs, and an extraction manner of the parameter extraction rule.
A parameter variable list displaying module 32, configured to, in a process of performing parameter configuration on a second interface of the multiple interfaces, display a parameter variable list based on the parameter extraction rule information, where the parameter variable list includes parameter variables provided by the at least one first interface, and the first interface is a front interface of the second interface.
And the parameter variable selecting module 33 is configured to determine a target parameter variable in response to a user selecting operation on the parameter variable list.
A dependency relationship determining module 34, configured to determine a dependency relationship between the at least one first interface and the at least one second interface based on the parameter extraction rule information and the reference relationship between the target parameter variable.
A topology generating module 35, configured to record parameter extraction rule information of the first interface to the reference relationship based on the parameter extraction rule information and the target parameter variable when the parameter extraction is repeatedly performed on at least one first interface among the multiple interfaces, determine a dependency relationship between the at least one first interface and the second interface until obtaining a dependency relationship between each of the multiple interfaces, and generate a relationship topology based on the dependency relationship between each of the multiple interfaces.
In some embodiments, the apparatus 30 further comprises:
an extraction mode determining module, configured to determine the extraction mode of the first interface in response to a configuration operation of a user on the first interface, where the extraction mode information is used by the first interface to extract response header data and response volume data.
In some embodiments, the response header data is extracted based on a K-V key value pair.
In some embodiments, the extraction method of the response volume data includes at least one of a json path-based extraction method, an xPath-based extraction method, a regular expression-based extraction method, and a string interception-based extraction method.
In some embodiments, the extraction manner determining module is specifically configured to display an extraction configuration interface of the response volume data, where the extraction configuration interface includes a json path expression input box; and determining the extraction mode of the response volume data of the first interface in response to the input expression of the user in the jsonPath expression input box.
In some embodiments, the extraction method of the response volume data is a json path-based extraction method, and the extraction method determining module is specifically configured to display an extraction configuration interface of the response volume data of the first interface, where the extraction configuration interface includes a visualized tree structure formed by a plurality of json format data keys; generating a json Path parameter extraction expression in response to a drag operation of a user on a key of json format data in the tree structure; and determining the extraction mode of the first interface based on the jsonPath parameter extraction expression.
In some embodiments, the apparatus 30 further comprises:
and the detection module is used for determining the sequential execution relationship of the plurality of interfaces and the cyclic dependence detection result among the plurality of interfaces based on the relationship topological graph.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 13 is a block diagram illustrating an electronic device 700 according to an example embodiment. As shown in fig. 13, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of an I/O interface 704 (i.e., an input/output interface), and a communications component 705.
The processor 701 is configured to control the overall operation of the electronic device 700, so as to complete all or part of the steps in the motor control method. The memory 702 is used to store various types of data to support operation at the electronic device 700, such as instructions for any application or method operating on the electronic device 700 and application-related data, such as contact data, transmitted and received messages, pictures, audio, video, and so forth. The Memory 702 may be implemented by any type or combination of volatile and non-volatile Memory devices, such as Static Random Access Memory (SRAM), electrically Erasable Programmable Read-Only Memory (EEPROM), erasable Programmable Read-Only Memory (EPROM), programmable Read-Only Memory (PROM), read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic or optical disk. The I/O interface 704 provides an interface between the processor 701 and other interface modules, such as a keyboard, a mouse, buttons, a display (e.g., a touch screen), etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, or combinations thereof, which is not limited herein. The corresponding communication component 705 may thus include: wi-Fi module, bluetooth module, NFC module, etc.
In an exemplary embodiment, the electronic Device 700 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the motor control methods described above.
In another exemplary embodiment, a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the above-described motor control method is also provided. For example, the computer readable storage medium may be the memory 702 described above including program instructions that are executable by the processor 701 of the electronic device 700 to perform the motor control method described above.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.
Claims (10)
1. A method for generating a relationship topological graph of an interface is characterized by comprising the following steps:
when at least one first interface in a plurality of interfaces carries out parameter extraction, recording parameter extraction rule information of the first interface, wherein the parameter extraction rule information comprises a parameter name, a matching expression, an affiliated interface and an extraction mode of a parameter extraction rule;
in the process of parameter configuration of a second interface in the plurality of interfaces, a parameter variable list is displayed based on the parameter extraction rule information, wherein the parameter variable list comprises parameter variables provided by the at least one first interface, and the first interface is a front interface of the second interface;
responding to the selection operation of the user on the parameter variable list, and determining a target parameter variable;
determining a dependency relationship of the at least one first interface and the second interface based on the parameter extraction rule information and the reference relationship of the target parameter variable;
when the parameter extraction is repeatedly executed on at least one first interface in the multiple interfaces, the parameter extraction rule information of the first interface is recorded to the reference relation based on the parameter extraction rule information and the target parameter variable, the dependency relation between the at least one first interface and the second interface is determined until the dependency relation between the multiple interfaces is obtained, and a relation topological graph is generated based on the dependency relation between the multiple interfaces.
2. The method of claim 1, further comprising:
and determining the extraction mode of the first interface in response to the configuration operation of the first interface by a user, wherein the extraction mode information is used for the first interface to extract response head data and response volume data.
3. The method of claim 2, wherein the response header data is extracted based on a K-V key value pair.
4. The method according to claim 2, wherein the extraction manner of the response volume data includes at least one of an extraction manner based on jsonPath, an extraction manner based on xPath, an extraction manner based on regular expression, and an extraction manner based on string extraction.
5. The method of claim 2, wherein the determining the extraction manner of the first interface in response to the configuration operation of the first interface by the user comprises:
displaying an extraction configuration interface of the response volume data, wherein the extraction configuration interface comprises a jsonPath expression input box;
and determining the extraction mode of the response volume data of the first interface in response to the input expression of the user in the jsonPath expression input box.
6. The method according to claim 2, wherein the extraction manner of the response volume data is an extraction manner based on json path, and the determining the extraction manner of the first interface in response to the configuration operation of the first interface by the user includes:
displaying an extraction configuration interface of response volume data of the first interface, wherein the extraction configuration interface comprises a visualized tree structure formed by a plurality of json format data keys;
generating a json Path parameter extraction expression in response to a drag operation of a user on a key of json format data in the tree structure;
and determining the extraction mode of the first interface based on the jsonPath parameter extraction expression.
7. The method according to any of claims 1-6, wherein after said generating the relational topology graph, the method further comprises:
and determining the sequential execution relation of the plurality of interfaces and a cyclic dependence detection result among the plurality of interfaces based on the relation topological graph.
8. An apparatus for generating a relational topology map of an interface, comprising:
the device comprises a recording module, a parameter extracting module and a parameter extracting module, wherein the recording module is used for recording parameter extracting rule information of at least one first interface in a plurality of interfaces when the first interface carries out parameter extraction, and the parameter extracting rule information comprises a parameter name, a matching expression, an affiliated interface and an extracting mode of a parameter extracting rule;
a parameter variable list display module, configured to display a parameter variable list based on the parameter extraction rule information in a process of performing parameter configuration on a second interface of the multiple interfaces, where the parameter variable list includes parameter variables provided by the at least one first interface, and the first interface is a front interface of the second interface;
the parameter variable selection module is used for responding to the selection operation of the user on the parameter variable list and determining a target parameter variable;
a dependency relationship determination module, configured to determine a dependency relationship between the at least one first interface and the second interface based on the parameter extraction rule information and a reference relationship between the target parameter variable;
and the topological graph generating module is used for recording parameter extraction rule information of the first interface to the reference relation based on the parameter extraction rule information and the target parameter variable when the parameter extraction is repeatedly executed on at least one first interface in the plurality of interfaces, determining the dependency relation between the at least one first interface and the second interface until the dependency relation between the interfaces in the plurality of interfaces is obtained, and generating a relational topological graph based on the dependency relation between the interfaces in the plurality of interfaces.
9. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 7.
10. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211219775.9A CN115292205B (en) | 2022-10-08 | 2022-10-08 | Method and device for generating relational topological graph of interface, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211219775.9A CN115292205B (en) | 2022-10-08 | 2022-10-08 | Method and device for generating relational topological graph of interface, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115292205A true CN115292205A (en) | 2022-11-04 |
CN115292205B CN115292205B (en) | 2022-12-09 |
Family
ID=83834722
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211219775.9A Active CN115292205B (en) | 2022-10-08 | 2022-10-08 | Method and device for generating relational topological graph of interface, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115292205B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109597754A (en) * | 2018-10-22 | 2019-04-09 | 中国平安财产保险股份有限公司 | Operation flow interface test method, device, computer equipment and storage medium |
CN111552509A (en) * | 2020-04-30 | 2020-08-18 | 深圳前海微众银行股份有限公司 | Method and device for determining dependency relationship between interfaces |
CN112364107A (en) * | 2020-11-10 | 2021-02-12 | 平安普惠企业管理有限公司 | System analysis visualization method and device, electronic equipment and computer readable storage medium |
CN112905848A (en) * | 2021-02-10 | 2021-06-04 | 北京有竹居网络技术有限公司 | Information query method, device, electronic equipment, storage medium and program product |
CN113791984A (en) * | 2021-10-28 | 2021-12-14 | 建信金融科技有限责任公司 | Automatic interface testing method and device |
CN114385485A (en) * | 2021-12-15 | 2022-04-22 | 连连(杭州)信息技术有限公司 | Interface test method, device, equipment and storage medium |
US11321885B1 (en) * | 2020-10-29 | 2022-05-03 | Adobe Inc. | Generating visualizations of analytical causal graphs |
-
2022
- 2022-10-08 CN CN202211219775.9A patent/CN115292205B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109597754A (en) * | 2018-10-22 | 2019-04-09 | 中国平安财产保险股份有限公司 | Operation flow interface test method, device, computer equipment and storage medium |
CN111552509A (en) * | 2020-04-30 | 2020-08-18 | 深圳前海微众银行股份有限公司 | Method and device for determining dependency relationship between interfaces |
US11321885B1 (en) * | 2020-10-29 | 2022-05-03 | Adobe Inc. | Generating visualizations of analytical causal graphs |
CN112364107A (en) * | 2020-11-10 | 2021-02-12 | 平安普惠企业管理有限公司 | System analysis visualization method and device, electronic equipment and computer readable storage medium |
CN112905848A (en) * | 2021-02-10 | 2021-06-04 | 北京有竹居网络技术有限公司 | Information query method, device, electronic equipment, storage medium and program product |
CN113791984A (en) * | 2021-10-28 | 2021-12-14 | 建信金融科技有限责任公司 | Automatic interface testing method and device |
CN114385485A (en) * | 2021-12-15 | 2022-04-22 | 连连(杭州)信息技术有限公司 | Interface test method, device, equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
刘虎球等: "一种面向内核接口的顺序依赖规则挖掘与违例检测方法", 《计算机学报》 * |
Also Published As
Publication number | Publication date |
---|---|
CN115292205B (en) | 2022-12-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109086204B (en) | Node relation tree establishing method, page marking method, page identifying method, page marking device, page identifying device and storage medium | |
CN109697066B (en) | Method and system for realizing data sheet splicing and automatically training machine learning model | |
JP6514244B2 (en) | Difference detection device and program | |
US20220374339A1 (en) | Techniques for visual software test automation management | |
US20170242832A1 (en) | Character editing method and device for screen display device | |
WO2019100635A1 (en) | Editing method and apparatus for automated test script, terminal device and storage medium | |
CN111831815B (en) | Control method and device for questionnaire display, storage medium and electronic equipment | |
US20220374334A1 (en) | Techniques for visual software test automation management | |
CN112115313B (en) | Regular expression generation and data extraction methods, devices, equipment and media | |
JP2021103581A (en) | Method for extracting form in image, device for extracting form in image, electronic apparatus, computer readable storage medium, method for training form extraction module, and computer program | |
US20220374338A1 (en) | Techniques for visual software test automation management | |
CN117493158A (en) | Test method and device, electronic equipment and storage medium | |
CN109840201B (en) | UI test method, device, electronic equipment and computer readable storage medium | |
CN114647699A (en) | Data synchronization method and device, electronic equipment and storage medium | |
JP6723976B2 (en) | Test execution device and program | |
CN115292205B (en) | Method and device for generating relational topological graph of interface, electronic equipment and storage medium | |
CN111143205B (en) | Android platform-oriented test case automatic generation method and generation system | |
CN115629990B (en) | Service testing method and device, electronic equipment and storage medium | |
CN109857735B (en) | Data construction method and system for rule description through excel | |
CN115729642B (en) | Method, system, equipment and storage medium for processing user behavior based on state machine | |
EP3807780A1 (en) | Binding query scope to directory attributes | |
CN113886221B (en) | Test script generation method and device, storage medium and electronic equipment | |
CN113254315B (en) | Reporting method of embedded point information, embedded point method, device, medium and electronic equipment | |
US10740223B1 (en) | Systems and methods for checkpoint-based machine learning model | |
US10454807B2 (en) | Connection minimization for distributed system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |