Interface testing methods and apparatus

By determining test rules based on the interface type (synchronous or asynchronous) and obtaining application scenario type data after processing asynchronous interfaces, the problem of excessive query time in interface testing is solved, thus improving testing efficiency.

CN116126674BActive Publication Date: 2026-11-17MASHANG CONSUMER FINANCE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210891554.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-27
Publication Date
2026-11-17
Estimated Expiration
2042-07-27

AI Technical Summary

Technical Problem

In existing technologies, different types of interfaces are tested using the same method, which leads to excessively long query times when the data volume is large, reducing the efficiency of interface testing.

Method used

Test rules are determined based on the interface type (synchronous or asynchronous). For asynchronous interfaces, the first target data is obtained after processing the target application scenario type data. Database data is then filtered by application scenario type to improve data query efficiency.

Benefits of technology

By obtaining application scenario type data for asynchronous interfaces, query time was reduced and interface testing efficiency was improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126674B_ABST
    Figure CN116126674B_ABST
Patent Text Reader

Abstract

This application provides an interface testing method and apparatus. The method includes: determining the interface type of the interface to be tested, wherein the interface type includes synchronous type and asynchronous type. Asynchronous type interfaces are used to process data stored in a database categorized by different application scenario types, while synchronous type interfaces are used to process data in the database that does not distinguish between application scenario types. If the interface type of the interface to be tested is asynchronous, after the interface to be tested processes the target data corresponding to the application scenario type, first target data corresponding to the application scenario type is obtained, and the state of the interface to be tested is determined based on the first target data. This application improves the query efficiency of the data corresponding to the interface to be tested, thereby improving the testing efficiency of the interface to be tested.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of automated testing technology, and in particular to an interface testing method and apparatus. Background Technology

[0002] With the development of network technology, the application of interfaces has become increasingly widespread. Different functions can be achieved through interfaces, thereby meeting different user needs.

[0003] In the existing technology, in order to ensure the normal operation of the interface, the interface can be tested first, and then the interface can be officially used after the test is passed.

[0004] However, there may be multiple types of interfaces. When testing interfaces, different interface types are all tested using the same method, which is to directly look up the corresponding data in the database by data name and test the interface based on the determined data. When the data volume is large, the query time is long, which reduces the efficiency of interface testing. Summary of the Invention

[0005] This application provides an interface testing method and apparatus to improve the efficiency of interface testing.

[0006] In a first aspect, embodiments of this application provide an interface testing method, including:

[0007] Determine the interface type of the interface to be tested, wherein the interface type includes synchronous type and asynchronous type. The asynchronous type interface is used to process data stored in the database according to different application scenario types, and the synchronous type interface is used to process data in the database that does not distinguish between application scenario types.

[0008] If the interface type of the interface to be tested is the asynchronous type, then after the interface to be tested processes the target data corresponding to the target application scenario type, the first target data corresponding to the target application scenario type is obtained, wherein the first target data is the data generated after the interface to be tested processes the target data corresponding to the target application scenario type;

[0009] The state of the interface to be tested is determined based on the first target data.

[0010] Secondly, embodiments of this application provide an interface testing apparatus, comprising:

[0011] The determination module is used to determine the interface type of the interface to be tested. The interface type includes synchronous type and asynchronous type. The asynchronous type interface is used to process data stored in the database according to different application scenario types. The synchronous type interface is used to process data in the database that does not distinguish between application scenario types.

[0012] The processing module is configured to, if the interface type of the interface to be tested is the asynchronous type, obtain first target data corresponding to the target application scenario type after the interface to be tested processes the target data corresponding to the target application scenario type, wherein the first target data is the data generated after the interface to be tested processes the target data corresponding to the target application scenario type;

[0013] The processing module is further configured to determine the state of the interface to be tested based on the first target data.

[0014] Thirdly, embodiments of this application provide an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0015] The memory stores computer-executed instructions;

[0016] The processor executes computer execution instructions stored in the memory to implement the interface testing method described in the first aspect and various possible designs of the first aspect.

[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the interface testing method described in the first aspect and various possible designs of the first aspect.

[0018] This application provides an interface testing method and apparatus. Using the above scheme, the interface type of the interface to be tested can be determined first. The interface type can include synchronous and asynchronous types. If the interface type is asynchronous, after the interface to be tested processes the target data corresponding to the target application scenario type, the first target data corresponding to the target application scenario type can be obtained. Then, the state of the interface to be tested can be determined based on the first target data. Since asynchronous interfaces correspond to a large amount of data, different data may belong to different application scenarios when testing asynchronous interfaces. Therefore, the application scenario type corresponding to the interface can be obtained first, and then the data in the database can be filtered by the application scenario type to obtain the first target data corresponding to the application scenario type. This allows the data corresponding to the interface to be tested to be obtained more quickly after the interface to be tested is completed, reducing the query time for the data corresponding to the interface to be tested, improving the query efficiency of the data corresponding to the interface to be tested, and thus improving the testing efficiency of the interface to be tested. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A schematic diagram of the implementation environment for the interface testing method provided in the embodiments of this application;

[0021] Figure 2 A flowchart illustrating an interface testing method provided in an embodiment of this application;

[0022] Figure 3 A schematic diagram illustrating the principle of an interface testing method provided in an embodiment of this application;

[0023] Figure 4 This is a schematic diagram of the interface testing device provided in the embodiments of this application;

[0024] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0026] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can also include other sequential examples besides those illustrated or described. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0027] In related technologies, users can process data, such as uploading data to a specified page or downloading data to a preset location. To facilitate user operation, APIs can be used to implement data download and upload functions. Furthermore, to ensure the API can function correctly, it should be tested before official implementation. Alternatively, the API can be tested after a period of use to determine if it functions properly or if any improvements are needed. However, APIs can be of various types (e.g., synchronous or asynchronous). When testing different API types, using the same testing method—directly searching the database for the corresponding data by name and then testing based on that data—can lead to longer query times when dealing with large amounts of data, reducing testing efficiency.

