CN112084114B - Method and apparatus for testing interfaces - Google Patents
Method and apparatus for testing interfaces Download PDFInfo
- Publication number
- CN112084114B CN112084114B CN202010974069.XA CN202010974069A CN112084114B CN 112084114 B CN112084114 B CN 112084114B CN 202010974069 A CN202010974069 A CN 202010974069A CN 112084114 B CN112084114 B CN 112084114B
- Authority
- CN
- China
- Prior art keywords
- interface
- data
- request
- comparison
- tested
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
Embodiments of the present disclosure disclose methods and apparatus for testing interfaces. One embodiment of the method comprises the following steps: 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 which are included in interface data corresponding to the comparison interface; acquiring test return data of a request indicated by the request data of the interface to be tested; and comparing the interface return data with the test return data to generate a test result of the interface to be tested. The embodiment realizes convenient automatic test of the interface to be tested.
Description
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a method and apparatus for testing interfaces.
Background
With the change of service requirements, the upgrade of system architecture, the alternation of application versions, etc., the service migration is followed. The service migration generally needs a tester to test an application interface related to the service, so that the condition that errors exist in data exchange of an API and the like due to the service migration is avoided, and the correctness and the reliability of the service migration are ensured.
The existing API testing method comprises the steps that a tester writes testing data manually, and then the testing data is utilized to test an interface to be tested. Or the tester writes the automatic test case, and then realizes the automatic test by using the test case.
Disclosure of Invention
Embodiments of the present disclosure propose methods and apparatus for testing interfaces.
In a first aspect, embodiments of the present disclosure provide a method for testing an interface, the method comprising: 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 which are included in interface data corresponding to the comparison interface; acquiring test return data of a request indicated by the request data of the interface to be tested; and comparing the interface return data with the test return data to generate a test result of the interface to be tested.
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 interface log.
In some embodiments, the obtaining the identifier of the control interface includes: receiving attribute information of a comparison interface; and determining the identification of the comparison interface according to the received attribute information of the comparison interface.
In some embodiments, the above method further comprises: in response to receiving the attribute update request for the collation interface, the attribute information of the collation interface is updated according to the attribute update request.
In some embodiments, the above method further comprises: and in response to receiving the data deleting request for the comparison interface, deleting the pre-stored interface data corresponding to the comparison interface according to the data deleting 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: checking the received request data to obtain a checking result; and obtaining test return data based on the received request data in response to determining that the obtained check result indicates that the check is passed.
In some embodiments, obtaining test return data of the interface under test for the request indicated by the request data includes: transmitting the request data to an interface to be tested; and determining the return data of the interface to be tested aiming at the request data as test return data.
In some embodiments, the request data includes a request string of request messages corresponding to the reference interface.
In some embodiments, after determining the request data and the interface return data included in the interface data corresponding to the reference interface, the method further includes: the association stores the identity of the reference interface, the request data and the interface return data.
In a second aspect, embodiments of the present disclosure provide an apparatus for testing an interface, the apparatus comprising: 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 prestored historical interface data according to the identification of the comparison interface; the determining unit is configured to determine request data and interface return data which are included in the interface data corresponding to the comparison interface; the return data acquisition unit is configured to acquire test return data of a request indicated by the request data of the interface to be tested; 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 interface log.
In some embodiments, the above-mentioned identification acquisition unit is further configured to: receiving attribute information of a comparison interface; and determining the identification of the comparison interface according to the received attribute information of the comparison interface.
In some embodiments, the apparatus further comprises: and an updating unit configured to update the attribute information of the collation interface according to the attribute update request in response to receiving the attribute update request for the collation interface.
In some embodiments, the apparatus further comprises: and the deleting unit is configured to delete the pre-stored interface data corresponding to the comparison interface according to the data deleting request in response to receiving the data deleting request aiming at the comparison interface.
In some embodiments, the return data acquisition 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: checking the received request data to obtain a checking result; and obtaining test return data based on the received request data in response to determining that the obtained check result indicates that the check is passed.
In some embodiments, the return data acquisition unit is further configured to: transmitting the request data to an interface to be tested; and determining the return data of the interface to be tested aiming at the request data as test return data.
In some embodiments, the request data includes a request string of request messages corresponding to the reference interface.
In some embodiments, the apparatus further comprises: and a storage unit configured to store the identification of the collation interface, the request data, and the interface return data in association.
In a third aspect, embodiments of the present disclosure provide a terminal including: one or more processors; a storage means for storing one or more programs; the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described in any of the implementations of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a 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 are selected from the prestored historical interface data by utilizing 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 for the request indicated by the request data is determined based on the request data corresponding to the comparison interface, further the test result of the interface to be tested can be directly obtained by comparing the interface return data with the test return data, the convenient automatic test of the interface to be tested is realized, a tester does not need to write 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 present disclosure will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings:
FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
FIG. 2 is a flow chart of 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 according to an embodiment of the present disclosure;
FIG. 4 is a flow chart of yet another embodiment of a method for testing an interface according to the present disclosure;
FIG. 5 is a schematic structural view of 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 drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. 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 methods for testing interfaces or apparatuses for testing interfaces of the present disclosure 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 by various connection types (e.g., wired, wireless communication links, or fiber optic cables, etc.).
Various client applications may be installed on the first terminal apparatus 101 and the second terminal apparatus 103. For example, browser class applications, search class applications, instant messaging tools, social platform software, and the like, information streaming class 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, smartphones, tablets, electronic book readers, laptop portable computers, desktop computers, and the like. When the first terminal apparatus 101 and the second terminal apparatus 103 are software, they can be installed in the above-listed electronic apparatuses. Which may be implemented as multiple software or software modules (e.g., multiple software or software modules for providing distributed services) or as a single software or software module. The present invention is not particularly limited herein.
The database 102 may be various types of databases that are matched to the first terminal apparatus 101. The database 102 may store various data 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 interface data corresponding to a reference interface of the application to be tested.
The database 102 may be provided in the first terminal device 101, and the number stored in the database 102 may be directly stored in the first terminal device 101.
The second terminal device 103 may have an application to be tested installed thereon to complete the test of the 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 request indicated by the request data by the interface to be tested.
It should be noted that, the method for testing an interface provided by the embodiment of the present disclosure is generally performed by the first terminal device 101, and accordingly, the apparatus for testing an 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 according to the present disclosure is shown. The method for testing the interface comprises the following steps:
step 201, an identification of a collation interface is obtained.
In this embodiment, the interface may refer broadly to a convention in which different components of the software system are joined. Generally, interfaces may enable communication between different components of a software system and between different software systems. Meanwhile, the interface can be used as a middleware to realize data flow between different system platforms. For example, interfaces include, but are not limited to: APIs (Application Programming Interface, application program interfaces), access interfaces to database systems, HTTP (HyperText Transfer Protocol ) interfaces, webService interfaces, and so forth.
The comparison interface may refer to an interface that is compared with an interface to be tested to complete testing of the interface to be tested. In general, the collation interface and the interface under test may be a front-to-back collation of the same interface. For example, the reference 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 obtained after the version of the original application is updated. For another example, the reference interface is an interface "B" of an application using the 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 the interface may be various information capable of uniquely identifying the interface. In general, the identity of the interface may be preset by a technician.
The execution body of the method for testing an interface (e.g. the first terminal device 101 shown in fig. 1) may obtain from a local or other storage device the identity of the collation interface sent by the tester. For example, the tester may input an identification of the collation interface using the executive body described above. For another example, the tester may use the terminal device that he uses to send an identification of the collation interface to the execution body. For another example, the executing body may provide the tester with the identifier of each interface, and then the tester may select the identifier from the identifiers as the identifier of the reference interface.
Step 202, selecting interface data corresponding to the comparison interface from prestored historical interface data according to the identification of the comparison interface.
In this embodiment, the interface data corresponding to the interface may include data that flows 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, interface data corresponding to an interface may generally include request data received by the interface (e.g., request data corresponding to a get request or a post request, etc.) 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 request message corresponding to the received request, i.e., a request string of the request message corresponding to the collation interface. The type, format, etc. of the interface for the requested return data may be different depending on the interface and application scenario. For example, the return data may be in JSON (JavaScript Object Notation ) format. At this point, the return data includes several Key-Value pairs (Key-Value).
The historical interface data may include historical interface data corresponding to each interface in a preset interface set where the reference interface is located. The preset interface set can be preset by a technician according to actual application requirements. In general, the preset interface set may be composed of a comparison interface corresponding to each interface to be tested. For example, when testing some or all of the interfaces of the target application, the preset interface set may be composed of some or all of the interfaces of the target application.
The history interface data may be stored in advance in the execution body, or may be stored in a database connected to the execution body. Specifically, a correspondence relationship between the identification of the interface and the history 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 request data and interface return data included in the interface data corresponding to the reference 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) by the technician in advance, so as to determine the request data and the return data of the interface. The request data may be used to indicate a request received by the reference interface, and the interface return data may be used to refer to return data of the reference interface for the request.
Further, request data and interface return data included in the interface data corresponding to the reference interface may also be stored. In particular, the identification of the reference interface, the request data and the interface return data can be stored in a correlated mode 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 the request data included in the interface data corresponding to the reference interface to the interface to be tested, and then the interface to be tested processes the request data, so as to obtain the return data of the interface to be tested for the request data as the test return data.
And 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, whether the interface return data and the test return data are consistent or not can be compared, and the test result of the interface to be tested can be determined. If the interface return data is consistent with the test return data, the data processing of the interface to be tested can be indicated to be normal. If the interface return data is inconsistent with the test return data, the data processing of the interface to be tested can be indicated to have abnormality, and then the interface to be tested can be further checked or adjusted by a technician 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 alternative 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 scenes. For example, the preset time period may be one day. At this time, the pre-stored history data is interface data generated in the current day. For another example, the preset time period is 8 hours. At this time, the pre-stored history data is the interface data generated within 8 hours from the current time.
Therefore, the on-line real-time interface data is utilized to test the interface to be tested, the validity and the reliability of the interface data are guaranteed, the interface data are not required to be manufactured manually for testing, the testing cost is reduced, the condition that the interface data are invalid or wrong is avoided, and the like is avoided, and the testing efficiency and the testing quality are improved.
Alternatively, the preset historical interface data may also be interface data generated within a preset time period from the current time and meeting preset requirements. The preset requirements can be set by a technician according to actual application requirements. Therefore, the on-line real-time interface data can be utilized to test the interface to be tested, so that the test efficiency and the test quality are improved, the on-line real-time interface data can be screened by utilizing preset conditions, redundant or unnecessary interface data are avoided, the subsequent test workload can be reduced, and the test efficiency is further improved.
In some alternative implementations of the present embodiment, a Message Queue (MQ) may be utilized to store historical interface data. In particular, historical interface data may be stored using existing various message queues, or message queues that are adjusted to existing message queues. At this time, after the identifier of the collation interface is acquired, interface data corresponding to the collation interface may be selected from the history interface data stored in advance in the message queue.
In some alternative implementations of the present embodiment, the 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 an interface log implementation method developed in advance by a technician. At this time, the interface log may be acquired by calling the interface of the interface log. And then analyzing the interface log to obtain interface data corresponding to the comparison interface.
Alternatively, the historical interface data may be stored simultaneously using a message queue and an interface log. At this time, an operation for indicating the data source may be received, and then interface data corresponding to the collation interface may be acquired according to the received data source indicated by the operation. For example, if the data source of the received operation instruction is a message queue, interface data corresponding to the comparison interface is obtained from the message queue. For another example, if the data source of the received operation instruction is an interface log, the interface data corresponding to the comparison interface is obtained from the interface log.
Storing historical interface data through a message queue and/or an interface log is beneficial to improving the response speed and stability of the whole test process, and is convenient for the management and maintenance of the interface data.
In some optional implementations of the present embodiment, in response to receiving an attribute update request for the collation interface, the attribute information of the collation interface is updated according to the attribute update request. Wherein, the attribute information of the comparison interface can be used for describing the attribute of the comparison interface. The attributes of the control interface may be various attributes. For example, attributes of the collation 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 memory of interface data corresponding to the interface. The check code may be used to check whether the request received by the interface belongs to a request of unknown origin (e.g., a malicious fake request, etc.).
In particular, the attribute update request may indicate that there is an attribute of the collation interface and new attribute information of the attribute to be updated. The attribute information for that attribute of the collation 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 actual application requirements, so that the test of the interface to be tested is more convenient.
In some optional implementations of this embodiment, in response to receiving a data deletion request for the collation interface, the pre-stored interface data corresponding to the collation interface is deleted according to the data deletion request.
Wherein the data deletion request may indicate interface data to be deleted. The interface data indicated by the data deletion request may then be deleted from the historical interface data. In this way, the tester can flexibly and conveniently manage and maintain the historical interface data.
In some optional implementations 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 first verify the received request data to obtain a verification 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 is not passed, the request data can be discarded, and abnormal prompt information can be generated to prompt that the request data which is not passed the verification is received. For example, the request data may include verification data (e.g., a verification code that may be an 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, a tester may select or input an identification "a" of the reference interface in the terminal 301 that he uses, while selecting the data source as a message queue. The historical interface data recorded in the message queue 302 may then be parsed according to the identification "a" to obtain the request data and the return data corresponding to the reference 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, where the interface to be tested may obtain the return data for the request data by processing the received request data. Then, whether the returned data corresponding to the comparison interface is consistent with the returned data of the interface to be tested can be compared, so that a test result 305 of the interface to be tested is obtained.
In the prior art, a large number of test cases are usually required to be manually made for request data or written according to test requirements so as to complete the test of the interface to be tested. However, these methods are very time-consuming, resulting in excessive time costs, and are prone to error, and cannot guarantee the integrity of the data, thereby degrading the quality of the test. In addition, there is another way to directly forward the interface data on the line to the interface to be tested for testing, but this way, in the subsequent testing, has a great amount of workload and a great amount of redundant data processing process, thereby reducing the testing efficiency.
According to the method provided by the embodiment of the disclosure, the historical interface data are pre-stored, so that the interface data corresponding to the comparison interface can be obtained directly according to the identification of the comparison interface, the request data included in the interface data corresponding to the comparison interface are utilized to obtain the test return data of the interface to be tested for the request indicated by the request data, and then the interface return data and the test return data of 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 efficient 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 or write a large number of test cases according to test requirements, thereby reducing time cost. In the subsequent test process, excessive redundant data or error data cannot occur, so that the test quality is ensured.
With further reference to fig. 4, a flow 400 of yet another embodiment of a method for testing an interface is shown. The flow 400 of the method for testing an interface includes the steps of:
In step 401, attribute information of a collation interface is received.
In this embodiment, the execution body may first receive attribute information of the collation interface from the local or other terminal device. For example, attribute information of a collation interface input by a tester may be received. For another example, attribute information of the collation interface transmitted by the tester through the terminal device used by the tester may be received.
Wherein, the attribute information of the comparison interface can be used for describing the attribute of the comparison interface. The attributes of the control interface may be various attributes. For example, attributes of the collation interface include, but are not limited to: name, interface type, current limit threshold, modification time, keywords, etc. The modification time may be used to indicate the time when the interface was last used for testing, or may also represent the time when the attribute information of the interface was last updated. The key may refer to a key in the return data of the interface.
As an example, the execution body may provide a front 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 body 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 comparison interface may be determined.
In some cases, the identification of the collation interface may also consist of several attribute information of the collation interface. For example, the identification of the collation interface may consist of the name and key of the collation interface.
Step 403, selecting interface data corresponding to the comparison interface from the prestored historical interface data according to the identification of the comparison interface.
Step 404, determining request data and interface return data included in the interface data corresponding to the reference interface.
Step 405, obtaining test return data of the interface to be tested for the request indicated by the request data.
And step 406, generating a test result of the interface to be tested by comparing the interface return data with the test return data.
The specific implementation of steps 403-406 may refer to the relevant descriptions of steps 202-205 in the corresponding embodiment of fig. 2, and will not be repeated here.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the method for testing an interface in this embodiment highlights the process of determining the comparison interface by specifying the attribute information of the interface by the tester, so that the comparison interface can be flexibly screened from multiple dimensions according to the test requirement in the test process, and meanwhile, the interface data to be processed subsequently can be screened, so that the interface data to be processed can be more accurately selected, the workload after that is reduced on the premise of ensuring that the test requirement is met, and the test efficiency and the test quality are improved.
With further reference to fig. 5, as an implementation of the method shown in the above figures, the present disclosure provides an embodiment of an apparatus for testing an interface, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 5, the apparatus 500 for testing an interface provided in this embodiment includes an identification acquisition unit 501, a selection unit 502, a determination unit 503, a return data acquisition unit 504, and a generation unit 505. Wherein the identifier obtaining unit 501 is configured to obtain an identifier of the collation interface; the selecting unit 502 is configured to select interface data corresponding to the comparison interface from the prestored historical interface data according to the identification of the comparison interface; the determining unit 503 is configured to determine request data and interface return data included in the interface data corresponding to the collation interface; the return data acquisition unit 504 is configured to acquire test return data of the interface under test for a request indicated by the request data; the generating unit 505 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 this embodiment, in the apparatus 500 for testing an interface: specific processes 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 and technical effects thereof may refer to the relevant descriptions of the steps 201, 202, 203, 204 and 205 in the corresponding embodiment of fig. 2, and are not repeated herein.
In some optional implementations of this embodiment, the generation time of the historical interface data is within a preset time period from the current time.
In some alternative implementations of the present embodiment, the historical interface data described above is stored in a message queue and/or interface log.
In some optional implementations of this embodiment, the identifier obtaining unit 501 is further configured to: receiving attribute information of a comparison interface; and determining the identification of the comparison interface according to the received attribute information of the comparison interface.
In some optional implementations of this embodiment, the apparatus 500 for testing an interface further includes: an updating unit (not shown in the figure) is configured to update the attribute information of the collation interface according to the attribute update request in response to receiving the attribute update request for the collation interface.
In some optional implementations of this embodiment, the apparatus 500 for testing an interface further includes: the deletion unit (not shown in the figure) is configured to delete pre-stored interface data corresponding to the collation interface according to the data deletion request in response to receiving the data deletion request for the collation interface.
In some optional implementations of this 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: checking the received request data to obtain a checking result; and obtaining test return data based on the received request data in response to determining that the obtained check result indicates that the check is passed.
In some optional implementations of this embodiment, the return data obtaining unit 504 is further configured to: transmitting the request data to an interface to be tested; and determining the return data of the interface to be tested aiming at the request data as test return data.
In some optional implementations of the present embodiment, the request data includes a request string of request messages corresponding to the reference interface.
In some optional implementations of this embodiment, the apparatus further includes: a storage unit (not shown in the figure) is configured to store in association an identification of the collation interface, request data, and interface return data.
The device provided by the embodiment of the disclosure acquires the identifier of the comparison interface through the identifier acquisition unit; the selecting unit selects interface data corresponding to the comparison interface from prestored historical interface data according to the identification of the comparison interface; the determining unit determines request data and interface return data which are included in interface data corresponding to the comparison interface; the method comprises the steps that a return data acquisition unit acquires test return data of a request indicated by request data of an interface to be tested; the generating unit generates a test result of the interface to be tested by comparing the interface return data with the test return data, so that the convenient automatic test of the interface to be tested can be realized, a tester does not need to write a large number of test cases in advance according to a service scene, and the test efficiency is improved.
Referring now to fig. 6, a schematic structural diagram of an electronic device (e.g., a first terminal device in fig. 1) 600 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), car terminals (e.g., car navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The terminal device shown in fig. 6 is only one example, and should not impose any limitation on the functions and scope of use of the embodiments of the present disclosure.
As shown in fig. 6, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to 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 required 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 through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic 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 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 6 may represent one device or a plurality of devices as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to 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 shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing means 601.
It should be noted that, the computer readable medium according to 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. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any 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 an embodiment of the present 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. Whereas in embodiments of the present disclosure, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the terminal; or may exist alone without being fitted 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 which are included in interface data corresponding to the comparison interface; acquiring test return data of a request indicated by the request data of the interface to be tested; and comparing the interface return data with the test return data to generate a test result of the interface to be tested.
Computer program code for carrying out operations of embodiments of the present disclosure may be written in 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts 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 involved in the embodiments described in the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor includes an identification acquisition unit, a selection unit, a determination unit, a return data acquisition unit, and a generation unit. The names of these units do not constitute a limitation on the unit itself in some cases, and for example, the identification acquisition unit may also be described as "a unit that acquires the identification of the collation interface".
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being 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 technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.
Claims (15)
1. A method for testing an interface, comprising:
Receiving attribute information selected by a tester from all attribute information displayed on a front-end page as attribute information of a comparison interface;
Determining the identification of the comparison interface according to the attribute information of the comparison interface;
Selecting interface data corresponding to the comparison interface from prestored historical interface data according to the identification, wherein a data source of the prestored historical interface data is selected by the tester on a front-end page;
determining request data and interface return data included in interface data corresponding to the comparison interface;
Acquiring test return data of a request indicated by the request data of the interface to be tested;
generating a test result of the interface to be tested by comparing the interface return data with the test return data;
The request data comprises check data, and the check data is used for checking whether the request data is abnormal or not.
2. The method of claim 1, wherein the historical interface data is generated at a time 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. A method according to any of claims 1-3, wherein said obtaining an identification of a collation interface comprises:
receiving attribute information of a comparison interface;
And determining the identification of the comparison interface according to the attribute information.
5. A method according to one of claims 1-3, wherein the method further comprises:
And in response to receiving an attribute updating request for the comparison interface, updating attribute information of the comparison interface according to the attribute updating request.
6. A method according to one of claims 1-3, wherein the method further comprises:
and in response to receiving a data deleting request aiming at the comparison interface, deleting pre-stored interface data corresponding to the comparison interface according to the data deleting request.
7. A method according to any of claims 1-3, wherein said obtaining test return data of the interface under test for the request indicated by the request data comprises:
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:
Checking the received request data to obtain a checking result;
And obtaining test return data based on the received request data in response to determining that the obtained check result indicates that the check is passed.
8. A method according to any of claims 1-3, wherein said obtaining 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. A method according to any of claims 1-3, wherein the request data comprises a request string of request messages corresponding to the collation interface.
10. A method according to any of claims 1-3, wherein after said determining that the interface data corresponding to the collation interface comprises request data and interface return data, the method further comprises:
and storing the identification of the comparison interface, the request data and the interface return data in an associated mode.
11. An apparatus for testing an interface, wherein the apparatus comprises:
The identification acquisition unit is configured to receive attribute information selected by a tester from all attribute information displayed on the front-end page as attribute information of the comparison interface; determining the identification of the comparison interface according to the attribute information of the comparison interface;
The selecting unit is configured to select interface data corresponding to the comparison interface from prestored historical interface data according to the identification, wherein a data source of the prestored historical interface data is selected by the tester on a front-end page;
The determining unit is configured to determine request data and interface return data included in the interface data corresponding to the comparison interface;
the return data acquisition unit is configured to acquire test return data of a request indicated by the request data of the interface to be tested;
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;
The request data comprises check data, and the check data is used for checking whether the request data is abnormal or not.
12. The apparatus of claim 11, wherein the historical interface data is generated at a time 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, causes the one or more processors to implement the method of any of claims 1-10.
15. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-10.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010974069.XA CN112084114B (en) | 2020-09-16 | 2020-09-16 | Method and apparatus for testing interfaces |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010974069.XA CN112084114B (en) | 2020-09-16 | 2020-09-16 | Method and apparatus for testing interfaces |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112084114A CN112084114A (en) | 2020-12-15 |
CN112084114B true CN112084114B (en) | 2024-07-16 |
Family
ID=73737247
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010974069.XA Active CN112084114B (en) | 2020-09-16 | 2020-09-16 | Method and apparatus for testing interfaces |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112084114B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112835808A (en) * | 2021-03-12 | 2021-05-25 | 中国平安财产保险股份有限公司 | Interface testing method, device, computer equipment and storage medium |
CN113238939A (en) * | 2021-05-11 | 2021-08-10 | 北京沃东天骏信息技术有限公司 | Test case generation method, device, equipment, storage medium and program |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105099811A (en) * | 2015-06-03 | 2015-11-25 | 北京金山安全软件有限公司 | Interface testing method and device |
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 |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8291387B2 (en) * | 2005-11-22 | 2012-10-16 | International Business Machines Corporation | Method and system for testing a software application interfacing with multiple external software applications in a simulated test environment |
JP4940791B2 (en) * | 2006-07-04 | 2012-05-30 | 富士通株式会社 | 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 |
US9846633B2 (en) * | 2015-10-06 | 2017-12-19 | Ca, Inc. | Generating tests for testing software applications |
US10860616B2 (en) * | 2016-06-06 | 2020-12-08 | International Business Machines Corporation | Test data management |
US10002069B2 (en) * | 2016-09-23 | 2018-06-19 | International Business Machines Corporation | Automated testing of application program interface |
CN109491894B (en) * | 2018-10-25 | 2022-01-14 | 深圳壹账通智能科技有限公司 | Interface test method and equipment |
-
2020
- 2020-09-16 CN CN202010974069.XA patent/CN112084114B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105099811A (en) * | 2015-06-03 | 2015-11-25 | 北京金山安全软件有限公司 | Interface testing method and device |
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 |
Also Published As
Publication number | Publication date |
---|---|
CN112084114A (en) | 2020-12-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108897691B (en) | Data processing method, device, server and medium based on interface simulation service | |
CN112597047A (en) | Test method, test device, electronic equipment and computer readable medium | |
CN109684188B (en) | Test method and device | |
CN112463729B (en) | Data file warehousing method and device, electronic equipment and medium | |
CN112684968A (en) | Page display method and device, electronic equipment and computer readable medium | |
CN109542743B (en) | Log checking method and device, electronic equipment and computer readable storage medium | |
CN110737655B (en) | Method and device for reporting data | |
CN113360365A (en) | Flow testing method and flow testing system | |
CN109299124B (en) | Method and apparatus for updating a model | |
CN112084114B (en) | Method and apparatus for testing interfaces | |
CN114168485A (en) | Test method, device, equipment and medium | |
CN108287792B (en) | Method and apparatus for outputting information | |
CN110866031A (en) | Database access path optimization method and device, computing equipment and medium | |
CN110110032B (en) | Method and device for updating index file | |
CN112445697B (en) | Method and apparatus for testing applications | |
CN112579428B (en) | Interface testing method, device, electronic equipment and storage medium | |
CN112882948A (en) | Stability testing method, device and system for application and storage medium | |
CN114861054B (en) | Information collection method, device, electronic device and storage medium | |
CN117176576A (en) | Network resource changing method, device, equipment and storage medium | |
CN116738184A (en) | Application program fault analysis method and device, electronic equipment and storage medium | |
CN111338642B (en) | Method, device, terminal and storage medium for determining application download path | |
CN113094268A (en) | Test method, device, equipment, medium and program product | |
CN109960659B (en) | Method and device for detecting application program | |
CN114637689A (en) | Application evaluation method, device, equipment and storage medium | |
CN115705258A (en) | Test method, test device, storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
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. |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |