CN109739700B - Interface testing method and device - Google Patents

Interface testing method and device Download PDF

Info

Publication number
CN109739700B
CN109739700B CN201811519800.9A CN201811519800A CN109739700B CN 109739700 B CN109739700 B CN 109739700B CN 201811519800 A CN201811519800 A CN 201811519800A CN 109739700 B CN109739700 B CN 109739700B
Authority
CN
China
Prior art keywords
interface
ith
test
response data
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811519800.9A
Other languages
Chinese (zh)
Other versions
CN109739700A (en
Inventor
王炳伟
张文佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Unicompay Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Unicompay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd, Unicompay Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN201811519800.9A priority Critical patent/CN109739700B/en
Publication of CN109739700A publication Critical patent/CN109739700A/en
Application granted granted Critical
Publication of CN109739700B publication Critical patent/CN109739700B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Test And Diagnosis Of Digital Computers (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses an interface test method and device, relates to the technical field of computer communication, and is applied to an interface test system, wherein the interface test system comprises n interfaces, n is not less than 1, services are transmitted through the interfaces sequentially, and the nth interface is an interface to be tested, the method comprises the following steps: s101, inputting ith test data into an ith interface to obtain ith response data of the ith interface; wherein i is a natural number; the initial value of i is 1, and the ith test data comprises ith interface parameters and values, interface return check values, interface protocols and calling methods; s102, if i is not equal to n, converting the ith response data into ith +1 test data, i = i +1, and re-executing the step S101; s103, if i is equal to n, the ith response data is nth response data, and whether the nth response data is consistent with the return check value of the interface to be tested is compared; and S104, determining a test result according to the comparison result.

Description

一种接口测试方法和装置Method and device for interface testing

技术领域technical field

本申请涉及计算机通信技术领域,尤其涉及一种接口测试方法和装置。The present application relates to the technical field of computer communication, in particular to an interface testing method and device.

背景技术Background technique

随着互联网技术的发展,各种协议的接口被广泛应用,由于每个接口传输的数据不同,处理的逻辑不同,且在不同场景下,数据传输的过程及接口的调用关系也不同,因此想要保证接口之间传输数据的稳定性,有效地对接口进行测试就变得至关重要。With the development of Internet technology, interfaces of various protocols are widely used. Since the data transmitted by each interface is different, the logic of processing is different, and in different scenarios, the process of data transmission and the calling relationship of the interface are also different. Therefore, I want to To ensure the stability of data transmission between interfaces, it is very important to test the interfaces effectively.

目前现有技术是通过虚拟测试(mock-test)的方式,在需要数据时,对单接口进行测试,并通过mock返回,无法实现具有业务关系的接口串联测试,接口间依赖数据不能实时传递,以至于无法验证真实的业务场景。At present, the existing technology uses a virtual test (mock-test) method. When data is needed, a single interface is tested and returned through the mock. It is impossible to implement serial testing of interfaces with business relationships, and the dependent data between interfaces cannot be transmitted in real time. So that it is impossible to verify the real business scenario.

发明内容Contents of the invention

本申请的实施例提供一种接口测试方法和装置,用于解决现有技术中有业务关联的接口无法串联测试的技术问题。Embodiments of the present application provide an interface testing method and device, which are used to solve the technical problem in the prior art that interfaces with service associations cannot be tested in series.

为达到解决上述技术问题的目的,本申请的实施例采用如下技术方案:In order to achieve the purpose of solving the above-mentioned technical problems, the embodiments of the present application adopt the following technical solutions:

第一方面,本申请的实施例提供了一种接口测试方法,应用于接口测试系统中,所述接口测试系统包括n个接口,n不小于1,业务依次通过各个接口传输,且第n个接口为待测接口,该方法包括:In the first aspect, the embodiment of the present application provides an interface testing method, which is applied in an interface testing system. The interface testing system includes n interfaces, where n is not less than 1, and services are transmitted through each interface in turn, and the nth The interface is the interface to be tested, and the method includes:

S101、将第i测试数据输入第i接口以获取所述第i接口的第i响应数据;其中,所述i为自然数;所述i的初始取值为1,第1测试数据为预定义测试数据,第i测试数据包括第i接口的参数及取值、接口的协议、调用方法以及返回校验值。S101. Input the i-th test data into the i-th interface to obtain the i-th response data of the i-th interface; wherein, the i is a natural number; the initial value of the i is 1, and the first test data is a predefined test Data, the i-th test data includes the parameters and values of the i-th interface, the protocol of the interface, the calling method and the return verification value.

S102、若i不等于n,则将所述第i响应数据转换为第i+1测试数据,i=i+1,重新执行步骤S101。S102. If i is not equal to n, convert the i-th response data into i+1-th test data, i=i+1, and re-execute step S101.

S103、若i等于n,则第i响应数据为第n响应数据,比较所述第n响应数据与所述待测接口的返回校验值是否一致。S103. If i is equal to n, then the i-th response data is the n-th response data, and compare whether the n-th response data is consistent with the check value returned by the interface to be tested.

S104、根据比较结果确定测试结果。S104. Determine the test result according to the comparison result.

第二方面,本申请的实施例提供了一种接口测试装置,应用于接口测试系统中,所述接口测试系统包括n个接口,n不小于1,业务依次通过各个接口传输,且第n个接口为待测接口,该装置包括:In the second aspect, the embodiment of the present application provides an interface testing device, which is applied in an interface testing system. The interface testing system includes n interfaces, where n is not less than 1, and services are transmitted through each interface in turn, and the nth The interface is the interface to be tested, and the device includes:

获取单元,用于将第i测试数据输入第i接口以获取所述第i接口的第i响应数据;其中,所述i为自然数;所述i的初始取值为1,第1测试数据为预定义测试数据,第i测试数据包括第i接口的参数及取值、接口的协议、调用方法以及返回校验值。An acquisition unit, configured to input the i-th test data into the i-th interface to obtain the i-th response data of the i-th interface; wherein, the i is a natural number; the initial value of the i is 1, and the first test data is The test data is predefined, and the i-th test data includes the parameters and values of the i-th interface, the protocol of the interface, the calling method, and the return verification value.

转换单元,用于若i不等于n,则将所述第i响应数据转换为第i+1测试数据,i=i+1,重新执行获取单元。A conversion unit, configured to convert the i-th response data into the i+1-th test data if i is not equal to n, where i=i+1, and re-execute the acquisition unit.

比较单元,用于若i等于n,则第i响应数据为第n响应数据,比较所述第n响应数据与所述待测接口的返回校验值是否一致。The comparison unit is configured to, if i is equal to n, then the i-th response data is the n-th response data, and compare whether the n-th response data is consistent with the check value returned by the interface to be tested.

确定单元,用于根据比较结果确定测试结果。The determining unit is used for determining the test result according to the comparison result.

第三方面,提供了一种存储一个或多个程序的计算机可读存储介质,所述一个或多个程序包括指令,所述指令当被计算机执行时使所述计算机执行如第一方面所述的接口测试方法。In a third aspect, there is provided a computer-readable storage medium that stores one or more programs, the one or more programs include instructions, and when the instructions are executed by a computer, the computer executes the computer-readable storage medium described in the first aspect. The interface test method.

第四方面,提供了一种包含指令的计算机程序产品,当所述指令在计算机上运行时,使得计算机执行如第一方面所述的接口测试方法。In a fourth aspect, a computer program product containing instructions is provided, and when the instructions are run on a computer, the computer is made to execute the interface testing method as described in the first aspect.

第五方面,提供一种接口测试装置,包括:处理器、存储器和通信接口,通信接口用于所述接口测试装置和其他设备或网络通信,存储器用于存储程序,处理器调用存储器存储的程序,以执行上述第一方面所述的接口测试方法。In a fifth aspect, an interface testing device is provided, including: a processor, a memory, and a communication interface, the communication interface is used for the interface testing device to communicate with other equipment or a network, the memory is used to store programs, and the processor calls the programs stored in the memory , to execute the interface testing method described in the first aspect above.

本申请的实施例提供一种接口测试方法,由于第1测试数据为预定义测试数据,数据内容可根据需要进行扩展,因此通过设计测试数据,提高了接口测试过程的可控性,接口测试的执行方式包括单接口和多接口两种,系统可根据第1测试数据自动识别执行方式,且多接口测试的执行方式涵盖了一系列与待测接口具有业务关联的接口测试,通过数据的传递及调用,执行处理逻辑,使待测接口的测试结果更加接近真实业务场景的使用方式,测试结果更加可靠。Embodiments of the present application provide a method for interface testing. Since the first test data is predefined test data, the data content can be expanded as required. Therefore, by designing the test data, the controllability of the interface test process is improved, and the interface test Execution methods include single interface and multi-interface. The system can automatically identify the execution method according to the first test data, and the execution method of multi-interface test covers a series of interface tests related to the interface to be tested. Through data transmission and Call and execute the processing logic, so that the test results of the interface to be tested are closer to the usage of real business scenarios, and the test results are more reliable.

附图说明Description of drawings

图1为本申请的实施例提供的一种接口测试方法的流程示意图;Fig. 1 is a schematic flow chart of an interface testing method provided by an embodiment of the present application;

图2为本申请的实施例提供的一种接口测试装置示意图一;Fig. 2 is a schematic diagram 1 of an interface testing device provided by an embodiment of the present application;

图3为本申请的实施例提供的一种接口测试装置示意图二。FIG. 3 is a second schematic diagram of an interface testing device provided by an embodiment of the present application.

具体实施方式Detailed ways

下面结合附图,对本申请的实施例进行描述。Embodiments of the present application are described below in conjunction with the accompanying drawings.

本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。The term "and/or" in this article is just an association relationship describing associated objects, which means that there can be three relationships, for example, A and/or B can mean: A exists alone, A and B exist simultaneously, and there exists alone B these three situations.

此外,本申请的描述中所提到的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括其他没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。In addition, the terms "including" and "having" mentioned in the description of the present application and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes other unlisted steps or units, or optionally also includes Other steps or elements inherent to the process, method, product or apparatus are included.

需要说明的是,本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。It should be noted that, in the embodiments of the present application, words such as "exemplary" or "for example" are used as examples, illustrations or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of the present application shall not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete manner.

在本申请的描述中,除非另有说明,“多个”的含义是指两个或两个以上In the description of this application, unless otherwise stated, the meaning of "plurality" refers to two or more

本申请的实施例提供一种接口测试方法和装置,该方法应用于接口测试系统中,所述接口测试系统包括n个接口,n不小于1,业务依次通过各个接口传输,n个接口之间具有业务关联,上个接口的响应数据可转化为下个接口的输入参数,所述n个接口中包括待测接口,在本实施例中,该待测接口为第n个接口。Embodiments of the present application provide a method and device for interface testing. The method is applied in an interface testing system. The interface testing system includes n interfaces, where n is not less than 1. Services are transmitted through each interface in turn. With business association, the response data of the previous interface can be converted into the input parameters of the next interface, and the n interfaces include the interface to be tested. In this embodiment, the interface to be tested is the nth interface.

参考图1所示,本申请的实施例提供了一种接口测试方法,该方法包括步骤S101-S104:Referring to Fig. 1, the embodiment of the present application provides an interface testing method, the method includes steps S101-S104:

S101、将第i测试数据输入第i接口以获取所述第i接口的第i响应数据。S101. Input the i-th test data into the i-th interface to obtain the i-th response data of the i-th interface.

该接口测试系统中,包括用户交互界面,该用户交互界面用于与用户进行交互,系统根据交互内容创建新的接口测试线程以及配置接口的测试数据,将第i测试数据输入第i接口,其中,所述i为自然数,i的初始取值为1,且第1测试数据为预定义测试数据,可以根据接口中参数的取值范围、类型、长度等特征,按照等价类或边界类的设计方式,将该第1测试数据设计成不同的测试数据,对于其它需要信息,如描述说明等,随时扩展加入到测试数据中。The interface testing system includes a user interaction interface, which is used to interact with the user, the system creates a new interface test thread and configures the test data of the interface according to the interaction content, and inputs the i-th test data into the i-th interface, wherein , the i is a natural number, the initial value of i is 1, and the first test data is predefined test data, which can be based on the value range, type, length and other characteristics of the parameters in the interface, according to the equivalence class or boundary class In the design mode, the first test data is designed as different test data, and other required information, such as descriptions, etc., are expanded and added to the test data at any time.

系统预置所有接口类型的接口测试模块,将预定义测试数据即第1测试数据输入第1接口后,系统会根据该第1接口的第1测试数据识别第1接口的接口类型,通过该接口类型来调用预设的接口测试模块,有效的提高接口测试的效率以及覆盖范围,接口测试模块的数据可被重复动态的使用,无需每次测试都重新设计用例。最后通过执行调用的该接口测试模块输出第1响应数据。当i取其他值时,第i测试数据包括第i接口的参数及取值、接口的协议、调用方法以及返回校验值等必要内容,也通过同样的方式调用接口测试模块并输出第i响应数据,在此不再赘述。The system presets interface test modules for all interface types. After inputting the predefined test data, namely the first test data, into the first interface, the system will identify the interface type of the first interface according to the first test data of the first interface. Type to call the preset interface test module, which effectively improves the efficiency and coverage of the interface test. The data of the interface test module can be used repeatedly and dynamically, without redesigning the use case for each test. Finally, the first response data is output by the calling interface testing module. When i takes other values, the i-th test data includes necessary content such as the parameters and values of the i-th interface, the protocol of the interface, the calling method, and the return check value, etc., and the interface test module is called in the same way and the i-th response is output data and will not be repeated here.

S102、若i不等于n,则将所述第i响应数据转换为第i+1测试数据,i=i+1,重新执行步骤S101。S102. If i is not equal to n, convert the i-th response data into i+1-th test data, i=i+1, and re-execute step S101.

通过步骤S101得到了第i接口的第i响应数据后,判断i的值是否等于n,n为本测试线程中的接口数量,若i不等于n,说明线程还未运行到第n接口,即待测接口,需将该第i响应数据做参数化处理。参数化处理的过程就是将第i响应数据通过数据转化层转化为下个接口的测试数据,从而驱动该下个接口继续执行线程,参数化处理的方法包括提取目标参数和/或将响应数据与预定义测试数据结合,从而得到第i+1测试数据,例如获取到第1接口的第1响应数据后,同时将第1测试数据中包含的第2接口的接口协议、调用方法以及返回校验值提取出来,共同组成第2接口的第2测试数据,或者直接提取第1响应数据中包含的目标参数值。系统通过该第i+1测试数据构造新的接口请求,此时i的取值加1,i=i+1,然后重新执行步骤S101。以此方式从业务顶端,串联执行每个接口,依次将生成的响应数据传递给下个接口,直至执行完待测接口。After obtaining the i-th response data of the i-th interface through step S101, judge whether the value of i is equal to n, and n is the number of interfaces in the test thread. If i is not equal to n, it means that the thread has not run to the n-th interface, that is For the interface to be tested, the i-th response data needs to be parameterized. The process of parameterized processing is to convert the i-th response data into the test data of the next interface through the data conversion layer, so as to drive the next interface to continue executing the thread. The method of parameterized processing includes extracting target parameters and/or combining the response data with Combine the predefined test data to obtain the i+1th test data. For example, after obtaining the first response data of the first interface, at the same time, the interface protocol, calling method and return verification of the second interface contained in the first test data Values are extracted to form the second test data of the second interface together, or directly extract the target parameter value contained in the first response data. The system constructs a new interface request based on the i+1th test data, at this time, the value of i is increased by 1, i=i+1, and then re-executes step S101. In this way, from the top of the business, execute each interface in series, and pass the generated response data to the next interface in turn until the interface to be tested is executed.

可选的,在比较i与n的值之前,先比较该第i响应数据与预定义的第i接口的返回校验值是否一致,若不一致,则说明该第i接口存在问题,需先修复该第i接口后,再执行测试流程;若一致,则可以进一步判断i的值是否等于n。以此方式逐个排查线程中的接口性能。避免中间接口性能不佳导致的测试结果的误差。Optionally, before comparing the values of i and n, first compare whether the i-th response data is consistent with the return verification value of the predefined i-th interface. If they are inconsistent, it means that there is a problem with the i-th interface and needs to be repaired first After the i-th interface, the test process is executed; if they are consistent, it can be further judged whether the value of i is equal to n. In this way, check the performance of interfaces in threads one by one. Avoid errors in test results caused by poor performance of intermediate interfaces.

S103、若i等于n,则第i响应数据为第n响应数据,比较所述第n响应数据与所述待测接口的返回校验值是否一致;S103. If i is equal to n, then the i-th response data is the n-th response data, and compare whether the n-th response data is consistent with the returned verification value of the interface to be tested;

若i的值等于n,则第i响应数据为第n响应数据,该第i接口即待测接口,直接比较该第n响应数据与待测接口的返回校验值是否一致,从而得出比较结果。例如:接口描述为判断接口的输入参数是正值、零还是负值,预置url地址和调用方法,当data1的输入参数为1、0或-2时,返回校验值分别为res100、res200和res300,本用例为单接口的执行方式,用例设计的参考代码如下,If the value of i is equal to n, then the i-th response data is the n-th response data, and the i-th interface is the interface to be tested. Directly compare whether the n-th response data is consistent with the returned verification value of the interface to be tested, and then compare result. For example: the interface description is to judge whether the input parameter of the interface is a positive value, zero or negative value, and preset the url address and calling method. When the input parameter of data1 is 1, 0 or -2, the returned verification value is res100 and res200 respectively and res300, this use case is the execution mode of single interface, the reference code of the use case design is as follows,

Figure BDA0001902930020000051
Figure BDA0001902930020000051

Figure BDA0001902930020000061
Figure BDA0001902930020000061

S104、根据比较结果确定测试结果。S104. Determine the test result according to the comparison result.

若比较结果为第n响应数据与待测接口的返回校验值一致,说明待测接口性能良好,通过存在业务关联的多接口线程测试,使待测接口的测试结果更加接近真实业务场景的使用方式,测试结果更加可靠。例如在网上平台进行购物时,通常包括登录接口、商品浏览接口、下单接口、付款接口等,通过登录相应的购物APP,输入欲购买的商品品类,然后根据选择的具体商品驱动下单接口,下单接口响应后继续驱动付款接口,通过模拟上述场景,对接口进行串联测试得到测试结果。If the comparison result shows that the nth response data is consistent with the returned verification value of the interface to be tested, it means that the interface to be tested has good performance. Through the multi-interface thread test with business associations, the test results of the interface to be tested are closer to the use of real business scenarios. way, the test results are more reliable. For example, when shopping on an online platform, it usually includes a login interface, a product browsing interface, an order interface, a payment interface, etc., by logging into the corresponding shopping APP, inputting the product category to be purchased, and then driving the order interface according to the selected specific product. After the order interface responds, continue to drive the payment interface. By simulating the above scenario, the interface is serially tested to obtain the test results.

本申请的实施例提供一种接口测试方法,由于第1测试数据为预定义测试数据,数据内容可根据需要进行扩展,因此通过设计测试数据,提高了接口测试过程的可控性,接口测试的执行方式包括单接口和多接口两种,系统可根据第1测试数据自动识别执行方式,且多接口测试的执行方式涵盖了一系列与待测接口具有业务关联的接口测试,通过数据的传递及调用,执行处理逻辑,使待测接口的测试结果更加接近真实业务场景的使用方式,测试结果更加可靠。Embodiments of the present application provide a method for interface testing. Since the first test data is predefined test data, the data content can be expanded as required. Therefore, by designing the test data, the controllability of the interface test process is improved, and the interface test Execution methods include single interface and multi-interface. The system can automatically identify the execution method according to the first test data, and the execution method of multi-interface test covers a series of interface tests related to the interface to be tested. Through data transmission and Call and execute the processing logic, so that the test results of the interface to be tested are closer to the usage of real business scenarios, and the test results are more reliable.

本申请实施例可以根据上述方法示例对系统进行功能模块或者功能单元的划分,例如,可以对应各个功能划分各个功能模块或者功能单元,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块或者功能单元的形式实现。其中,本申请实施例中对模块或者单元的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiments of the present application can divide the system into functional modules or functional units according to the above method example, for example, each functional module or functional unit can be divided corresponding to each function, or two or more functions can be integrated into one processing module middle. The above-mentioned integrated modules can be implemented in the form of hardware, or in the form of software function modules or functional units. Wherein, the division of modules or units in the embodiment of the present application is schematic, and is only a logical function division, and there may be another division manner in actual implementation.

参照图2中所示,本申请实施例提供了一种接口测试装置,可以应用于如上所示的接口测试方法。该接口测试装置100包括:Referring to FIG. 2 , an embodiment of the present application provides an interface testing device, which can be applied to the interface testing method shown above. The interface testing device 100 includes:

获取单元101,用于将第i测试数据输入第i接口以获取所述第i接口的第i响应数据;其中,所述i为自然数;所述i的初始取值为1,第1测试数据为预定义测试数据,第i测试数据包括第i接口的参数及取值、所有接口的协议、调用方法以及返回校验值;The obtaining unit 101 is configured to input the i-th test data into the i-th interface to obtain the i-th response data of the i-th interface; wherein, the i is a natural number; the initial value of the i is 1, and the first test data For pre-defined test data, the i-th test data includes the parameters and values of the i-th interface, the protocol of all interfaces, the calling method and the return verification value;

转换单元102,用于若i不等于n,则将所述第i响应数据转换为第i+1测试数据,i=i+1,重新执行获取单元;The conversion unit 102 is used to convert the i-th response data into the i+1-th test data if i is not equal to n, i=i+1, and re-execute the acquisition unit;

比较单元103,用于若i等于n,则比较所述第n响应数据与所述待测接口的返回校验值是否一致;A comparison unit 103, configured to compare whether the nth response data is consistent with the returned check value of the interface to be tested if i is equal to n;

确定单元104,用于根据比较结果确定测试结果。A determining unit 104, configured to determine the test result according to the comparison result.

可选的,所述获取单元具体用于:Optionally, the acquisition unit is specifically used for:

根据第i测试数据识别所述第i接口的接口类型;identifying the interface type of the i-th interface according to the i-th test data;

调用与所述接口类型对应的预设接口测试模块;calling a preset interface test module corresponding to the interface type;

执行调用的所述预设接口测试模块并输出第i响应数据。Execute the invoked preset interface test module and output the i-th response data.

可选的,所述比较单元还用于:Optionally, the comparing unit is also used for:

比较所述第i响应数据与预定义的第i接口的返回校验值是否一致;Comparing whether the i-th response data is consistent with the return check value of the predefined i-th interface;

若是,则将所述第i响应数据做参数化处理以转换为第i+1测试数据,所述参数化处理的方法包括提取目标参数和/或将响应数据与预定义测试数据结合。If so, perform parameterization processing on the i-th response data to convert it into i+1-th test data, the method of the parameterization processing includes extracting target parameters and/or combining response data with predefined test data.

图3示出了上述实施例中所涉及接口测试装置的又一种可能的结构示意图。该装置包括:处理器202和通信接口203。处理器202用于对装置的动作进行控制管理,例如,执行上述获取单元101、转换单元102、比较单元103以及确定单元105执行的步骤,和/或用于执行本文所描述的技术的其它过程。通信接口203用于支持该装置与其他网络实体的通信,例如,执行获取预定义测试数据。终端还可以包括存储器201和总线204,存储器201用于存储装置的程序代码和数据。Fig. 3 shows another possible structural schematic diagram of the interface testing device involved in the above embodiment. The device includes: a processor 202 and a communication interface 203 . The processor 202 is used to control and manage the actions of the device, for example, to execute the steps performed by the acquisition unit 101, the conversion unit 102, the comparison unit 103, and the determination unit 105, and/or other processes for performing the techniques described herein . The communication interface 203 is used to support communication between the device and other network entities, for example, to perform acquisition of predefined test data. The terminal may also include a memory 201 and a bus 204, and the memory 201 is used to store program codes and data of the device.

其中,上述处理器202可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,单元和电路。该处理器可以是中央处理器,通用处理器,数字信号处理器,专用集成电路,现场可编程门阵列或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,单元和电路。所述处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,DSP和微处理器的组合等。Wherein, the above-mentioned processor 202 may implement or execute various exemplary logical blocks, units and circuits described in conjunction with the disclosure of the present application. The processor may be a central processing unit, a general purpose processor, a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute the various illustrative logical blocks, units and circuits described in connection with the present disclosure. The processor may also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

存储器201可以包括易失性存储器,例如随机存取存储器;该存储器也可以包括非易失性存储器,例如只读存储器,快闪存储器,硬盘或固态硬盘;该存储器还可以包括上述种类的存储器的组合。The memory 201 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, flash memory, hard disk or solid state disk; the memory may also include the above-mentioned types of memory combination.

总线204可以是扩展工业标准结构(Extended Industry StandardArchitecture,EISA)总线等。总线404可以分为地址总线、数据总线、控制总线等。为便于表示,图3中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The bus 204 may be an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus or the like. The bus 404 can be divided into address bus, data bus, control bus and so on. For ease of representation, only one thick line is used in FIG. 3 , but it does not mean that there is only one bus or one type of bus.

通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能单元的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元完成,即将装置的内部结构划分成不同的功能单元,以完成以上描述的全部或者部分功能。上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of the description, only the division of the above-mentioned functional units is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated according to needs Completed by different functional units, that is, the internal structure of the device is divided into different functional units to complete all or part of the functions described above. For the specific working process of the above-described system, device, and unit, reference may be made to the corresponding process in the foregoing method embodiments, and details are not repeated here.

本申请的实施例提供一种存储一个或多个程序的计算机可读存储介质,所述一个或多个程序包括指令,所述指令当被计算机执行时使计算机执行如图1中所述的接口测试方法。An embodiment of the present application provides a computer-readable storage medium that stores one or more programs, the one or more programs include instructions, and the instructions, when executed by a computer, cause the computer to perform the interface as described in FIG. 1 Test Methods.

本申请的实施例提供一种包含指令的计算机程序产品,当指令在计算机上运行时,使得计算机执行如图1中所述的接口测试方法。Embodiments of the present application provide a computer program product containing instructions, and when the instructions are run on a computer, the computer is made to execute the interface testing method as shown in FIG. 1 .

其中,计算机可读存储介质,例如可以是但不限于电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘。随机存取存储器(Random Access Memory,RAM)、只读存储器(Read-Only Memory,ROM)、可擦式可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、寄存器、硬盘、光纤、便携式紧凑磁盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光存储器件、磁存储器件、或者上述的人以合适的组合、或者本领域数值的任何其他形式的计算机可读存储介质。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于特定用途集成电路(Application Specific Integrated Circuit,ASIC)中。在本申请实施例中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。Wherein, the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples (non-exhaustive list) of computer readable storage media include: electrical connection having one or more wires, portable computer disk, hard disk. Random Access Memory (Random Access Memory, RAM), Read-Only Memory (Read-Only Memory, ROM), Erasable Programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), registers, hard disk, optical fiber, portable compact Disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any other form of computer-readable storage medium in a suitable combination of the above, or values in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may be located in an application specific integrated circuit (Application Specific Integrated Circuit, ASIC). In the embodiments of the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, device or device.

由于本申请的实施例中的接口测试装置、计算机可读存储介质、计算机程序产品可以应用于上述方法,因此,其所能获得的技术效果也可参考上述方法实施例,本申请实施例在此不再赘述。Since the interface testing device, computer-readable storage medium, and computer program product in the embodiments of the present application can be applied to the above methods, the technical effects that can be obtained can also refer to the above method embodiments, and the embodiments of the present application are hereby No longer.

Claims (4)

1. An interface test method is characterized in that the method is applied to an interface test system, the interface test system comprises n interfaces, n is not less than 1, services are transmitted through each interface in sequence, and the nth interface is an interface to be tested, the method comprises the following steps:
s101, inputting ith test data into an ith interface to obtain ith response data of the ith interface; wherein i is a natural number; the initial value of i is 1, the 1 st test data is predefined test data, and the ith test data comprises the parameters and values of an ith interface, the protocol of the interface, a calling method and a returned check value;
s102, if i is not equal to n, converting the ith response data into ith +1 test data, i = i +1, and re-executing the step S101;
s103, if i is equal to n, the ith response data is nth response data, and whether the nth response data is consistent with the return check value of the interface to be tested is compared;
s104, determining a test result according to the comparison result;
if i is not equal to n, before converting the ith response data into the (i + 1) th test data, the method further comprises:
comparing whether the ith response data is consistent with the return check value of the predefined ith interface;
if yes, carrying out parameterization processing on the ith response data to convert the ith response data into (i + 1) th test data, wherein the parameterization processing method comprises the steps of extracting target parameters and/or combining the response data with predefined test data;
the acquiring ith response data of the ith interface comprises:
identifying the interface type of the ith interface according to the ith test data;
calling a preset interface test module corresponding to the interface type;
and executing the called preset interface test module and outputting ith response data.
2. An interface testing device is characterized in that the interface testing device is applied to an interface testing system, the interface testing system comprises n interfaces, n is not less than 1, services are transmitted through each interface in sequence, and the nth interface is an interface to be tested, the device comprises:
the device comprises an acquisition unit, a processing unit and a control unit, wherein the acquisition unit is used for inputting ith test data into an ith interface to acquire ith response data of the ith interface; wherein i is a natural number; the initial value of i is 1, the 1 st test data is predefined test data, and the ith test data comprises the parameter and value of the ith interface, the protocol of the interface, a calling method and a returned check value;
a converting unit, configured to convert the ith response data into ith +1 test data if i is not equal to n, where i = i +1, and re-execute step S101;
the comparison unit is used for comparing whether the nth response data is consistent with the returned check value of the interface to be detected or not if i is equal to n;
the determining unit is used for determining a test result according to the comparison result;
the comparison unit is further configured to:
comparing whether the ith response data is consistent with the return check value of the predefined ith interface;
if yes, carrying out parameterization processing on the ith response data to convert the ith response data into (i + 1) th test data, wherein the parameterization processing method comprises the steps of extracting target parameters and/or combining the response data with predefined test data;
the obtaining unit is specifically configured to:
identifying the interface type of the ith interface according to the ith test data;
calling a preset interface test module corresponding to the interface type;
and executing the called preset interface test module and outputting ith response data.
3. A computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a computer, cause the computer to perform the interface testing method of claim 1.
4. An interface testing apparatus, comprising: a processor, a memory and a communication interface, the communication interface is used for the interface testing device to communicate with other equipment or networks, the memory is used for storing programs, and the processor calls the programs stored in the memory to execute the interface testing method according to claim 1.
CN201811519800.9A 2018-12-12 2018-12-12 Interface testing method and device Active CN109739700B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811519800.9A CN109739700B (en) 2018-12-12 2018-12-12 Interface testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811519800.9A CN109739700B (en) 2018-12-12 2018-12-12 Interface testing method and device

Publications (2)

Publication Number Publication Date
CN109739700A CN109739700A (en) 2019-05-10
CN109739700B true CN109739700B (en) 2023-03-28

Family

ID=66358944

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811519800.9A Active CN109739700B (en) 2018-12-12 2018-12-12 Interface testing method and device

Country Status (1)

Country Link
CN (1) CN109739700B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111581109A (en) * 2020-05-15 2020-08-25 杭州安恒信息技术股份有限公司 Method, system and equipment for checking interface return data
CN112162923A (en) * 2020-09-25 2021-01-01 中诚信征信有限公司 An interface testing method and device
CN112363944A (en) * 2020-11-20 2021-02-12 上海悦易网络信息技术有限公司 Method and equipment for comparing return values of multiple environment interfaces
US11604724B2 (en) * 2020-12-18 2023-03-14 International Business Machines Corporation Software application component testing
CN114297084B (en) * 2021-12-31 2022-08-19 北京航天驭星科技有限公司 Method and device for testing satellite test, operation and control data interface, electronic equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101145993A (en) * 2007-10-11 2008-03-19 中兴通讯股份有限公司 A multi-point access interface test method and its test system
CN107301122A (en) * 2017-05-10 2017-10-27 深圳市小牛在线互联网信息咨询有限公司 interface test method, device, storage medium and computer equipment
CN107704386A (en) * 2017-09-25 2018-02-16 金蝶软件(中国)有限公司 Unit test method, device, computer equipment and the storage medium of operation flow
CN108549606A (en) * 2018-04-16 2018-09-18 成都医云科技有限公司 interface test method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8245080B2 (en) * 2009-03-19 2012-08-14 International Business Machines Corporation Model-based testing of an application program under test

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101145993A (en) * 2007-10-11 2008-03-19 中兴通讯股份有限公司 A multi-point access interface test method and its test system
CN107301122A (en) * 2017-05-10 2017-10-27 深圳市小牛在线互联网信息咨询有限公司 interface test method, device, storage medium and computer equipment
CN107704386A (en) * 2017-09-25 2018-02-16 金蝶软件(中国)有限公司 Unit test method, device, computer equipment and the storage medium of operation flow
CN108549606A (en) * 2018-04-16 2018-09-18 成都医云科技有限公司 interface test method and device

Also Published As

Publication number Publication date
CN109739700A (en) 2019-05-10

Similar Documents

Publication Publication Date Title
CN109739700B (en) Interface testing method and device
CN104360920B (en) A kind of automatic interface testing method and device
CN107229559B (en) Detection method and device for testing integrity of service system
CN108415826B (en) Application test method, terminal device and computer-readable storage medium
CN109815141B (en) A test method and device
US10452522B1 (en) Synthetic data generation from a service description language model
CN111538659B (en) Interface testing method, system, electronic equipment and storage medium of business scene
CN112417798B (en) Time sequence testing method and device, electronic equipment and storage medium
WO2020237508A1 (en) Assertion validation code binding method and apparatus
CN117493309A (en) Standard model generation method, device, equipment and storage medium
CN115687108A (en) Verification method, platform, terminal and storage medium based on combination of UVM and FPV
CN106326102A (en) Test method and apparatus
CN114968864B (en) Verification environment construction method, chip verification method and system
CN114866447A (en) Automatic test method and device for message receiving and sending of vehicle controller
CN118363715A (en) Integration method and device of reference model, electronic equipment and storage medium
CN108334313A (en) Continuous integrating method, apparatus and code management system for large-scale SOC research and development
CN109783718B (en) Repeated request judgment method and device
CN111597020A (en) Application Programming Interface (API) debugging method and debugging terminal
US11954017B2 (en) Dynamic analysis of rest API testing in microservice architecture
CN116414762A (en) PCIe link control method, control device, equipment and medium
CN115809193A (en) Front-end reverse abnormal data robustness detection method, device and storage medium
CN115563930A (en) Automatic verification method and device based on storage model, terminal and storage medium
CN115757172A (en) Test execution method and device, storage medium and computer equipment
CN114090357A (en) A hard disk performance testing method, device, electronic device and storage medium
CN115034164A (en) Verification method, electronic device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant