[go: up one dir, main page]

CN111639026A - Interface test method, device and system - Google Patents

Interface test method, device and system Download PDF

Info

Publication number
CN111639026A
CN111639026A CN202010451313.4A CN202010451313A CN111639026A CN 111639026 A CN111639026 A CN 111639026A CN 202010451313 A CN202010451313 A CN 202010451313A CN 111639026 A CN111639026 A CN 111639026A
Authority
CN
China
Prior art keywords
interface
test
document
online
test case
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.)
Pending
Application number
CN202010451313.4A
Other languages
Chinese (zh)
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.)
Shanghai Zhongtongji Network Technology Co Ltd
Original Assignee
Shanghai Zhongtongji Network Technology 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 Shanghai Zhongtongji Network Technology Co Ltd filed Critical Shanghai Zhongtongji Network Technology Co Ltd
Priority to CN202010451313.4A priority Critical patent/CN111639026A/en
Publication of CN111639026A publication Critical patent/CN111639026A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明涉及一种接口测试方法、装置和系统,接收测试用户发送的携带待测接口的接口标识的接口测试指令;根据接口测试指令,获取接口标识对应的在线接口文档以及利用在线接口文档进行联调的联调数据;对在线接口文档进行解析,确定格式化接口文档,从而保证接口测试文档格式统一。根据联调数据和格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;利用接口测试用例和断言,对待测接口进行测试,得到测试结果。采用本申请的技术方案,可以自动生成接口测试用例,从而进行接口测试,相比于现有技术中手动或者半自动编写接口用例脚本来说,能够节省人力与时间,提高接口测试的测试效率。

Figure 202010451313

The invention relates to an interface testing method, device and system, which receive an interface testing instruction carrying an interface identification of an interface to be tested sent by a test user; obtain an online interface document corresponding to the interface identification according to the interface testing instruction, and use the online interface document for connection The joint debugging data of the debugging; analyze the online interface document, determine the formatted interface document, so as to ensure the unified format of the interface test document. According to the joint debugging data and formatted interface documents, use the preset interface test case generation rules to automatically generate interface test cases and assertions; use the interface test cases and assertions to test the interface to be tested to obtain the test results. Using the technical solution of the present application, an interface test case can be automatically generated to perform an interface test. Compared with the manual or semi-automatic scripting of the interface use case in the prior art, manpower and time can be saved, and the test efficiency of the interface test can be improved.

Figure 202010451313

Description

接口测试方法、装置和系统Interface testing method, apparatus and system

技术领域technical field

本发明涉及接口测试技术领域,具体涉及一种接口测试方法、装置和系统。The invention relates to the technical field of interface testing, in particular to an interface testing method, device and system.

背景技术Background technique

在当今互联网时代,随着通信技术的不断发展,计算机软件在全行业的广泛使用,软件的质量至关重要,软件测试作为软件质量保障的重要途径越来越受到重视以及专业化。软件的前端服务和后台服务之间的交互,都是通过API(Application ProgrammingInterface,应用程序接口)进行通信的,因此接口测试在软件测试中也是尤为重要的。In today's Internet era, with the continuous development of communication technology and the widespread use of computer software in the whole industry, the quality of software is of paramount importance. As an important way to ensure software quality, software testing has received more and more attention and specialization. The interaction between the front-end service and the back-end service of the software is all communicated through API (Application Programming Interface, application programming interface), so interface testing is also particularly important in software testing.

传统情况下,接口测试文档来源众多,且格式各不相同,并且在做接口测试时,测试中接口用例脚本的编写都是手动或者半自动,每次脚本的编写都花费了大量的人力以及时间,导致接口测试的测试效率较低。Traditionally, there are many sources of interface test documents, and the formats are different, and when doing interface testing, the scripting of interface use cases in the test is written manually or semi-automatically, and each script writing takes a lot of manpower and time. The test efficiency of the interface test is low.

发明内容SUMMARY OF THE INVENTION

有鉴于此,本发明的目的在于提供一种接口测试方法、装置和系统,以解决现有技术中接口测试的测试效率较低的问题。In view of this, the purpose of the present invention is to provide an interface testing method, device and system to solve the problem of low testing efficiency of interface testing in the prior art.

为实现以上目的,本发明采用如下技术方案:To achieve the above purpose, the present invention adopts the following technical solutions:

一种接口测试方法,包括:An interface testing method, including:

接收测试用户发送的接口测试指令;所述接口测试指令携带待测接口的接口标识;Receive an interface test instruction sent by the test user; the interface test instruction carries the interface identifier of the interface to be tested;

根据所述接口测试指令,获取所述接口标识对应的在线接口文档以及利用所述在线接口文档进行联调的联调数据;According to the interface test instruction, obtain the online interface document corresponding to the interface identifier and the joint debugging data for joint debugging using the online interface document;

对所述在线接口文档进行解析,确定格式化接口文档;Parsing the online interface document to determine the formatted interface document;

根据所述联调数据和所述格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;According to the joint debugging data and the formatted interface document, using preset interface test case generation rules, automatically generate interface test cases and assertions;

利用所述接口测试用例和所述断言,对所述待测接口进行测试,得到测试结果。Using the interface test case and the assertion, the interface to be tested is tested to obtain a test result.

进一步地,上述接口测试方法中,所述获取所述接口标识对应的在线接口文档,包括:Further, in the above-mentioned interface testing method, the obtaining the online interface document corresponding to the interface identifier includes:

根据所述接口测试指令携带的所述接口标识,获取所述接口标识对应的所述在线接口文档的统一资源定位符URL;According to the interface identifier carried by the interface test instruction, obtain the uniform resource locator URL of the online interface document corresponding to the interface identifier;

根据所述URL,访问并得到所述URL对应的所述在线接口文档。According to the URL, the online interface document corresponding to the URL is accessed and obtained.

进一步地,上述接口测试方法中,所述在线接口文档为利用swagger框架组件进行编码和注解生成的接口文档。Further, in the above-mentioned interface testing method, the online interface document is an interface document generated by coding and annotation using the swagger framework component.

进一步地,上述接口测试方法中,所述自动生成接口测试用例和断言之后,还包括:Further, in the above interface testing method, after the automatic generation of interface test cases and assertions, the method further includes:

根据所述接口测试用例,记录所述接口测试用例的每次改动情况;According to the interface test case, record each modification of the interface test case;

根据所述每次改动情况,生成并输出接口测试用例改动日志。According to each modification, an interface test case modification log is generated and output.

进一步地,上述接口测试方法中,所述接口测试用例生成规则包括:等价类划分规则和/或边界值规则。Further, in the above interface testing method, the interface test case generation rules include: equivalence class division rules and/or boundary value rules.

本发明还提供一种接口测试装置,包括:The present invention also provides an interface testing device, comprising:

接收模块,用于接收测试用户发送的接口测试指令;所述接口测试指令携带待测接口的接口标识;a receiving module, configured to receive an interface test instruction sent by a test user; the interface test instruction carries the interface identifier of the interface to be tested;

获取模块,用于根据所述接口测试指令,获取所述接口标识对应的在线接口文档以及利用所述在线接口文档进行联调的联调数据;an acquisition module, configured to acquire, according to the interface test instruction, an online interface document corresponding to the interface identifier and joint debugging data for joint debugging using the online interface document;

接口文档解析模块,用于对所述在线接口文档进行解析,确定格式化接口文档;an interface document parsing module, configured to parse the online interface document and determine the formatted interface document;

测试用例生成模块,用于根据所述联调数据和所述格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;A test case generation module, configured to automatically generate interface test cases and assertions by using preset interface test case generation rules according to the joint debugging data and the formatted interface document;

测试模块,用于利用所述接口测试用例和所述断言,对所述待测接口进行测试,得到测试结果。A test module, configured to test the interface to be tested by using the interface test case and the assertion to obtain a test result.

进一步地,上述接口测试装置中,所述获取模块包括:URL获取单元和访问单元;Further, in the above-mentioned interface testing device, the acquisition module includes: a URL acquisition unit and an access unit;

所述URL获取单元,用于根据所述接口测试指令携带的所述接口标识,获取所述接口标识对应的所述在线接口文档的统一资源定位符URL;The URL obtaining unit is configured to obtain the Uniform Resource Locator URL of the online interface document corresponding to the interface identification according to the interface identification carried by the interface testing instruction;

所述访问单元,用于根据所述URL,访问并得到所述URL对应的所述在线接口文档。The access unit is configured to access and obtain the online interface document corresponding to the URL according to the URL.

进一步地,上述接口测试装置,还包括:接口文档生成模块;Further, the above-mentioned interface testing device also includes: an interface document generation module;

所述接口文档生成模块,用于利用swagger框架组件进行编码和注解,生成在线接口文档。The interface document generation module is used for coding and annotation using the swagger framework components to generate online interface documents.

进一步地,上述接口测试装置,还包括:记录模块和输出模块;Further, the above-mentioned interface testing device also includes: a recording module and an output module;

所述记录模块,用于根据所述接口测试用例,记录所述接口测试用例的每次改动情况;The recording module is configured to record each modification of the interface test case according to the interface test case;

所述输出模块,用于根据所述每次改动情况,生成并输出接口测试用例改动日志。The output module is configured to generate and output the interface test case modification log according to the modification situation of each time.

本发明还提供一种接口测试系统,包括:处理器以及与所述处理器相连的存储器;The present invention also provides an interface testing system, comprising: a processor and a memory connected to the processor;

所述存储器用于存储计算机程序,所述计算机程序至少用于上述接口测试方法;The memory is used for storing a computer program, and the computer program is at least used for the above-mentioned interface testing method;

所述处理器用于调用并执行所述计算机程序。The processor is used to invoke and execute the computer program.

