An interface test method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202210960219.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-11
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2042-08-11
AI Technical Summary
[0003]目前,在实现接口测试过程中,需要通过人工根据接口文档编写大量的测试用例,耗费大量的时间,并且可能导致测试用例生成的遗漏
[0042]根据本发明的另一方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现本发明任一实施例所述的接口测试方法。
Smart Images

Figure CN115269431B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of interface testing technology, and in particular to an interface testing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Interface testing is a type of testing that examines the interfaces between system components, and it is an important part of software testing. Interface testing detects the interaction points between external systems and the system itself, as well as between various internal subsystems, focusing on the exchange, transmission, and control management processes of data, and the logical dependencies between systems.
[0003] Currently, in the process of implementing interface testing, a large number of test cases need to be written manually based on the interface documentation, which consumes a lot of time and may lead to omissions in test case generation. Summary of the Invention
[0004] This invention provides an interface testing method, apparatus, electronic device, and storage medium to improve the efficiency and comprehensiveness of test case generation, as well as the efficiency of interface testing.
[0005] According to one aspect of the present invention, an interface testing method is provided, the method comprising:
[0006] Obtain initial interface document data, and determine target interface document data based on the initial interface document data;
[0007] Based on the target interface document data, generate interface test cases and corresponding interface configuration files for the interface test cases;
[0008] The interface test cases are executed according to the interface configuration file to obtain the interface test results.
[0009] The step of executing the interface test cases according to the interface configuration file includes:
[0010] The first expression in the interface configuration file is used to call the target code in the interface test case that is related to the first expression; wherein, the first expression includes a calling expression;
[0011] At least one first test data point is generated for the interface test case based on the target code, and the interface test case is executed based on the first test data.
[0012] The advantages of this setup are: by calling the target code in the interface test case through the first expression to generate the first test data, there is no need to configure a large amount of repetitive or similar test data in the interface configuration file, which improves the flexibility of the interface configuration file to drive the execution of interface test cases; and the amount of data in the interface configuration file is reduced, thereby improving the simplicity of the interface configuration file.
[0013] Optionally, the step of executing the interface test cases according to the interface configuration file includes:
[0014] The interface test case is generated by generating at least two second test data using the second expression in the interface configuration file, and the interface test case is executed based on the second test data; wherein the second expression includes a conditional expression.
[0015] The advantage of this setup is that it generates multiple second test data using a single second expression, eliminating the need to fully display all the test data in the interface configuration file, thus reducing the amount of data in the interface configuration file and improving its simplicity.
[0016] Optionally, the step of executing the interface test cases according to the interface configuration file includes:
[0017] The assertion parameters of the interface test cases are configured through the third expression in the interface configuration file, and the interface test cases are executed according to the assertion parameters; wherein, the third expression includes assertion expressions.
[0018] The advantage of this setup is that it allows configuration of assertion parameters for interface test cases via a third expression, avoiding the problem in existing technologies where assertion parameters are only configured in the interface test case code. This necessitates code modifications when assertion parameters change, reducing efficiency. It also improves the flexibility of assertion data modification.
[0019] Optionally, the step of executing the interface test cases according to the interface configuration file includes:
[0020] In response to the debugging operation of the interface test case, the interface test case is executed according to the interface configuration file.
[0021] Obtain the execution data of the interface test cases, and update the interface configuration file based on the execution data;
[0022] The updated interface configuration file drives the execution of the interface test cases.
[0023] The advantage of this setup is that by updating the interface configuration file with updated data, the content of the relatively simple interface configuration file, which is directly generated from the target interface document data, is enriched. This makes it easier to obtain more accurate interface test results when executing interface test cases based on the updated interface configuration file, thereby improving the accuracy of interface testing.
[0024] Optionally, the method further includes:
[0025] An interface library is obtained by encapsulating the target interface document data.
[0026] Based on the interface call request issued during the execution of the interface test case, the target interface is called from the interface library.
[0027] The advantages of this setup are: by encapsulating the target interface document data, the interface is automatically and uniformly encapsulated, avoiding omissions in interface generation; and when the target interface document data changes, the interface can be updated in a timely manner, improving update efficiency.
[0028] This also allows the interface to be called directly by issuing an interface call request when the interface test case needs to be executed, without the need to temporarily generate the corresponding interface, thus improving the efficiency of interface calls; and avoids the repeated encapsulation of the same interface due to temporary encapsulation each time it is called, thus improving the effectiveness of interface encapsulation.
[0029] Optionally, after calling the target interface from the interface library, the method further includes:
[0030] Obtain the call data of the target interface;
[0031] The call status of the target interface is determined based on the call data;
[0032] The return data of the target interface is determined based on the call status.
[0033] The advantage of this setup is that by determining the return data of the target interface based on the call status, it avoids returning all call data, thereby avoiding the need for manual verification of the validity of the returned data, which would reduce the efficiency of interface testing and improve the validity of the returned data.
[0034] According to another aspect of the present invention, an interface testing apparatus is provided, the apparatus comprising:
[0035] The document data determination module is used to acquire initial interface document data and determine target interface document data based on the initial interface document data.
[0036] The test case file generation module is used to generate interface test cases based on the target interface document data, and to generate the interface configuration file corresponding to the interface test cases;
[0037] The test case execution module is used to execute the interface test cases according to the interface configuration file and obtain the interface test results.
[0038] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0039] At least one processor; and
[0040] A memory communicatively connected to the at least one processor; wherein,
[0041] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the interface testing method described in any embodiment of the present invention.
[0042] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the interface testing method described in any embodiment of the present invention.
[0043] The technical solution of this invention automatically generates a full set of interface test cases based on initial interface document data, avoiding omissions that may occur when manually writing interface test cases based on document data, thus improving the efficiency and comprehensiveness of interface test case generation. It also automatically generates corresponding interface configuration files for all interface test cases based on the initial interface document data, improving the relevance between interface configuration files and interface test cases, thereby enhancing the effectiveness and efficiency of interface configuration file generation. Furthermore, by automatically generating interface test cases and interface configuration files based on the initial interface document data, the system can promptly update the interface test cases and interface configuration files when the initial interface document data changes, improving update efficiency.
[0044] By driving the execution of interface test cases through interface configuration files, test case execution can be driven by managing interface configuration files, eliminating the need to frequently modify the code in interface test cases during testing, thereby improving the usability of interface test cases and the efficiency of interface testing.
[0045] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0046] Figure 1A flowchart of an interface testing method provided in Embodiment 1 of the present invention;
[0047] Figure 2 This is a flowchart of the first interface testing method provided in Embodiment 2 of the present invention;
[0048] Figure 3 This is a flowchart of the second interface testing method provided in Embodiment 2 of the present invention;
[0049] Figure 4 This is a flowchart of the third interface testing method provided in Embodiment 2 of the present invention;
[0050] Figure 5 A flowchart of an interface testing method provided in Embodiment 3 of the present invention;
[0051] Figure 6 This is a schematic diagram of the structure of an interface testing device provided in Embodiment 4 of the present invention;
[0052] Figure 7 This is a schematic diagram of the structure of an electronic device used to implement embodiments of the present invention. Detailed Implementation
[0053] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0054] It should be noted that the terms "first," "second," "target," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0055] Example 1
[0056] Figure 1This is a flowchart illustrating an interface testing method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where interface test cases are executed via an interface configuration file. The method can be executed by the interface testing device provided in this embodiment, which can be implemented in software and / or hardware. See also... Figure 1 The interface testing method provided in this embodiment includes:
[0057] Step 110: Obtain initial interface document data and determine target interface document data based on the initial interface document data.
[0058] The initial document data refers to the original interface document data, including all data related to the interface, such as RAP interface document data. This embodiment does not impose any restrictions on this. The initial interface document data can be obtained by sending a data retrieval request to the initial interface document to obtain data of the appropriate type, such as the full or most recently updated initial interface document data.
[0059] The target API documentation data is API documentation data in a target format. The target API documentation data is determined based on the initial API documentation data. This can be achieved by parsing the initial API documentation data and converting its original format to the target format. For example, the initial API documentation data in JSON format can be converted to YAML format to obtain the target API documentation data.
[0060] Step 120: Generate interface test cases based on the target interface document data, and generate the interface configuration file corresponding to the interface test cases.
[0061] The process of generating interface test cases and interface configuration files by analyzing target interface document data involves identifying the target interface document data, obtaining the data required to generate interface test cases and the data required to generate interface configuration files, and then generating interface test cases and interface configuration files based on the data required to generate interface test cases and interface configuration files, respectively.
[0062] Optionally, when the initial interface documentation data is updated and interface test cases are generated again, you can choose to overwrite or skip the already generated interface test cases.
[0063] Step 130: Execute the interface test cases according to the interface configuration file to obtain the interface test results.
[0064] The interface test cases are executed by driving the interface configuration file. That is, the input data is read from the interface configuration file and the data is input into the interface test cases as parameters for interface testing. The interface configuration file and the interface test cases are independent of each other.
[0065] Different execution methods for interface test cases can be achieved by adding expressions to the interface configuration file. For example, adding a variable substitution expression to the interface configuration file can replace variables in the interface test cases, improving variable substitution efficiency. For instance, if the variable is a user ID, and the user ID in the test case is ID1, and it needs to be changed to ID2, a change expression can be added to the interface configuration file. This will automatically replace the user ID in the interface test case with ID2 when the interface test case is executed based on the interface configuration file. It should be noted that if there are situations where variable substitution cannot be performed on the interface test case based on the interface configuration file, the code in the interface test case can be directly modified to achieve the purpose of variable substitution.
[0066] After obtaining the interface test results, an interface test report can be generated based on the test process. This allows for the subsequent acquisition of relevant data from the test process for further processing.
[0067] In this embodiment, optionally, the step of executing the interface test cases according to the interface configuration file driver includes:
[0068] In response to the debugging operation of the interface test case, the interface test case is executed according to the interface configuration file.
[0069] Obtain the execution data of the interface test cases, and update the interface configuration file based on the execution data;
[0070] The updated interface configuration file drives the execution of the interface test cases.
[0071] Among them, the response to the debugging operation of the interface test cases can be the operation of getting the interface working, that is, executing the interface test cases according to the generated initial interface configuration file, and filling in the correct parameters during the execution process to make the interface test cases run successfully.
[0072] Obtaining execution data for interface test cases can involve obtaining the return data after the interface is successfully executed. The return data can include data automatically generated during the execution of interface test cases, such as assertion expressions.
[0073] Add a portion of the returned data, such as the generated detailed assertion expressions, to the interface configuration file, replacing the original simpler initial data in the interface configuration file with more complex data to update the interface configuration file.
[0074] Based on the updated interface configuration file, the interface test cases are executed according to the test requirements to obtain the corresponding interface test results.
[0075] The advantage of this setup is that by updating the interface configuration file with updated data, the content of the relatively simple interface configuration file, which is directly generated from the target interface document data, is enriched. This makes it easier to obtain more accurate interface test results when executing interface test cases based on the updated interface configuration file, thereby improving the accuracy of interface testing.
[0076] The technical solution provided in this embodiment automatically generates a full set of interface test cases based on the initial interface documentation data, avoiding omissions that may occur when manually writing interface test cases based on the documentation data, thus improving the efficiency and comprehensiveness of interface test case generation. It also automatically generates corresponding interface configuration files for all interface test cases based on the initial interface documentation data, improving the relevance between the interface configuration files and the interface test cases, thereby enhancing the effectiveness and efficiency of interface configuration file generation. Furthermore, by automatically generating interface test cases and interface configuration files based on the initial interface documentation data, the system can promptly update the interface test cases and interface configuration files when the initial interface documentation data changes, improving update efficiency.
[0077] By driving the execution of interface test cases through interface configuration files, test case execution can be driven by managing interface configuration files, eliminating the need to frequently modify the code in interface test cases during testing, thereby improving the usability of interface test cases and the efficiency of interface testing.
[0078] Example 2
[0079] Figure 2 This is a flowchart of the first interface testing method provided in Embodiment 2 of the present invention. Based on the above embodiments, this embodiment further specifies the process of executing interface test cases driven by the interface configuration file. For example... Figure 2 As shown, the method includes:
[0080] Step 210: Obtain initial interface document data and determine target interface document data based on the initial interface document data.
[0081] Step 220: Generate interface test cases based on the target interface document data, and generate the interface configuration file corresponding to the interface test cases.
[0082] Step 230: Call the target code related to the first expression in the interface test case through the first expression in the interface configuration file; wherein, the first expression includes a calling expression.
[0083] The calling expression is located in the interface configuration file and is used to call the target code in the interface test case. The target code is the code related to the calling expression. For example, if the calling expression is an expression that calls the code of the mobile phone number generation method, then the target code called is the code about mobile phone number generation in the interface test case. The code about mobile phone number generation in the interface test case can be added in advance to a specified location in the interface test case.
[0084] Step 240: Generate at least one first test data for the interface test case based on the target code, and execute the interface test case based on the first test data to obtain the interface test result.
[0085] At least one first test data point for generating interface test cases based on the target code can be generated. This can be at least one test variable data point required for generating interface test cases based on the called target code. For example, if the target code is code related to generating mobile phone numbers, then generating at least one first test data point for interface test cases based on the target code can generate ten mobile phone numbers.
[0086] In actual interface testing, the interface test cases are executed based on the generated first test data.
[0087] The advantages of this setup are: by calling the target code in the interface test case through the first expression to generate the first test data, there is no need to configure a large amount of repetitive or similar test data in the interface configuration file, which improves the flexibility of the interface configuration file to drive the execution of interface test cases; and the amount of data in the interface configuration file is reduced, thereby improving the simplicity of the interface configuration file.
[0088] Figure 3 This is a flowchart of the second interface testing method provided in Embodiment 2 of the present invention. Based on the above embodiments, this embodiment further specifies the process of executing interface test cases driven by the interface configuration file to obtain interface test results. For example... Figure 3 As shown, the method includes:
[0089] Step 310: Obtain initial interface document data and determine target interface document data based on the initial interface document data.
[0090] Step 320: Generate interface test cases based on the target interface document data, and generate the interface configuration file corresponding to the interface test cases.
[0091] Step 330: Generate at least two second test data for the interface test case using the second expression in the interface configuration file, and execute the interface test case based on the second test data to obtain the interface test result; wherein, the second expression includes a conditional expression.
[0092] The conditional expression is located in the interface configuration file and is used to generate multiple test data by combining multiple conditions based on the condition content in a single expression. For example, if the conditional expression is [['name',in',['tom','joe']],['age','in',[7,8]]], then four test data can be generated based on this conditional expression: name:tom age7, name:tom age8, name:joe age7, name:joe age8.
[0093] In the actual interface testing process, the interface test cases are executed based on the generated second test data.
[0094] The advantage of this setup is that it generates multiple second test data using a single second expression, eliminating the need to fully display all the test data in the interface configuration file, thus reducing the amount of data in the interface configuration file and improving its simplicity.
[0095] Figure 4 This is a flowchart of the third interface testing method provided in Embodiment 2 of the present invention. Based on the above embodiments, this embodiment further specifies the process of executing interface test cases driven by the interface configuration file to obtain interface test results. For example... Figure 4 As shown, the method includes:
[0096] Step 410: Obtain initial interface document data and determine target interface document data based on the initial interface document data.
[0097] Step 420: Generate interface test cases based on the target interface document data, and generate the interface configuration file corresponding to the interface test cases.
[0098] Step 430: Configure the assertion parameters of the interface test cases through the third expression in the interface configuration file, and drive the execution of the interface test cases according to the assertion parameters to obtain the interface test results; wherein, the third expression includes assertion expressions.
[0099] Assertion expressions, located in the interface configuration file, are used to configure the assertion parameters used in interface test cases and support all assertions included in the assertpy library. By changing the assertion expressions and corresponding assertion parameters, the interface test cases are executed based on the determined assertion parameters during actual interface testing.
[0100] The advantage of this setup is that it allows configuration of assertion parameters for interface test cases via a third expression, avoiding the problem in existing technologies where assertion parameters are only configured in the interface test case code. This necessitates code modifications when assertion parameters change, reducing efficiency. It also improves the flexibility of assertion data modification.
[0101] Example 3
[0102] Figure 5 This is a flowchart of an interface testing method provided in Embodiment 3 of the present invention. This embodiment further specifies the interface testing process based on the above embodiments. For example... Figure 5 As shown, the method includes:
[0103] Step 510: Obtain initial interface document data.
[0104] Step 520: Determine the target interface document data based on the initial interface document data.
[0105] Step 530: Generate interface test cases based on the target interface document data.
[0106] Step 540: Generate the interface configuration file corresponding to the interface test case based on the target interface document data.
[0107] Step 550: Execute the interface test cases according to the interface configuration file to obtain the interface test results.
[0108] Step 560: Obtain the interface library by performing a data encapsulation operation on the target interface document data.
[0109] The data encapsulation operation for the target interface document data can be performed after the target interface document data is determined. This can involve obtaining interface data related to the interface from the target interface document data and encapsulating this interface data. The interface data can be all interface data or interface data associated with the interface test cases; this embodiment does not impose any restrictions. The encapsulated interfaces are then stored to obtain an interface library.
[0110] Optionally, when the initial interface documentation data is updated and the interface is re-encapsulated, you can choose to overwrite or skip the already encapsulated interface.
[0111] Step 570: Based on the interface call request issued during the execution of the interface test case, call the target interface from the interface library.
[0112] If an interface call request is issued during the execution of an interface test case, the target interface associated with the interface call request is called from the interface library according to the interface call request, so that the interface test case is executed according to the interface configuration file based on the called target interface, and the interface test result is obtained.
[0113] In this embodiment, optionally, after calling the target interface from the interface library, the method further includes:
[0114] Obtain the call data of the target interface;
[0115] The call status of the target interface is determined based on the call data;
[0116] The return data of the target interface is determined based on the call status.
[0117] The call data for the target interface can include the call result, which is the data obtained when calling the target interface, such as string data. The call data can also include a call code, which indicates the call status, such as whether the call was successful or failed.
[0118] Determining the call status of a target interface based on the call data can be done by using the call code. For example, if the call code is A, the call status is determined to be a call failure.
[0119] The return data of the target interface is the data actually returned to the caller after the target interface is called; the return data of the target interface is determined according to the call status. For example, if the call status is successful, the call result is used as the interface return data; if the call status is failed, only the call status is returned, and the call result is not returned.
[0120] The advantage of this setup is that by determining the return data of the target interface based on the call status, it avoids returning all call data, thereby avoiding the need for manual verification of the validity of the returned data, which would reduce the efficiency of interface testing and improve the validity of the returned data.
[0121] This invention automatically encapsulates the interface uniformly by performing data encapsulation operations on the target interface document data, avoiding omissions in interface generation; and when the target interface document data changes, the interface can be updated in a timely manner, improving update efficiency.
[0122] This also allows the interface to be called directly by issuing an interface call request when the interface test case needs to be executed, without the need to temporarily generate the corresponding interface, thus improving the efficiency of interface calls; and avoids the repeated encapsulation of the same interface due to temporary encapsulation each time it is called, thus improving the effectiveness of interface encapsulation.
[0123] Example 4
[0124] Figure 6 This is a schematic diagram of an interface testing device provided in Embodiment 4 of the present invention. This device can be implemented in hardware and / or software, and can execute an interface testing method provided in any embodiment of the present invention, possessing the corresponding functional modules and beneficial effects of the method execution. Figure 6 As shown, the device includes:
[0125] The document data determination module 610 is used to acquire initial interface document data and determine target interface document data based on the initial interface document data.
[0126] The test case file generation module 620 is used to generate interface test cases based on the target interface document data, and to generate interface configuration files corresponding to the interface test cases.
[0127] The test case execution module 630 is used to execute the interface test cases according to the interface configuration file and obtain the interface test results.
[0128] Based on the above technical solutions, optionally, the test case execution module includes:
[0129] The target code invocation unit is used to invoke the target code related to the first expression in the interface test case through the first expression in the interface configuration file; wherein, the first expression includes a invocation expression;
[0130] The first test case execution unit is used to generate at least one first test data for the interface test case based on the target code, and drive the execution of the interface test case based on the first test data.
[0131] Based on the above technical solutions, optionally, the test case execution module includes:
[0132] The second test case execution unit is used to generate at least two second test data for the interface test case through the second expression in the interface configuration file, and drive the execution of the interface test case according to the second test data; wherein, the second expression includes a conditional expression.
[0133] Based on the above technical solutions, optionally, the test case execution module includes:
[0134] The third test case execution unit is used to configure the assertion parameters of the interface test cases through the third expression of the interface configuration file, and drive the execution of the interface test cases according to the assertion parameters; wherein, the third expression includes an assertion expression.
[0135] Based on the above technical solutions, optionally, the test case execution module includes:
[0136] The fourth test case execution unit is used to execute the interface test cases according to the interface configuration file in response to the debugging operation of the interface test cases;
[0137] The configuration file update unit is used to obtain the execution data of the interface test cases and update the interface configuration file according to the execution data;
[0138] The fifth test case execution unit is used to execute the interface test cases according to the updated interface configuration file.
[0139] Based on the above technical solutions, optionally, the device further includes:
[0140] The data encapsulation module is used to obtain the interface library by performing data encapsulation operations on the target interface document data;
[0141] The target interface invocation module is used to invoke the target interface from the interface library based on the interface invocation request issued during the execution of the interface test case.
[0142] Based on the above technical solutions, optionally, the device further includes:
[0143] The data acquisition module is invoked to acquire the call data of the target interface after the target interface call module is invoked.
[0144] The call status determination module is used to determine the call status of the target interface based on the call data;
[0145] The return data determination module is used to determine the return data of the target interface based on the call status.
[0146] Example 5
[0147] Figure 7A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0148] like Figure 7 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0149] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0150] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as interface testing methods.
[0151] In some embodiments, the interface testing method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the interface testing method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the interface testing method by any other suitable means (e.g., by means of firmware).
[0152] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0153] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0154] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0155] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0156] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0157] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0158] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0159] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. An interface testing method, characterized in that, include: Obtain initial interface document data, and determine target interface document data based on the initial interface document data; wherein, the initial interface document data is the full or most recently updated original interface document data obtained by sending a data acquisition request to the initial interface document; Based on the target interface document data, generate interface test cases and corresponding interface configuration files for the interface test cases; The interface test cases are executed according to the interface configuration file, and the interface test results are obtained. The step of executing the interface test cases according to the interface configuration file includes: In response to the debugging operation of the interface test case, the interface test case is executed according to the interface configuration file. Obtain the execution data of the interface test cases, and update the interface configuration file based on the execution data; The updated interface configuration file drives the execution of the interface test cases.
2. The method according to claim 1, characterized in that, The step of executing the interface test cases according to the interface configuration file includes: The first expression in the interface configuration file is used to call the target code in the interface test case that is related to the first expression; wherein, the first expression includes a calling expression; At least one first test data point is generated for the interface test case based on the target code, and the interface test case is executed based on the first test data.
3. The method according to claim 1, characterized in that, The step of executing the interface test cases according to the interface configuration file includes: The interface test case is generated by generating at least two second test data using the second expression in the interface configuration file, and the interface test case is executed based on the second test data; wherein the second expression includes a conditional expression.
4. The method according to claim 1, characterized in that, The step of executing the interface test cases according to the interface configuration file includes: The assertion parameters of the interface test cases are configured through the third expression in the interface configuration file, and the interface test cases are executed according to the assertion parameters; wherein, the third expression includes assertion expressions.
5. The method according to any one of claims 1-4, characterized in that, The method further includes: An interface library is obtained by performing data encapsulation operations on the target interface document data; Based on the interface call request issued during the execution of the interface test case, the target interface is called from the interface library.
6. The method according to claim 5, characterized in that, After calling the target interface from the interface library, the method further includes: Obtain the call data of the target interface; The call status of the target interface is determined based on the call data; The return data of the target interface is determined based on the call status.
7. An interface testing device, characterized in that, include: The document data determination module is used to acquire initial interface document data and determine target interface document data based on the initial interface document data; wherein, the initial interface document data is the full or most recently updated original interface document data obtained by sending a data acquisition request to the initial interface document. The test case file generation module is used to generate interface test cases based on the target interface document data, and to generate the interface configuration file corresponding to the interface test cases; The test case execution module is used to execute the interface test cases according to the interface configuration file and obtain the interface test results. The test case execution module includes: The fourth test case execution unit is used to execute the interface test cases according to the interface configuration file in response to the debugging operation of the interface test cases; The configuration file update unit is used to obtain the execution data of the interface test cases and update the interface configuration file according to the execution data; The fifth test case execution unit is used to execute the interface test cases according to the updated interface configuration file.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the interface testing method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the interface testing method according to any one of claims 1-6.
Citation Information
Patent Citations
Method, device and system for interface testing
CN110990269A
Method and system for quickly and automatically testing based on swagger
CN111930635A