Interface testing method, device, computer equipment, and storage medium

By using a database to store and update interface request information in interface testing, the data export problem caused by placeholders is solved, the integrity and accuracy of test data are ensured, and the efficiency of interface testing is improved.

CN114238085BActive Publication Date: 2025-09-12SUZHOU LANGDONG NET TEC CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111452001.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2025-09-12
Estimated Expiration
2041-11-30

AI Technical Summary

Technical Problem

During the interface testing process, the existing technology cannot export the test request data as a test resource, and the use of placeholders in the test script makes it impossible to correctly compose the request data.

Method used

By pre-storing interface request information in the database, updating the database in real time, obtaining placeholder replacement values, building test requests, and judging whether the asserted expected value is the same as the actual value, the database is updated to eliminate the placeholder.

Benefits of technology

It realizes the export of complete request data without placeholders in interface testing, provides accurate test data for subsequent testing activities, and improves the accuracy of interface testing and data export efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238085B_ABST
    Figure CN114238085B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an interface testing method, apparatus, computer equipment, and storage medium. The method includes: reading interface request information of an interface test script from a database to construct a first test request; sending the first test request to obtain a return value; obtaining an expected assertion value from the database, obtaining an actual assertion value from the return value, determining whether the expected assertion value is the same as the actual assertion value, and updating the database according to the actual assertion value if the expected assertion value is different from the actual assertion value; obtaining a placeholder corresponding value in the return value, and updating the database according to the placeholder corresponding value; repeating the above steps until the interface test script is executed. The present disclosure facilitates the subsequent export of complete request data without placeholders by updating the database in real time, thereby providing test data for other testing activities.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of interface testing, and in particular to an interface testing method, apparatus, computer equipment, and storage medium. Background Art

[0002] Interface testing is a type of testing that tests the interfaces between system components. Interface testing is primarily used to examine the interaction points between external systems and between internal subsystems. Testing focuses on verifying data exchange, transmission, and control management processes, as well as the logical dependencies between systems. In software engineering, within the layered testing pyramid model, interface testing falls under the second layer of service integration testing. Compared to automated testing at the UI layer (primarily web or app), automated interface testing offers greater benefits, is easy to implement, and has low maintenance costs, making it the preferred choice for automated testing.

[0003] In traditional technologies, during interface testing, it is often impossible to export test request data as test resources to provide test data for other test activities. In addition, most test scripts use placeholders to obtain data from other request response results. Direct export will contain placeholders and cannot correctly form request data. Summary of the Invention

[0004] Based on this, it is necessary to provide an interface testing method, apparatus, computer equipment, storage medium and computer program product to address the above technical issues.

[0005] In a first aspect, the present disclosure provides an interface testing method. The method comprises:

[0006] Reading interface request information of the interface test script from a database, obtaining a placeholder replacement value from the database according to the placeholder in the interface request information, replacing the placeholder in the interface request information with the placeholder replacement value, and then constructing a first test request;

[0007] Send the first test request and obtain a return value;

[0008] Obtaining an assertion expected value from the database, obtaining an assertion actual value from the return value, determining whether the assertion expected value is the same as the assertion actual value, and if the assertion expected value is not the same as the assertion actual value, updating the database according to the assertion actual value;

[0009] Obtaining a value corresponding to the placeholder in the return value, and updating the database according to the value corresponding to the placeholder;

[0010] Repeat the above steps until the interface test script is executed.

[0011] In one embodiment, the process of reading the interface request information of the interface test script from the database includes:

[0012] Entering the interface test script and storing the test information of the interface test script in the database; the test information includes interface request information, interface assertion information, and interface placeholder information;

[0013] Receive an execution request from a client to execute the interface test script.

[0014] In one embodiment, entering the interface test script and storing the test information of the interface test script in the database includes:

[0015] Storing the interface request information in the test information into a first data table, the interface request information including a request protocol, a request method, a request header, and a request address;

[0016] Storing the interface assertion information in the test information into a second data table, the interface assertion information including an assertion value expression, an assertion expression, an assertion actual value, and an assertion expected value;

[0017] The interface placeholder information in the test information is stored in a third data table, where the interface placeholder information includes a placeholder keyword, a placeholder value expression, and a placeholder replacement value.

[0018] In one embodiment, after executing the interface test script, the method further includes:

[0019] receiving an export request from a client to export the first test request; the interface test script corresponding to the first test request is in an execution-completed state;

