CN115904995A - Interface association method and device and electronic equipment - Google Patents

Interface association method and device and electronic equipment Download PDF

Info

Publication number
CN115904995A
CN115904995A CN202211578130.4A CN202211578130A CN115904995A CN 115904995 A CN115904995 A CN 115904995A CN 202211578130 A CN202211578130 A CN 202211578130A CN 115904995 A CN115904995 A CN 115904995A
Authority
CN
China
Prior art keywords
parameter
interface
data
name
associated parameter
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.)
Pending
Application number
CN202211578130.4A
Other languages
Chinese (zh)
Inventor
古明泉
张雨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Zhongxinjia Technology Development Co ltd
Original Assignee
Sichuan Zhongxinjia Technology Development Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Sichuan Zhongxinjia Technology Development Co ltd filed Critical Sichuan Zhongxinjia Technology Development Co ltd
Priority to CN202211578130.4A priority Critical patent/CN115904995A/en
Publication of CN115904995A publication Critical patent/CN115904995A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention provides an interface association method, an interface association device and electronic equipment, which are used for acquiring first test data of a first interface; the first test data comprises first parameter data which is marked by a first mark in advance, and the first parameter data comprises names of associated parameters; before a first service request of a first interface is carried out, first parameter data are obtained from first test data based on a first identifier; updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in association with the yaml file, and the updated parameter data is used for carrying out a first service request of the first interface. The invention can solve the problem that the prior interface association scheme can not quickly determine the association parameters when the interface test has error.

Description