[0028] Based on the aforementioned technical issues, this application addresses the problem by first obtaining the application scenario type corresponding to the interface, and then filtering the data in the database based on the application scenario type to obtain the first target data corresponding to the application scenario type. This allows the data corresponding to the interface to be tested to be obtained more quickly after the interface to be tested is executed, achieving the technical effect of both reducing the query time of the data corresponding to the interface to be tested and improving the query efficiency of the data corresponding to the interface to be tested, thereby improving the testing efficiency of the interface to be tested.

[0029] Figure 1 This is a schematic diagram of the implementation environment for the interface testing method provided in the embodiments of this application, such as... Figure 1 As shown in this embodiment, the implementation environment may include the interface to be tested and an electronic device. The electronic device is a testing device used to perform interface testing. The interface to be tested can have multiple interface types, and the data volume corresponding to different types of interfaces may differ. Therefore, different interface testing rules can be constructed for different types of interfaces. For example, the interface type to be tested can be synchronous or asynchronous. Generally, when the amount of data to be processed is small, a synchronous interface can be used; when the amount of data to be processed is large, an asynchronous interface can be used. Furthermore, different interface testing rules can be assigned to synchronous and asynchronous interfaces, thereby improving the flexibility and efficiency of interface testing.

[0030] Optionally, interface testing rules for different types of interfaces can be implemented programmatically, and this program can be deployed on electronic devices. These electronic devices can be servers, server clusters, or personal computers, or other devices capable of interface testing.

[0031] Furthermore, after deploying the interface testing program on an electronic device, the device can then test the interface to be tested. When testing the interface, the interface type can be determined first. After the interface completes its execution, different interface testing rules can be invoked according to the interface type to test the interface and thus determine its state. Optionally, when testing the interface, the data generated after the interface completes its execution can be obtained first, and then the interface can be processed based on this data. If the interface type is synchronous, since synchronous interfaces have relatively little data, the data can be directly retrieved from the database after the interface completes its execution. That is, the data to be processed for synchronous interfaces is stored in the database without distinguishing between application scenario types. If the interface type is asynchronous, since asynchronous interfaces have a lot of data, directly retrieving the data from the database would be inefficient. Therefore, the data can be pre-classified according to application scenarios to obtain data corresponding to different application scenario types and stored in the database. When the interface runs, you can first obtain the application scenario type, then find the data corresponding to the application scenario type from the database, and then determine the data corresponding to the interface to be tested from the data corresponding to the application scenario type.

[0032] In summary, by first determining the application scenario type to which the data belongs when retrieving data for asynchronous interfaces, and then retrieving the corresponding data from the database based on the application scenario type, we can obtain the data for the interface under test more quickly, reduce the query time for the data for the interface under test, and improve the query efficiency for the data for the interface under test.

[0033] Optionally, there can be multiple interfaces to be tested, meaning one testing device can test multiple interfaces, saving computing resources. Furthermore, the interfaces to be tested can be deployed within electronic devices or deployed independently; these limitations are not detailed here.

[0034] The technical solutions of this application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0035] Figure 2 This is a flowchart illustrating an interface testing method provided in an embodiment of this application. The method in this embodiment can be executed by an electronic device. Figure 2 As shown, the method in this embodiment may include:

[0036] S201: Determine the interface type of the interface to be tested. The interface type includes synchronous type and asynchronous type. Asynchronous type interfaces are used to process data stored in the database according to different application scenario types, while synchronous type interfaces are used to process data in the database that does not distinguish between application scenario types.

[0037] In this embodiment, since different interface types correspond to different interface testing rules, when testing an interface to be tested, the interface type of the interface to be tested can be determined first, and then the corresponding interface testing rules can be determined based on the determined interface type. The interface type can be synchronous or asynchronous. Asynchronous interfaces are used to process data stored in the database according to different application scenario types, while synchronous interfaces are used to process data in the database that does not distinguish between application scenario types.

[0038] Optionally, there are several ways to determine the interface type of the interface to be tested. One possible implementation is to determine the interface type using relevant fields in a pre-stored description document of the interface to be tested. Another possible implementation is to determine the interface type by how the interface retrieves historical data. For example, if the interface to be tested retrieves historical data directly from the relevant interface, then the interface type is synchronous. If the interface to be tested does not retrieve historical data directly from the relevant interface, but instead first finds the download list or data storage directory and then retrieves the historical data from the download list or data storage directory, then the interface type is asynchronous.