一种接口测试方法、装置和系统,接收测试用户发送的携带待测接口的接口标识的接口测试指令;根据接口测试指令,获取接口标识对应的在线接口文档以及利用在线接口文档进行联调的联调数据;对在线接口文档进行解析,确定格式化接口文档,从而保证接口测试文档格式统一。根据联调数据和格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;利用接口测试用例和断言,对待测接口进行测试,得到测试结果。这样,可以自动生成接口测试用例,从而进行接口测试,相比于现有技术中手动或者半自动编写接口用例脚本来说,能够节省人力与时间,提高接口测试的测试效率。An interface testing method, device and system, receiving an interface test instruction carrying an interface identifier of an interface to be tested sent by a test user; according to the interface testing instruction, acquiring an online interface document corresponding to the interface identifier and an online interface document for joint debugging. Adjust data; parse the online interface document to determine the formatted interface document, so as to ensure the uniform format of the interface test document. According to the joint debugging data and formatted interface documents, use the preset interface test case generation rules to automatically generate interface test cases and assertions; use the interface test cases and assertions to test the interface under test to obtain the test results. In this way, the interface test case can be automatically generated to perform the interface test. Compared with the manual or semi-automatic writing of the interface test case script in the prior art, manpower and time can be saved, and the test efficiency of the interface test can be improved.

应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本发明。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.

图1是本发明的接口测试方法一种实施例提供的流程图;1 is a flowchart provided by an embodiment of an interface testing method of the present invention;

图2是本发明的接口测试装置一种实施例提供的结构示意图;2 is a schematic structural diagram provided by an embodiment of an interface testing device of the present invention;

图3是本发明的接口测试系统一种实施例提供的结构示意图。FIG. 3 is a schematic structural diagram provided by an embodiment of an interface testing system of the present invention.

具体实施方式Detailed ways

为使本发明的目的、技术方案和优点更加清楚,下面将对本发明的技术方案进行详细的描述。显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所得到的所有其它实施方式,都属于本发明所保护的范围。In order to make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be described in detail below. Obviously, the described embodiments are only some, but not all, embodiments of the present invention. Based on the embodiments of the present invention, all other implementations obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present invention.

图1是本发明的接口测试方法一种实施例提供的流程图,如图1所示,本实施例的接口测试方法具体可以包括如下步骤:FIG. 1 is a flowchart provided by an embodiment of an interface testing method of the present invention. As shown in FIG. 1 , the interface testing method of this embodiment may specifically include the following steps:

S101、接收测试用户发送的接口测试指令;接口测试指令携带待测接口的接口标识;S101. Receive an interface test instruction sent by a test user; the interface test instruction carries an interface identifier of the interface to be tested;

当测试用户在对数据接口进行测试时,测试用户会向服务器发送接口测试指令,服务器会接收该接口测试指令,该接口测试指令会携带待测接口的接口标识。When the test user is testing the data interface, the test user will send an interface test instruction to the server, and the server will receive the interface test instruction, and the interface test instruction will carry the interface identifier of the interface to be tested.

S102、根据接口测试指令,获取接口标识对应的在线接口文档以及利用在线接口文档进行联调的联调数据;S102, according to the interface test instruction, obtain the online interface document corresponding to the interface identifier and the joint debugging data for joint debugging using the online interface document;

服务器接收到接口测试指令后,根据接口测试指令携带的待测接口的接口标识,从接口文档存储库中获取该接口标识对应的在线接口文档。在进行数据接口测试时,需要利用在线接口文档联调接口,因此,需要获取利用在线接口文档进行接口联调的联调数据,其中,该联调数据是测试用户发送的接口相关信息,该接口相关信息可以包括请求地址、请求头、请求体、请求参数、请求类型、是否必填项、取值范围、响应头、响应体、返回格式、返回参数类型等。After receiving the interface test instruction, the server obtains the online interface document corresponding to the interface identifier from the interface document repository according to the interface identifier of the interface to be tested carried in the interface test instruction. When testing the data interface, it is necessary to use the online interface document to jointly debug the interface. Therefore, it is necessary to obtain the joint debugging data for the interface joint debugging using the online interface document, wherein the joint debugging data is the interface-related information sent by the test user. Relevant information may include request address, request header, request body, request parameter, request type, whether the item is required, value range, response header, response body, return format, return parameter type, etc.

进一步地,获取接口标识对应的在线接口文档具体步骤包括:Further, the specific steps of obtaining the online interface document corresponding to the interface identifier include:

第一,根据接口测试指令携带的接口标识,获取接口标识对应的在线接口文档的统一资源定位符URL;First, according to the interface identifier carried by the interface test instruction, obtain the Uniform Resource Locator URL of the online interface document corresponding to the interface identifier;

获取到接口测试指令后,需要根据接口测试指令携带的待测接口的接口标识,获取该待测接口的接口标识对应的在线接口文档的统一资源定位符URL。After the interface test instruction is obtained, it is necessary to obtain the Uniform Resource Locator URL of the online interface document corresponding to the interface identifier of the interface to be tested according to the interface identifier of the interface to be tested carried in the interface test instruction.

第二,根据URL,访问并得到URL对应的在线接口文档。Second, according to the URL, access and obtain the online interface document corresponding to the URL.

获取到在线接口文档的URL后,需要根据该URL,访问并获取接口文档存储库中与该URL对应的在线接口文档。After obtaining the URL of the online interface document, you need to access and obtain the online interface document corresponding to the URL in the interface document repository according to the URL.

进一步地,上述在线接口文档是利用swagger框架组件进行编码和注解生成的接口文档。Further, the above-mentioned online interface document is an interface document generated by using swagger framework components to encode and annotate.

S103、对在线接口文档进行解析,确定格式化接口文档;S103, parse the online interface document, and determine the formatted interface document;

获取在线接口文档后,需要对在线接口文档进行解析,从而确定格式化接口文档。接口文档存储库中的各个在线接口文档可能存在格式不同情况,因此,在进行数据接口测试时,需要对获取的在线接口文档进行解析,以将在线接口文档转化为统一格式的文档,即格式化接口文档。其中,格式化接口文档可以为XML格式、txt格式或excel格式的文件。After obtaining the online interface document, the online interface document needs to be parsed to determine the formatted interface document. Each online interface document in the interface document repository may have different formats. Therefore, during the data interface test, the obtained online interface document needs to be parsed to convert the online interface document into a unified format document, that is, formatted Interface documentation. The formatted interface document may be a file in XML format, txt format or excel format.

S104、根据联调数据和格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;S104, according to the joint debugging data and the formatted interface document, using a preset interface test case generation rule to automatically generate an interface test case and an assertion;

获取到利用在线接口文档进行联调的联调数据,以及解析出格式化接口文档后,根据待测接口对应的联调数据以及格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言。其中,预设的接口测试用例生成规则包括:等价类划分规则和/或边界值规则,即在进行接口测试用例生成时,既可只利用等价类划分规则,也可只利用边界值规则,还可利用等价类划分规则和边界值规则结合。After obtaining the joint debugging data for joint debugging using the online interface document, and parsing the formatted interface document, according to the joint debugging data corresponding to the interface to be tested and the formatted interface document, use the preset interface test case generation rules to automatically generate Interface test cases and assertions. The preset interface test case generation rules include: equivalence class division rules and/or boundary value rules, that is, when generating interface test cases, only the equivalence class division rules or the boundary value rules can be used. , and the combination of equivalence class partitioning rules and boundary value rules can also be used.

S105、利用接口测试用例和断言,对待测接口进行测试,得到测试结果。S105 , using the interface test case and the assertion to test the interface to be tested to obtain a test result.

利用接口测试用例生成规则生成接口测试用例和断言后,利用该接口测试用例和断言对待测接口进行测试,得到测试结果,以使测试用户查看该测试结果,根据测试结果对数据接口进行调试。其中,本实施例的接口测试用例是通过swagger框架提供的在开发中通过注解方式,编写注释,自动且及时生成在线接口文档及接口联调的能力,通过分析生成标准格式的格式化接口文档及接口联调数据,自动生成可复用的接口测试用例,从而能够提高接口测试效率。After the interface test case and assertion are generated by the interface test case generation rule, the interface to be tested is tested by the interface test case and the assertion, and the test result is obtained, so that the test user can view the test result and debug the data interface according to the test result. Among them, the interface test case of this embodiment is provided by the swagger framework through the annotation method in development, the ability to write annotations, automatically and timely generate online interface documents and interface joint debugging, and generate standard format formatted interface documents through analysis. Interface joint debugging data automatically generates reusable interface test cases, which can improve the efficiency of interface testing.

进一步地,本实施例的接口测试方法,在自动生成接口测试用例和断言之后,还可以包括以下步骤:Further, the interface testing method of this embodiment may further include the following steps after automatically generating the interface test case and assertion:

第一,根据接口测试用例,记录接口测试用例的每次改动情况;First, according to the interface test case, record each change of the interface test case;

在对数据接口进行测试时,根据每次接口测试生成的接口测试用例,分析并记录接口测试用例的每次改动情况。When testing the data interface, analyze and record each modification of the interface test case according to the interface test case generated by each interface test.

第二,根据每次改动情况,生成并输出接口测试用例改动日志。Second, according to each change, generate and output the interface test case change log.

记录下接口测试用例的每次改动情况后,根据每次改动情况,生成接口测试用例改动日志,并将该接口测试用例改动日志输出,以使测试用户查看接口测试用例改动日志,根据该接口测试改动日志调整对在线接口文档的编码与注解,提高接口测试用例生成的准确性,提高接口测试用例的复用性,从而提高测试效率。其中,接口测试改动日志可以以文件的形式输出,例如txt,html,excel形式。After recording each change of the interface test case, generate the interface test case change log according to each change, and output the interface test case change log, so that the test user can view the interface test case change log, and test according to the interface test case. The change log adjusts the coding and annotation of online interface documents, improves the accuracy of interface test case generation, improves the reusability of interface test cases, and thus improves test efficiency. Among them, the interface test change log can be output in the form of files, such as txt, html, and excel.

因代码实现方式为更新模式,故首次生成接口测试用例,日志记录为全部变动,第二次重复生成,会对比之前的生成版本,将改动部分输出。如果想要重新生成,而不做更新记录,只要在接口测试工具上重新开启一个线程组即可。其中,接口测试工具可以使用postman、jmeter、soupui等。Because the code is implemented in the update mode, the interface test case is generated for the first time, and the log records are all changes. The second repeated generation will compare the previous generation version and output some of the changes. If you want to regenerate without updating records, just restart a thread group on the interface testing tool. Among them, the interface testing tools can use postman, jmeter, soupui, etc.

本实施例的接口测试方法,接收测试用户发送的携带待测接口的接口标识的接口测试指令;根据接口测试指令,获取接口标识对应的在线接口文档以及利用在线接口文档进行联调的联调数据;对在线接口文档进行解析,确定格式化接口文档,从而保证接口测试文档格式统一。根据联调数据和格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;利用接口测试用例和断言,对待测接口进行测试,得到测试结果。这样,可以自动生成接口测试用例,从而进行接口测试,相比于现有技术中手动或者半自动编写接口用例脚本来说,能够节省人力与时间,提高接口测试的测试效率。另外,根据接口测试用例,记录接口测试用例的每次改动情况;根据每次改动情况,生成并输出接口测试用例改动日志,能够使测试用户调整对在线接口文档的编码与注解,提高接口测试用例生成的准确性和接口测试用例的复用性,从而提高测试效率。The interface testing method of this embodiment receives an interface test instruction that carries an interface identifier of the interface to be tested and is sent by a test user; according to the interface test instruction, obtains an online interface document corresponding to the interface identifier and joint debugging data for joint debugging using the online interface document ; Analyze the online interface document and determine the formatted interface document, so as to ensure the uniform format of the interface test document. According to the joint debugging data and formatted interface documents, use the preset interface test case generation rules to automatically generate interface test cases and assertions; use the interface test cases and assertions to test the interface under test to obtain the test results. In this way, the interface test case can be automatically generated to perform the interface test. Compared with the manual or semi-automatic writing of the interface test case script in the prior art, manpower and time can be saved, and the test efficiency of the interface test can be improved. In addition, according to the interface test case, record each modification of the interface test case; according to each modification, generate and output the interface test case modification log, which enables the test user to adjust the coding and annotation of the online interface document and improve the interface test case. The accuracy of the generated and the reusability of the interface test cases, thereby improving the test efficiency.

为了更全面,对应于本发明实施例提供的接口测试方法,本申请还提供了中接口测试装置。To be more comprehensive, corresponding to the interface testing method provided by the embodiments of the present invention, the present application also provides a middle interface testing device.

图2是本发明的接口测试装置一种实施例提供的结构示意图,如图2所示,本实施例的接口测试装置包括:接收模块101、获取模块102、接口文档解析模块103、测试用例生成模块104和测试模块105。FIG. 2 is a schematic structural diagram provided by an embodiment of the interface testing apparatus of the present invention. As shown in FIG. 2 , the interface testing apparatus of this embodiment includes: a receiving module 101 , an acquiring module 102 , an interface document parsing module 103 , and a test case generation Module 104 and Test Module 105.

接收模块101,用于接收测试用户发送的接口测试指令;接口测试指令携带待测接口的接口标识;A receiving module 101, configured to receive an interface test instruction sent by a test user; the interface test instruction carries an interface identifier of the interface to be tested;

获取模块102,用于根据接口测试指令,获取接口标识对应的在线接口文档以及利用在线接口文档进行联调的联调数据;The obtaining module 102 is used for obtaining the online interface document corresponding to the interface identifier and the joint debugging data for joint debugging using the online interface document according to the interface test instruction;

接口文档解析模块103,用于对在线接口文档进行解析,确定格式化接口文档;The interface document parsing module 103 is configured to parse the online interface document and determine the formatted interface document;

测试用例生成模块104,用于根据联调数据和格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;The test case generation module 104 is configured to automatically generate interface test cases and assertions by using preset interface test case generation rules according to the joint debugging data and formatted interface documents;

测试模块105,用于利用接口测试用例和断言,对待测接口进行测试,得到测试结果。The testing module 105 is used to test the interface to be tested by using the interface test case and assertion to obtain the test result.

进一步地,本实施例的接口测试装置中,获取模块102包括:URL获取单元和访问单元。Further, in the interface testing apparatus of this embodiment, the obtaining module 102 includes: a URL obtaining unit and an accessing unit.

URL获取单元,用于根据接口测试指令携带的接口标识,获取接口标识对应的在线接口文档的统一资源定位符URL;The URL obtaining unit is configured to obtain the Uniform Resource Locator URL of the online interface document corresponding to the interface identification according to the interface identification carried by the interface testing instruction;

访问单元,用于根据URL,访问并得到URL对应的在线接口文档。The access unit is used to access and obtain the online interface document corresponding to the URL according to the URL.

进一步地,本实施例的接口测试装置,还包括接口文档生成模块;Further, the interface testing device of this embodiment further includes an interface document generating module;

接口文档生成模块,用于利用swagger框架组件进行编码和注解,生成在线接口文档。The interface document generation module is used to encode and annotate using swagger framework components to generate online interface documents.

