Testing method, device, computing equipment and medium for multiple interfaces

By configuring the interface parameters and test case data of multiple interfaces, the interface structure and test results that meet the application scenarios are obtained, and the complexity and repetition of multiple interfaces simultaneous requests and internal calls of the interface are solved in the prior art, and efficient and accurate interface testing is achieved.

CN111290941BActive Publication Date: 2025-04-15BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201811505029.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-12-10
Publication Date
2025-04-15
Estimated Expiration
2038-12-10

AI Technical Summary

Technical Problem

The prior art is difficult to effectively test the situation where multiple interfaces are requested at the same time, methods are called internally between interfaces, and intermediate results need to be thrown, resulting in large workloads and frequent repetitions in the creation of test cases and application scenarios.

Method used

By configuring the interface parameters of multiple interfaces, an interface structure that satisfies the order of call in the application scenario, including incoming parameters and outgoing parameters, and the test data of the test case is assigned to the incoming parameters of the interface structure, obtaining the test results. Obtain the use case test results based on the test results and expected results, and import and present the expected results and test results through components to visualize the test results.

Benefits of technology

It simplifies the testing process of multiple interfaces, reduces duplicate work, improves testing efficiency and accuracy, and can effectively handle calls between interfaces and throws intermediate results, improving the disadvantages of black box testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111290941B_ABST
    Figure CN111290941B_ABST
Patent Text Reader

Abstract

The present disclosure provides a testing method, apparatus, computer equipment and medium for multiple interfaces, the method comprising: configuring interface parameters of the multiple interfaces to obtain an interface structure so that the multiple interfaces satisfy a calling sequence in an application scenario, wherein the interface structure comprises an input parameter and an output parameter, and the output parameter comprises an interface structure output parameter or an interface structure output parameter and at least one interface output parameter; assigning test data of at least one test case to the input parameter of the interface structure, obtaining the value of the interface structure output parameter as a test result; and obtaining a test result of the case according to the test result and an expected result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to a method, apparatus, computing device and medium for testing multiple interfaces. Background Art

[0002] Interface testing is mainly used to detect the interaction points between external systems and between internal subsystems. The focus of the test is to check the data exchange, transmission and control management process, as well as the mutual logical dependencies between systems. As the complexity of the system continues to increase, the cost of traditional testing methods has risen sharply, and the testing efficiency has dropped significantly. Interface testing can provide a solution in this case.

[0003] In the prior art, there is mainly a single interface test, for example, adopting Postman, JMeter or other automation frameworks (Django) to realize the test of different situations of a single interface. In addition, there is also a Mock test, which is used to test some objects that are not easy to conceive.

[0004] However, when multiple interfaces are requested at the same time, methods between interfaces are called internally, and intermediate results need to be thrown out, the creation of each test case and application scenario needs to verify the stored results, which is a huge workload and repetitive work is frequent. Summary of the invention

[0005] In view of this, the present disclosure provides a testing method, apparatus, computing device and medium for multiple interfaces that can cope with the problem that when multiple interfaces are requested at the same time and intermediate results need to be thrown out, individual test cases or application scenarios are difficult to create.

[0006] One aspect of the present disclosure provides a testing method for multiple interfaces, comprising: first, configuring interface parameters of the multiple interfaces to obtain an interface structure so that the multiple interfaces satisfy a calling order in an application scenario, wherein the interface structure includes input parameters and output parameters, and the output parameters include interface structure output parameters or interface structure output parameters and at least one interface output parameter, then, assigning test data of at least one test case to the input parameters of the interface structure, obtaining the value of the output parameter of the interface structure as a test result, and obtaining the use case test result according to the test result and the expected result.

[0007] According to an embodiment of the present disclosure, the interface parameters of the multiple interfaces configured to obtain the interface structure may include: first, determining multiple interfaces and the calling order of the multiple interfaces according to the calling order of each interface in the code and the application scenario, and then configuring the interface parameters of the multiple interfaces so that the multiple interfaces meet the calling order, wherein the interface parameters include any one or more of the following: protocol type, interface address, interface method name, interface input parameter and interface output parameter, and in addition, the mapping relationship between the interface address and the IP address of the test server needs to be configured according to the test environment. In this way, an interface structure that meets a certain application scenario can be obtained.

[0008] According to an embodiment of the present disclosure, the interface method name includes any one or more of the following: information request, header request, processing request, deletion request, local modification request, transmission request or method return request.

[0009] According to an embodiment of the present disclosure, the method may further include the following operations: when the calling sequence changes, the corresponding interface parameters are changed; and / or when the test environment changes, the mapping relationship between the corresponding interface address and the IP address of the test server is changed. This facilitates simple and timely maintenance when the calling sequence of certain interfaces in the application scenario changes, and also facilitates timely changes when the test environment, such as the test host, changes.

[0010] According to an embodiment of the present disclosure, the assignment of the test data of at least one test case to the input parameter of the interface structure may include the following operations, for example, first, obtaining a test case, the test case including a test variable and corresponding test data, then storing the test variable and the corresponding test data in a readable and writable file, and then setting the data value path of the input parameter corresponding to the test data. In this way, the value of the parameter of the test case can be quickly and accurately modified, without the need to regenerate the test case when the value of the parameter of the test case changes.

[0011] According to an embodiment of the present disclosure, the test results are stored in a database, and the method may further include the following operations: first, preset database field names and field values, which can be used as identifiers of results that need to be focused on; accordingly, obtaining the test results of the use case based on the test results and expected results may include: comparing the test results and expected results corresponding to the database field names and field values, and if there is a difference between the test results and the expected results, obtaining the difference and the log corresponding to the difference. In this way, it is possible to focus on some important results, and when an important result is abnormal, a log is thrown out in time to facilitate the analysis of the cause.

[0012] According to an embodiment of the present disclosure, the method may further include the following operations: after obtaining the interface structure, adding components, so that the expected results and the test results can be imported through the components and displayed to achieve visualization of the test results, which helps to improve the test efficiency of the testers.

[0013] According to an embodiment of the present disclosure, the method may further include the following operation: when the test results of some test cases differ from the expected results, regression testing of the some test cases is implemented through a test case switch. Since the interface structure provided by the present disclosure can run multiple test cases at the same time, when some test cases are abnormal, the test case switch can be used to simply and quickly implement testing of only the test cases with abnormalities, thereby improving the convenience of testing.

[0014] Another aspect of the present disclosure provides a testing device for multiple interfaces, including an interface configuration module, a test module and a result acquisition module, wherein the interface configuration module is used to configure the interface parameters of the multiple interfaces to obtain an interface structure so that the multiple interfaces satisfy the calling order in the application scenario, the interface structure includes input parameters and output parameters, the output parameters include interface structure output parameters or interface structure output parameters and at least one interface output parameter, the test module is used to assign test data of at least one test case to the input parameter of the interface structure, obtain the value of the output parameter of the interface structure as a test result, and the result acquisition module is used to obtain the use case test result according to the test result and the expected result.

[0015] According to an embodiment of the present disclosure, the interface configuration module may include a calling order acquisition unit, a first configuration unit and a second configuration unit, wherein the calling order acquisition unit is used to determine multiple interfaces and the calling order of multiple interfaces according to the calling order and application scenarios of each interface in the code, the first configuration unit is used to configure the interface parameters of the multiple interfaces so that the multiple interfaces satisfy the calling order, the interface parameters include any one or more of the following: protocol type, interface address, interface method name, interface input parameters and interface output parameters, and the second configuration unit is used to configure the mapping relationship between the interface address and the IP address of the test server according to the test environment.

[0016] According to an embodiment of the present disclosure, the interface method name may include any one or more of the following: information request, header request, processing request, deletion request, local modification request, transmission request or method return request.

[0017] According to an embodiment of the present disclosure, the device may also include: a first change module and a second change module, wherein the first change module is used to change the corresponding interface parameters when the calling order changes, and the second change module is used to change the mapping relationship between the IP address and the host name of the corresponding test host when the test environment changes.

[0018] According to an embodiment of the present disclosure, the test module may include a test case acquisition unit, a storage unit, and a first setting unit. The test case acquisition unit is used to acquire a test case, the test case includes a test variable and corresponding test data, the storage unit is used to store the test variable and the corresponding test data in a readable and writable file, and the first setting unit is used to set the data value path of the input parameter corresponding to the test data.

[0019] According to an embodiment of the present disclosure, the result acquisition module can be specifically used to compare the test result with the expected result to obtain the use case test result.

[0020] According to an embodiment of the present disclosure, the storage unit may also be used to store the test result in a database, and accordingly, the device may further include a setting module, which is used to preset the database field name and field value. Correspondingly, the result acquisition module may include a comparison unit and a log acquisition unit, wherein the comparison unit is used to compare the test result and the expected result corresponding to the database field name and field value, and the log acquisition unit is used to obtain the difference and the log corresponding to the difference if there is a difference between the test result and the expected result.

[0021] According to an embodiment of the present disclosure, the device may further include a component adding module and a display module, wherein the component adding module is used to add components after obtaining the interface structure, and the display module is used to import the expected results and the test results through the components and display them. Optionally, the component adding module includes a second setting unit and an importing unit, wherein the second setting unit is used to set the data value path of the database field name and field value corresponding to the test result, and the importing unit is used to import the expected results and the test results through the components.

[0022] According to an embodiment of the present disclosure, the device may further include a use case switch module, which is used to implement regression testing on some test cases through test case switches when test results of some test cases differ from expected results.

[0023] Another aspect of the present disclosure provides a computing device, which may include one or more processors and a storage device, wherein the storage device is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the method as described above is implemented.

[0024] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.

[0025] Another aspect of the present disclosure provides a computer program, which includes computer executable instructions, and the instructions are used to implement the method described above when executed.

[0026] According to the embodiments of the present disclosure, the problem in the prior art that different testers need to repeatedly create test cases or create test scenarios when testing the same application scenario can be at least partially solved, and intermediate results can be thrown out to facilitate testers to assist in locating the cause of defects based on the logs corresponding to the intermediate results, which helps to improve the drawbacks of black box testing.

[0027] According to the embodiments of the present disclosure, the configuration interface call sequence is consistent with the code implementation, which can improve the accuracy of the test results. This is because there may be more than one system or subsystem that can implement a certain function, but these systems or subsystems are not exactly the same. Configuring the corresponding interfaces according to the call sequence of each interface in the code can at least partially avoid the failure to detect anomalies due to inconsistency between the called interface and the interface in the code, or causing abnormal test results.

[0028] According to the embodiments of the present disclosure, the correspondence between field names and field values ​​is implemented after data is imported, which makes it easier to focus on key results and improves test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0030] Figure 1A A schematic diagram of an olive model of a test field according to an embodiment of the present disclosure is schematically shown;

[0031] Figure 1B The application scenarios of the testing method, apparatus, computing device and medium for multiple interfaces according to the embodiments of the present disclosure are schematically shown;

[0032] Figure 1C A schematic diagram schematically shows multiple interface calls according to an embodiment of the present disclosure;

[0033] Figure 2AA flowchart schematically illustrates a method for testing multiple interfaces according to an embodiment of the present disclosure;

[0034] Figure 2B The following schematically shows a schematic diagram of interface parameter configuration according to an embodiment of the present disclosure;

[0035] Figure 2C A flowchart schematically illustrates a method for testing multiple interfaces according to another embodiment of the present disclosure;

[0036] Figure 2D A flowchart schematically illustrates a method for testing multiple interfaces according to another embodiment of the present disclosure;

[0037] Figure 3A A block diagram schematically shows a test device for multiple interfaces according to an embodiment of the present disclosure;

[0038] Figure 3B A block diagram schematically shows a testing device for multiple interfaces according to another embodiment of the present disclosure;

[0039] Figure 3C A block diagram schematically shows a testing device for multiple interfaces according to another embodiment of the present disclosure;

[0040] Figure 4 A block diagram of a computer system suitable for implementing a testing method for multiple interfaces according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0041] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0042] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0043] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0044] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but not be limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but not be limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). Those skilled in the art should also understand that any transitional conjunctions and / or phrases that substantially indicate two or more optional items, whether in the specification, claims, or drawings, should be understood to give the possibility of including one of these items, either of these items, or both of these items. For example, the phrase "A or B" should be understood to include the possibilities of "A" or "B", or "A and B".

[0045] The embodiments of the present disclosure provide a testing method, apparatus, computing device and medium for multiple interfaces. The method includes an interface structure configuration process and a testing process. In the interface structure configuration process, the interface parameters of the multiple interfaces are configured to obtain an interface structure so that the multiple interfaces satisfy the calling order in the application scenario, wherein the interface structure includes input parameters and output parameters, and the output parameters include interface structure output parameters or interface structure output parameters and at least one interface output parameter. After completing the interface structure configuration, the testing process is entered, and the test data of at least one test case is assigned to the input parameter of the interface structure, and the value of the output parameter of the interface structure is obtained as the test result, and then the test result of the case is obtained according to the test result and the expected result.

[0046] Figure 1A Schematic diagram of an olive model of a test field according to an embodiment of the present disclosure is schematically shown. Figure 1AAs shown, the existing tests mainly include User Interface (UI) testing, Application Programming Interface (API) testing and Unit testing, among which the Application Programming Interface testing is hereinafter referred to as Interface testing. Generally speaking, the lower-level tests, such as unit testing, have higher stability, efficiency and lower cost, but relatively more investment is required and higher technical expertise is required. Taking the above problems into consideration, the Olive Model is proposed. After comparing interface testing, UI testing and unit testing, it is finally determined that interface testing has the highest return on investment.

[0047] Figure 1B The application scenarios of the test method, apparatus, computing device and medium for multiple interfaces according to the embodiments of the present disclosure are schematically shown. Figure 1B The exemplary system architecture 100 is shown. It should be noted that Figure 1B What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0048] like Figure 1B As shown, the system architecture 100 according to this embodiment may include one or more servers 101, and a network 102 connecting the multiple servers 101. The network 102 is used to provide a medium for communication links between the servers 101. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0049] The server 101 may be any electronic device having a display screen and supporting a test system, including but not limited to a laptop, a desktop computer, a server cluster, etc. Specifically, the server 101 may be an electronic device providing a test service, for example, for detecting interaction points between external systems and between subsystems within the system.