[0039] S202: If the interface type of the interface to be tested is asynchronous, then after the interface to be tested processes the target data corresponding to the target application scenario type, the first target data corresponding to the target application scenario type is obtained, wherein the first target data is the data generated after the interface to be tested processes the target data corresponding to the target application scenario type.

[0040] In this embodiment, after determining that the interface type of the interface to be tested is asynchronous, the interface to be tested can be processed according to the interface testing rules corresponding to the asynchronous type.

[0041] Optionally, the interface testing rules for asynchronous types are post-test rules, meaning that the interface to be tested can only be tested after the interface to be tested has finished running.

[0042] Optionally, the operation of the interface under test can be as follows: the interface under test receives a data processing request, which includes an application scenario type. The interface then processes the target data corresponding to the application scenario type according to the data processing request. For example, it can download the target data corresponding to the application scenario type based on the data processing request. Furthermore, the interface under test can receive data processing requests in several ways. In one possible implementation, a data processing request can be generated in response to a user's touch operation on the display interface and sent to the interface under test. In another possible implementation, it can also receive data processing requests from other devices, etc.

[0043] Furthermore, the application scenario type can be customized according to the actual scenario or business requirements. For example, there can be three scenarios: A, B, and C. Scenario A corresponds to two pages, A1 and A2; scenario B corresponds to three pages, B1, B2, and B3; and scenario C corresponds to three pages, C1, C2, and C3. Each page contains its corresponding application scenario type. If the data processed by the interface under test is downloaded from page B2, then the application scenario type can be determined as B. After the interface under test completes its operation, when testing the interface, the processed first target data corresponding to application scenario type B can be directly retrieved from the database.

[0044] S203: Determine the status of the interface to be tested based on the first target data.

[0045] In this embodiment, after processing the target data, first target data can be obtained. Then, the state of the first target data can be determined, and the state of the interface to be tested can be determined based on the state of the first target data.

[0046] Optionally, the interface to be tested can have multiple functions. The status of the interface can be determined by the implementation of these functions. For example, the interface to be tested can have download and upload functions. If the download function is confirmed to be working correctly, the interface is considered to be in a normal operating state. Similarly, if the upload function is confirmed to be working correctly, the interface is considered to be in a normal operating state. If the download and / or upload functions fail to work correctly, the interface is considered to be in an abnormal operating state.

[0047] By adopting the above scheme, the interface type of the interface to be tested can be determined first. Interface types can include synchronous and asynchronous types. If the interface type is asynchronous, after the interface processes the target data corresponding to the target application scenario type, the first target data corresponding to the target application scenario type can be obtained. Then, the state of the interface to be tested can be determined based on the first target data. Since asynchronous interfaces involve a large amount of data, and different data may belong to different application scenarios, the application scenario type corresponding to the interface can be obtained first. Then, the data in the database can be filtered by the application scenario type to obtain the target data corresponding to the application scenario type. This allows for faster retrieval of the data corresponding to the interface after its execution, reducing the query time and improving the query efficiency, thereby improving the testing efficiency of the interface.

[0048] based on Figure 2In addition to the method described herein, this specification also provides some specific implementation schemes of the method, which will be described below.

[0049] In another embodiment, obtaining the first target data corresponding to the target application scenario type may specifically include:

[0050] Determine at least one initial first target data corresponding to the target application scenario type from the file download table in the database.

[0051] The first target data is obtained by determining the latest initial first target data from the at least one initial first target data.

[0052] In this embodiment, the information stored in the database can be of various types. When retrieving the processed first target data corresponding to the application scenario type from the database, a file download table can be determined first. The data recorded in this file download table is the data downloaded through the interface. Then, at least one initial first target data corresponding to the application scenario type can be determined from the file download table. That is, there can be one or more data corresponding to the application scenario type in the file download table, and then the first target data to be downloaded by the interface to be tested can be determined from the at least one initial first target data corresponding to the application scenario type.

[0053] Optionally, when testing an interface to be tested, the latest initial target data that corresponds to the application scenario type can be downloaded by default as the first target data to be downloaded for the interface to be tested. This simplifies the process of determining the data corresponding to the interface to be tested, thereby improving the testing efficiency of the interface to be tested.

[0054] Furthermore, there may be multiple interfaces to be tested, and before the interfaces to be tested process the target data corresponding to the target application scenario type, the following may also be included:

[0055] During the current round of interface testing, different application scenario types are assigned to the multiple interfaces to be tested. The application scenario types include at least one of the following: scenario types involving encrypted data, scenario types involving big data, and scenario types involving third-party interfaces.

[0056] Specifically, if multiple interfaces need to be tested during a single round of interface testing, different application scenario types can be assigned to each interface, meaning each interface corresponds to a different application scenario type. There can be various application scenario types. For example, application scenario types can include scenarios involving encrypted data, scenarios involving big data, and scenarios involving third-party interfaces. Correspondingly, scenarios involving encrypted data mainly refer to scenarios where data encryption is required, such as contract signing. Scenarios involving big data mainly refer to scenarios where the data volume exceeds a preset threshold. For example, in loan processing, the amount of loan-related data exceeds the preset threshold. Scenarios involving third-party interfaces mainly refer to scenarios where external interfaces need to be called to implement related business processes. For example, in money transfer processing, the interfaces of the banks corresponding to the sending and receiving accounts need to be called.

[0057] Furthermore, assigning different application scenario types to the multiple interfaces to be tested may specifically include:

[0058] For each interface to be tested, determine the data processing request received by the interface to be tested, wherein the data processing request contains a scenario type identifier, which is used to indicate the application scenario type to which the data to be processed belongs.

[0059] The application scenario type is assigned to the interface to be tested based on the scenario type identifier.

[0060] Specifically, application scenario types can be represented using scenario type identifiers. This means that when generating a data processing request, a scenario type identifier indicating the application scenario type can be included in the data processing request. Subsequently, after receiving the data processing request, the interface under test can assign an application scenario type to the interface based on the scenario type identifier contained in the data processing request.

[0061] In summary, this application, by determining the initial first target data with the latest download time as the data downloaded by the interface under test in this round of testing, not only realizes the testing of the interface under test in different application scenarios, but also simplifies the process of determining the data corresponding to the interface under test, thereby improving the efficiency of interface testing.

[0062] In another embodiment, determining the state of the interface to be tested based on the first target data may specifically include:

[0063] Determine the status of the first target data.

[0064] If the status of the first target data is "download successful", then the download function of the interface to be tested is determined to be in normal operating condition.

[0065] In this embodiment, the state of the interface to be tested can be determined based on the state of the acquired first target data. The state of the first target data can be a successful download, a download in progress, or a download failure.

[0066] Optionally, if the status of the first target data is "download successful", it indicates that the first target data has been successfully downloaded to the preset location through the interface under test, and thus it can be determined that the download function of the interface under test is in normal operation.

[0067] In addition, if the first target data is in the downloading state, then wait for a preset time.

[0068] If the first target data is still in the downloading state after the preset time period, and the number of times the state of the first target data is determined is not higher than the preset number threshold, then the steps of determining the state of the first target data and subsequent steps are re-executed.

[0069] If the number of times the state of the first target data is determined is higher than the number threshold, then the download function of the interface to be tested is determined to be in an abnormal operating state.

[0070] Specifically, if the status of the first target data is "downloading," it indicates that the interface under test is still in the process of downloading the first target data. In this case, the test can wait for a preset duration. If, after the preset duration, the status of the first target data is still "downloading," and the number of times the status of the first target data is determined does not exceed a preset threshold, then the steps for determining the status of the first target data and subsequent steps are repeated until the status of the first target data is "download successful." The preset duration and preset threshold can be customized according to the actual application scenario. For example, the preset duration can be any value between 2 and 5 seconds, and the threshold can be any value between 15 and 20 times.

[0071] Optionally, if the number of times the status of the first target data is determined exceeds the threshold, it indicates that a device failure or network failure may have occurred. In this case, the download function of the interface under test can be directly determined to be in an abnormal operating state. This avoids the situation where the first target data cannot be downloaded successfully due to device failure or network failure, and the judgment is performed indefinitely, further saving the computing resources of electronic devices.

[0072] For example, an assertion indicating successful file generation can be added to the program corresponding to the interface under test, such as `assert_equal("${get_file_status($uploadType)}", True)`. By calling the interface under test and passing the file type `uploadType`, such as "letter data export", after the interface request ends, based on a set threshold number of times (e.g., 20) and a waiting time (e.g., 3 seconds), the latest first target data with the application scenario type "letter data export" in the file download table of the database is polled, and it is determined whether the status of the first target data is final. If it is final (i.e., the data status is "download successful"), it indicates that the download function of the interface under test is running normally. If the polling count exceeds 20, or the final status is "download failed", or no data with the file type "letter data export" is found, it indicates that file generation failed, that is, the download function of the interface under test is running abnormally.

[0073] In summary, determining the status of the interface under test by using the status of the first target data in the file download table of the database simplifies the testing process and improves the testing efficiency of the interface under test.

[0074] Furthermore, if the status of the first target data is "download successful," then the download function of the interface under test is determined to be in normal operating condition, which may specifically include:

[0075] If the status of the first target data is "download successful", then the first target data is uploaded to the preset directory through the interface to be tested.

[0076] The first target data is searched in the preset directory by using the first target data identifier to obtain the search result, wherein the first target data identifier is the identification information of the first target data.

[0077] If the search result shows that the first target data is found in the preset directory, then the download function of the interface to be tested is determined to be in normal operating condition.

[0078] Specifically, after confirming that the status of the first target data is successfully downloaded, in order to further determine the download function of the interface to be tested, the first target data can be uploaded to a preset directory through the interface to be tested. Then, the first target data can be searched in the preset directory by the first target data identifier of the first target data to obtain the search results. Based on the search results, it can be further determined whether the download function of the interface to be tested is in normal operating condition.