[0020] Reading the interface request information of the interface test script from the updated database, obtaining a placeholder replacement value from the database according to the placeholder in the interface request information, replacing the placeholder in the interface request information with the placeholder replacement value, and constructing a second test request; repeating the step of constructing the second test request until all the second test requests are constructed;

[0021] The second test request is returned to the client.

[0022] In one embodiment, the step of constructing the second test request further includes:

[0023] In the case that the placeholder replacement value is obtained from the database according to the placeholder in the interface request information, the execution of the export request of other first test requests is jumped.

[0024] In one embodiment, obtaining the assertion expected value from the database, obtaining the assertion actual value from the return value, determining whether the assertion expected value is the same as the assertion actual value, and if the assertion expected value is not the same as the assertion actual value, updating the database according to the assertion actual value includes:

[0025] Obtaining an assertion expected value from the interface assertion information of the database according to the assertion value expression;

[0026] Obtaining an assertion actual value from the return value according to the assertion value expression;

[0027] Determine whether the assertion expected value is the same as the assertion actual value; if the assertion expected value is not the same as the assertion actual value, replace the corresponding assertion expected value in the database according to the assertion actual value.

[0028] In a second aspect, the present disclosure further provides an interface testing device. The device comprises:

[0029] A first test request module is configured to read interface request information of an interface test script from a database, obtain a placeholder replacement value from the database according to a placeholder in the interface request information, replace the placeholder in the interface request information with the placeholder replacement value, and then construct a first test request;

[0030] A sending module, configured to send the first test request and obtain a return value;

[0031] an assertion update module, configured to obtain an expected assertion value from the database, obtain an actual assertion value from the return value, determine whether the expected assertion value is the same as the actual assertion value, and update the database according to the actual assertion value if the expected assertion value is not the same as the actual assertion value;

[0032] The placeholder updating module is used to obtain the placeholder corresponding value in the return value and update the database according to the placeholder corresponding value.

[0033] In one embodiment, the apparatus further comprises:

[0034] An input module, used to input the interface test script and store the test information of the interface test script into the database; the test information includes interface request information, interface assertion information, and interface placeholder information;

[0035] The client interaction module is used to receive an execution request initiated by the client to execute the interface test script.

[0036] In one embodiment, the entry module includes:

[0037] A first data unit is used to store the interface request information in the test information into a first data table, wherein the interface request information includes a request protocol, a request method, a request header, and a request address;

[0038] A second data unit is used to store the interface assertion information in the test information into a second data table, where the interface assertion information includes an assertion value expression, an assertion expression, an assertion actual value, and an assertion expected value;

[0039] The third data unit is used to store the interface placeholder information in the test information into a third data table, where the interface placeholder information includes a placeholder keyword, a placeholder value expression, and a placeholder replacement value.

[0040] In one embodiment, the client interaction module is further configured to receive an export request from the client to export the first test request; the interface test script corresponding to the first test request is in an execution completion state;

[0041] The apparatus further includes a second test request module configured to read interface request information of an interface test script from an updated database, obtain a placeholder replacement value from the database according to a placeholder in the interface request information, replace the placeholder in the interface request information with the placeholder replacement value, and construct a second test request; and repeat the step of constructing the second test request until all second test requests are constructed.

[0042] The client interaction module is further configured to return the second test request to the client.

[0043] In one embodiment, the assertion update module includes:

[0044] An assertion expectation unit, configured to obtain an assertion expected value from the interface assertion information of the database according to an assertion value expression;

[0045] An assertion actual value unit, configured to obtain an assertion actual value from the return value according to the assertion value expression;

[0046] The assertion updating unit is used to determine whether the assertion expected value is the same as the assertion actual value. If the assertion expected value is not the same as the assertion actual value, the assertion expected value in the database is replaced according to the assertion actual value.

[0047] In a third aspect, the present disclosure further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned interface testing method when executing the computer program.

[0048] In a fourth aspect, the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above-mentioned interface testing method when executed by a processor.

[0049] In a fifth aspect, the present disclosure further provides a computer program product, which includes a computer program that implements the steps of the above-mentioned interface testing method when executed by a processor.

[0050] The above-mentioned interface testing method, apparatus, computer device, storage medium and computer program product have at least the following beneficial effects:

[0051] The present disclosure pre-stores interface request information in a database and updates the database in real time when executing the test script, which helps to subsequently export complete request data without placeholders and provide test data for other test activities. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the traditional technology, the following briefly introduces the drawings required for use in the embodiments or the description of the traditional technology. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0053] Figure 1 An application environment diagram of an interface testing method in an embodiment;

[0054] Figure 2 Schematic diagram of a flow chart of an interface testing method in one embodiment;

[0055] Figure 3 A flowchart illustrating steps of constructing a first test request in one embodiment;

[0056] Figure 4 A flowchart of steps before reading interface request information of an interface test script in one embodiment;

[0057] Figure 5 A flowchart of the steps for entering an interface test script in one embodiment;

[0058] Figure 6 A schematic diagram of a flow chart of a step of deriving a second test request in one embodiment;

[0059] Figure 7 A schematic diagram of a flow chart of a step of constructing a second test request in one embodiment;

[0060] Figure 8is a structural block diagram of an interface testing device in one embodiment;

[0061] Figure 9 is another structural block diagram of an interface testing device in one embodiment;

[0062] Figure 10 is a structural block diagram of an input module in one embodiment;

[0063] Figure 11 is another structural block diagram of an interface testing device in one embodiment;

[0064] Figure 12 is a structural block diagram of an assertion update module in one embodiment;

[0065] Figure 13 FIG. 1 is a block diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0067] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art in the art of the present disclosure. The terms used herein in the specification of the present disclosure are only for the purpose of describing specific embodiments and are not intended to limit the present disclosure.

[0068] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the accompanying drawings are used to distinguish similar items and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims. The terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, product, or apparatus comprising a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, product, or apparatus. Without further limitation, this does not preclude the presence of additional identical or equivalent elements in the process, method, product, or apparatus comprising the elements. For example, the use of terms such as "first," "second," and the like are intended to indicate names and do not imply any specific order.

[0069] As used herein, the singular forms "a," "an," and "the" may also include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "include," "comprising," "having," and the like specify the presence of stated features, integers, steps, operations, components, parts, or combinations thereof, but do not preclude the presence or addition of one or more other features, integers, steps, operations, components, parts, or combinations thereof. Also, in this specification, the term "and / or" includes any and all combinations of the relevant listed items.

[0070] The interface testing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. The client 102 communicates with the server 104 via the network. The database can store data that the server 104 needs to process. The database can be integrated on the server 104, or it can be placed on the cloud or other network servers. The client 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, or other servers. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers. The server 104 is used to provide interface automation testing services. After receiving the test request from the client 102, it executes the interface test script and returns the test request data to the client 102.

[0071] In some embodiments of the present disclosure, Figure 2 As shown, an interface testing method is provided, which is applied to Figure 1 Taking the server 104 in the example as an example, the following steps are included:

[0072] Step S10: Read the interface request information of the interface test script from the database, obtain the placeholder replacement value from the database according to the placeholder in the interface request information, replace the placeholder in the interface request information with the placeholder replacement value, and then construct a first test request.

[0073] Specifically, the database pre-stores an interface test script, and the interface request information is obtained by reading the interface test script. Figure 3, in the process of reading the interface request information, it is determined whether the current statement contains a placeholder. If it contains a placeholder, the key value of the placeholder is obtained, and the placeholder replacement value of the placeholder is queried in the database according to the placeholder, and the placeholder in the current statement is replaced with the queried placeholder replacement value, and finally the various parts of the interface request information are combined into a complete first test request. In the case that the current statement does not contain a placeholder, the next statement can be read sequentially or the first test request can be directly exported at the node where the reading is completed. At this time, the first test request does not contain a placeholder. Among them, the interface test script may refer to an executable file written in a specific descriptive language and format for fully realizing the functions of interface automation testing, automatic execution and emailing test reports. The interface request information may refer to the information containing the interface request in the interface test script.

[0074] Step S20: Send the first test request and obtain a return value.

[0075] Specifically, interface testing is primarily used for interaction points between external systems and between internal subsystems. Specific interaction points are defined and then, through these interaction points, data is exchanged using specific rules, also known as protocols. By executing the interface test script, the first test request is sent to the system under test, and the test return value is obtained.

[0076] Step S30: Obtain the assertion expected value from the database, obtain the assertion actual value from the return value, determine whether the assertion expected value is the same as the assertion actual value, and if the assertion expected value is not the same as the assertion actual value, update the database according to the assertion actual value.

[0077] Specifically, the expected assertion value is queried from the database, the actual assertion value is read from the return value, and the expected assertion value is compared with the actual assertion value. If the actual assertion value differs from the expected assertion value, the expected assertion value in the database is updated based on the actual assertion value in the return value, and the data information when the two differ is recorded.

[0078] Step S40: Obtain the corresponding value of the placeholder in the return value, and update the database according to the corresponding value of the placeholder.

[0079] Specifically, the corresponding value of the placeholder is read from the return value, the obtained corresponding value of the placeholder is replaced with the corresponding placeholder in the database, and the database is updated.

[0080] Step S50: Repeat the above steps until the interface test script is executed.

[0081] Specifically, the above steps S10 to S40 are repeated until all interface test scripts are executed.

[0082] In the above interface testing method, the interface request information is pre-stored in the database. When the test script is executed, the database is updated in real time, which helps to subsequently export complete request data without placeholders and provide test data for other testing activities.

[0083] In some embodiments of the present disclosure, Figure 4 As shown, the interface request information of the interface test script is read from the database, including:

[0084] Step A10: input the interface test script, and store the test information of the interface test script into the database; the test information includes interface request information, interface assertion information, and interface placeholder information.

[0085] Specifically, before executing the interface test script, the test information of the interface test script is pre-entered into the database, wherein the test information includes interface request information related to the interface request, interface assertion information related to the assertion, and interface placeholder information related to the placeholder.

[0086] Step A20: Receive an execution request from the client to execute the interface test script.

[0087] Specifically, the client can receive a user's instruction through human-computer interaction, and after receiving the user's instruction, trigger an execution request to the server to execute the interface test script. After receiving the execution request from the client, the server executes the interface test script to perform interface testing.

[0088] This embodiment enters the test information of the interface test script into the database in advance, which can provide test information in subsequent tests and continuously update it, and promptly involve the updated database in the test, thereby improving the accuracy of the interface test and helping to improve the efficiency of request data export.

[0089] In some embodiments of the present disclosure, Figure 5 As shown, the above step A10 includes:

[0090] Step A12: Store the interface request information in the test information into the first data table, where the interface request information includes a request protocol, a request method, a request header, and a request address.

[0091] Specifically, three data tables are established in the database, and interface request information related to the interface request is stored in the first data table. The first data table is used to store request protocols, request methods, request headers, request addresses and request parameters including but not limited to interface test requests.

[0092] Step A14: Store the interface assertion information in the test information into a second data table, where the interface assertion information includes an assertion value expression, an assertion expression, an assertion actual value, and an assertion expected value.

[0093] Specifically, the second data table is used to store interface assertion information related to assertions, such as including but not limited to assertion value expressions, assertion expressions, assertion actual values, and assertion expected values.

[0094] Step A16: Store the interface placeholder information in the test information into a third data table, wherein the interface placeholder information includes a placeholder keyword, a placeholder value expression, and a placeholder replacement value.

[0095] Specifically, the third data table is used to store interface placeholder information related to the placeholder, such as including but not limited to placeholder keywords, placeholder value expressions, and placeholder replacement values.

[0096] This embodiment stores key information of the test information separately, and stores interface request information, interface assertion information, and interface placeholder information in the form of data tables, thereby greatly improving data query efficiency.

[0097] In some embodiments of the present disclosure, Figure 6 As shown, after executing the interface test script, the following steps are also included:

[0098] Step B10: receiving an export request from the client to export the first test request; the interface test script corresponding to the first test request is in an execution completion state.

[0099] Specifically, after the interface test script is executed, an export request for exporting the first test request sent by the client is received.

[0100] Step B20: Read the interface request information of the interface test script from the updated database, obtain the placeholder replacement value from the database according to the placeholder in the interface request information, replace the placeholder in the interface request information with the placeholder replacement value, and construct a second test request; repeat the step of constructing the second test request until all second test requests are constructed.

[0101] Specifically, the execution process of the interface test script is accompanied by the update of the database. When the first test request is exported, the interface request information of the interface test script is read from the updated database. The reading process refers to the reading step in the above step S10. The request data of each part are assembled into a complete request from the database. When a placeholder is encountered, the corresponding placeholder replacement value is queried according to the key value of the placeholder, until all placeholders are replaced and assembled to obtain the second test request.

[0102] Step B30: Return the second test request to the client.

[0103] Specifically, after the second test request is assembled, the export request sent by the client is responded to and the second test request is returned to the client.

[0104] When exporting the second test request, this embodiment responds to the client's export request, constructs a complete second test request without placeholders based on the interface request information of each part in the updated database, and returns it to the client, thereby ensuring the integrity of the exported test request data and facilitating subsequent test result analysis.

[0105] In some embodiments of the present disclosure, the step of constructing the second test request further includes:

[0106] In the case that the placeholder replacement value is obtained from the database according to the placeholder in the interface request information, the execution of the export request of other first test requests is jumped.

[0107] Specifically, when exporting the second test request, the first test requests are exported in sequence. When the export of a first test request fails, the next first test request is automatically exported to avoid the inability to assemble the second test request due to the failure of exporting one test request.

[0108] This embodiment monitors the export status of the first test request, responds promptly to the failure of exporting the first test request, and ensures the assembly integrity of the entire second test request by exporting other first test requests.

[0109] In some embodiments of the present disclosure, Figure 7 As shown, the above step S30 includes:

[0110] Step S32: Obtaining an assertion expected value from the interface assertion information in the database according to the assertion value expression.

[0111] Specifically, the assertion value expression is stored in the database, and the assertion expected value is obtained from the database using the jsonpath assertion value expression of the assertion data.

[0112] Step S34: Obtain the assertion actual value from the return value according to the assertion value expression.

[0113] Specifically, the jsonpath assertion value expression of the assertion data is used to obtain the assertion expected value from the return value.

[0114] Step S36: Determine whether the assertion expected value is the same as the assertion actual value. If the assertion expected value is not the same as the assertion actual value, replace the corresponding assertion expected value in the database according to the assertion actual value.

[0115] Specifically, it is determined whether the assertion actual value is the same as the assertion expected value. If they are not the same, the assertion expected value in the database is replaced with the assertion actual value, and the assertion expected value in the database is updated.

[0116] This embodiment obtains the assertion actual value and the assertion expected value through the assertion value expression, thereby improving the efficiency of data acquisition and ensuring the timeliness of the data in the database by updating the assertion expected value.

[0117] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0118] Based on the same inventive concept, the embodiments of the present disclosure also provide an interface testing device for implementing the interface testing method involved above. The implementation solution provided by this device is similar to the implementation solution described in the above method. Therefore, the specific limitations of one or more interface testing device embodiments provided below can be found in the above-mentioned limitations of the interface testing method and will not be repeated here.

[0119] The device may include a system (including a distributed system), software (application), module, component, server, client, etc. that uses the method described in the embodiments of this specification and is combined with the necessary implementation hardware. Based on the same innovative concept, the device in one or more embodiments provided by the embodiments of the present disclosure is as described in the following embodiments. Since the implementation scheme and method for solving the problem of the device are similar, the implementation of the specific device in the embodiments of this specification can refer to the implementation of the aforementioned method, and the repetitions will not be repeated. As used below, the term "unit" or "module" can implement a combination of software and / or hardware for a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0120] In some embodiments of the present disclosure, Figure 8 As shown, an interface testing device is provided, and the device Z00 may include:

[0121] A first test request module Z10 is configured to read interface request information of an interface test script from a database, obtain placeholder replacement values ​​from the database according to placeholders in the interface request information, replace the placeholders in the interface request information with the placeholder replacement values, and then construct a first test request;

[0122] A sending module Z20 is configured to send the first test request and obtain a return value;

[0123] an assertion updating module Z30, configured to obtain an expected assertion value from the database, obtain an actual assertion value from the return value, determine whether the expected assertion value is the same as the actual assertion value, and if the expected assertion value is not the same as the actual assertion value, update the database according to the actual assertion value;

[0124] The placeholder updating module Z40 is configured to obtain the placeholder corresponding value in the return value and update the database according to the placeholder corresponding value.

[0125] In some embodiments of the present disclosure, Figure 9 As shown, the device Z00 further includes:

[0126] An input module Z50 is used to input the interface test script and store the test information of the interface test script into the database; the test information includes interface request information, interface assertion information, and interface placeholder information;

[0127] The client interaction module Z60 is used to receive an execution request initiated by the client to execute the interface test script.

[0128] In some embodiments of the present disclosure, Figure 10 As shown, the input module Z50 includes:

[0129] A first data unit Z52 is used to store the interface request information in the test information into a first data table, wherein the interface request information includes a request protocol, a request method, a request header, and a request address;

[0130] A second data unit Z54 is used to store the interface assertion information in the test information into a second data table, where the interface assertion information includes an assertion value expression, an assertion expression, an assertion actual value, and an assertion expected value;

[0131] The third data unit Z56 is used to store the interface placeholder information in the test information into a third data table, where the interface placeholder information includes a placeholder keyword, a placeholder value expression, and a placeholder replacement value.

[0132] In some embodiments of the present disclosure, Figure 11 As shown, the client interaction module Z60 is further configured to receive an export request from the client to export the first test request; the interface test script corresponding to the first test request is in the executed state;

[0133] The device Z00 further includes a second test request module Z70 configured to read interface request information of an interface test script from an updated database, obtain placeholder replacement values ​​from the database according to placeholders in the interface request information, replace the placeholders in the interface request information with the placeholder replacement values, and construct a second test request; and repeat the step of constructing the second test request until all second test requests are constructed.

[0134] The client interaction module Z60 is further configured to return the second test request to the client.

[0135] In some embodiments of the present disclosure, Figure 12 As shown, the assertion update module Z30 includes:

[0136] Assertion expectation unit Z32, used to obtain an assertion expected value from the interface assertion information of the database according to an assertion value expression;

[0137] Assertion actual unit Z34, used to obtain the assertion actual value from the return value according to the assertion value expression;

[0138] The assertion updating unit Z36 is used to determine whether the assertion expected value is the same as the assertion actual value. If the assertion expected value is not the same as the assertion actual value, the assertion expected value in the database is replaced with the assertion actual value.

[0139] Each module in the above-mentioned interface testing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules. It should be noted that the division of modules in the embodiment of the present disclosure is schematic and is only a logical function division. In actual implementation, there may be other division methods.

[0140] Based on the embodiment description of the aforementioned interface testing method, in another embodiment provided by the present disclosure, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 13 As shown. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an interface testing method is implemented.

[0141] Those skilled in the art will understand that the structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0142] Based on the description of the embodiment of the aforementioned interface testing method, in another embodiment provided in the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0143] Based on the description of the embodiment of the aforementioned interface testing method, in another embodiment provided in the present disclosure, a computer program product is provided, including a computer program, which implements the steps in the aforementioned method embodiments when executed by a processor.

[0144] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.

[0145] Throughout this specification, references to terms such as "some embodiments," "other embodiments," and "desired embodiments" indicate that a particular feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. Although these terms are used interchangeably throughout this specification, they do not necessarily refer to the same embodiment or example.

[0146] It is understood that the various embodiments of the above method in this specification are described in a progressive manner. The same / similar parts between the various embodiments can be referred to in detail. Each embodiment focuses on the differences from other embodiments. For related parts, please refer to the description of other method embodiments.

[0147] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features of the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0148] The above-described embodiments merely represent several implementation methods of the present disclosure. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present disclosure, all of which fall within the scope of protection of the present disclosure. Therefore, the scope of protection of the patent disclosed herein shall be determined by the appended claims.

Claims

1. An interface testing method, characterized in that: The method comprises: Step S10: reading interface request information of the interface test script from a database, obtaining placeholder replacement values ​​from the database according to placeholders in the interface request information, replacing the placeholders in the interface request information with the placeholder replacement values, and constructing a first test request; Step S20: Send the first test request and obtain a return value; Step S30, obtaining the assertion expected value from the database, obtaining the assertion actual value from the return value, determining whether the assertion expected value is the same as the assertion actual value, and if the assertion expected value is not the same as the assertion actual value, updating the assertion expected value in the database according to the assertion actual value in the return value; Step S40, obtaining a value corresponding to the placeholder in the return value, and replacing the obtained value corresponding to the placeholder with a corresponding placeholder in the database; Step S50, repeating step S10, step S20, step S30, and step S40 until all interface test scripts are executed.

2. The method according to claim 1, characterized in that The interface request information of the interface test script is read from the database, which includes: Entering the interface test script and storing the test information of the interface test script in the database; the test information includes interface request information, interface assertion information and interface placeholder information; Receive an execution request from a client to execute the interface test script.

3. The method according to claim 2, characterized in that The step of entering the interface test script and storing the test information of the interface test script in the database includes: Storing the interface request information in the test information into a first data table, the interface request information including a request protocol, a request method, a request header, and a request address; Storing the interface assertion information in the test information into a second data table, the interface assertion information including an assertion value expression, an assertion expression, an assertion actual value, and an assertion expected value; The interface placeholder information in the test information is stored in a third data table, where the interface placeholder information includes a placeholder keyword, a placeholder value expression, and a placeholder replacement value.