[0050] It should be noted that the test method for multiple interfaces provided in the embodiment of the present disclosure can generally be executed by the server 101. For example, only one server 101 is used for testing. Of course, if conditions permit, multiple servers 101 can also be used for testing, such as different systems installed on different servers 101, which is closer to the real application environment. Accordingly, the test device for multiple interfaces provided in the embodiment of the present disclosure can generally be set in the server 101. The test method for multiple interfaces provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 101 and can communicate with the server 101. Accordingly, the test device for multiple interfaces provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 101 and can communicate with the server 101.

[0051] It should be understood that Figure 1B The number of servers and networks in the embodiment is only for illustration. Any number of servers and networks may be provided as required.

[0052] Figure 1C A schematic diagram schematically shows multiple interface calls according to an embodiment of the present disclosure.

[0053] like Figure 1C As shown in the figure, the directed arrows represent the calling relationship. Each interface may call multiple interfaces or be called by multiple interfaces. For example, when entering detailed product information in the background, creating products for display in the front desk, editing various categories, setting various function buttons, triggering in the front desk, and other application scenarios, multiple interfaces will be requested at the same time, methods between interfaces will be called internally, and intermediate results will be processed to achieve final data storage in Redis, JIM or other databases. At this time, the creation of each test case and application scenario requires verification of the storage results, which is extremely labor-intensive and requires frequent repetition of work. There is no shortcut for regression testing, which is time-consuming and labor-intensive.

[0054] Postman, Jmeter or other automation frameworks (Django) in the prior art can only implement return result verification tests for different situations and usage scenarios of a single interface, and cannot verify the final results of multiple interface contract calls. In addition, manually creating, modifying, deleting, and checking data results, including inserting and updating data in the library, table, and field, are all time-consuming tasks, and it is necessary to ensure that the use cases are fully covered, the test process is clear, and the final field value is not missed. If the test passes once, only the test effort of different use cases is used. If the test fails, multiple test efforts must be paid.

[0055] Figure 2AThe flowchart of the method for testing multiple interfaces according to the embodiment of the present disclosure is schematically shown.

[0056] like Figure 2A As shown, the method includes operations S201 to S203.

[0057] In operation S201, the interface parameters of the multiple interfaces are configured to obtain an interface structure so that the multiple interfaces satisfy the calling order in the application scenario, wherein the interface structure includes input parameters and output parameters, and the output parameters include interface structure output parameters or interface structure output parameters and at least one interface output parameter.

[0058] In this embodiment, the interface structure can be configured according to the interface calling sequence (including internal method calling). The configuration of the interface structure can be specifically achieved by configuring interface parameters. The interface parameters may include: configuration protocol type, interface type, interface address, interface method name, etc.

[0059] Specifically, the protocol type may include but is not limited to: HTTP interface protocol type, Jeff interface protocol type or webservice interface protocol type, etc. The specific configuration methods of different interface protocol types are different, but they are not the focus of this disclosure. Here, only the HTTP interface protocol type is schematically illustrated. For example, the interface address, interface method name and interface output parameter are encapsulated in the HTTP request, and the HTTP request is sent to the interface address to find the HTTP interface to be called. In this way, when testing, for example, the value of the interface output parameter can be assigned to the interface input parameter of the HTTP interface to be called for testing.

[0060] Figure 2B A schematic diagram of interface parameter configuration according to an embodiment of the present disclosure is schematically shown.

[0061] like Figure 2B As shown, the test interface may include the server IP address, port number, connection status information, interface method name, etc. First, the HTTP request may be selected, and then the interface parameters may be configured in the interface parameter configuration interface, such as the method being get, etc.

[0062] In one embodiment, the interface parameters of the multiple interfaces configured to obtain the interface structure may include the following operations: first, multiple interfaces and the calling order of multiple interfaces are determined according to the calling order and application scenarios of each interface in the code, and then the interface parameters of the multiple interfaces are configured so that the multiple interfaces meet the calling order, wherein the interface parameters may include any one or more of the following: protocol type, interface address, interface method name, interface input parameter and interface output parameter, etc. In addition, if the test is performed on a test server, the test server needs to be configured, for example, the mapping relationship between the interface address and the IP address of the test server is configured according to the test environment. Among them, the calling order in the interface structure is determined according to the calling order of each interface in the code, so that the configuration interface calling order can be consistent with the code implementation, which can avoid the following problems: if a certain function can be implemented by multiple interfaces respectively, but there are actually certain differences between the interfaces, if the randomly selected interface does not show problems during the test, the interface actually required to be used may be abnormal during use.

[0063] In a specific embodiment, the interface method name includes any one or more of the following: information request (get), header request (head), processing request (post), deletion request (delete), local modification request (patch), transmission request (put) or method return request (option), etc.

[0064] Through the above operations, the interface structure can be solidified. In the corresponding test scenario, there is no need to rewrite the interface call program to implement the call between interfaces. In other words, only one configuration is required to complete multiple use case executions, multiple coverage tests, regression tests, etc., effectively saving test time. In addition, since the output parameter can include an interface structure output parameter and at least one interface output parameter, the interface output parameter can throw out an intermediate result, thus effectively improving the problem that only black box testing can be implemented during existing functional testing.

[0065] It should be noted that the subsequent maintenance of the interface structure may include the following operations: when the call sequence changes, the corresponding interface parameters are changed. Or when the test environment changes, the mapping relationship between the corresponding interface address and the IP address of the test server (host) is changed. For example, when the interface call sequence changes, the interface parameters of the changed interface can be reconfigured. When the test server changes, only the host of the changed test server needs to be configured.

[0066] Then, in operation S202, the test data of at least one test case is assigned to the input parameter of the interface structure, and the value of the output parameter of the interface structure is obtained as the test result.

[0067] In this embodiment, the interface testing process may include: first, assigning the value of the test case to the corresponding interface input parameter, so that the value of each interface output parameter can be obtained.

[0068] Taking the call without error throwing as an example, the following operations can be performed:

[0069] Set_default_headers()

[0070] Initialize()

[0071] Prepare()

[0072] HTTP Methods()

[0073] On_finish()

[0074] Taking the call with an error as an example, the following operations can be performed:

[0075] Set_default_headers()

[0076] Initialize()

[0077] Prepare()

[0078] HTTP Methods()

[0079] Set_default_headers()

[0080] Write_error()

[0081] On_finish()

[0082] When there is a call that throws an error, you can get the log of the interface for analysis when the value of a certain interface output parameter is incorrect.

[0083] In addition, in order to facilitate the change of test data and the input of test data, the assignment of test data of at least one test case to the input parameter of the interface structure includes the following operations: first, obtaining the test case, the test case including test variables and corresponding test data, then storing the test variables and the corresponding test data in a readable and writable file, and then setting the data value path of the input parameter corresponding to the test data, so that automatic reading of the test data can be achieved.

[0084] Specifically, you can first design the test cases, then enter the test data used in each test case into an Excel or txt document, enter the expected result data into another document, and then configure the parameter value $ and set the data source value path.

[0085] In operation S203, the test result of the use case is obtained according to the test result and the expected result.

[0086] In this embodiment, the comparison process can be the same as the prior art, for example, the comparison can be performed manually or automatically by a computer. In addition, in order to further improve the test efficiency, only the results that need attention can be compared.

[0087] The interface test provided in this embodiment can implement any one or more of the following tests: business function testing (including normal scenarios and abnormal scenarios), editing analysis testing (such as business rule boundary analysis and input and output parameter boundary analysis), parameter combination testing, abnormal situation testing (such as repeated submission, concurrent testing, transaction testing, distributed testing, environmental anomalies, large number testing, etc.), performance testing (such as response time, throughput, concurrency, server resource utilization, etc.) and security testing (such as whether sensitive information is encrypted, etc.).

[0088] Figure 2C The flowchart schematically shows a method for testing multiple interfaces according to another embodiment of the present disclosure.

[0089] In this embodiment, the test results are stored in a database, such as Figure 2C As shown, the method may further include operation S204.

[0090] In operation S204, a database field name and a field value are preset, and the database field name and the field value correspond to the result requiring attention.

[0091] Accordingly, obtaining the use case test results based on the test results and expected results may include: first, comparing the test results and expected results corresponding to the database field names and field values, and if there are differences between the test results and the expected results, obtaining the differences and the logs corresponding to the differences.

[0092] In addition, in order to further facilitate the tester to view the results that need attention, the test results can be visualized. Specifically, after obtaining the interface structure, components can be added, and the expected results and the test results can be imported and displayed through the components.

[0093] Specifically, the importing of the test results through the component includes: first, importing the database field name and field value through the component, and then setting the data value path of the test results corresponding to the database field name and field value.

[0094] In a specific embodiment, in the component adding stage, first, add the component, import the result that needs to be concerned (corresponding to the specific database field name and field value), then import the data file corresponding to the expected result, and visualize it for the convenience of the tester to check, and then configure the actual result field data path. In the testing stage, the test is performed when the interface structure, test case and expected result are ready. During the testing process, multiple test cases can be executed in parallel, and the test results of the test case compared with the expected result can be obtained. If the test result of the test case or the intermediate result (the value of the interface output parameter) is inconsistent with the expected result, a log log can be attached to facilitate the tester to locate the problem according to the log analysis. It should be noted that the visual comparison result can provide a variety of schemes to facilitate the tester to choose a visualization scheme suitable for him, for example, simply compare only the value of the interface structure output parameter, or visualize the comparison with the intermediate result (at least one interface output parameter value) that is focused on, or visualize the result that needs to be concerned (including the intermediate result and the value of the interface structure output parameter). Of course, there can also be other feasible visualization result comparison schemes, which are not limited here.

[0095] Figure 2D The flowchart schematically shows a method for testing multiple interfaces according to another embodiment of the present disclosure.

[0096] like Figure 2D As shown, the method may further include operation S205.

[0097] In operation S205, when the test results of some test cases are different from the expected results, regression testing is performed on the some test cases through the test case switch.

[0098] Since the interface structure provided by the present disclosure can realize the parallel execution of multiple test cases, when one or more of the test cases are abnormal, the usual practice is to stop the test process of all test cases, start looking for abnormal test cases, and further analyze the abnormal test cases to find the abnormal interface. In this embodiment, since the output parameters of the interface structure can include interface structure output parameters and at least one interface output parameter, that is, the intermediate results can be compared at any time, and the results that need to be paid attention to are preset, so that the tester can easily find the abnormal test results and the corresponding test cases. Therefore, the test case switch can be set to choose to stop the test process of abnormal test cases or normal test cases, which helps to improve the convenience of testers.

[0099] Figure 3A The block diagram schematically shows a test device for multiple interfaces according to an embodiment of the present disclosure.

[0100] Accordingly, the present disclosure also provides a test device for multiple interfaces. Figure 3A As shown, the test device 300 may include an interface configuration module 310, a test module 320, and a result acquisition module 330. The interface configuration module 310, the test module 320, and the result acquisition module 330 may perform the following operations: FIG. 2A to FIG. 2B Test methods for multiple interfaces are shown.

[0101] Among them, the interface configuration module 310 is used to configure the interface parameters of the multiple interfaces to obtain an interface structure so that the multiple interfaces satisfy the calling order in the application scenario, wherein the interface structure includes input parameters and output parameters, and the output parameters include interface structure output parameters or interface structure output parameters and at least one interface output parameter.

[0102] The test module 320 is used to assign the test data of at least one test case to the input parameter of the interface structure, and obtain the value of the output parameter of the interface structure as the test result.

[0103] The result acquisition module 330 is used to acquire the test result of the use case according to the test result and the expected result.

[0104] In one embodiment, the interface configuration module 310 may include a calling sequence obtaining unit, a first configuration unit and a second configuration unit.

[0105] The calling sequence acquisition unit is used to determine multiple interfaces and the calling sequence of multiple interfaces according to the calling sequence of each interface in the code and the application scenario.

[0106] The first configuration unit is used to configure interface parameters of the multiple interfaces so that the multiple interfaces meet the calling order, and the interface parameters include any one or more of the following: protocol type, interface address, interface method name, interface input parameter and interface output parameter.

[0107] The second configuration unit is used to configure the mapping relationship between the interface address and the IP address of the test server according to the test environment.

[0108] In one embodiment, the interface method name includes any one or more of the following: information request, header request, processing request, deletion request, local modification request, transmission request or method return request.

[0109] In another embodiment, in order to facilitate maintenance of the test device for the multiple interfaces, the device may further include a first changing module 340 and / or a second changing module 350 .

[0110] The first changing module 340 is used to change the corresponding interface parameters when the calling sequence is changed.

[0111] The second changing module 350 is used to change the mapping relationship between the IP address and the host name of the corresponding test host when the test environment changes.

[0112] In yet another embodiment, the test module 320 may include a test case acquisition unit, a storage unit, and a first setting unit.

[0113] The test case acquisition unit is used to acquire a test case, and the test case includes a test variable and corresponding test data.

[0114] The storage unit is used to store the test variables and corresponding test data in a readable and writable file.

[0115] The first setting unit is used to set a data value path of an input parameter corresponding to the test data.

[0116] Accordingly, the result acquisition module 330 is specifically used to compare the test result with the expected result to obtain the use case test result.

[0117] Figure 3B A block diagram schematically shows a testing device for multiple interfaces according to another embodiment of the present disclosure.

[0118] like Figure 3B As shown, in this embodiment, the test device 300 for multiple interfaces may further include a setting module 360, and the test device 300 for multiple interfaces may implement the following Figure 2C Accordingly, the storage unit is also used to store the test result in a database.

[0119] The setting module 360 ​​is used to preset database field names and field values.

[0120] Correspondingly, the result acquisition module 330 may include a comparison unit and a log acquisition unit.

[0121] The comparison unit is used to compare the test results and expected results corresponding to the database field names and field values.

[0122] The log acquisition unit is used to acquire the difference and the log corresponding to the difference if there is a difference between the test result and the expected result.

