CN112084114A - Method and apparatus for testing an interface - Google Patents

Method and apparatus for testing an interface Download PDF

Info

Publication number
CN112084114A
CN112084114A CN202010974069.XA CN202010974069A CN112084114A CN 112084114 A CN112084114 A CN 112084114A CN 202010974069 A CN202010974069 A CN 202010974069A CN 112084114 A CN112084114 A CN 112084114A
Authority
CN
China
Prior art keywords
interface
data
request
tested
test
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
CN202010974069.XA
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.)
JD Digital Technology Holdings Co Ltd
Original Assignee
JD Digital Technology Holdings 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 JD Digital Technology Holdings Co Ltd filed Critical JD Digital Technology Holdings Co Ltd
Priority to CN202010974069.XA priority Critical patent/CN112084114A/en
Publication of CN112084114A publication Critical patent/CN112084114A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Abstract

Embodiments of the present disclosure disclose methods and apparatus for testing an interface. One embodiment of the method comprises: acquiring an identifier of a comparison interface; selecting interface data corresponding to the comparison interface from prestored historical interface data according to the identification of the comparison interface; determining request data and interface return data included in interface data corresponding to the comparison interface; acquiring test return data of the interface to be tested aiming at the request indicated by the request data; and generating a test result of the interface to be tested by comparing the interface return data with the test return data. The implementation mode realizes convenient and fast automatic test of the interface to be tested.

Description