4. The method according to claim 1, wherein After the interface test script is executed, the following steps are also included: receiving an export request from a client to export the first test request; the interface test script corresponding to the first test request is in an execution-completed state; The step of constructing a second test request: reading the interface request information of the interface test script from the updated database, obtaining a placeholder replacement value from the database according to the placeholder in the interface request information, replacing the placeholder in the interface request information with the placeholder replacement value, and constructing the second test request; Repeat the step of constructing the second test request until the second test request corresponding to all the interface request information is constructed; The second test request is returned to the client.

5. The method according to claim 4, characterized in that The step of constructing the second test request further includes: In the case that the placeholder replacement value is obtained from the database according to the placeholder in the interface request information, the execution of the export request of other first test requests is jumped.

6. The method according to claim 1, characterized in that The acquiring the assertion expected value from the database, acquiring the assertion actual value from the return value, determining whether the assertion expected value is the same as the assertion actual value, and if the assertion expected value is not the same as the assertion actual value, updating the assertion expected value in the database according to the assertion actual value in the return value, includes: Obtaining an assertion expected value from the interface assertion information of the database according to the assertion value expression; Obtaining an assertion actual value from the return value according to the assertion value expression; Determine whether the assertion expected value is the same as the assertion actual value; if the assertion expected value is not the same as the assertion actual value, replace the corresponding assertion expected value in the database according to the assertion actual value.

7. An interface testing device, characterized in that: The device comprises: A first test request module is configured to read interface request information of an interface test script from a database, obtain a placeholder replacement value from the database according to a placeholder in the interface request information, replace the placeholder in the interface request information with the placeholder replacement value, and then construct a first test request; A sending module, configured to send the first test request and obtain a return value; an assertion update module, configured to obtain an assertion expected value from the database, obtain an assertion actual value from the return value, determine whether the assertion expected value is the same as the assertion actual value, and if the assertion expected value is not the same as the assertion actual value, update the assertion expected value in the database according to the assertion actual value in the return value; The placeholder updating module is used to obtain the corresponding value of the placeholder in the return value and replace the obtained corresponding value of the placeholder with the corresponding placeholder in the database.

8. The device according to claim 7, characterized in that The device further comprises: An input module, configured to input the interface test script and store the test information of the interface test script into the database; the test information includes interface request information, interface assertion information and interface placeholder information; The client interaction module is used to receive an execution request initiated by the client to execute the interface test script.

9. The device according to claim 8, characterized in that The input module includes: A first data unit, configured to store the interface request information in the test information into a first data table, wherein the interface request information includes a request protocol, a request method, a request header, and a request address; A second data unit is used to store the interface assertion information in the test information into a second data table, where the interface assertion information includes an assertion value expression, an assertion expression, an assertion actual value, and an assertion expected value; The third data unit is used to store the interface placeholder information in the test information into a third data table, where the interface placeholder information includes a placeholder keyword, a placeholder value expression, and a placeholder replacement value.

10. The device according to claim 8, characterized in that The client interaction module is further configured to receive an export request from the client to export the first test request; the interface test script corresponding to the first test request is in an execution completion state; The apparatus further includes a second test request module configured to read interface request information of an interface test script from an updated database, obtain a placeholder replacement value from the database according to a placeholder in the interface request information, replace the placeholder in the interface request information with the placeholder replacement value, and construct a second test request; Repeat the step of constructing the second test request until the second test request corresponding to all the interface request information is constructed; The step of constructing the second test request includes: reading interface request information of the interface test script from the updated database, obtaining a placeholder replacement value from the database according to the placeholder in the interface request information, replacing the placeholder in the interface request information with the placeholder replacement value, and constructing the second test request; The client interaction module is further configured to return the second test request to the client.

11. The device according to claim 7, characterized in that The assertion update module includes: An assertion expectation unit, configured to obtain an assertion expected value from the interface assertion information of the database according to an assertion value expression; An assertion actual value unit, configured to obtain an assertion actual value from the return value according to the assertion value expression; The assertion updating unit is used to determine whether the assertion expected value is the same as the assertion actual value. If the assertion expected value is not the same as the assertion actual value, the assertion expected value in the database is replaced according to the assertion actual value.

12. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method and device for asserting data of test interfaces

    CN107122296A

  • Performance test method, device and equipment for service system and readable storage medium

    CN110221982A