[0079] Furthermore, if the search result indicates that the first target data cannot be found in the preset directory, then the download function of the interface to be tested is determined to be in an abnormal operating state.

[0080] Correspondingly, the search results can be of two types. One is that the first target data is found in the preset directory, which indicates that the interface under test has successfully uploaded the first target data to the preset directory, thus confirming that the download function of the interface under test is in normal operating condition. The other is that the first target data cannot be found in the preset directory, which indicates that the interface under test has not uploaded the first target data to the preset directory, thus confirming that the download function of the interface under test is in an abnormal operating condition.

[0081] In summary, by determining that the first target data has been successfully downloaded, and then uploading the first target data to a preset directory through the interface under test, and determining whether the download function of the interface under test is running normally based on the upload result, the accuracy of determining the running status of the download function of the interface under test is further improved.

[0082] Furthermore, uploading the first target data to a preset directory through the interface to be tested may specifically include:

[0083] If the first target data is encrypted, the first target data is decrypted according to the encryption key corresponding to the first target data stored in the database, and the decrypted first target data is uploaded to a preset directory through the interface to be tested.

[0084] Correspondingly, if the search result is that the first target data is found in the preset directory, then it is determined that the download function of the interface to be tested is in normal operating condition, including:

[0085] If the search result shows that the decrypted first target data is found in the preset directory, then the download and decryption functions of the interface to be tested are determined to be in normal operating condition.

[0086] Specifically, after obtaining the first target data, which may be encrypted, in order to determine whether the decryption function of the interface under test is in normal working order, the encryption key of the first target data can be obtained first, and then the first target data can be decrypted according to the encryption key. If the decryption is successful, it indicates that the decryption function of the interface under test is in normal working order.

[0087] If decryption fails, it indicates that the decryption function of the interface under test is malfunctioning. Similarly, if the encryption key for the first target data is not obtained, it also indicates that the decryption function of the interface under test is malfunctioning.

[0088] Optionally, an error message can be generated and displayed on the electronic device to remind testers that the function of the interface under test is in an abnormal operating state.

[0089] Optionally, the first target data can be of various types, and different types of first target data can correspond to different decryption methods. The type of the first target data can be determined by its name. For example, the type of the first target data can be determined by the suffix in its name. For instance, the type of the first target data can be an Excel spreadsheet, an image, a compressed file, a PDF, or a text file, etc.

[0090] For Excel spreadsheets: You can download the target data to the "download" directory, then use the obtained encryption key to decrypt the Excel file, generate an unencrypted Excel file, and copy the unencrypted Excel file to the preset upload directory, such as the "uploadfile" directory.

[0091] For image types: You can download them to the "download" directory and copy them to the uploadfile directory.

[0092] For compressed file types: You can download the first target data to the "download" directory, then decrypt the compressed file using the obtained encryption key to generate an unencrypted compressed file, and copy the unencrypted compressed file to the preset upload directory, such as the "uploadfile" directory.

[0093] For PDF files: The target data can be downloaded to the "download" directory. Then, using the obtained encryption key, the PDF is decrypted to generate an unencrypted PDF file, which is then copied to a preset upload directory, such as the "uploadfile" directory. For text files: The target data can be downloaded to the "download" directory. Then, using the obtained encryption key, the target data is decrypted to generate an unencrypted text file, which is then copied to a preset upload directory, such as the "uploadfile" directory.

[0094] Furthermore, when determining the status of the first target data, different judgment methods can be used depending on the type of the first target data. For example, if the first target data is of Excel type, the correctness of the Excel exported data can be determined by comparing the number of rows in the downloaded data with the number of rows in the pre-stored data, or by checking whether the column or row content of the Excel file matches the content in the pre-stored data. If the first target data is of compressed file type, the success of the data download can be determined by checking the number of decompressed files, their names, and file sizes to determine if the compressed file content is missing.

[0095] In addition, in another embodiment, it may also include:

[0096] Obtain second target data from a preset directory, wherein the second target data contains data types, and the first target data is data from a single round of interface testing or data from multiple rounds of interface testing. If the first target data is data from a single round of interface testing, then the second target data is the same as the first target data. If the first target data is data from multiple rounds of interface testing, then the second target data is any one or more of the first target data.

[0097] The data information to be modified is determined based on the data type, wherein the data information to be modified includes the field to be modified and the target value corresponding to the field to be modified.

[0098] The modified fields in the second target data are modified through the interface to be tested to obtain the modified second target data.

[0099] The operating status of the upload function of the interface to be tested is determined by the modified second target data and the target value.

[0100] In this embodiment, in addition to testing the download function of the interface, the upload function of the interface can also be tested. When testing the upload function of the interface, this can be achieved by modifying the second target data in a preset directory. The second target data and the first target data can be the same data or different data. The first target data is data from one round of interface testing or data from multiple rounds of interface testing. If the first target data is data from one round of interface testing, then the second target data is the same as the first target data. If the first target data is data from multiple rounds of interface testing, then the second target data is any one or more of the first target data. When determining whether the upload function of the interface under test is running normally, the upload function of the interface under test can be determined immediately after the download function of the interface under test is determined to be normal. In this case, the second target data and the first target data can be the same data. Alternatively, after the download function of multiple interfaces under test has been tested successfully, the upload function of any one interface under test can be determined. In this case, the second target data and the first target data can be the same data or different data.

[0101] Optionally, the modification method varies depending on the data type of the second target data. After determining the data type of the second target data, the data information to be modified can be determined based on the data type. Then, the fields to be modified in the data information to be modified can be modified through the interface to be tested to obtain the modified second target data. After the modification is completed, the running status of the upload function of the interface to be tested can be determined through the modified second target data and the target value. The modification method corresponding to different data types can be customized according to the actual application scenario. For example, if the data type of the second target data is an Excel spreadsheet, the modification method can be to modify the data in the Nth row or the Mth column of the spreadsheet. If the data type of the second target data is an image, the modification method can be to add a predefined occlusion image at a preset position in the image.

[0102] In summary, users or operations and maintenance personnel need to manually download the latest file before uploading it (which can be a document, spreadsheet, or related template) and then upload it through the interface. The testing process provided in this application can test the function of automatically downloading and uploading files through the interface, thereby reducing the workload of testers and improving the testing efficiency of the interface under test.

[0103] Furthermore, if the interface type of the interface to be tested is the asynchronous type, determining the running status of the upload function of the interface to be tested through the modified second target data and the target value may specifically include:

[0104] Obtain the file upload result, wherein the file upload result is the result of the interface to be tested uploading the field to be modified;

[0105] If the file upload result is normal, then retrieve the uploaded second target data from the database;

[0106] If the value corresponding to the field to be modified in the uploaded second target data is the target value, then the upload function of the interface to be tested is determined to be in normal operating condition.

[0107] Specifically, after modifying the field to be modified in the second target data through the interface to be tested, the upload function of the interface to be tested can be determined by checking whether the field to be modified was successfully modified.

[0108] Optionally, the interface to be tested can be of two types: synchronous and asynchronous. If the interface is synchronous, the uploaded second target data can be retrieved directly from the database or directly from the display page. Then, it is determined whether the value of the field to be modified in the uploaded second target data matches the target value. If yes, the upload function of the interface is running normally; otherwise, it is running abnormally. If the interface is asynchronous, the upload result of the file representing the uploaded field to be modified can be obtained first. Then, the running status of the upload function can be determined based on the specific content of the upload result. If the upload result is abnormal, the upload function of the interface is running abnormally. If the upload result is normal, the uploaded second target data can be retrieved from the database, and the upload function can be determined based on the relationship between the value of the field to be modified and the target value.

[0109] Furthermore, the upload result can be generated after the interface under test has completed modifying the fields to be modified in the second target data, and can represent the specific upload result of the fields to be modified. For example, if the upload result shows 0 rows in the Excel file, it means that all fields to be modified were successfully modified and uploaded successfully; if the upload result shows 4 rows in the Excel file, it means that 4 data entries were not successfully modified and the fields to be modified were not successfully uploaded.

[0110] In addition, the method may also include:

[0111] If the interface type of the interface to be tested is synchronous, then after the interface to be tested processes the data corresponding to the data identifier according to the received data processing request, the third target data is obtained from the display interface corresponding to the data identifier.

[0112] The state of the interface to be tested is determined based on the third target data.

[0113] In this embodiment, when the interface type of the interface to be tested is synchronous, in addition to directly obtaining the data corresponding to the interface to be tested from the database using existing methods, the data obtained from the synchronous interface processing can also be directly displayed on the display interface. Therefore, the third target data can be directly obtained from the display interface corresponding to the data identifier.

[0114] Furthermore, the data processing request may include a data identifier. Different data identifiers may correspond to data displayed on the same or different interfaces. Therefore, the display interface where the data is located can be determined by the data identifier, and then the third target data can be displayed on that interface. If the data processing request is generated in response to a user's touch operation on the display interface, then the display interface responding to the user's touch operation and the display interface displaying the third target data can be the same interface.

[0115] In summary, by directly obtaining the third target data downloaded from the synchronous type interface on the display interface, the efficiency of obtaining the third target data is improved.

[0116] Figure 3 This is a schematic diagram illustrating the principle of an interface testing method provided in an embodiment of this application. The method in this embodiment can be executed by an electronic device. Figure 3 As shown, the method in this embodiment may include:

[0117] Determine the interface type of the interface to be tested. If the interface type is asynchronous, monitor its running status. After the interface processes the target data corresponding to the target application scenario type, retrieve the processed first target data corresponding to the target application scenario type from the database. If the first target data is successfully downloaded, upload it to a preset directory through the interface. Then, search for the first target data in the preset directory using its identifier. If the first target data is found in the preset directory, the download function of the interface is considered to be running normally. If the first target data is not found in the preset directory, the download function is considered to be running abnormally. If the interface type is synchronous, after the interface processes the data corresponding to the data identifier, retrieve the third target data from the display interface corresponding to the data identifier, and determine the status of the interface based on the third target data. For example, the data identifier can be a data name.

[0118] Furthermore, if the first target data is in a download failure state, the download function of the interface under test can be directly determined to be in an abnormal operating state. Alternatively, if the first target data is in a downloading state, it can be polled a preset number of times until the first target data is in a download success state or the number of polls exceeds a preset threshold, at which point the first target data can be directly determined to be in a download failure state.

[0119] Based on the same idea, this specification also provides an apparatus corresponding to the above method. Figure 4 This is a schematic diagram of the interface testing device provided in the embodiments of this application, as shown below. Figure 4 As shown, the interface testing device 40 provided in this embodiment may include:

[0120] The determination module 401 is used to determine the interface type of the interface to be tested. The interface type includes synchronous type and asynchronous type. The asynchronous type interface is used to process data stored in the database according to different application scenario types. The synchronous type interface is used to process data in the database that does not distinguish between application scenario types.

[0121] The processing module 402 is configured to, if the interface type of the interface to be tested is the asynchronous type, obtain first target data corresponding to the target application scenario type after the interface to be tested processes the target data corresponding to the target application scenario type, wherein the first target data is data generated after the interface to be tested processes the target data corresponding to the target application scenario type.

[0122] The processing module 402 is further configured to determine the state of the interface to be tested based on the first target data.

[0123] In another embodiment, the processing module 402 is further configured to:

[0124] Determine at least one initial first target data corresponding to the target application scenario type from the file download table in the database.

[0125] The first target data is obtained by determining the latest initial first target data from the at least one initial first target data.

[0126] In another embodiment, the processing module 402 is further configured to:

[0127] Determine the status of the first target data.

[0128] If the status of the first target data is "download successful", then the download function of the interface to be tested is determined to be in normal operating condition.

[0129] If the first target data is in the downloading state, then wait for a preset time.

[0130] If the first target data is still in the downloading state after the preset time period, and the number of times the state of the first target data is determined is not higher than the preset number threshold, then the steps of determining the state of the first target data and subsequent steps are re-executed.

[0131] If the number of times the state of the first target data is determined is higher than the number threshold, then the download function of the interface to be tested is determined to be in an abnormal operating state.

[0132] In this embodiment, the processing module 402 is further configured to:

[0133] If the status of the first target data is "download successful", then the first target data is uploaded to the preset directory through the interface to be tested.

[0134] The first target data is searched in the preset directory by using the first target data identifier to obtain the search result, wherein the first target data identifier is the identification information of the first target data.

[0135] If the search result shows that the first target data is found in the preset directory, then the download function of the interface to be tested is determined to be in normal operating condition.

[0136] Furthermore, the processing module 402 is also used for:

[0137] If the first target data is encrypted, the first target data is decrypted according to the encryption key corresponding to the first target data stored in the database, and the decrypted first target data is uploaded to a preset directory through the interface to be tested.

[0138] If the search result shows that the decrypted first target data is found in the preset directory, then the download and decryption functions of the interface to be tested are determined to be in normal operating condition.

[0139] In another embodiment, the processing module 402 is further configured to:

[0140] Obtain second target data from a preset directory, wherein the second target data contains data types, and the first target data is data from a single round of interface testing or data from multiple rounds of interface testing. If the first target data is data from a single round of interface testing, then the second target data is the same as the first target data. If the first target data is data from multiple rounds of interface testing, then the second target data is any one or more of the first target data.

[0141] The data information to be modified is determined based on the data type, wherein the data information to be modified includes the field to be modified and the target value corresponding to the field to be modified.

[0142] The modified fields in the second target data are modified through the interface to be tested to obtain the modified second target data.

[0143] The operating status of the upload function of the interface to be tested is determined by the modified second target data and the target value.

[0144] In addition, the processing module 402 is also used for:

[0145] Obtain the file upload result, wherein the file upload result is the result of the interface to be tested uploading the field to be modified.

[0146] If the file upload result is normal, then the uploaded second target data is retrieved from the database.

[0147] If the value corresponding to the field to be modified in the uploaded second target data is the target value, then the upload function of the interface to be tested is determined to be in normal operating condition.

[0148] The apparatus provided in this application embodiment can achieve the above-mentioned... Figure 2 The methods in the embodiments shown are similar in principle and technical effect, and will not be described again here.

[0149] Figure 5 A schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application, such as... Figure 5 As shown, the device 500 provided in this embodiment includes a processor 501 and a memory communicatively connected to the processor. The processor 501 and the memory 502 are connected via a bus 503.

[0150] In the specific implementation process, the processor 501 executes the computer execution instructions stored in the memory 502, causing the processor 501 to execute the method in the above method embodiment.

[0151] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0152] In the above Figure 5In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0153] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage.

[0154] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0155] This application also provides a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the interface testing method of the above-described method embodiments.

[0156] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the interface testing method described above.