Method and apparatus for testing an interface
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a method and apparatus for testing an interface.
Background
With changes in business needs, upgrades of system architectures, changes in application versions, and so on, what follows is the work of business migration. Service migration usually requires a tester to test an application interface related to a service, so as to avoid situations such as errors in data exchange of an API (application program interface) caused by service migration, and ensure the correctness and reliability of service migration.
The existing API test method comprises the steps that a tester writes test data manually, and then tests an interface to be tested by using the test data. Or, the tester writes an automatic test case, and then uses the test case to realize automatic test.
Disclosure of Invention
Embodiments of the present disclosure propose methods and apparatuses for testing an interface.
In a first aspect, an embodiment of the present disclosure provides a method for testing an interface, the method including: acquiring an identifier of a comparison interface; selecting interface data corresponding to the comparison interface from prestored historical interface data according to the identification of the comparison interface; determining request data and interface return data included in interface data corresponding to the comparison interface; acquiring test return data of the interface to be tested aiming at the request indicated by the request data; and generating a test result of the interface to be tested by comparing the interface return data with the test return data.
In some embodiments, the generation time of the historical interface data is within a preset time period from the current time.
In some embodiments, the historical interface data is stored in a message queue and/or an interface log.
In some embodiments, the obtaining the identifier of the contrast interface includes: receiving attribute information of a contrast interface; and determining the identification of the contrast interface according to the received attribute information of the contrast interface.
In some embodiments, the above method further comprises: and in response to receiving the attribute updating request aiming at the contrast interface, updating the attribute information of the contrast interface according to the attribute updating request.
In some embodiments, the above method further comprises: and in response to the received data deletion request aiming at the comparison interface, deleting the pre-stored interface data corresponding to the comparison interface according to the data deletion request.
In some embodiments, the obtaining test return data of the interface to be tested for the request indicated by the request data includes: sending a request indicated by the request data to the interface to be tested so that the interface to be tested executes the following processing steps: verifying the received request data to obtain a verification result; and obtaining test return data based on the received request data in response to determining that the obtained verification result indicates that the verification is passed.
In some embodiments, obtaining test return data of the interface under test for the request indicated by the request data includes: sending the request data to an interface to be tested; and determining the return data of the interface to be tested for the request data as the test return data.
In some embodiments, the request data includes a request string of request messages corresponding against the interface.
In some embodiments, after determining that the request data and the interface return data included in the interface data corresponding to the interface are matched, the method further includes: the association stores the identification against the interface, the request data, and the interface return data.
In a second aspect, an embodiment of the present disclosure provides an apparatus for testing an interface, the apparatus including: an identification acquisition unit configured to acquire an identification of the collation interface; the selecting unit is configured to select interface data corresponding to the comparison interface from pre-stored historical interface data according to the identification of the comparison interface; a determining unit configured to determine request data and interface return data included in interface data corresponding to an interface; a return data acquisition unit configured to acquire test return data of the interface to be tested for a request indicated by the request data; and the generating unit is configured to generate a test result of the interface to be tested by comparing the interface return data with the test return data.
In some embodiments, the generation time of the historical interface data is within a preset time period from the current time.
In some embodiments, the historical interface data is stored in a message queue and/or an interface log.
In some embodiments, the identifier obtaining unit is further configured to: receiving attribute information of a contrast interface; and determining the identification of the contrast interface according to the received attribute information of the contrast interface.
In some embodiments, the above apparatus further comprises: and the updating unit is configured to respond to the received attribute updating request aiming at the comparison interface and update the attribute information of the comparison interface according to the attribute updating request.
In some embodiments, the above apparatus further comprises: and the deleting unit is configured to respond to the received data deleting request aiming at the comparison interface, and delete the pre-stored interface data corresponding to the comparison interface according to the data deleting request.
In some embodiments, the return data obtaining unit is further configured to: sending a request indicated by the request data to the interface to be tested so that the interface to be tested executes the following processing steps: verifying the received request data to obtain a verification result; and obtaining test return data based on the received request data in response to determining that the obtained verification result indicates that the verification is passed.
In some embodiments, the return data obtaining unit is further configured to: sending the request data to an interface to be tested; and determining the return data of the interface to be tested for the request data as the test return data.
In some embodiments, the request data includes a request string of request messages corresponding against the interface.
In some embodiments, the above apparatus further comprises: and the storage unit is configured to store the identification of the contrast interface, the request data and the interface return data in an associated manner.
In a third aspect, an embodiment of the present disclosure provides a terminal, including: one or more processors; storage means for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any implementation of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, which computer program, when executed by a processor, implements the method as described in any of the implementations of the first aspect.
According to the method and the device for testing the interface, the interface data corresponding to the comparison interface is selected from the pre-stored historical interface data by using the identification of the comparison interface, so that the request data and the interface return data corresponding to the comparison interface are determined, then the test return data of the interface to be tested aiming at the request indicated by the request data is determined based on the request data corresponding to the comparison interface, and then the test result of the interface to be tested can be directly obtained by comparing the interface return data with the test return data, so that the convenient and fast automatic test of the interface to be tested is realized, a tester does not need to compile a large number of test cases according to a service scene in advance, and the test efficiency is improved.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of a method for testing an interface, according to the present disclosure;
FIG. 3 is a schematic diagram of one application scenario of a method for testing an interface in accordance with an embodiment of the present disclosure;
FIG. 4 is a flow diagram of yet another embodiment of a method for testing an interface according to the present disclosure;
FIG. 5 is a schematic block diagram illustrating one embodiment of an apparatus for testing an interface according to the present disclosure;
FIG. 6 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 to which embodiments of the disclosed method for testing an interface or apparatus for testing an interface may be applied.
As shown in fig. 1, the system architecture 100 may include a first terminal device 101, a second terminal device 103, and a database 102. The first terminal device 101 may be connected to a database 102. The first terminal device 101 and the second terminal device 103 may be communicatively connected via various connection types (e.g., wired, wireless communication link, or fiber optic cable, etc.).
Various client applications may be installed on the first terminal apparatus 101 and the second terminal apparatus 103. For example, browser-like applications, search-like applications, instant messaging tools, social platform software, and the like, information flow-like applications, and the like.
The first terminal apparatus 101 and the second terminal apparatus 103 may be hardware or software. When the first terminal device 101 and the second terminal device 103 are hardware, they may be various electronic devices including, but not limited to, a smart phone, a tablet computer, an e-book reader, a laptop portable computer, a desktop computer, and the like. When the first terminal apparatus 101 and the second terminal apparatus 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The database 102 may be various types of databases matched to the first terminal apparatus 101. Various data may be stored in the database 102 in advance for use by the first terminal apparatus 101. For example, the database 102 may store request data and interface return data included in the interface data corresponding to the interface of the application to be tested.
The database 102 may be provided in the first terminal apparatus 101, and the number stored in the database 102 may be directly stored in the local area of the first terminal apparatus 101.
The second terminal device 103 may be installed with an application to be tested to complete testing of an interface to be tested of the application to be tested. The application to be tested installed on the second terminal device 103 may receive the request data corresponding to the comparison interface sent by the first terminal device 101, and determine, according to the received request data, a test return value of the interface to be tested for the request indicated by the request data.
It should be noted that the method for testing the interface provided by the embodiment of the present disclosure is generally performed by the first terminal device 101, and accordingly, the apparatus for testing the interface is generally disposed in the first terminal device 101.
It should be understood that the number of first terminal devices, second terminal devices and databases in fig. 1 is merely illustrative. There may be any number of first terminal devices, second terminal devices and databases, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for testing an interface in accordance with the present disclosure is shown. The method for testing the interface comprises the following steps:
step 201, acquiring the identifier of the contrast interface.
In this embodiment, an interface may generally refer to a convention for interfacing different components of a software system. Generally, the interface can realize the intercommunication of different components and different software systems of the software system. Meanwhile, the interface can be used as a middleware to realize data transfer between different system platforms. For example, interfaces include, but are not limited to: an API (Application Programming Interface), an access Interface of a database system, an HTTP (HyperText Transfer Protocol) Interface, a WebService Interface, and the like.
The comparison interface may refer to an interface for comparison with the interface to be tested to complete testing of the interface to be tested. In general, the contrast interface and the interface to be tested may be a cross-contrast of the same interface. For example, the contrast interface may be an interface "a" of the original application, and the interface to be tested may be an interface "a" of the new version of the application, which is obtained by updating the version of the original application. For another example, the contrast interface is an interface "B" of an application using an original system architecture, and the interface to be tested may be an interface "B" of an application using a new architecture obtained by upgrading the original system architecture.
The identification of an interface may be a variety of information that can uniquely identify the interface. Generally, the identity of the interface may be preset by a technician.
The executing agent of the method for testing an interface (e.g., the first terminal device 101 shown in fig. 1) may retrieve the identification of the control interface sent by the tester from a local or other storage device. For example, the test person may input the identification of the control interface using the execution body described above. For another example, the tester may use the terminal device used by the tester to send the identification of the cross-connect to the execution agent. For another example, the execution subject may provide the identifier of each interface to the tester, and the tester may select the identifier as the identifier of the comparison interface.
Step 202, selecting interface data corresponding to the comparison interface from the pre-stored historical interface data according to the identification of the comparison interface.
In this embodiment, the interface data corresponding to the interface may include data circulated through the interface, including but not limited to data generated by the interface, data consumed by the interface, data transferred by the interface, and so on. Generally, in various applications, the interface data corresponding to the interface may generally include request data (e.g., request data corresponding to a get request or a post request, etc.) received by the interface and return data for a request indicated by the request data.
Wherein the request data may be used to indicate a request received by the interface. At this time, the request data may include a request string of the received request message corresponding to the request, i.e., a request string of the request message corresponding to the interface. The type, format, etc. of the return data of the interface for the request may be different according to the difference of the interface and the difference of the application scenario. For example, the return data may be in JSON (JavaScript Object Notation) format. At this time, the return data includes a number of Key-Value pairs (Key-Value).
The historical interface data may include historical interface data corresponding to each interface in a preset interface set in which the comparison interface is located. The preset interface set can be preset by a technician according to actual application requirements. Generally, the preset interface set may be composed of comparison interfaces respectively corresponding to the interfaces to be tested. For example, when testing some or all interfaces of the target application, the preset interface set may be composed of some or all interfaces of the target application.
The historical interface data may be stored locally in the execution agent in advance, or may be stored in a database connected to the execution agent. Specifically, the correspondence between the identification of the interface and the historical interface data of the interface may be stored in advance. At this time, after the identifier of the comparison interface is obtained, the interface data corresponding to the comparison interface can be screened out according to the identifier of the comparison interface.
Step 203, determining the request data and the interface return data included in the interface data corresponding to the contrast interface.
In this embodiment, after obtaining the interface data corresponding to the comparison interface, the interface data of the comparison interface may be parsed based on the design of the comparison interface (such as the format of the request and the format of the return data received by the comparison interface, etc.) in advance by a technician to determine the request data and the interface return data therefrom. The request data may be used to indicate a request received by the contrast interface, and the interface return data may be referred to as return data of the contrast interface for the request.
Further, request data and interface return data included in the interface data corresponding to the interface may also be stored. In particular, the identification of the comparison interface, the request data and the interface return data can be stored in association so as to facilitate data query and comparison during interface test.
Step 204, obtaining test return data of the interface to be tested for the request indicated by the request data.
In this embodiment, the executing body may send request data included in the interface data corresponding to the comparison interface to the interface to be tested, and then the interface to be tested processes the request data, so as to obtain return data of the interface to be tested for the request data, which is used as the test return data.
Step 205, comparing the interface return data with the test return data to generate a test result of the interface to be tested.
In this embodiment, the test result of the interface to be tested may be used to indicate whether the data processing of the interface to be tested is normal. Specifically, the interface return data and the test return data may be compared to determine the test result of the interface to be tested. If the interface return data is consistent with the test return data, the data processing of the interface to be tested can be normal. If the interface return data is inconsistent with the test return data, it can be indicated that the data processing of the interface to be tested is abnormal, and then the technician can further check or adjust the interface to be tested so as to ensure that the data processing of the interface to be tested is normal.
Optionally, a test report may be further generated to record the test result of the interface to be tested, so that the tester can know and record the test result of the interface to be tested.
In some optional implementations of this embodiment, the generation time of the pre-stored historical interface data is within a preset time period from the current time. The preset time period can be set by a technician according to actual application requirements and application scenarios. For example, the preset time period may be one day. At this time, the pre-stored historical data is interface data generated within the current day. For another example, the preset time period is 8 hours. At this time, the pre-stored historical data is interface data generated within 8 hours from the current time.
Therefore, the interface to be tested is tested by utilizing the online real-time interface data, the effectiveness and the reliability of the interface data are ensured, the interface data do not need to be artificially manufactured for testing, the testing cost is reduced, the situations of invalidation or errors of the interface data and the like are avoided, and the testing efficiency and the testing quality are improved.
Optionally, the preset historical interface data may also be interface data which is generated within a preset time period from the current time and meets preset requirements. The preset requirement can be set by a technician according to the actual application requirement. Therefore, the interface to be tested can be tested by utilizing the online real-time interface data, so that the testing efficiency and the testing quality are improved, the online real-time interface data can be screened by utilizing preset conditions, the redundancy or unnecessary interface data are avoided, the testing workload can be reduced, and the testing efficiency is further improved.
In some alternative implementations of the present embodiment, the historical interface data may be stored using a Message Queue (MQ). Specifically, the historical interface data may be stored using various existing message queues, or a message queue obtained by adjusting an existing message queue. At this time, after the identifier of the comparison interface is obtained, the interface data corresponding to the comparison interface may be selected from the historical interface data stored in advance in the message queue.
In some alternative implementations of the present embodiment, historical interface data may be stored using an interface log. Wherein the interface log may be used to record historical interface data. Specifically, the interface log may be implemented based on existing various interface log implementation methods or interface log implementation methods developed in advance by technicians. At this time, the interface log may be acquired by calling an interface of the interface log. And then analyzing the interface log to obtain interface data corresponding to the comparison interface.
Alternatively, historical interface data may be stored concurrently with the message queue and the interface log. At this time, an operation for instructing a data source may be received, and then interface data corresponding to the comparison interface may be acquired according to the data source instructed by the received operation. For example, if the data source of the received operation instruction is a message queue, interface data corresponding to the comparison interface is acquired from the message queue. For another example, if the data source of the received operation instruction is an interface log, interface data corresponding to the comparison interface is acquired from the interface log.
The historical interface data is stored through the message queue and/or the interface log, so that the response speed and the stability of the whole testing process are improved, and the management and the maintenance of the interface data are facilitated.
In some optional implementations of this embodiment, in response to receiving an attribute update request for the contrast interface, the attribute information of the contrast interface is updated according to the attribute update request. Wherein, the attribute information of the contrast interface can be used for describing the attribute of the contrast interface. The attributes of the contrast interface may be various attributes. For example, attributes of the contrast interface include, but are not limited to: name, interface type, current limit threshold, check code, etc.
The current limit threshold may be used to refer to a maximum amount of interface data corresponding to the interface. The check code may be used to check whether a request received by the interface belongs to a request of unknown origin (e.g., a request forged by a malicious party, etc.).
In particular, the attribute update request may indicate that there are attributes of the control interface to be updated and new attribute information for the attributes. The attribute information for that attribute of the control interface may then be updated with the new attribute information.
By the mode, a tester can flexibly adjust the attribute information of the comparison interface at any time according to the actual application requirement so as to be more convenient for testing the interface to be tested.
In some optional implementation manners of this embodiment, in response to receiving a data deletion request for the comparison interface, the interface data corresponding to the comparison interface that is pre-stored is deleted according to the data deletion request.
Wherein the data deletion request may indicate the interface data to be deleted. Then, the interface data indicated by the data deletion request may be deleted from the historical interface data. In this way, the tester can flexibly and conveniently manage and maintain historical interface data.
In some optional implementation manners of this embodiment, after determining the request data included in the interface data corresponding to the comparison interface, the request data may be further sent to the interface to be tested, and then the interface to be tested may check the received request data to obtain a check result.
And if the verification result indicates that the verification is passed, processing the received request data to obtain test return data. If the verification result indicates that the verification fails, the request data can be discarded, and abnormal prompt information can be generated to prompt that the request data which fails to pass the verification is received. For example, the request data may include verification data (e.g., a verification code of the interface, etc.), so that the request data may be verified by the received verification data of the request data.
Therefore, the process of verifying the request data received by the interface to be tested is added in the test process of the interface to be tested, so that the conditions of maliciously forging the request data and the like can be avoided, and the safety of the test process is ensured.
With continued reference to fig. 3, fig. 3 is a schematic diagram 300 of an application scenario of the method for testing an interface according to the present embodiment. In the application scenario of fig. 3, the tester may select or enter the identifier "a" of the control interface in the terminal 301 he uses, while selecting the data source as a message queue. Then, the historical interface data recorded in the message queue 302 may be parsed according to the identifier "a" to obtain the request data and the return data corresponding to the comparison interface "a", and stored in the database 303.
Then, the obtained request data corresponding to the comparison interface "a" may be sent to the interface to be tested running on the terminal 304, and the interface to be tested may obtain the return data for the request data by processing the received request data. Then, it may compare whether the return data corresponding to the comparison interface is consistent with the return data of the interface to be tested, so as to obtain the test result 305 of the interface to be tested.
In the prior art, request data is usually manually made or a large number of test cases are written according to test requirements to complete the test of the interface to be tested. However, these methods are time consuming, resulting in high time cost, error prone, and no guarantee of data integrity, thereby reducing test quality. In addition, there is another method that directly forwards the on-line interface data to the interface to be tested for testing, but this method has a very large workload and a large number of redundant data processing processes during the subsequent testing, thereby reducing the testing efficiency.
According to the method provided by the embodiment of the disclosure, the historical interface data is prestored, so that the interface data corresponding to the comparison interface can be directly obtained according to the identifier of the comparison interface, the test return data of the interface to be tested for the request indicated by the request data is obtained by using the request data included in the interface data corresponding to the comparison interface, and then the interface return data and the test return data of the interface to be tested for the request indicated by the request data included in the interface data corresponding to the comparison interface are compared to obtain the test result of the interface to be tested, so that the high-efficiency automatic test of the interface to be tested is realized, and any person can be used as a tester to quickly test the interface to be tested. Compared with the prior art, the method does not need to manually make request data and compile a large number of test cases according to test requirements, thereby reducing the time cost. In the subsequent test process, excessive redundant data or error data can not occur, thereby ensuring the test quality.
With further reference to FIG. 4, a flow 400 of yet another embodiment of a method for testing an interface is shown. The process 400 of the method for testing an interface includes the steps of:
step 401, receiving attribute information of a contrast interface.
In this embodiment, the execution main body may first receive attribute information of the comparison interface from a local or other terminal device. For example, attribute information of the control interface input by a tester may be received. For another example, the attribute information of the collation interface transmitted from the terminal device used by the tester may be received.
Wherein, the attribute information of the contrast interface can be used for describing the attribute of the contrast interface. The attributes of the contrast interface may be various attributes. For example, attributes of the contrast interface include, but are not limited to: name, interface type, current limit threshold, modification time, keyword, etc. The modification time may be used to indicate the last time the interface was used for testing, or may also indicate the last time the attribute information of the interface was updated. The key may refer to a key in the returned data of the interface.
As an example, the execution subject may provide a front-end page to a tester to show various attribute information of the interface, and then the tester selects the attribute information according to the test requirement, so that the execution subject may determine the comparison interface according to the attribute information selected by the tester.
Step 402, determining the identification of the comparison interface according to the attribute information.
In this embodiment, after the attribute information of the comparison interface is received, the comparison interface may be determined, and then the identifier preset by the interface may be compared.
In some cases, the identification of the contrasting interface may also consist of several attribute information of the contrasting interface. For example, the identification of the referencing interface may consist of the name and key of the referencing interface.
And step 403, selecting interface data corresponding to the comparison interface from the pre-stored historical interface data according to the identifier of the comparison interface.
Step 404, determining the request data and the interface return data included in the interface data corresponding to the contrast interface.
Step 405, obtaining test return data of the interface to be tested for the request indicated by the request data.
Step 406, comparing the interface return data with the test return data to generate a test result of the interface to be tested.
The specific execution process of the steps 403-406 can refer to the related description of the step 202-205 in the corresponding embodiment of fig. 2, and will not be described herein again.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the process 400 of the method for testing an interface in this embodiment highlights a process that a tester can specify attribute information of an interface to determine a comparison interface, so that in the testing process, the comparison interface can be flexibly screened from multiple dimensions according to a testing requirement, and meanwhile, interface data to be processed is screened subsequently, so that the interface data to be processed can be more accurately selected, and on the premise of ensuring that the testing requirement is met, the workload after the interface data is reduced, and the testing efficiency and the testing quality are improved.
With further reference to fig. 5, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for testing an interface, which corresponds to the embodiment of the method shown in fig. 2, and which may be applied in various electronic devices.
As shown in fig. 5, the apparatus 500 for testing an interface provided in this embodiment includes an identifier obtaining unit 501, a selecting unit 502, a determining unit 503, a return data obtaining unit 504, and a generating unit 505. Wherein the identifier obtaining unit 501 is configured to obtain an identifier of the contrast interface; the selecting unit 502 is configured to select interface data corresponding to the comparison interface from the pre-stored historical interface data according to the identifier of the comparison interface; the determining unit 503 is configured to determine the request data and the interface return data included in the interface data corresponding to the interface; the return data obtaining unit 504 is configured to obtain test return data of the interface under test for the request indicated by the request data; the generating unit 505 is configured to generate a test result of the interface under test by comparing the interface return data with the test return data.
In the present embodiment, in the apparatus 500 for testing an interface: the specific processing and the technical effects of the identifier obtaining unit 501, the selecting unit 502, the determining unit 503, the return data obtaining unit 504, and the generating unit 505 may refer to the related descriptions of step 201, step 202, step 203, step 204, and step 205 in the corresponding embodiment of fig. 2, which are not described herein again.
In some optional implementations of the embodiment, the generation time of the historical interface data is within a preset time period from the current time.
In some optional implementations of this embodiment, the historical interface data is stored in a message queue and/or an interface log.
In some optional implementations of this embodiment, the identifier obtaining unit 501 is further configured to: receiving attribute information of a contrast interface; and determining the identification of the contrast interface according to the received attribute information of the contrast interface.
In some optional implementations of the present embodiment, the apparatus 500 for testing an interface further includes: the updating unit (not shown in the figure) is configured to update the attribute information of the contrast interface according to the attribute update request in response to receiving the attribute update request for the contrast interface.
In some optional implementations of the present embodiment, the apparatus 500 for testing an interface further includes: the deleting unit (not shown in the figure) is configured to delete pre-stored interface data corresponding to the comparison interface according to the data deleting request in response to receiving the data deleting request for the comparison interface.
In some optional implementations of the present embodiment, the return data obtaining unit 504 is further configured to: sending a request indicated by the request data to the interface to be tested so that the interface to be tested executes the following processing steps: verifying the received request data to obtain a verification result; and obtaining test return data based on the received request data in response to determining that the obtained verification result indicates that the verification is passed.
In some optional implementations of the present embodiment, the return data obtaining unit 504 is further configured to: sending the request data to an interface to be tested; and determining the return data of the interface to be tested for the request data as the test return data.
In some optional implementations of this embodiment, the request data includes a request string of a request message corresponding to the cross-interface.
In some optional implementations of this embodiment, the apparatus further includes: the storage unit (not shown in the figures) is configured to store the identification of the cross-connect, the request data and the interface return data in association.
In the apparatus provided in the foregoing embodiment of the present disclosure, the identifier of the comparison interface is obtained by the identifier obtaining unit; the selection unit selects interface data corresponding to the comparison interface from pre-stored historical interface data according to the identification of the comparison interface; the determining unit determines request data and interface return data included in interface data corresponding to the comparison interface; the return data acquisition unit acquires test return data of the interface to be tested aiming at the request indicated by the request data; the generating unit generates the test result of the interface to be tested by comparing the interface return data with the test return data, so that the convenient and fast automatic test of the interface to be tested can be realized, a large number of test cases do not need to be compiled by a tester according to a service scene in advance, and the test efficiency is improved.
Referring now to fig. 6, a schematic diagram of an electronic device (e.g., the first terminal device of fig. 1) 600 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the use range of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 6 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the terminal; or may exist separately and not be assembled into the terminal. The computer readable medium carries one or more programs which, when executed by the terminal, cause the terminal to: acquiring an identifier of a comparison interface; selecting interface data corresponding to the comparison interface from prestored historical interface data according to the identification of the comparison interface; determining request data and interface return data included in interface data corresponding to the comparison interface; acquiring test return data of the interface to be tested aiming at the request indicated by the request data; and generating a test result of the interface to be tested by comparing the interface return data with the test return data.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes an identification acquisition unit, a selection unit, a determination unit, a return data acquisition unit, and a generation unit. Where the names of these units do not in some cases constitute a limitation on the unit itself, for example, the identification acquisition unit may also be described as a "unit that acquires an identification against an interface".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (15)

1. A method for testing an interface, comprising:
acquiring an identifier of a comparison interface;
selecting interface data corresponding to the comparison interface from prestored historical interface data according to the identifier;
determining request data and interface return data included in the interface data corresponding to the comparison interface;
acquiring test return data of the interface to be tested aiming at the request indicated by the request data;
and generating a test result of the interface to be tested by comparing the interface return data with the test return data.
2. The method of claim 1, wherein the generation time of the historical interface data is within a preset time period from a current time.
3. The method of claim 1, wherein the historical interface data is stored in a message queue and/or an interface log.
4. The method of one of claims 1 to 3, wherein the obtaining an identification of a control interface comprises:
receiving attribute information of a contrast interface;
and determining the identification of the comparison interface according to the attribute information.
5. The method according to one of claims 1-3, wherein the method further comprises:
in response to receiving an attribute update request for the contrast interface, updating attribute information of the contrast interface according to the attribute update request.
6. The method according to one of claims 1-3, wherein the method further comprises:
and in response to receiving a data deletion request aiming at the comparison interface, deleting pre-stored interface data corresponding to the comparison interface according to the data deletion request.
7. The method according to one of claims 1 to 3, wherein the obtaining of the test return data of the interface under test for the request indicated by the request data comprises:
sending the request indicated by the request data to the interface to be tested so that the interface to be tested executes the following processing steps:
verifying the received request data to obtain a verification result;
and obtaining test return data based on the received request data in response to determining that the obtained verification result indicates that the verification is passed.
8. The method according to one of claims 1 to 3, wherein the obtaining of the test return data of the interface under test for the request indicated by the request data comprises:
sending the request data to the interface to be tested;
and determining the return data of the interface to be tested aiming at the request data as test return data.
9. The method of any of claims 1-3, wherein the request data comprises a request string of a request message corresponding to the cross-reference interface.
10. The method of any of claims 1-3, wherein after the determining that the interface data corresponding to the cross-interface includes request data and interface return data, the method further comprises:
and storing the identification of the contrast interface, the request data and the interface return data in an associated manner.
11. An apparatus for testing an interface, wherein the apparatus comprises:
an identification acquisition unit configured to acquire an identification of the collation interface;
the selecting unit is configured to select interface data corresponding to the comparison interface from pre-stored historical interface data according to the identification;
the determining unit is configured to determine request data and interface return data included in the interface data corresponding to the comparison interface;
a return data acquisition unit configured to acquire test return data of an interface to be tested for a request indicated by the request data;
the generating unit is configured to generate a test result of the interface to be tested by comparing the interface return data with the test return data.
12. The apparatus of claim 11, wherein the generation time of the historical interface data is within a preset time period from a current time.
13. The apparatus of claim 11, wherein the historical interface data is stored in a message queue and/or an interface log.
14. A terminal, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-10.
15. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-10.
CN202010974069.XA 2020-09-16 2020-09-16 Method and apparatus for testing an interface Pending CN112084114A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010974069.XA CN112084114A (en) 2020-09-16 2020-09-16 Method and apparatus for testing an interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010974069.XA CN112084114A (en) 2020-09-16 2020-09-16 Method and apparatus for testing an interface

Publications (1)

Publication Number Publication Date
CN112084114A true CN112084114A (en) 2020-12-15

Family

ID=73737247

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010974069.XA Pending CN112084114A (en) 2020-09-16 2020-09-16 Method and apparatus for testing an interface

Country Status (1)

Country Link
CN (1) CN112084114A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112835808A (en) * 2021-03-12 2021-05-25 中国平安财产保险股份有限公司 Interface testing method and device, computer equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007060094A2 (en) * 2005-11-22 2007-05-31 International Business Machines Corporation Software application interfacing testing
US20080008101A1 (en) * 2006-07-04 2008-01-10 Fujitsu Limited Computer-readable medium storing test support program, test support apparatus, and test support method
US8209666B1 (en) * 2007-10-10 2012-06-26 United Services Automobile Association (Usaa) Systems and methods for testing interfaces and applications
CN105099811A (en) * 2015-06-03 2015-11-25 北京金山安全软件有限公司 Interface testing method and device
US20170097882A1 (en) * 2015-10-06 2017-04-06 Ca, Inc. Generating Tests for Testing Software Applications
US20170351746A1 (en) * 2016-06-06 2017-12-07 International Business Machines Corporation Test data management
US20180089072A1 (en) * 2016-09-23 2018-03-29 International Business Machines Corporation Automated testing of application program interface
CN109597759A (en) * 2018-11-09 2019-04-09 深圳壹账通智能科技有限公司 Test method and device, storage medium, the computer equipment of business software
CN109960653A (en) * 2019-02-18 2019-07-02 天津五八到家科技有限公司 Regression testing method, device, equipment and storage medium
WO2020082585A1 (en) * 2018-10-25 2020-04-30 深圳壹账通智能科技有限公司 Method and device for interface testing
CN111131303A (en) * 2019-12-31 2020-05-08 苏宁云计算有限公司 Request data verification system and method

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007060094A2 (en) * 2005-11-22 2007-05-31 International Business Machines Corporation Software application interfacing testing
US20080008101A1 (en) * 2006-07-04 2008-01-10 Fujitsu Limited Computer-readable medium storing test support program, test support apparatus, and test support method
US8209666B1 (en) * 2007-10-10 2012-06-26 United Services Automobile Association (Usaa) Systems and methods for testing interfaces and applications
CN105099811A (en) * 2015-06-03 2015-11-25 北京金山安全软件有限公司 Interface testing method and device
US20170097882A1 (en) * 2015-10-06 2017-04-06 Ca, Inc. Generating Tests for Testing Software Applications
US20170351746A1 (en) * 2016-06-06 2017-12-07 International Business Machines Corporation Test data management
US20180089072A1 (en) * 2016-09-23 2018-03-29 International Business Machines Corporation Automated testing of application program interface
WO2020082585A1 (en) * 2018-10-25 2020-04-30 深圳壹账通智能科技有限公司 Method and device for interface testing
CN109597759A (en) * 2018-11-09 2019-04-09 深圳壹账通智能科技有限公司 Test method and device, storage medium, the computer equipment of business software
CN109960653A (en) * 2019-02-18 2019-07-02 天津五八到家科技有限公司 Regression testing method, device, equipment and storage medium
CN111131303A (en) * 2019-12-31 2020-05-08 苏宁云计算有限公司 Request data verification system and method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112835808A (en) * 2021-03-12 2021-05-25 中国平安财产保险股份有限公司 Interface testing method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN108900776B (en) Method and apparatus for determining response time
CN108897691B (en) Data processing method, device, server and medium based on interface simulation service
CN109684188B (en) Test method and device
CN107644075B (en) Method and device for collecting page information
CN112597047A (en) Test method, test device, electronic equipment and computer readable medium
CN112463729B (en) Data file warehousing method and device, electronic equipment and medium
CN108959102B (en) Method and device for generating test data and testing application to be tested
CN110737655B (en) Method and device for reporting data
CN112084114A (en) Method and apparatus for testing an interface
CN111221727A (en) Test method, test device, electronic equipment and computer readable medium
CN109218338B (en) Information processing system, method and device
CN115454956A (en) Log generation method and device, electronic equipment and storage medium
CN113360365B (en) Flow test method and flow test system
CN113918525A (en) Data exchange scheduling method, system, electronic device, medium, and program product
CN114428815A (en) Data storage method and device, electronic equipment and computer readable medium
CN112783903B (en) Method and device for generating update log
CN115203178A (en) Data quality inspection method and device, electronic equipment and storage medium
CN108287792B (en) Method and apparatus for outputting information
CN112860538A (en) Method and device for performing interface regression test based on online log
CN112579428A (en) Interface testing method and device, electronic equipment and storage medium
CN112532747B (en) Method, apparatus, device and storage medium for outputting information
CN109376023B (en) Method and equipment for generating calling information and issuing return code group
CN110110032B (en) Method and device for updating index file
CN115629983A (en) Test case set generation method, device, equipment and medium
CN115904954A (en) Interface general use case generation method and device, electronic equipment and medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 221, 2nd floor, Block C, 18 Kechuang 11th Street, Daxing Economic and Technological Development Zone, Beijing, 100176

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: Room 221, 2nd floor, Block C, 18 Kechuang 11th Street, Daxing Economic and Technological Development Zone, Beijing, 100176

Applicant before: Jingdong Digital Technology Holding Co., Ltd