Interface association method and device and electronic equipment
Technical Field
The present invention relates to the field of test development technologies, and in particular, to an interface association method and apparatus, and an electronic device.
Background
In the process of carrying out automatic interface testing, dependence conditions among interfaces are common, interface association is often required among the interfaces, the existing interface association scheme generally stores association parameters and corresponding values thereof as class attributes in classes through a python reflection mechanism, then carries out interface association, but the parameters extracted through the python reflection mechanism and the corresponding values thereof are dynamically stored in the classes, the parameters and the corresponding values thereof can be recovered after interface requests are finished, if an interface test has errors, the association parameters extracted in the interface association process cannot be quickly and clearly checked and judged whether the association parameters are correct or not in the problem positioning process, and therefore bug positioning cannot be quickly carried out.
Disclosure of Invention
In view of the above, an object of the present invention is to provide an interface association method, an interface association apparatus, and an electronic device, so as to alleviate a problem that an association parameter cannot be determined quickly when an interface test has an error.
In a first aspect, an embodiment of the present invention provides an interface association method, where the method includes: acquiring first test data of a first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters; before a first service request of the first interface is carried out, acquiring the first parameter data from the first test data based on the first identifier; updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file in an associated manner, and the updated parameter data is used for making a first service request of the first interface.
In a second aspect, an embodiment of the present invention further provides an interface association apparatus, where the apparatus includes: the first acquisition module is used for acquiring first test data of the first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters; a second obtaining module, configured to obtain the first parameter data from the first test data based on the first identifier before a first service request of the first interface is performed; the updating module is used for updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file in an associated manner, and the updated parameter data is used for making a first service request of the first interface.
In a third aspect, an embodiment of the present invention further provides an electronic device, which includes a processor and a memory, where the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the interface association method.
The interface association method, the interface association device and the electronic equipment provided by the embodiment of the invention are used for acquiring first test data of a first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters; before a first service request of a first interface is carried out, first parameter data are obtained from first test data based on a first identifier; updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in association with the yaml file, and the updated parameter data is used for carrying out a first service request of the first interface. By adopting the technology, the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file, the latest value corresponding to the associated parameter can be dynamically obtained and the associated parameter extracted in the interface association process can be quickly and clearly viewed when the interface test is carried out, and the problem of quick positioning is solved, so that the problem that the associated parameter cannot be quickly determined when the interface test has errors in the existing interface association scheme is solved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic flowchart of an interface association method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of an interface association apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of another interface association apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the embodiments. 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.
At present, in an automatic interface test, the dependency condition between interfaces is common, and interface association is often required between the interfaces, in the existing interface association scheme, an association parameter and a corresponding value thereof are stored under a class as a class attribute through a python reflection mechanism, and then interface association is performed, but the parameter extracted through the python reflection mechanism and the corresponding value thereof are dynamically stored under the class, and the parameter and the corresponding value thereof are recovered after an interface request is ended.
Based on this, the interface association method, the interface association device and the electronic device provided by the embodiment of the invention can solve the problem that the association parameters cannot be quickly determined when the interface test has an error.
To facilitate understanding of the present embodiment, first, a detailed description is given of an interface association method disclosed in the embodiment of the present invention, and referring to fig. 1, the method may include the following steps:
step S102, acquiring first test data of a first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters.
The association parameter is a parameter for performing interface association between the first interface and the second interface. In order to obtain the first parameter data including the name of the associated parameter when the subsequent interface is associated, the first parameter data may be identified by the first identifier in advance. The first identifier may specifically be in the form of a designated character, a designated keyword, and the like, which is not limited herein.
Illustratively, taking an example that a commodity is added into a shopping cart by an online shopping platform, the service mainly involves a login interface and a shopping cart adding interface, when a user performs shopping cart adding operation, if the user does not log in, the user needs to log in first, after the login is successful, the online shopping platform gives a token to the user at the background as an identity pass, and when the user performs shopping cart adding operation, the user needs to bring the token, so that the shopping cart adding interface depends on the login interface, after the login is successful, the token is carried in a service request to perform the service of adding the shopping cart interface, and at this time, the token is used as an association parameter to perform interface association between the shopping cart adding interface and the login interface.
Step S104, before the first service request of the first interface is carried out, first parameter data is obtained from the first test data based on the first identification.
Illustratively, continuing with the previous example, the interface for joining a shopping cart may be used as a first interface, the login interface may be used as a second interface, and the test data (i.e. the first test data) joined to the shopping cart interface already has the first parameter data containing the token name, which is identified by the specified character (i.e. the first identifier) in advance; since the first interface and the second interface need to be subjected to interface association, in order to achieve the purpose, before a service request for joining the shopping cart is performed, parameter data including a token name needs to be determined and acquired from test data for joining the shopping cart interface by using a specified character, so that subsequent interface association is performed.
Step S106, updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in association with the yaml file, and the updated parameter data is used for carrying out a first service request of the first interface.
Exemplarily, continuing with the previous example, the token name and the value corresponding to the token may be stored in a yaml file in advance in an associated manner, after parameter data including the token name is obtained from test data added to the shopping cart interface, since the token name is known, the value corresponding to the token may be determined and obtained from the yaml file by using the token name, and then the value corresponding to the token is applied to update the parameter data (i.e., the first parameter data) including the token name, so as to obtain updated parameter data, thereby implementing the interface association between the shopping cart interface and the login interface; and after the interface association is completed, carrying out a service request for joining the shopping cart by using the updated parameter data.
The interface association method provided by the embodiment of the invention comprises the steps of acquiring first test data of a first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters; before a first service request of a first interface is carried out, first parameter data are obtained from first test data based on a first identifier; updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in association with the yaml file, and the updated parameter data is used for carrying out a first service request of the first interface. By adopting the technology, the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file, the latest value corresponding to the associated parameter can be dynamically obtained and the associated parameter extracted in the interface association process can be quickly and clearly viewed when the interface test is carried out, and the problem of quick positioning is solved, so that the problem that the associated parameter cannot be quickly determined when the interface test has errors in the existing interface association scheme is solved.
As a possible implementation manner, the step S106 (i.e. updating the first parameter data based on the name of the associated parameter and the preset yaml file to obtain the updated parameter data) may include: and acquiring a value corresponding to the associated parameter from a preset yaml file based on the name of the associated parameter, and replacing the name of the associated parameter in the first parameter data with the value corresponding to the associated parameter to obtain updated parameter data.
Illustratively, continuing with the previous example, after parameter data including a token name is obtained from test data added to the shopping cart interface, a value corresponding to the token can be obtained from a yaml file by using the token name, and then the token name in the parameter data including the token name (i.e. the first parameter data) is replaced with the value corresponding to the token to update the first parameter data, so as to obtain updated parameter data, thereby establishing an association relationship between the shopping cart interface and the login interface through the value corresponding to the token.
As a possible implementation, the interface association method may further include:
(11) Acquiring second test data of a second interface; the second test data comprises second parameter data which is identified by a second identifier in advance, and the second parameter data comprises names of associated parameters and jsonnpath expressions of the associated parameters.
Similar to the first identifier, the second identifier may specifically take the form of a designated character, a designated keyword, and the like, which is not limited.
(12) When a second service request of a second interface is carried out, second parameter data are obtained from second test data based on a second identifier, and second service response data corresponding to the second service request are obtained; and the second service response data comprises values corresponding to the correlation parameters.
Illustratively, following the previous example, the second parameter data including the token name and the token jsonnph expression, which is labeled with the specified keyword in advance, is already included in the test data (i.e., the second test data) of the login interface, and in order to implement the interface association between the shopping cart interface and the login interface, when a logged-in service request is made, the specified keyword may be used to determine and obtain the parameter data including the token name and the token jsonnph expression from the test data of the login interface, and receive the service response data (i.e., the second service response data) corresponding to the service request, where the service response data includes the value corresponding to the token.
(13) And extracting a value corresponding to the associated parameter from the second service response data based on the jsonnpath expression of the associated parameter, and storing the name of the associated parameter and the value corresponding to the associated parameter into the yaml file in an associated manner.
Illustratively, continuing with the previous example, after obtaining the token name and the token jsonnph expression and receiving the service response data corresponding to the logged service request, the value corresponding to the token may be extracted from the service response data based on the token jsonnph expression, and the token name and the value corresponding to the token are stored in a xml file in an associated manner, so that the value corresponding to the token may be obtained from the xml file in the subsequent interface association process, thereby improving the efficiency of interface association.
As a possible implementation manner, the step of storing the name of the associated parameter and the value corresponding to the associated parameter in the yaml file in an associated manner may include: and storing the name of the associated parameter and the value corresponding to the associated parameter in the yaml file in an associated manner in a key value pair manner. The storage mode can ensure the stability of the association relation between the name of the associated parameter and the value corresponding to the associated parameter, and can improve the efficiency of acquiring the value corresponding to the associated parameter from the yaml file, thereby ensuring the high-efficiency implementation of interface association.
As a possible implementation, the interface association method may further include: acquiring first original test data of a first interface; the first original test data comprise first original parameter data of the associated parameters, and the first original parameter data comprise names of the associated parameters; and identifying the name of the associated parameter in the first original parameter data by using the first identifier to obtain first parameter data.
For example, following the previous example, before the token is used as the association parameter to interface-associate the shopping cart interface and the login interface, the original parameter data (i.e. the first original parameter data) including the token name in the original test data (i.e. the first original test data) added to the shopping cart interface may be identified by using a specified character (i.e. the first identifier), so as to obtain the first parameter data identified by using the specified character.
As a possible implementation, the interface association method may further include: acquiring second original test data of a second interface; the second original test data comprise second original parameter data of the associated parameters, and the second original parameter data comprise names of the associated parameters and jsonnpath expressions of the associated parameters; and identifying the name of the associated parameter and the jsonnpath expression of the associated parameter in the second original parameter data by using a second identifier to obtain second parameter data.
For example, continuing with the previous example, before the token is used as the association parameter to interface-associate the interface of the shopping cart with the login interface, the original parameter data (i.e. the second original parameter data) including the token name and the token jsonnph expression in the original test data (i.e. the second original test data) of the login interface may be identified by using a specified keyword (i.e. the second identifier), so as to obtain the second parameter data identified by using the specified keyword.
For ease of understanding, the above interface association method is exemplarily described with fig. 2 as follows: referring to fig. 2, for an interface a (i.e., a second interface) and an interface B (i.e., a first interface) that need to perform interface association, the interface association method may be performed according to the following operation flows:
step 1, storing second test data of an interface A to a first xml file in a key value pair mode; and identifying the associated parameters to be extracted and the jsonnpath expression corresponding to the associated parameters by keyword extract in the second test data.
Illustratively, the name of the associated parameter and the jsonnpath expression corresponding to the associated parameter are stored in a key-value format, where key is the name of the associated parameter and value is the jsonnpath expression corresponding to the associated parameter.
For example, in a case where a token is required to be used as an association parameter to perform interface association between a shopping cart joining interface and a login interface, the interface a is the login interface, the interface B is the shopping cart joining interface, and the second test data of the login interface can be stored in the following form:
Figure BDA0003989723470000081
Figure BDA0003989723470000091
the name of the associated parameter (i.e. token) to be extracted is access _ token, the jsonnph expression corresponding to the token is $.
Step 2, initiating a second service request of the interface A, and receiving second service response data corresponding to the second service request by using the variable A; and the second service response data comprises values corresponding to the correlation parameters.
Continuing the previous example, the interface a is a login interface, when a login request is initiated, the variable a is used to receive response text data of the login interface, and the response text data can be stored in the following form:
A={"result":"success",
"code":200,
"message": operation is successful,
"data":{"accessToken":"6306fd18e4b08db293da20db",
"tokenType":"bearer"}}
wherein the associated parameter (i.e. token) corresponds to a value of 6306fd18e4b08db293da20db.
And step 3, traversing the second test data of the interface A to judge whether a keyword extract exists, and if the keyword extract exists, acquiring the name of the associated parameter to be extracted under the keyword extract and the jsonnph expression corresponding to the associated parameter.
Continuing the previous example, the interface A is a login interface, traversing second test data of the login interface, judging whether a keyword extract exists, if so, circularly obtaining a key of value under the keyword extract (in the example, obtaining access _ token: $ accessToken), and if not, indicating that the login interface does not need to extract parameter data associated with the interface.
And 4, after acquiring the associated parameter to be extracted under the keyword extract and the jsoproath expression corresponding to the associated parameter, extracting the value corresponding to the associated parameter from the second service response data by using the jsoproath expression corresponding to the associated parameter.
Continuing to the previous example, the interface A is a login interface, and after acquiring access _ token under extract $.. AccesToken, extracting a value1 corresponding to the token (in this example, 6306fd18e4b08db293da20 db) from the variable A by using a jsonnpath value extraction method jsonnpath. (obj, expr); where obj is the data source (variable a in this example) and expr is the jsonnpath expression ($.. Accessotoken in this example).
And 5, after the value corresponding to the associated parameter is obtained, storing the name of the associated parameter and the value corresponding to the associated parameter into an extract.
Continuing with the previous example, interface A is a login interface, extracts the value1 (in this example, 6306fd18e4b08db293da20 db) corresponding to the token, assembles the original key (in this example, access _ token) and value1 into a key-value pair key 1 (in this example, access _ token:6306fd18e4b08db293da20 db), and writes the key-value pair into an extract.
Step 6, storing the first test data of the interface B to a second xml file in a key value pair mode; the name of the associated parameter to be extracted is identified by an identifier "{ } }" in the first test data, and the identified form is "{ { name of the associated parameter to be extracted } }".
For example, if there is an associated parameter to be extracted from the interface a in the first test data, the parameter name: { { name of associated parameter to be extracted } }).
Continuing with the previous example, interface B is a shopping cart interface, and the first test data added to the shopping cart interface may be stored in the following form:
Figure BDA0003989723470000111
wherein, the name of the associated parameter (i.e. token) to be extracted is access _ token.
And 7, before initiating the first service request of the interface B, traversing first test data of the interface B to judge whether an identifier is "{ } }", and if the identifier is "{ } }", extracting the name of the associated parameter in the identifier "{ } }".
Continuing with the previous example, the interface B is a shopping cart adding interface, before initiating a shopping cart adding request, first test data added to the shopping cart interface is traversed, after a data type of the first test data is converted into a character string, whether an identifier "{ } }", and if yes, data (in this example, access _ token) in the identifier "{ } }" is extracted.
And 8, acquiring a value corresponding to the associated parameter from the extract. Yaml file by using the extracted name of the associated parameter, and replacing the { { the name of the associated parameter to be extracted } } in the first test data by using the value corresponding to the associated parameter to obtain the test data after the replacement is completed.
Continuing with the previous example, the interface B is a shopping cart interface, and after obtaining the name (in this example, access _ token) of the associated parameter (i.e., token) from the first test data, the name is used to read the value (in this example, 6306fd18e4B08db293da20 db) corresponding to the associated parameter in the extract.yaml file, and then 6306fd18e4B08db293da20db is used to replace { { access _ token } in the first test data, so as to obtain the replaced test data. The test data after the replacement is completed can be stored in the following form:
Figure BDA0003989723470000112
Figure BDA0003989723470000121
and 9, carrying out a first service request of the interface B by using the replaced test data, thereby realizing the interface association of the interface A and the interface B.
Continuing with the previous example, the interface a is a login interface, the interface B is a shopping cart adding interface, and after { { access _ token } } in the first test data is replaced by 6306fd18e4B08db293da20db to obtain replaced test data, the replaced test data is used to make a shopping cart adding request, thereby realizing the interface association between the login interface and the shopping cart adding interface.
In the interface association method, an association parameter to be extracted and a jsonnpath expression corresponding to the association parameter are identified through a keyword extract, when an interface A service request is carried out, if the relevant keyword extract in test data of the interface A, the name of the association parameter under the keyword extract and the jsonnpath expression corresponding to the association parameter are obtained, the jsonnpath expression corresponding to the association parameter is used for extracting a value corresponding to the association parameter from response data corresponding to the interface A service request, and then the name of the association parameter and the value corresponding to the association parameter are stored into an extract. Before the service request of the interface B is carried out, if the identifier { } exists in the test data of the interface B, the name of the associated parameter in the identifier is obtained, the extracted name of the associated parameter is used for obtaining the value corresponding to the associated parameter from extract.yaml, the name of the associated parameter is used for replacing the name of the associated parameter in the test data of the interface B, the name of the associated parameter is used for completing the association operation of the interface, and the replaced test data can be used for carrying out the service request of the interface B. By adopting the technology, the name of the associated parameter and the value corresponding to the associated parameter can be stored through extract.
Based on the above interface association method, an embodiment of the present invention further provides an interface association apparatus, and referring to fig. 2, the apparatus may include the following modules:
a first obtaining module 202, configured to obtain first test data of a first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters.
The second obtaining module 204 may be configured to obtain the first parameter data from the first test data based on the first identifier before the first service request of the first interface is performed.
An updating module 206, configured to update the first parameter data based on the name of the associated parameter and a preset yaml file, to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file in an associated manner, and the updated parameter data is used for making a first service request of the first interface.
The interface association device provided by the embodiment of the invention acquires first test data of a first interface; the first test data comprises first parameter data which is marked by a first mark in advance, and the first parameter data comprises names of associated parameters; before a first service request of a first interface is carried out, first parameter data are obtained from first test data based on a first identifier; updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in association with the yaml file, and the updated parameter data is used for carrying out a first service request of the first interface. By adopting the technology, the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file, the latest value corresponding to the associated parameter can be dynamically obtained when the interface test is carried out, the associated parameter extracted in the interface association process can be quickly and clearly checked, and the problem of quick positioning can be solved, so that the problem that the associated parameter cannot be quickly determined when the interface test has errors in the existing interface association scheme can be solved.
The update module 206 may be further configured to: and acquiring a value corresponding to the associated parameter from a preset yaml file based on the name of the associated parameter, and replacing the name of the associated parameter in the first parameter data with the value corresponding to the associated parameter to obtain updated parameter data.
Based on the interface association apparatus shown in fig. 2, an embodiment of the present invention further provides another interface association apparatus, as shown in fig. 3, the apparatus may further include:
a third obtaining module 208, configured to obtain second test data of the second interface; wherein the second test data includes second parameter data previously identified with a second identifier, and the second parameter data includes a name of the associated parameter and a jsonnpath expression of the associated parameter.
A fourth obtaining module 210, configured to obtain, when a second service request of a second interface is performed, second parameter data from the second test data based on the second identifier, and obtain second service response data corresponding to the second service request; wherein the second service response data includes a value corresponding to the correlation parameter.
The association storage module 212 may be configured to extract a value corresponding to the association parameter from the second service response data based on the jsonnpath expression of the association parameter, and store the name of the association parameter and the value corresponding to the association parameter in the yaml file in an association manner.
The association storage module 212 may further be configured to: and storing the name of the associated parameter and the value corresponding to the associated parameter into the yaml file in an associated manner in the form of a key-value pair.
Referring to fig. 3, the interface association apparatus may further include:
a fifth obtaining module 214, configured to obtain first original test data of the first interface; wherein the first raw test data comprises first raw parameter data of an associated parameter, the first raw parameter data comprising a name of the associated parameter.
The first identification module 216 may be configured to identify, by using the first identifier, a name of the associated parameter in the first original parameter data, to obtain the first parameter data.
Referring to fig. 3, the interface association apparatus may further include:
a sixth obtaining module 218, configured to obtain second original test data of the second interface; wherein the second raw test data comprises second raw parameter data of an associated parameter, the second raw parameter data comprising a name of the associated parameter and a jsonnpath expression of the associated parameter.
The second identifying module 220 may be configured to identify, by using the second identifier, the name of the associated parameter and the jsonnpath expression of the associated parameter in the second original parameter data, so as to obtain the second parameter data.
The interface association apparatus provided in the embodiment of the present invention has the same implementation principle and technical effect as those of the interface association method embodiment, and for brief description, reference may be made to corresponding contents in the method embodiment for a part not mentioned in the apparatus embodiment.
An embodiment of the present invention further provides an electronic device, as shown in fig. 4, which is a schematic structural diagram of the electronic device, where the electronic device includes a processor 41 and a memory 40, the memory 40 stores computer-executable instructions that can be executed by the processor 41, and the processor 41 executes the computer-executable instructions to implement the interface association method.
In the embodiment shown in fig. 4, the electronic device further comprises a bus 42 and a communication interface 43, wherein the processor 41, the communication interface 43 and the memory 40 are connected by the bus 42.
The Memory 40 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 43 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, etc. may be used. The bus 42 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 42 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but this does not indicate only one bus or one type of bus.
The processor 41 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 41. The Processor 41 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, or discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in ram, flash, rom, prom, or eprom, registers, etc. as is well known in the art. The storage medium is located in a memory, and the processor 41 reads information in the memory and completes the steps of the interface association method of the foregoing embodiment in combination with hardware thereof.
Unless specifically stated otherwise, the relative steps, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
The functions, if implemented in software functional units and sold or used as a stand-alone product, may be stored in a non-transitory computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. An interface association method, the method comprising:
acquiring first test data of a first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters;
before a first service request of the first interface is carried out, acquiring the first parameter data from the first test data based on the first identifier;
updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file in an associated manner, and the updated parameter data is used for making a first service request of the first interface.
2. The method according to claim 1, wherein updating the first parameter data based on the name of the associated parameter and a preset yaml file, and the step of obtaining updated parameter data comprises:
and acquiring a value corresponding to the associated parameter from a preset yaml file based on the name of the associated parameter, and replacing the name of the associated parameter in the first parameter data with the value corresponding to the associated parameter to obtain updated parameter data.
3. The method of claim 1, further comprising:
acquiring second test data of a second interface; the second test data comprises second parameter data which is identified by a second identifier in advance, and the second parameter data comprises the name of the associated parameter and a jsonnpath expression of the associated parameter;
when a second service request of a second interface is carried out, acquiring second parameter data from the second test data based on the second identifier, and acquiring second service response data corresponding to the second service request; the second service response data comprises values corresponding to the correlation parameters;
extracting a value corresponding to the associated parameter from the second service response data based on the jsonnpath expression of the associated parameter, and storing the name of the associated parameter and the value corresponding to the associated parameter into the yaml file in an associated manner.
4. The method according to claim 3, wherein the step of storing the name of the associated parameter and the value corresponding to the associated parameter in the yaml file in an associated manner comprises:
and storing the name of the associated parameter and the value corresponding to the associated parameter into the yaml file in an associated manner in the form of a key-value pair.
5. The method of claim 1, further comprising:
acquiring first original test data of the first interface; wherein the first original test data comprises first original parameter data of an associated parameter, the first original parameter data comprising a name of the associated parameter;
and identifying the name of the associated parameter in the first original parameter data by using the first identifier to obtain the first parameter data.
6. The method of claim 3, further comprising:
acquiring second original test data of the second interface; wherein the second raw test data comprises second raw parameter data of an associated parameter, the second raw parameter data comprising a name of the associated parameter and a jsonnpath expression of the associated parameter;
and identifying the name of the associated parameter and the jsonnpath expression of the associated parameter in the second original parameter data by using the second identifier to obtain the second parameter data.
7. An interface association apparatus, the apparatus comprising:
the first acquisition module is used for acquiring first test data of the first interface; the first test data comprises first parameter data which is identified by a first identifier in advance, and the first parameter data comprises names of associated parameters;
a second obtaining module, configured to obtain the first parameter data from the first test data based on the first identifier before a first service request of the first interface is performed;
the updating module is used for updating the first parameter data based on the name of the associated parameter and a preset yaml file to obtain updated parameter data; the name of the associated parameter and the value corresponding to the associated parameter are stored in the yaml file in an associated manner, and the updated parameter data is used for making a first service request of the first interface.
8. The apparatus of claim 7, wherein the update module is further configured to:
and acquiring a value corresponding to the associated parameter from a preset yaml file based on the name of the associated parameter, and replacing the name of the associated parameter in the first parameter data with the value corresponding to the associated parameter to obtain updated parameter data.
9. The apparatus of claim 7, further comprising:
the third acquisition module is used for acquiring second test data of the second interface; the second test data comprises second parameter data which is identified by a second identifier in advance, and the second parameter data comprises the name of the associated parameter and a jsonnpath expression of the associated parameter;
a fourth obtaining module, configured to, when a second service request of a second interface is performed, obtain, based on the second identifier, the second parameter data from the second test data, and obtain second service response data corresponding to the second service request; the second service response data comprises values corresponding to the correlation parameters;
and the association storage module is used for extracting a value corresponding to the association parameter from the second service response data based on the jsonnpath expression of the association parameter, and associating and storing the name of the association parameter and the value corresponding to the association parameter into the yaml file.
10. An electronic device comprising a processor and a memory, the memory storing computer-executable instructions executable by the processor, the processor executing the computer-executable instructions to implement the method of any one of claims 1 to 6.
CN202211578130.4A 2022-12-09 2022-12-09 Interface association method and device and electronic equipment Pending CN115904995A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211578130.4A CN115904995A (en) 2022-12-09 2022-12-09 Interface association method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211578130.4A CN115904995A (en) 2022-12-09 2022-12-09 Interface association method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115904995A true CN115904995A (en) 2023-04-04

Family

ID=86493152

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211578130.4A Pending CN115904995A (en) 2022-12-09 2022-12-09 Interface association method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115904995A (en)

Similar Documents

Publication Publication Date Title
CN112148509A (en) Data processing method, device, server and computer readable storage medium
CN111858376A (en) Request message generation method and interface test method
KR20190095099A (en) Transaction system error detection method, apparatus, storage medium and computer device
CN112232794A (en) Payment method and device, storage medium and electronic equipment
CN110851207A (en) State transition management method and device, electronic equipment and computer readable storage medium
CN112187622B (en) Instant message display method and device and server
CN115904995A (en) Interface association method and device and electronic equipment
CN111078529A (en) Client write-in module testing method and device and electronic equipment
CN112882707B (en) Rendering method and device, storage medium and electronic equipment
CN115408298A (en) Test method, device and system
CN112906404B (en) Translation document verification method, electronic device, and readable storage medium
CN111125605B (en) Page element acquisition method and device
CN112702324A (en) Method and device for determining website record type and server
CN113076094A (en) Front end component construction method and device and electronic equipment
CN112580334A (en) File processing method, file processing device, server and storage medium
CN112199529A (en) Picture processing method and device, electronic equipment and storage medium
CN114371866A (en) Version reconfiguration test method, device and equipment of service system
US9584614B2 (en) Method and system for migrating an interface
CN113408250B (en) Project file processing method and device
CN115509944A (en) Method and device for generating financial document abnormal case and electronic equipment
CN116414692A (en) Interface assertion method, device, server and storage medium
CN117033196A (en) Method, device, equipment and medium for testing file interface in banking business
CN115904481A (en) Interface document construction method and device, electronic equipment and storage medium
CN112506783A (en) Test method, test device and storage medium
CN116795840A (en) Service table processing method and device and electronic equipment

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