进一步地,本实施例的接口测试装置,还包括记录模块和输出模块。Further, the interface testing device of this embodiment further includes a recording module and an output module.

记录模块,用于根据接口测试用例,记录接口测试用例的每次改动情况;The recording module is used to record each change of the interface test case according to the interface test case;

输出模块,用于根据每次改动情况,生成并输出接口测试用例改动日志。The output module is used to generate and output the interface test case change log according to each change.

本实施例的接口测试装置,接收模块101接收测试用户发送的携带待测接口的接口标识的接口测试指令;获取模块102根据接口测试指令,获取接口标识对应的在线接口文档以及利用在线接口文档进行联调的联调数据;接口文档解析模块103对在线接口文档进行解析,确定格式化接口文档,从而保证接口测试文档格式统一。测试用例生成模块104根据联调数据和格式化接口文档,利用预设的接口测试用例生成规则,自动生成接口测试用例和断言;测试模块105利用接口测试用例和断言,对待测接口进行测试,得到测试结果。这样,可以自动生成接口测试用例,从而进行接口测试,相比于现有技术中手动或者半自动编写接口用例脚本来说,能够节省人力与时间,提高接口测试的测试效率。另外,记录模块根据接口测试用例,记录接口测试用例的每次改动情况;输出模块根据每次改动情况,生成并输出接口测试用例改动日志,能够使测试用户调整对在线接口文档的编码与注解,提高接口测试用例生成的准确性和接口测试用例的复用性,从而提高测试效率。In the interface testing apparatus of this embodiment, the receiving module 101 receives an interface testing instruction that carries the interface identifier of the interface to be tested and sent by the test user; the acquiring module 102 acquires the online interface document corresponding to the interface identifier according to the interface testing instruction, and uses the online interface document to perform The joint debugging data of the joint debugging; the interface document parsing module 103 parses the online interface document, and determines the formatted interface document, thereby ensuring that the format of the interface test document is uniform. The test case generation module 104 uses preset interface test case generation rules to automatically generate interface test cases and assertions according to the joint debugging data and formatted interface documents; the test module 105 uses the interface test cases and assertions to test the interface to be tested, and obtains Test Results. In this way, the interface test case can be automatically generated to perform the interface test. Compared with the manual or semi-automatic writing of the interface test case script in the prior art, manpower and time can be saved, and the test efficiency of the interface test can be improved. In addition, the recording module records each modification of the interface test case according to the interface test case; the output module generates and outputs the modification log of the interface test case according to each modification, which enables the test user to adjust the coding and annotation of the online interface document. Improve the accuracy of interface test case generation and the reusability of interface test cases, thereby improving test efficiency.

关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the apparatus in the above-mentioned embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be described in detail here.

图3是本发明的接口测试系统一种实施例提供的结构示意图。如图3所示,接口测试系统包括处理器22和与处理器22相连的存储器21。FIG. 3 is a schematic structural diagram provided by an embodiment of an interface testing system of the present invention. As shown in FIG. 3 , the interface testing system includes a processor 22 and a memory 21 connected to the processor 22 .

存储器21用于存储计算机程序,该计算机程序至少用于执行上述实施例所述的接口测试方法;The memory 21 is used to store a computer program, and the computer program is at least used to execute the interface testing method described in the above embodiment;

处理器22用于调用并执行存储器21中存储的计算机程序,即处理器22用于调用并执行上述实施例所述的接口测试方法。The processor 22 is used to call and execute the computer program stored in the memory 21, that is, the processor 22 is used to call and execute the interface testing method described in the above embodiments.

本实施例的接口测试系统,通过处理器22调用并执行存储器21中存储的接口测试方法,可以自动生成接口测试用例,从而进行接口测试,相比于现有技术中手动或者半自动编写接口用例脚本来说,能够节省人力与时间,提高接口测试的测试效率。另外,还能根据接口测试用例,记录接口测试用例的每次改动情况;根据每次改动情况,生成并输出接口测试用例改动日志,能够使测试用户调整对在线接口文档的编码与注解,提高接口测试用例生成的准确性,从而提高测试效率。In the interface test system of this embodiment, the processor 22 invokes and executes the interface test method stored in the memory 21, and can automatically generate interface test cases, thereby performing interface tests. Compared with the manual or semi-automatic writing of interface test scripts in the prior art In other words, it can save manpower and time and improve the test efficiency of interface testing. In addition, each modification of the interface test case can be recorded according to the interface test case; according to each modification, the interface test case modification log can be generated and output, which enables the test user to adjust the coding and annotation of the online interface document and improve the interface The accuracy of test case generation, thereby improving test efficiency.

可以理解的是,上述各实施例中相同或相似部分可以相互参考,在一些实施例中未详细说明的内容可以参见其他实施例中相同或相似的内容。It can be understood that, the same or similar parts in the above embodiments may refer to each other, and the content not described in detail in some embodiments may refer to the same or similar content in other embodiments.

需要说明的是,在本发明的描述中,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性。此外,在本发明的描述中,除非另有说明,“多个”的含义是指至少两个。It should be noted that, in the description of the present invention, the terms "first", "second", etc. are only used for the purpose of description, and should not be construed as indicating or implying relative importance. Furthermore, in the description of the present invention, unless otherwise specified, the meaning of "plurality" means at least two.

流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本发明的实施例所属技术领域的技术人员所理解。Any description of a process or method in the flowcharts or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing a specified logical function or step of the process , and the scope of the preferred embodiments of the invention includes alternative implementations in which the functions may be performed out of the order shown or discussed, including performing the functions substantially concurrently or in the reverse order depending upon the functions involved, which should It is understood by those skilled in the art to which the embodiments of the present invention belong.

应当理解,本发明的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。例如,如果用硬件来实现,和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。It should be understood that various parts of the present invention may be implemented in hardware, software, firmware or a combination thereof. In the above-described embodiments, various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one or a combination of the following techniques known in the art: Discrete logic circuits, application specific integrated circuits with suitable combinational logic gates, Programmable Gate Arrays (PGA), Field Programmable Gate Arrays (FPGA), etc.

本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。Those skilled in the art can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, and the program can be executed when the program is executed. , including one or a combination of the steps of the method embodiment.

此外,在本发明各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing module, or each unit may exist physically alone, or two or more units may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium.

上述提到的存储介质可以是只读存储器,磁盘或光盘等。The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, and the like.

在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任何的一个或多个实施例或示例中以合适的方式结合。In the description of this specification, description with reference to the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples", etc., mean specific features described in connection with the embodiment or example , structure, material or feature is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。Although the embodiments of the present invention have been shown and described above, it should be understood that the above-mentioned embodiments are exemplary and should not be construed as limiting the present invention. Embodiments are subject to variations, modifications, substitutions and variations.

Claims (10)

1. An interface testing method, comprising:
receiving an interface test instruction sent by a test user; the interface test instruction carries an interface identifier of an interface to be tested;
acquiring an online interface document corresponding to the interface identifier and joint debugging data for joint debugging by using the online interface document according to the interface test instruction;
analyzing the online interface document to determine a formatted interface document;
automatically generating an interface test case and assertion according to the joint debugging data and the formatted interface document by using a preset interface test case generation rule;
and testing the interface to be tested by using the interface test case and the assertion to obtain a test result.
2. The interface testing method according to claim 1, wherein the obtaining of the online interface document corresponding to the interface identifier includes:
acquiring a Uniform Resource Locator (URL) of the online interface document corresponding to the interface identifier according to the interface identifier carried by the interface test instruction;
and accessing and obtaining the online interface document corresponding to the URL according to the URL.
3. The interface testing method of claim 2, wherein the online interface document is an interface document generated by encoding and annotating with swagger framework components.
4. The interface testing method according to claim 1, wherein after automatically generating the interface test case and the assertion, the method further comprises:
recording each change condition of the interface test case according to the interface test case;
and generating and outputting an interface test case change log according to the change condition of each time.
5. The interface test method according to claim 1, wherein the interface test case generation rule includes: equivalence class partitioning rules and/or boundary value rules.
6. An interface testing apparatus, comprising:
the receiving module is used for receiving an interface test instruction sent by a test user; the interface test instruction carries an interface identifier of an interface to be tested;
the acquisition module is used for acquiring an online interface document corresponding to the interface identifier and joint debugging data for joint debugging by using the online interface document according to the interface test instruction;
the interface document analysis module is used for analyzing the online interface document and determining a formatted interface document;
the test case generation module is used for automatically generating an interface test case and assertion according to the joint debugging data and the formatted interface document by using a preset interface test case generation rule;
and the test module is used for testing the interface to be tested by using the interface test case and the assertion to obtain a test result.
7. The interface test apparatus of claim 6, wherein the obtaining module comprises: a URL acquisition unit and an access unit;
the URL obtaining unit is used for obtaining a Uniform Resource Locator (URL) of the online interface document corresponding to the interface identifier according to the interface identifier carried by the interface test instruction;
and the access unit is used for accessing and obtaining the online interface document corresponding to the URL according to the URL.
8. The interface test apparatus of claim 7, further comprising: an interface document generation module;
and the interface document generation module is used for coding and annotating by using the swagger framework component to generate an online interface document.
9. The interface test apparatus of claim 6, further comprising: a recording module and an output module;
the recording module is used for recording each change condition of the interface test case according to the interface test case;
and the output module is used for generating and outputting an interface test case change log according to the change condition of each time.
10. An interface test system, comprising: the system comprises a processor and a memory connected with the processor;
the memory for storing a computer program for performing at least the interface testing method of any of claims 1-5;
the processor is used for calling and executing the computer program.
CN202010451313.4A 2020-05-25 2020-05-25 Interface test method, device and system Pending CN111639026A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010451313.4A CN111639026A (en) 2020-05-25 2020-05-25 Interface test method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010451313.4A CN111639026A (en) 2020-05-25 2020-05-25 Interface test method, device and system

Publications (1)

Publication Number Publication Date
CN111639026A true CN111639026A (en) 2020-09-08

Family

ID=72329103

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010451313.4A Pending CN111639026A (en) 2020-05-25 2020-05-25 Interface test method, device and system

Country Status (1)

Country Link
CN (1) CN111639026A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113176914A (en) * 2021-06-03 2021-07-27 上海中通吉网络技术有限公司 Modularized testing tool based on automatic Web end
CN113672504A (en) * 2021-08-04 2021-11-19 深圳Tcl新技术有限公司 A kind of intelligent equipment testing method, device, equipment and storage medium
CN114064469A (en) * 2021-11-09 2022-02-18 福建正孚软件有限公司 Interface automated testing method and storage medium
CN114328231A (en) * 2021-12-29 2022-04-12 苏州浪潮智能科技有限公司 Test method, test device, electronic equipment and storage medium
CN114328274A (en) * 2022-03-07 2022-04-12 深圳开源互联网安全技术有限公司 Test template generation method and device, computer equipment and storage medium
CN114647567A (en) * 2020-12-18 2022-06-21 陕西汽车集团有限责任公司 Automatic testing method based on model interface
CN115454877A (en) * 2022-10-12 2022-12-09 平安银行股份有限公司 Financial product processing method and device, intelligent equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092756A (en) * 2013-01-08 2013-05-08 彭勇 Interactive automated testing system and method thereof
US10534701B1 (en) * 2019-06-17 2020-01-14 Capital One Services, Llc API driven continuous testing systems for testing disparate software
CN110825619A (en) * 2019-10-12 2020-02-21 深圳壹账通智能科技有限公司 Automatic generation method and device of interface test case and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092756A (en) * 2013-01-08 2013-05-08 彭勇 Interactive automated testing system and method thereof
US10534701B1 (en) * 2019-06-17 2020-01-14 Capital One Services, Llc API driven continuous testing systems for testing disparate software
CN110825619A (en) * 2019-10-12 2020-02-21 深圳壹账通智能科技有限公司 Automatic generation method and device of interface test case and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
唐涛等, 中国电力出版社 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114647567A (en) * 2020-12-18 2022-06-21 陕西汽车集团有限责任公司 Automatic testing method based on model interface
CN113176914A (en) * 2021-06-03 2021-07-27 上海中通吉网络技术有限公司 Modularized testing tool based on automatic Web end
CN113672504A (en) * 2021-08-04 2021-11-19 深圳Tcl新技术有限公司 A kind of intelligent equipment testing method, device, equipment and storage medium
CN113672504B (en) * 2021-08-04 2024-08-20 深圳Tcl新技术有限公司 A method, device, equipment and storage medium for testing intelligent equipment
CN114064469A (en) * 2021-11-09 2022-02-18 福建正孚软件有限公司 Interface automated testing method and storage medium
CN114328231A (en) * 2021-12-29 2022-04-12 苏州浪潮智能科技有限公司 Test method, test device, electronic equipment and storage medium
CN114328231B (en) * 2021-12-29 2024-10-22 苏州浪潮智能科技有限公司 Test method, device, electronic device and storage medium
CN114328274A (en) * 2022-03-07 2022-04-12 深圳开源互联网安全技术有限公司 Test template generation method and device, computer equipment and storage medium
CN115454877A (en) * 2022-10-12 2022-12-09 平安银行股份有限公司 Financial product processing method and device, intelligent equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111639026A (en) Interface test method, device and system
CN106919612B (en) A method and device for processing an online structured query language script
CN111949520A (en) Interface automatic testing method and equipment
CN110825619A (en) Automatic generation method and device of interface test case and storage medium
CN108345532A (en) A kind of automatic test cases generation method and device
CN115080398A (en) An interface automated testing system and method
CN102981958A (en) Method and device for testing software
CN116541308B (en) A regression testing method and system
CN105912460A (en) Software test method and system based on QTP
CN112631894B (en) Code detection method, device, storage medium and computer equipment
CN108664385A (en) A kind of test method and device of application programming interface
CN107729238A (en) A kind of plug-in unit adjustment method, system, device and computer-readable recording medium
CN112148599A (en) Performance pressure measurement method, device and equipment
CN114138633A (en) Method, device and equipment for testing software based on data driving and readable medium
CN114780420A (en) Method, device, equipment and storage medium for automatic test based on test case
CN108459961A (en) The method, client and server of examination are resurveyed after a kind of failure of testing case
CN116204438A (en) Test case generation method, automatic test method and related device
CN117215910A (en) Interface test frame generation method, test method, electronic device and storage medium
CN117648257A (en) Web automatic test method and system under Linux operating system
CN111881021A (en) Interface testing method, apparatus and system
CN114168366B (en) Methods, apparatus, processors, and computer-readable storage media for front-end request sending and processing based on Swagger.
CN118839668B (en) A test result format conversion method and computing device
CN114385132B (en) Assertion code generation method, device, equipment and medium
CN107885648B (en) Method and device for generating test report
CN114385493A (en) Performance test method and device, electronic equipment 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200908

RJ01 Rejection of invention patent application after publication