[0123] In order to facilitate the test personnel to view the test results, pay attention to the results, etc., the visualization components can be encapsulated. Specifically, the test device 300 for multiple interfaces can also include a component adding module 370 and a display module 380.

[0124] The component adding module 370 is used to add components after obtaining the interface structure.

[0125] The display module 380 is used to import the expected result and the test result through the components and display them.

[0126] Preferably, the component adding module 370 may include a second setting unit and an importing unit. The second setting unit is used to set the data value path of the database field name and field value corresponding to the test result. The importing unit is used to import the expected result and the test result through the component.

[0127] Figure 3C A block diagram schematically shows a testing device for multiple interfaces according to another embodiment of the present disclosure.

[0128] like Figure 3C As shown, the test device 300 for multiple interfaces may further include a use case switch module 390. The test device 300 for multiple interfaces may implement the following Figure 2D The method shown. The use case switch module 390 is used to implement regression testing on some test cases through the test case switch when the test results of some test cases are different from the expected results. As mentioned above, since the output parameters of the interface structure can include at least one interface output parameter, the intermediate results can be obtained in time and displayed for necessary reading. In addition, the results that need to be paid attention to are preset, so that the tester can easily find abnormal test results and corresponding test cases. Therefore, the test case switch can be set to choose to stop the test process of abnormal test cases or normal test cases, which can effectively improve the convenience of testers.

[0129] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.

[0130] For example, any multiple of the interface configuration module 310, the test module 320, the result acquisition module 330, the first change module 340, the second change module 350, the setting module 360, the component adding module 370, the display module 380, and the use case switch module 390 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the interface configuration module 310, the test module 320, the result acquisition module 330, the first change module 340, the second change module 350, the setting module 360, the component addition module 370, the display module 380 and the use case switch module 390 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware and firmware or by an appropriate combination of any of them. Alternatively, at least one of the interface configuration module 310, the test module 320, the result acquisition module 330, the first change module 340, the second change module 350, the setting module 360, the component addition module 370, the display module 380 and the use case switch module 390 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0131] Figure 4 The block diagram of a computer system suitable for implementing the method described above according to an embodiment of the present disclosure is schematically shown. Figure 4 The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0132] like Figure 4 As shown, the computer system 400 according to the embodiment of the present disclosure includes a processor 401, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 402 or the program loaded from the storage part 408 to the random access memory (RAM) 403. The processor 401 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 401 may also include an onboard memory for caching purposes. The processor 401 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.

[0133] In RAM 403, various programs and data required for the operation of system 400 are stored. Processor 401, ROM 402 and RAM 403 are connected to each other through bus 404. Processor 401 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 402 and / or RAM 403. It should be noted that the program can also be stored in one or more memories other than ROM 402 and RAM 403. Processor 401 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0134] According to an embodiment of the present disclosure, the system 400 may further include an input / output (I / O) interface 405, which is also connected to the bus 404. The system 400 may further include one or more of the following components connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 405 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 408 as needed.

[0135] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 409, and / or installed from the removable medium 511. When the computer program is executed by the processor 401, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0136] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0137] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.

[0138] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 402 and / or the RAM 403 described above and / or one or more memories other than the ROM 402 and the RAM 403 .

[0139] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0140] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0141] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A method for testing multiple interfaces, comprising: Configuring the interface parameters of the multiple interfaces to obtain an interface structure, so that the multiple interfaces satisfy the calling order in the application scenario, wherein the interface structure includes input parameters and output parameters, the output parameters include interface structure output parameters or interface structure output parameters and at least one interface output parameter, and the interface structure is used to implement parallel execution of multiple test cases; the interface structure is solidified, the value of the interface output parameter represents the intermediate result, and the calling of the multiple interfaces includes multiple interfaces being requested at the same time; Wherein, configuring the interface parameters of the plurality of interfaces to obtain the interface structure comprises: configuring a mapping relationship between the interface address and the IP address of the test server according to the test environment; The method further comprises: When the calling sequence changes, change the corresponding interface parameters; and / or When the test environment changes, change the mapping relationship between the corresponding interface address and the IP address of the test server; Assigning the test data of at least one test case to the input parameter of the interface structure, and obtaining the value of the output parameter of the interface structure as the test result; and Obtain test results of the use case based on the test results and expected results; Wherein, the test results are stored in a database, and the method further comprises: presetting database field names and field values; wherein the database field names and field values ​​serve as identifiers of results that require attention; The obtaining of the test result of the use case according to the test result and the expected result includes: Compare the test results and expected results corresponding to the database field names and field values; The method further comprises: When the test results of some test cases are different from the expected results, regression testing is performed on the part of the test cases through a test case switch, wherein the test case switch is set to select stopping the test process of abnormal test cases or normal test cases.

2. The method according to claim 1, wherein: The configuring the interface parameters of the multiple interfaces to obtain the interface structure also includes: Determine multiple interfaces and the calling order of multiple interfaces according to the calling order and application scenarios of each interface in the code; The interface parameters of the multiple interfaces are configured so that the multiple interfaces satisfy the calling order, and the interface parameters include any one or more of the following: protocol type, interface address, interface method name, interface input parameter and interface output parameter.

3. The method according to claim 2, wherein: The interface method name includes any one or more of the following: information request, header request, processing request, deletion request, local modification request, transmission request or method return request.

4. The method according to claim 1, wherein: The step of assigning the test data of at least one test case to the input parameter of the interface structure includes: Obtaining a test case, wherein the test case includes a test variable and corresponding test data; storing the test variables and corresponding test data in a readable and writable file; and Set the data value path of the input parameter corresponding to the test data.

5. The method according to claim 1, wherein: The obtaining of the test result of the use case according to the test result and the expected result also includes: If there is a difference between the test result and the expected result, obtain the difference and the log corresponding to the difference.

6. The method according to claim 5, further comprising: After getting the interface structure, add components; as well as The expected result and the test result are imported through the component and displayed.

7. The method according to claim 6, wherein: Importing the test result by the component includes: Importing the database field names and field values ​​through the component; and Set the data value path of the test result corresponding to the database field name and field value.

8. A test device for multiple interfaces, comprising: An interface configuration module, configured to configure the interface parameters of the multiple interfaces to obtain an interface structure, so that the multiple interfaces satisfy the calling sequence in the application scenario, wherein the interface structure includes input parameters and output parameters, the output parameters include interface structure output parameters or interface structure output parameters and at least one interface output parameter, the interface structure is used to implement parallel execution of multiple test cases; the interface structure is solidified, the value of the interface output parameter represents the intermediate result, and the calling of the multiple interfaces includes multiple interfaces being requested at the same time; Wherein, the interface configuration module includes: a second configuration unit, configured to configure a mapping relationship between an interface address and an IP address of a test server according to a test environment; The device also includes: A first changing module is used to change the corresponding interface parameters when the calling sequence is changed; and / or The second change module is used to change the mapping relationship between the corresponding interface address and the IP address of the test server when the test environment changes; A test module, used to assign test data of at least one test case to an input parameter of the interface structure, and obtain a value of an output parameter of the interface structure as a test result; and A result acquisition module is used to obtain the test result of the test case according to the test result and the expected result; Wherein, the test module includes a storage unit, and the storage unit is used to store the test result in a database; The device further comprises: a setting module, which is used to preset the database field name and field value; wherein the database field name and field value serve as an identification of the result that needs attention; The result acquisition module comprises: A comparison unit, used for comparing the test results and expected results corresponding to the database field names and field values; The device also includes: The use case switch module is used to implement regression testing on some test cases through the test case switch when the test results of some test cases are different from the expected results, wherein the test case switch is set to select to stop the test process of abnormal test cases or normal test cases.

9. The device according to claim 8, wherein: The interface configuration module also includes: A calling sequence acquisition unit, used to determine multiple interfaces and the calling sequence of multiple interfaces according to the calling sequence of each interface in the code and the application scenario; The first configuration unit is used to configure interface parameters of the multiple interfaces so that the multiple interfaces meet the calling order, and the interface parameters include any one or more of the following: protocol type, interface address, interface method name, interface input parameter and interface output parameter.

10. The device according to claim 9, wherein: The interface method name includes any one or more of the following: information request, header request, processing request, deletion request, local modification request, transmission request or method return request.

11. The device according to claim 8, wherein: The test module includes: A test case acquisition unit, used to acquire a test case, wherein the test case includes a test variable and corresponding test data; The storage unit is used to store the test variables and corresponding test data in a readable and writable file; and The first setting unit is used to set a data value path of an input parameter corresponding to the test data.

12. The device according to claim 8, wherein: The result acquisition module is specifically used to compare the test result with the expected result to obtain the use case test result.

13. The device according to claim 12, wherein: The result acquisition module also includes: The log acquisition unit is used to acquire the difference and the log corresponding to the difference if there is a difference between the test result and the expected result.

14. The apparatus according to claim 13, further comprising: The component adding module is used to add components after obtaining the interface structure; A display module, used to import the expected result and the test result through the component and display them; The component adding module includes: A second setting unit is used to set the data value path of the database field name and field value corresponding to the test result; as well as An importing unit is used to import the expected result and the test result through the component.

15. A computing device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the method according to any one of claims 1 to 7 is implemented.

16. A computer-readable medium having executable instructions stored thereon, which, when executed by a processor, implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Application programming interface automatic test method, system, device and storage medium

    CN107729243A

  • Interface testing method and device

    CN107977308A