[0157] The aforementioned computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0158] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0159] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. An interface test method characterized by, include: Determine the interface type of the interface to be tested, wherein the interface type includes synchronous type and asynchronous type. The asynchronous type interface is used to process data stored in the database according to different application scenario types, and the synchronous type interface is used to process data in the database that does not distinguish between application scenario types. If the interface type of the interface to be tested is the asynchronous type, then after the interface to be tested processes the target data corresponding to the target application scenario type, at least one initial first target data corresponding to the target application scenario type is determined from the file download table of the database according to the target application scenario type; the initial first target data with the latest download time is determined from the at least one initial first target data to obtain the first target data corresponding to the target application scenario type, wherein the first target data is the data generated after the interface to be tested processes the target data corresponding to the target application scenario type; The state of the interface to be tested is determined based on the first target data; If the interface type of the interface to be tested is the synchronous type, then after the interface to be tested processes the data corresponding to the data identifier according to the received data processing request, the third target data is obtained from the display interface corresponding to the data identifier. The state of the interface to be tested is determined based on the third target data.

2. The method of claim 1, wherein, The interface to be tested is multiple, and before the interface to be tested processes the target data corresponding to the target application scenario type, it also includes: During the current round of interface testing, different application scenario types are assigned to multiple interfaces to be tested. The application scenario types include at least one of the following: scenario types involving encrypted data, scenario types involving big data, and scenario types involving third-party interfaces.

3. The method according to any of claims 1-2, characterized in that, Determining the state of the interface to be tested based on the first target data includes: Determine the state of the first target data; If the status of the first target data is "download successful", then the download function of the interface to be tested is determined to be in normal operating condition.

4. The method of claim 3, wherein, Also includes: If the first target data is in the downloading state, then wait for a preset time. If the first target data is still in the downloading state after the preset time period, and the number of times the state of the first target data is determined is not higher than the preset number threshold, then the steps of determining the state of the first target data and subsequent steps are re-executed. If the number of times the state of the first target data is determined is higher than the number threshold, then the download function of the interface to be tested is determined to be in an abnormal operating state.

5. The method of claim 3, wherein, If the status of the first target data is "download successful", then determining that the download function of the interface to be tested is in normal operation includes: If the status of the first target data is "download successful", then the first target data is uploaded to the preset directory through the interface to be tested; The first target data is searched in the preset directory by using the first target data identifier to obtain the search result, wherein the first target data identifier is the identification information of the first target data; If the search result shows that the first target data is found in the preset directory, then the download function of the interface to be tested is determined to be in normal operating condition.

6. The method of claim 5, wherein, Uploading the first target data to a preset directory through the interface to be tested includes: If the first target data is encrypted data, the first target data is decrypted according to the encryption key corresponding to the first target data stored in the database, and the decrypted first target data is uploaded to the preset directory through the interface to be tested. If the search result indicates that the first target data is found in the preset directory, then the download function of the interface to be tested is determined to be in normal operating condition, including: If the search result shows that the decrypted first target data is found in the preset directory, then the download and decryption functions of the interface to be tested are determined to be in normal operating condition.

7. The method of claim 5, wherein, Also includes: Obtain second target data from a preset directory, wherein the second target data contains data types, and the first target data is data from a single round of interface testing or data from multiple rounds of interface testing. If the first target data is data from a single round of interface testing, then the second target data is the same as the first target data. If the first target data is data from multiple rounds of interface testing, then the second target data is any one or more of the first target data. The data information to be modified is determined based on the data type, wherein the data information to be modified includes the field to be modified and the target value corresponding to the field to be modified; The modified fields in the second target data are modified through the interface to be tested to obtain the modified second target data; The operating status of the upload function of the interface to be tested is determined by the modified second target data and the target value.

8. The method of claim 7, wherein, The step of determining the running status of the upload function of the interface under test by using the modified second target data and the target value includes: Obtain the file upload result, wherein the file upload result is the result of the interface to be tested uploading the field to be modified; If the file upload result is normal, then retrieve the uploaded second target data from the database; If the value corresponding to the field to be modified in the uploaded second target data is the target value, then the upload function of the interface to be tested is determined to be in normal operating condition.

9. An interface testing device, characterized in that, include: The determination module is used to determine the interface type of the interface to be tested. The interface type includes synchronous type and asynchronous type. The asynchronous type interface is used to process data stored in the database according to different application scenario types. The synchronous type interface is used to process data in the database that does not distinguish between application scenario types. The processing module is configured to, if the interface type of the interface to be tested is the asynchronous type, after the interface to be tested processes the target data corresponding to the target application scenario type, determine at least one initial first target data corresponding to the target application scenario type from the file download table of the database according to the target application scenario type; determine the initial first target data with the latest download time from the at least one initial first target data to obtain the first target data corresponding to the target application scenario type, wherein the first target data is the data generated after the interface to be tested processes the target data corresponding to the target application scenario type; The processing module is further configured to determine the state of the interface to be tested based on the first target data; The processing module is further configured to, if the interface type of the interface to be tested is the synchronization type, then after the interface to be tested processes the data corresponding to the data identifier according to the received data processing request, obtain the third target data from the display interface corresponding to the data identifier. The state of the interface to be tested is determined based on the third target data.

10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the interface testing method as described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by the processor, implement the interface testing method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Asynchronous interface testing method, testing terminal and system

    CN107070735A

  • Data uploading interface test method and system, electronic equipment and readable storage medium

    CN113821800A

  • Test data generation method and device

    CN114138651A