Interface response data verification method and related device
By automatically comparing the interface response data with the benchmark data, the integrity of the interface response data is verified, which solves the problem of high cost and difficulty of manual verification and achieves efficient and accurate data verification.
Patent Information
- Application Number
- CN202410822264.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-08-27
AI Technical Summary
The existing interface response data verification method relies on manual verification, which results in high cost, difficulty, and low efficiency.
By obtaining the response data of the target interface and comparing it with the benchmark data, it is determined whether the response data contains the benchmark data. If it is included, the verification is successful, otherwise it fails, a verification report is generated, and the baseline data is updated to improve verification efficiency.
No manual participation is required, which reduces labor costs, improves the verification efficiency and accuracy of response data, and solves the problem of difficult verification.
Smart Images

Figure CN118550835A
Abstract
Description
Technical Field
[0001] The present application relates to the field of interface testing technology, and in particular to an interface response data verification method and related devices. Background Art
[0002] In modern software development, interface testing is one of the important means to ensure software quality and stability. When performing interface testing, the response data returned by the interface needs to be verified.
[0003] Currently, the method for verifying the response data returned by the interface is mainly a manual verification method, that is, the response data returned by the interface is verified manually.
[0004] However, manually verifying the response data returned by the interface requires a lot of manpower, and since the response data returned by the interface is usually complex data, manual verification is difficult. It can be seen that the current interface response data verification method has high labor costs and is difficult to verify. Summary of the invention
[0005] In view of this, the present application provides an interface response data verification method and related devices to solve the problem that the current interface response data verification method has high labor costs and high verification difficulty. The technical solution is as follows:
[0006] The first aspect of the present application provides an interface response data verification method, comprising:
[0007] Acquire response data returned by the target interface for the test request as target response data, wherein the target response data includes a plurality of field information, each field information includes a field name and a field value corresponding to the field name;
[0008] By comparing the target response data with the benchmark data, determining whether the target response data includes the benchmark data, wherein the benchmark data is determined based on N pieces of interface response data, the N pieces of interface response data are response data returned when the target interface is successfully executed N times, and the benchmark data includes field information common to the N pieces of interface response data, where N is an integer greater than 1;
[0009] If the target response data includes the reference data, it is determined that the verification of the target response data succeeds; otherwise, it is determined that the verification of the target response data fails.
[0010] In a possible implementation, the interface response data verification method further includes:
[0011] Generate a verification report corresponding to the target response data according to the comparison between the target response data and the benchmark data and the verification result of the target response data;
[0012] Among them, if the target response data verification is successful, the verification report corresponding to the target response data contains indication information that the target response data verification is successful; if the target response data verification fails, the verification report corresponding to the target response data contains indication information that the target response data verification fails and field information deleted and / or modified in the target response data.
[0013] In a possible implementation, the N pieces of interface response data are in a sequential order, the first piece of interface response data is the interface response data with the earliest return time, and the last piece of interface response data is the interface response data with the latest return time;
[0014] The interface response data verification method further includes:
[0015] If the target response data is successfully verified, determining the field information shared by the target response data and the last N-1 pieces of interface response data among the N pieces of interface response data;
[0016] The reference data is updated to field information shared by the target response data and the last N-1 pieces of interface response data among the N pieces of interface response data, so as to verify the next response data returned by the target interface based on the updated reference data.
[0017] In a possible implementation manner, determining the reference data based on the N pieces of interface response data includes:
[0018] Select two pieces of interface response data from the N pieces of interface response data;
[0019] By comparing the two selected interface response data, the common field information of the two selected interface response data is determined as temporary reference information;
[0020] Traversing the remaining interface response data in the N interface response data: by comparing the currently traversed interface response data with the temporary benchmark information determined last time, determining the field information shared by the currently traversed interface response data and the temporary benchmark information determined last time as the temporary benchmark information determined this time;
[0021] The last determined temporary benchmark information is used as the final benchmark information.
[0022] In a possible implementation, comparing the two selected interface response data to determine the field information common to the two selected interface response data includes:
[0023] If the data type of the response data returned by the target interface is an array, for a plurality of first arrays included in one of the interface response data, determine a second array corresponding to each first array from a plurality of second arrays included in another interface response data;
[0024] According to the field information shared by each first array and the corresponding second array, the field information shared by the two selected interface response data is obtained.
[0025] In a possible implementation, determining the second array corresponding to each first array from the plurality of second arrays included in another piece of interface response data includes: for each first array, determining the number of field information shared by the first array and each second array by comparing the first array with each second array;
[0026] The second array having the largest amount of field information in common with the first array is determined as the second array corresponding to the first array.
[0027] A second aspect of the present application provides an interface response data verification device, comprising: an interface response data acquisition module, a comparison and verification module, and a verification result determination module;
[0028] The interface response data acquisition module is used to acquire the response data returned by the target interface for the test request as the target response data, wherein the target response data includes a plurality of field information, each field information includes a field name and a field value corresponding to the field name;
[0029] The comparison and verification module is used to determine whether the target response data contains the benchmark data by comparing the target response data with the benchmark data, wherein the benchmark data is determined based on N pieces of interface response data, the N pieces of interface response data are response data returned after the target interface is successfully executed N times, and the benchmark data includes field information common to the N pieces of interface response data;
[0030] The verification result determination module is used to determine that the verification of the target response data is successful when the comparison and verification module determines that the target response data includes the benchmark data, and to determine that the verification of the target response data fails when the comparison and verification module determines that the target response data does not include the benchmark data.
[0031] A third aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0032] The memory is used to store computer programs;
[0033] The processor is used to execute the computer program so that the electronic device can implement the steps of any one of the above-mentioned interface response data verification methods.
[0034] The fourth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the steps of any one of the above-mentioned interface response data verification methods.
[0035] A fifth aspect of the present application provides a computer program product, comprising computer-readable instructions, which, when executed on an electronic device, enables the electronic device to implement the steps of any one of the above-mentioned interface response data verification methods.
[0036] By means of the above technical solution, the interface response data verification method provided by the present application first obtains the response data returned by the target interface for the test request as the target response data, and then determines whether the target response data contains the benchmark data by comparing the target response data with the benchmark data (the benchmark data includes the field information common to the N response data returned by the target interface after N successful executions). If the target response data contains the benchmark data, it is determined that the target response data verification is successful, otherwise, it is determined that the target response data verification fails. The interface response data verification method provided by the present application can obtain stable and reliable benchmark data in advance, and then verify the target response data based on the benchmark data. The interface response data verification method provided by the present application does not require manual participation, thus avoiding the problems caused by the manual verification method, that is, the interface response data verification method provided by the present application solves the problem of difficulty in response data verification, and at the same time, it also saves labor costs and improves the verification efficiency and accuracy of response data. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0038] Figure 1 A schematic diagram of the system architecture involved in this application;
[0039] Figure 2 A schematic diagram of a hardware structure of a terminal provided in an embodiment of the present application;
[0040] Figure 3 A schematic diagram of a hardware structure of a server provided in an embodiment of the present application;
[0041] Figure 4 A flowchart of an interface response data verification method provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of the structure of an interface response data verification device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0044] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0045] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0046] Before introducing the interface response data verification method provided by this application, the system architecture involved in this application is first explained.
[0047] like Figure 1 As shown, the system architecture may include a terminal device 100 and a server 200, wherein the server 200 may include one or more servers ( Figure 1 A server is included as an example for explanation).
[0048] The user can use the terminal device 100 to interact with the server 200 through a network (wired network or wireless network) to receive or send messages, etc. Various client applications can be installed on the terminal device 100, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0049] Next, the product form of the terminal 100 will be described.
[0050] The terminal 100 mentioned above can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiments of the present application do not impose any restrictions on this.
[0051] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.
[0052] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 The terminal 100 is merely an example and does not constitute a limitation on the terminal 100 , and may include more or less components than those shown in the figure, or may combine certain components, or may include different components.
[0053] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the terminal 100. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0054] The display unit 140 may be used to display information input by a user or information provided to a user, various menus of the terminal, an interactive interface, file display, and / or playback of any multimedia file.
[0055] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.
[0056] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal 100 as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on independent chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.
[0057] The radio frequency unit 110 (optional) can be used to receive and send information or receive and send signals during a call. For example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the radio frequency unit 110 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LowNoiseAmplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General PacketRadio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0058] In the embodiment of the present application, the radio frequency unit 110 can send data to other devices, and can also receive data sent by other devices. It should be understood that the radio frequency unit 110 is optional, and can be replaced by other communication interfaces, such as a network port.
[0059] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0060] The terminal 100 also includes an external interface 180, which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal.
[0061] Although not shown, the terminal 100 may further include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which will not be described in detail herein.
[0062] Next, the product form of the server 200 will be described.
[0063] Figure 3A structural diagram of the server 200 is provided. Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0064] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0065] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0066] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard drive (HDD), or a solid state drive (SSD).
[0067] It should be noted that the interface response data verification method provided in the embodiment of the present application is generally executed by the server 200. In view of this, the memory 204 can be used to store software codes related to the interface response data verification method, the processor 202 can call the software code stored in the memory 204, and can also schedule other units to implement corresponding functions.
[0068] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0069] In view of the fact that the current interface response data verification method (i.e., manual verification of the response data returned by the interface) has problems such as high labor costs and difficulty in manual verification, the inventor of this case conducted research and, through continuous research, ultimately proposed an interface response data verification method, which can automatically verify the interface response data and avoid the problems caused by manual verification.
[0070] Next, the interface response data verification method provided by this application is introduced through the following embodiments.
[0071] See also Figure 4 , shows a schematic diagram of the process of the interface response data verification method provided by an embodiment of the present application, the method may include:
[0072] Step S401: Acquire response data returned by the target interface for the test request as target response data.
[0073] Among them, the test request is a test request for a specified test case. It should be noted that an interface can be configured with different parameters. Different configured parameters will result in different functions implemented by the interface, and accordingly, the response data returned by the interface will also be different. The above-mentioned specified test case is an interface parameter. The response data mentioned in this case are all response data under the specified test case.
[0074] The target response data includes several fields, each of which includes a field name and a field value corresponding to the field name. The following shows an example of the response data returned by the target interface for the test request. Due to the large amount of response data, only a part of the response data is shown below:
[0075] “…
[0076] Body
[0077] {
[0078] "code": 200,
[0079] "msg": "Operation successful",
[0080] "data": {
[0081] …
[0082] "unixtime": 1716976803,
[0083] "tabBar2JumpUrl": "",
[0084] "tabBar2LoginFlag": 0,
[0085] …
[0086] "oa_check": 0,
[0087] "default_channel": 1,
[0088] "ad_flag": 1,
[0089] …”
[0090] In the above examples, "code", "msg", "unixtime", etc. are all field names, "200" is the field value corresponding to the field name "code", "operation successful" is the field value corresponding to the field name "msg", and "1716976803" is the field value corresponding to the field name "unixtime".
[0091] Step S402: Determine whether the target response data contains the benchmark data by comparing the target response data with the benchmark data.
[0092] The benchmark data is determined based on N pieces of interface response data, where the N pieces of interface response data are response data returned after the target interface is successfully executed N times, and the benchmark data includes field information common to the N pieces of interface response data, where N is an integer greater than 1. Optionally, the benchmark data may be stored in a database, and when the response data needs to be verified, the benchmark data may be obtained from the database.
[0093] For example, N is 10, and the response data returned by the target interface after 10 successful executions, that is, 10 pieces of response data, can be collected. Then, the common field information of the 10 pieces of response data (that is, the field information contained in all 10 pieces of response data) is obtained, and the common field information of the 10 pieces of response data is used as the benchmark data. Assume that all 10 pieces of response data contain field information a (field name A: field value v A )、field information b(field name B: field value v B )、field information c(field name C:field value v C ) and field information d (field name D: field value v D ), field information a, field information b, field information c and field information d are used as benchmark data.
[0094] It should be noted that the response data returned by the target interface will include a status code. If the status code in the response data returned by the target interface is "200", it is considered that the target interface is successfully executed.
[0095] An example of benchmark data is shown below:
[0096] "{
[0097] "code": 200,
[0098] "msg": "Operation successful",
[0099] "data": {
[0100] …
[0101] "tabBar2JumpUrl": "",
[0102] "tabBar2LoginFlag": 0,
[0103] …
[0104] "oa_check": 0,
[0105] "default_channel": 1,
[0106] "ad_flag": 1,
[0107] "tb_flag": 1,
[0108] "audit_flag": 0,
[0109] "vip_flag": 0,
[0110] "discover_channel_stickey": 1,
[0111] "mall_channel_stickey": 1,
[0112] "mt_flag": 0,
[0113] "mark_show_flag": 1,
[0114] "risk_management_flag": 1,
[0115] "mg_card_version": "4.4.0",
[0116] "lauchAniInterval": 604800,
[0117] "retry_domain_info": {
[0118] "retryStatus": 1,
[0119] "chemestatus": 1,
[0120] "mainHostTimeout": 4,
[0121] ..."
[0122] The present application pre-collects response data returned by the target interface after N successful executions, determines benchmark data based on the response data returned by the target interface after N successful executions, and then, when the response data returned by the target interface is obtained, the determined benchmark data is used to verify the response data.
[0123] Step S403a: If the target response data includes the reference data, it is determined that the target response data verification is successful.
[0124] For example, the benchmark data includes field information a (field name A: field value v A )、field information b(field name B: field value v B )、field information c(field name C:field value v C ) and field information d (field name D: field value v D ), if the target response data contains field information a (field name A: field value v A )、field information b(field name B: field value v B )、field information c(field name C:field value v C ) and field information d (field name D: field value v D ), it is determined that the target response data verification is successful.
[0125] Step S403b: If the target response data does not include the reference data, it is determined that the target response data verification fails.
[0126] It should be noted that there are two situations in which the target response data does not include the benchmark data. One situation is that the target response data includes part of the field information included in the benchmark data. The other situation is that the target response data does not include any field information in the field information included in the benchmark data.
[0127] For example, the benchmark data includes field information a (field name A: field value v A )、field information b(field name B: field value v B ) and field information c (field name C: field value v C ), assuming that the target response data contains field information a (field name A: field value v A )、field information b(field name B: field value v B )、field information c(field name C:field value v C ′ ), since the field value corresponding to the field name C in the target response data is different from the field value corresponding to the field name C in the benchmark data, the target response data does not contain the field information c in the benchmark data, that is, the target response data only contains part of the field information in the benchmark data, so it can be determined that the target response data verification has failed.
[0128] For example, the benchmark data includes field information a (field name A: field value v A )、field information b(field name B: field value v B ) and field information c (field name C: field value v C ), assuming that the target response data contains the field information b in the benchmark data (field name B: field value v B ) and field information c (field name C: field value v C ), does not include the field information a in the benchmark data (does not include the field name A and its corresponding field value v A ), since the target response data only contains part of the field information in the benchmark data, it is determined that the target response data verification fails.
[0129] For example, the benchmark data includes field information a (field name A: field value v A )、field information b(field name B: field value v B ) and field information c (field name C: field value v C ), assuming that the target response data does not contain any of the above three field information, it is determined that the target response data does not contain the benchmark data, and then it is determined that the target response data verification fails.
[0130] The interface response data verification method provided in the embodiment of the present application first obtains the response data returned by the target interface for the test request as the target response data, and then determines whether the target response data contains the benchmark data by comparing the target response data with the benchmark data (the benchmark data includes the field information common to the N response data returned by the target interface after N successful executions). If the target response data contains the benchmark data, it is determined that the target response data verification is successful, otherwise, it is determined that the target response data verification fails. The interface response data verification method provided in the embodiment of the present application can obtain stable and reliable benchmark data in advance, and then verify the target response data based on the benchmark data. The interface response data verification method provided in the embodiment of the present application does not require manual participation, avoiding the problems caused by the manual verification method, that is, the interface response data verification method provided in the embodiment of the present application solves the problem of difficulty in response data verification, and at the same time, it also saves labor costs and improves the verification efficiency and verification accuracy of the response data.
[0131] In another embodiment of the present application, the interface response data verification method may include, in addition to the above-mentioned steps S401 to S403, further including: generating a verification report corresponding to the target response data based on the comparison between the target response data and the benchmark data, and the verification result of the target response data.
[0132] Optionally, after generating the verification report corresponding to the target response data, the verification report corresponding to the target response data may be stored in a database.
[0133] It should be noted that if the target response data verification is successful, the verification report corresponding to the target response data may include indication information of successful verification of the target response data; if the target response data verification fails, the verification report corresponding to the target response data may include indication information of failed verification of the target response data and field information of deleted and / or modified target response data (i.e., difference information).
[0134] An example of the difference information between the target response data and the baseline data is shown below:
[0135] {
[0136] data: {
[0137] else_config: {
[0138] - show_interest: 1
[0139] +show_interest: 0
[0140] - show_setting: 1
[0141] + show_setting: 0
[0142] - show_welcome: 1
[0143] + show_welcome: 0
[0144] }
[0145] }
[0146] }
[0147] Among them, the field value corresponding to the field name "show_interest" in the benchmark data is "1", and the field value corresponding to the field name "show_interest" in the target response data is changed to "0", and the same applies to the others.
[0148] In another embodiment of the present application, the interface response data verification method may include, in addition to the above-mentioned steps S401 to S403, and the above-mentioned verification report generation step, further including: if the target response data verification is successful, determining the field information shared by the target response data and the last N-1 interface response data among the N interface response data; updating the baseline data to the field information shared by the target response data and the last N-1 interface response data among the N interface response data, so as to verify the next response data returned by the target interface based on the updated baseline data.
[0149] It should be noted that the above-mentioned "N pieces of interface response data" have a sequence. The first interface response data is the interface response data with the earliest return time, and the last interface response data is the interface response data with the latest return time. After the target response data is successfully verified, the field information shared by the target response data and the last N-1 pieces of interface response data in the above-mentioned "N pieces of interface response data" can be used as the latest benchmark data.
[0150] Each subsequent successful verification of a piece of interface response data will redetermine the benchmark data based on the successfully verified interface response data and the last N-1 pieces of interface response data among the N pieces of interface response data on which the last benchmark data was determined. When verifying the next piece of interface response data, the latest benchmark data will be used for verification.
[0151] The above embodiment mentioned that the reference data can be determined based on N pieces of interface response data. In another embodiment of the present application, a process of determining the reference data based on N pieces of interface response data is introduced.
[0152] The process of determining the benchmark data based on N pieces of interface response data may include:
[0153] Step a1: Select two pieces of interface response data from N pieces of interface response data.
[0154] In one possible implementation, the first two interface response data (the two interface response data with the earliest return time) may be selected from N interface response data (the N interface response data are sorted by return time). In another possible implementation, two interface response data may be randomly selected from the N interface response data.
[0155] Step a2: By comparing the two selected interface response data, the common field information of the two selected interface response data is determined as temporary reference information.
[0156] If the data type of the response data returned by the target interface is an object, the two selected interface response data may be directly compared to determine the common field information of the two selected interface response data.
[0157] If the data type of the response data returned by the target interface is an array, the process of comparing the two selected interface response data to determine the field information common to the two selected interface response data may include:
[0158] Step a21: for a plurality of first arrays included in one of the interface response data, determine a second array corresponding to each first array from a plurality of second arrays included in another interface response data.
[0159] Specifically, for each first array, the number of field information shared by the first array and each second array is determined by comparing the first array with each second array, and the second array that has the largest number of field information shared with the first array is determined as the second array corresponding to the first array.
[0160] Exemplarily, one of the two interface response data includes array A1, array A2, and array A3, and the other interface response data includes array B1, array B2, and array B3. For array A1, by comparing array A1 with array B1, the number n11 of field information shared by array A1 and array B1 is determined, by comparing array A1 with array B2, the number n12 of field information shared by array A1 and array B2 is determined, by comparing array A1 with array B3, the number n13 of field information shared by array A1 and array B3 is determined, assuming that n11, n12, and n13 are If n12 is the largest, it is determined that array A1 corresponds to array B2. For array A2, by comparing array A2 with array B1, the number n21 of field information shared by array A2 and array B1 is determined. By comparing array A2 with array B2, the number n22 of field information shared by array A2 and array B2 is determined. By comparing array A2 with array B3, the number n23 of field information shared by array A2 and array B3 is determined. Assuming that n21 is the largest among n21, n22, and n23, it is determined that array A2 corresponds to array B1. The same method can be used to determine that array A3 corresponds to array B3.
[0161] Step a22: According to the field information shared by each first array and the corresponding second array, obtain the field information shared by the two selected interface response data.
[0162] For the above example, after determining that array A1 corresponds to array B2, array A2 corresponds to array B1, and array A3 corresponds to array B3, the common field information of the two selected interface response data can be obtained based on the common field information of array A1 and array B2, the common field information of array A2 and array B1, and the common field information of array A3 and array B3.
[0163] It should be noted that the response data returned by the target interface may include multiple levels. When comparing the two selected interface response data, it is necessary to compare the data at the same level (such as arrays at the same level) in the two interface response data to obtain the common field information of the data at the same level (such as arrays at the same level).
[0164] Step a3, traverse the remaining interface response data in the N interface response data: by comparing the currently traversed interface response data with the temporary benchmark information determined last time, determine the field information shared by the currently traversed interface response data and the temporary benchmark information determined last time as the temporary benchmark information determined this time.
[0165] The implementation process of comparing the currently traversed interface response data with the previously determined temporary benchmark information to determine the field information shared by the currently traversed interface response data and the previously determined temporary benchmark information is similar to the implementation process of "determining the field information shared by the two selected interface response data by comparing them" described above, and this embodiment will not be described in detail here. It should be noted that the temporary benchmark information can be regarded as simplified interface response data.
[0166] Step a4: The temporary benchmark information determined last time is used as the final benchmark information.
[0167] Exemplarily, N is 10, and the 10 interface response data are y1, y2, y3, y4, y5, ..., y10. y1 can be compared with y2 first to determine the field information shared by y1 and y2 as temporary benchmark information s1, and then s1 can be compared with y3 to determine the field information shared by s1 and y3 as temporary benchmark information s2, and then s2 can be compared with y4 to determine the field information shared by s2 and y4 as temporary benchmark information s3, ..., s8 can be compared with y10 to determine the field information shared by s8 and y10 as the final benchmark information.
[0168] In addition to determining the benchmark information according to steps a1 to a4 above, other methods may be used to determine the benchmark information. For example, N pieces of interface response data may be divided into several pairs of interface response data, and the field information common to each pair of interface response data may be determined. The common field information may be further determined for the common fields of several pairs of interface response data. Assuming that there are 10 pieces of interface response data, the 10 pieces of interface response data may be divided into 5 pairs, and the field information common to each pair of interface response data may be determined. After obtaining the field information common to 5 pairs of interface response data, the common field information may be further determined for the field information common to the 5 pairs of interface response data.
[0169] After the benchmark data is obtained in the above manner, the target response data may be compared with the benchmark data to determine whether the target response data contains the benchmark data.
[0170] By comparing the target response data with the benchmark data, it is determined whether the target response data contains the benchmark data, that is, by comparing the target response data with the benchmark data, the field information shared by the target response data and the benchmark data is determined. If the field information shared by the target response data and the benchmark data is the same as the field information included in the benchmark data, it is determined that the target response data contains the benchmark data; if the field information shared by the target response data and the benchmark data is different from the field information included in the benchmark data, it is determined that the target response data does not contain the benchmark data.
[0171] It should be noted that the process of determining the field information shared by the target response data and the benchmark data by comparing the target response data with the benchmark data (the benchmark information can be regarded as simplified interface response data) is similar to the implementation process of the above-mentioned "determining the field information shared by the two selected interface response data by comparing them", and this embodiment will not be elaborated here.
[0172] The above introduces the interface response data verification method provided in the embodiment of the present application. The following will introduce the device corresponding to the above interface response data verification method.
[0173] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of an interface response data verification device provided in an embodiment of the present application. The interface response data verification device may include: an interface response data acquisition module 501, a comparison and verification module 502 and a verification result determination module 503.
[0174] The interface response data acquisition module 501 is used to acquire the response data returned by the target interface in response to the test request as target response data.
[0175] The target response data includes a number of field information, each of which includes a field name and a field value corresponding to the field name.
[0176] The comparison and verification module 502 is used to determine whether the target response data contains the benchmark data by comparing the target response data with the benchmark data.
[0177] The benchmark data is determined based on N pieces of interface response data, where the N pieces of interface response data are response data returned when the target interface is successfully executed N times, and the benchmark data includes field information common to the N pieces of interface response data.
[0178] The verification result determination module 503 is used to determine that the verification of the target response data is successful when the comparison and verification module 502 determines that the target response data includes the reference data, and to determine that the verification of the target response data fails when the comparison and verification module 502 determines that the target response data does not include the reference data.
[0179] In a possible implementation, the interface response data verification device may further include: a verification report generation module.
[0180] The verification report generation module is used to generate a verification report corresponding to the target response data based on the comparison between the target response data and the benchmark data, as well as the verification result of the target response data.
[0181] Among them, if the target response data verification is successful, the verification report corresponding to the target response data contains indication information of successful verification of the target response data; if the target response data verification fails, the verification report corresponding to the target response data contains indication information of failed verification of the target response data and field information of deleted and / or modified target response data.
[0182] The N pieces of interface response data have a sequence, the first piece of interface response data is the interface response data with the earliest return time, and the last piece of interface response data is the interface response data with the latest return time.
[0183] In a possible implementation, the interface response data verification device may further include: a reference data updating module.
[0184] The benchmark data update module is used to determine the field information shared by the target response data and the last N-1 interface response data among N interface response data when the target response data is successfully verified, and to update the benchmark data to the field information shared by the target response data and the last N-1 interface response data among N interface response data, so as to verify the next response data returned by the target interface based on the updated benchmark data.
[0185] In a possible implementation, the interface response data verification device may further include: a reference data determination module. The reference data determination module is configured to determine reference data based on N pieces of interface response data.
[0186] When determining the benchmark data based on the N pieces of interface response data, the benchmark data determination module is specifically used to:
[0187] Select two pieces of interface response data from N pieces of interface response data;
[0188] By comparing the two selected interface response data, the common field information of the two selected interface response data is determined as temporary reference information;
[0189] Traversing the remaining interface response data in the N interface response data: by comparing the currently traversed interface response data with the temporary benchmark information determined last time, determining the field information shared by the currently traversed interface response data and the temporary benchmark information determined last time as the temporary benchmark information determined this time;
[0190] The last determined temporary benchmark information is used as the final benchmark information.
[0191] In a possible implementation, when the reference data determination module determines the field information common to the two selected interface response data by comparing the two selected interface response data, it is specifically used to:
[0192] If the data type of the response data returned by the target interface is an array, then for a plurality of first arrays included in one of the interface response data, determine a second array corresponding to each first array from a plurality of second arrays included in another interface response data;
[0193] According to the field information shared by each first array and the corresponding second array, the field information shared by the two selected interface response data is obtained.
[0194] In a possible implementation, when the reference data determination module determines the second array corresponding to each first array from the plurality of second arrays included in another interface response data, it is specifically used to: for each first array, by comparing the first array with each second array, determine the number of field information shared by the first array and each second array;
[0195] The second array having the largest amount of field information in common with the first array is determined as the second array corresponding to the first array.
[0196] The interface response data verification device provided in the embodiment of the present application first obtains the response data returned by the target interface for the test request as the target response data, and then determines whether the target response data contains the benchmark data by comparing the target response data with the benchmark data (the benchmark data includes the field information common to the N pieces of response data returned by the target interface after N successful executions). If the target response data contains the benchmark data, it is determined that the verification of the target response data is successful, otherwise, it is determined that the verification of the target response data fails. The interface response data verification device provided in the embodiment of the present application can obtain stable and reliable benchmark data in advance, and then automatically verify the target response data based on the benchmark data. The interface response data verification device provided in the embodiment of the present application solves the problem of difficult response data verification, and at the same time, it also saves labor costs and improves the verification efficiency and verification accuracy of the response data.
[0197] An embodiment of the present application also provides an electronic device, which may include: at least one processor, at least one communication interface, at least one memory and at least one communication bus.
[0198] In the embodiment of the present application, the number of the processor, the communication interface, the memory, and the communication bus is at least one, and the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0199] The processor may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application;
[0200] The memory may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0201] The memory stores a program, and the processor can call the program stored in the memory, and the program is used to implement the steps of the interface response data verification method provided in the above embodiment.
[0202] An embodiment of the present application also provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the steps of the interface response data verification method provided in the above embodiment.
[0203] An embodiment of the present application also provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the steps of the interface response data verification method provided in the above embodiment.
[0204] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0205] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0206] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0207] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A method for verifying interface response data, characterized in that: include: Acquire response data returned by the target interface for the test request as target response data, wherein the target response data includes a plurality of field information, each field information includes a field name and a field value corresponding to the field name; By comparing the target response data with the benchmark data, determining whether the target response data includes the benchmark data, wherein the benchmark data is determined based on N pieces of interface response data, the N pieces of interface response data are response data returned when the target interface is successfully executed N times, and the benchmark data includes field information common to the N pieces of interface response data, where N is an integer greater than 1; If the target response data includes the reference data, it is determined that the verification of the target response data succeeds; otherwise, it is determined that the verification of the target response data fails.
2. The interface response data verification method according to claim 1, characterized in that: Also includes: Generate a verification report corresponding to the target response data according to the comparison between the target response data and the benchmark data and the verification result of the target response data; Among them, if the target response data verification is successful, the verification report corresponding to the target response data contains indication information that the target response data verification is successful; if the target response data verification fails, the verification report corresponding to the target response data contains indication information that the target response data verification fails and field information deleted and / or modified in the target response data.
3. The interface response data verification method according to claim 1, characterized in that: The N pieces of interface response data have a sequence, the first piece of interface response data is the interface response data with the earliest return time, and the last piece of interface response data is the interface response data with the latest return time; The interface response data verification method further includes: If the target response data is successfully verified, determining the field information shared by the target response data and the last N-1 pieces of interface response data among the N pieces of interface response data; The reference data is updated to field information shared by the target response data and the last N-1 pieces of interface response data among the N pieces of interface response data, so as to verify the next response data returned by the target interface based on the updated reference data.
4. The interface response data verification method according to claim 1, characterized in that: Determining the benchmark data based on the N pieces of interface response data includes: Select two pieces of interface response data from the N pieces of interface response data; By comparing the two selected interface response data, the common field information of the two selected interface response data is determined as temporary reference information; Traversing the remaining interface response data in the N interface response data: by comparing the currently traversed interface response data with the temporary benchmark information determined last time, determining the field information shared by the currently traversed interface response data and the temporary benchmark information determined last time as the temporary benchmark information determined this time; The last determined temporary benchmark information is used as the final benchmark information.
5. The interface response data verification method according to claim 4, characterized in that: The step of comparing the two selected interface response data to determine the field information common to the two selected interface response data includes: If the data type of the response data returned by the target interface is an array, for a plurality of first arrays included in one of the interface response data, determine a second array corresponding to each first array from a plurality of second arrays included in another interface response data; According to the field information shared by each first array and the corresponding second array, the field information shared by the two selected interface response data is obtained.
6. The interface response data verification method according to claim 5, characterized in that: The determining the second array corresponding to each first array from the plurality of second arrays included in another piece of interface response data comprises: for each first array, by comparing the first array with each second array, determining the number of field information shared by the first array and each second array; The second array having the largest amount of field information in common with the first array is determined as the second array corresponding to the first array.
7. An interface response data verification device, characterized in that: include: Interface response data acquisition module, comparison and verification module and verification result determination module; The interface response data acquisition module is used to acquire the response data returned by the target interface for the test request as the target response data, wherein the target response data includes a plurality of field information, each field information includes a field name and a field value corresponding to the field name; The comparison and verification module is used to determine whether the target response data contains the benchmark data by comparing the target response data with the benchmark data, wherein the benchmark data is determined based on N pieces of interface response data, the N pieces of interface response data are response data returned after the target interface is successfully executed N times, and the benchmark data includes field information common to the N pieces of interface response data; The verification result determination module is used to determine that the verification of the target response data is successful when the comparison and verification module determines that the target response data includes the benchmark data, and to determine that the verification of the target response data fails when the comparison and verification module determines that the target response data does not include the benchmark data.
8. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the steps of the interface response data verification method as described in any one of claims 1 to 6.
9. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the steps of the interface response data verification method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that It includes computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the steps of the interface response data verification method as described in any one of claims 1 to 6.
