[go: up one dir, main page]

CN109522228B - Interface automation test data construction method, device, platform and storage medium - Google Patents

Interface automation test data construction method, device, platform and storage medium Download PDF

Info

Publication number
CN109522228B
CN109522228B CN201811359053.7A CN201811359053A CN109522228B CN 109522228 B CN109522228 B CN 109522228B CN 201811359053 A CN201811359053 A CN 201811359053A CN 109522228 B CN109522228 B CN 109522228B
Authority
CN
China
Prior art keywords
target interface
data
interface
test data
programming statement
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
CN201811359053.7A
Other languages
Chinese (zh)
Other versions
CN109522228A (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.)
Shenzhen Lexin Software Technology Co Ltd
Original Assignee
Shenzhen Lexin Software 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 Shenzhen Lexin Software Technology Co Ltd filed Critical Shenzhen Lexin Software Technology Co Ltd
Priority to CN201811359053.7A priority Critical patent/CN109522228B/en
Publication of CN109522228A publication Critical patent/CN109522228A/en
Application granted granted Critical
Publication of CN109522228B publication Critical patent/CN109522228B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

The embodiment of the invention discloses a method, a device, a platform and a storage medium for constructing interface automation test data. Wherein, the method comprises the following steps: constructing a data generation template of the target interface according to the modified programming statement of the target interface and/or the data type of the target interface; and establishing automatic test data of the target interface according to the data generation template for testing the target interface. The technical scheme provided by the embodiment of the invention can construct different test data so as to facilitate the automatic test of the interface.

Description

接口自动化测试数据构造方法、装置、平台及存储介质Interface automated test data construction method, device, platform and storage medium

技术领域technical field

本发明涉及计算机技术领域,尤其涉及一种接口自动化测试数据构造方法、装置、平台及存储介质。The present invention relates to the field of computer technology, and in particular, to a method, device, platform and storage medium for constructing interface automation test data.

背景技术Background technique

随着产品功能越来越多,系统架构越来越复杂,服务端经常会涉及到版本改动或者系统重构,从而使得功能测试、性能测试及GUI(Graphical User Interface,图形用户界面)自动回归测试等很难对底层的业务逻辑进行校验。此外,大量的回归工作需要耗费大量的测试资源,因此接口自动化测试应运而生。With more and more product functions, the system architecture becomes more and more complex, and the server often involves version changes or system refactoring, so that functional testing, performance testing and GUI (Graphical User Interface, Graphical User Interface) automatic regression testing It is difficult to verify the underlying business logic. In addition, a lot of regression work requires a lot of testing resources, so interface automation testing came into being.

依赖接口自动化测试,系统的改动及重构可以依赖脚本进行保证,而自动化测试逻辑覆盖率也就依赖自动化测试案例的数量及完整性。但是,目前实现自动化测试系统成本相对比较高,特别是造数据环节,需要耗费大量的人力成本。Relying on automated testing of interfaces, system changes and refactorings can be guaranteed by scripts, and the coverage of automated testing logic also depends on the number and integrity of automated test cases. However, at present, the cost of implementing an automated test system is relatively high, especially in the data creation process, which requires a lot of labor costs.

发明内容SUMMARY OF THE INVENTION

本发明实施例提供一种接口自动化测试数据构造方法、装置、平台及存储介质,能够构造不同的测试数据,以便进行接口自动化测试使用。Embodiments of the present invention provide a method, device, platform and storage medium for constructing interface automation test data, which can construct different test data for use in interface automation test.

第一方面,本发明实施例提供了一种接口自动化测试数据构造方法,该方法包括:In a first aspect, an embodiment of the present invention provides a method for constructing interface automation test data, the method comprising:

根据目标接口的修改的编程语句和/或目标接口的数据类型,构建目标接口的数据生成模板;According to the modified programming statement of the target interface and/or the data type of the target interface, construct the data generation template of the target interface;

依据所述数据生成模板构建目标接口的自动化测试数据,用于对所述目标接口进行测试。The automated test data of the target interface is constructed according to the data generation template for testing the target interface.

第二方面,本发明实施例还提供了一种接口自动化测试数据构造装置,该装置包括:In a second aspect, an embodiment of the present invention further provides a device for constructing interface automation test data, the device comprising:

模板构建模块,用于根据目标接口的修改的编程语句和/或目标接口的数据类型,构建目标接口的数据生成模板;A template building module for constructing a data generation template of the target interface according to the modified programming statement of the target interface and/or the data type of the target interface;

测试数据生成模块,用于依据所述数据生成模板构建目标接口的自动化测试数据,用于对所述目标接口进行测试。The test data generation module is used for constructing the automated test data of the target interface according to the data generation template, so as to test the target interface.

第三方面,本发明实施例还提供了一种平台,该平台包括:In a third aspect, an embodiment of the present invention also provides a platform, the platform includes:

一个或多个处理器;one or more processors;

存储装置,用于存储一个或多个程序;a storage device for storing one or more programs;

当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现第一方面中任一所述的接口自动化测试数据构造方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the interface automated test data construction method in any one of the first aspect.

第四方面,本发明实施例还提供了一种存储介质,其上存储有计算机程序,该程序被处理器执行时实现第一方面中任一所述的接口自动化测试数据构造方法。In a fourth aspect, an embodiment of the present invention further provides a storage medium on which a computer program is stored, and when the program is executed by a processor, implements any one of the interface automated test data construction methods described in the first aspect.

本发明实施例提供的接口自动化测试数据构造方法、装置、平台及存储介质,在需要对目标接口进行测试时,可根据目标接口的修改的编程语句和/或目标接口的数据类型,构造该目标接口的数据生成模板;而后依据所构造的数据生成模板构建该目标接口的自动化测试数据,进而采用所构建的自动化测试数据对目标接口进行自动化测试。本方案,相比于现有的接口自动化测试方案,能够根据不同接口自动构造不同的测试数据,以便进行接口自动化测试使用,无需耗费大量的人力。The interface automation test data construction method, device, platform and storage medium provided by the embodiments of the present invention can construct the target interface according to the modified programming statement of the target interface and/or the data type of the target interface when the target interface needs to be tested. The data of the interface generates a template; then the automated test data of the target interface is constructed according to the constructed data generation template, and the automated test of the target interface is carried out by using the constructed automated test data. Compared with the existing interface automation test solution, this solution can automatically construct different test data according to different interfaces, so as to use the interface automation test without consuming a lot of manpower.

附图说明Description of drawings

通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本发明的其它特征、目的和优点将会变得更明显:Other features, objects and advantages of the present invention will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

图1是本发明实施例一中提供的一种接口自动化测试数据构造方法的流程图;1 is a flowchart of a method for constructing interface automation test data provided in Embodiment 1 of the present invention;

图2是本发明实施例二中提供的一种接口自动化测试数据构造方法的流程图;2 is a flowchart of a method for constructing interface automation test data provided in Embodiment 2 of the present invention;

图3A为本发明实施例三提供的一种接口自动化测试数据构造方法的流程图;3A is a flowchart of a method for constructing interface automation test data according to Embodiment 3 of the present invention;

图3B为本发明实施例三提供的一种接口自动化测试系统结构框图;3B is a structural block diagram of an automated interface testing system provided in Embodiment 3 of the present invention;

图4是本发明实施例四中提供的一种接口自动化测试数据构造装置的结构框图;Fig. 4 is a structural block diagram of an interface automatic test data construction device provided in Embodiment 4 of the present invention;

图5是本发明实施例五中提供的一种平台的结构示意图。FIG. 5 is a schematic structural diagram of a platform provided in Embodiment 5 of the present invention.

具体实施方式Detailed ways

下面结合附图和实施例对本发明作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅用于解释本发明,而非对本发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本发明相关的部分而非全部内容。The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention. In addition, it should be noted that, for the convenience of description, the drawings only show some but not all of the contents related to the present invention.

实施例一Example 1

图1为本发明实施例一提供的一种接口自动化测试数据构造方法的流程图,本实施例适用于对接口进行自动化测试时,如何构建接口所需的测试数据的情况。该方法可以由本发明实施例提供的接口自动化测试数据构造装置来执行,该装置可采用软件和/或硬件的方式实现,该装置可配置于接口自动化测试平台或设备上。参见图1,该方法具体包括:FIG. 1 is a flow chart of a method for constructing interface automated test data according to Embodiment 1 of the present invention. This embodiment is applicable to the situation of how to construct test data required by an interface when an interface is automatically tested. The method may be performed by the interface automated test data construction apparatus provided in the embodiment of the present invention, the apparatus may be implemented in software and/or hardware, and the apparatus may be configured on an interface automated test platform or equipment. Referring to Figure 1, the method specifically includes:

S110,根据目标接口的修改的编程语句和/或目标接口的数据类型,构建目标接口的数据生成模板。S110, construct a data generation template of the target interface according to the modified programming statement of the target interface and/or the data type of the target interface.

本实施例中,目标接口是指需要进行自动化测试的接口;修改的编程语句是指对目标接口的功能或业务逻辑等进行修改的编程语句。对数据库语言而言,编程语句可以包括:C++、JAVA或SQL(Structure Query Languge,结构化查询语言)语句等。而SQL是一种特殊目的的编程语言,是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统,同时也是数据库脚本文件的扩展名。因此,本实施例中,修改的编程语句优选为修改的SQL语句。In this embodiment, the target interface refers to an interface that needs to be tested automatically; the modified programming statement refers to a programming statement for modifying the function or business logic of the target interface. For database languages, programming statements may include C++, JAVA, or SQL (Structure Query Languge, structured query language) statements, and the like. SQL is a special-purpose programming language, a database query and programming language, used to access data and query, update, and manage relational database systems, and is also an extension of database script files. Therefore, in this embodiment, the modified programming statement is preferably a modified SQL statement.

目标接口的数据类型是指测试目标接口所需的测试数据的类型,该数据类型可以由目标接口的业务逻辑或接口中包含的方法等决定。示例性的,若两个接口含有部分相同的业务逻辑,或者两个接口中含有相同的方法等,则可以确定这两个接口中含有相同的数据类型。The data type of the target interface refers to the type of test data required to test the target interface, and the data type may be determined by the business logic of the target interface or the methods contained in the interface. Exemplarily, if the two interfaces contain part of the same business logic, or the two interfaces contain the same method, etc., it can be determined that the two interfaces contain the same data type.

本实施例中,数据生成模板是指用于参照该模板构建接口自动化测试所需数据的样板。需要说明的是,不同接口可能对应不同的数据生成模板,也可能对应相同的数据生成模板。例如,接口A和接口B中含有相同的数据类型,则说明接口A和接口B可以共用某一数据生成模板。可选的,一个接口可对应一个或多个数据生成模板。需要说明的是,一般情况下,一个接口对应一个数据生成模板;但是若一个接口所需的测试数据包含多种数据类型,则包含多个数据生成模板。In this embodiment, the data generation template refers to a template for constructing data required for automated testing of an interface with reference to the template. It should be noted that different interfaces may correspond to different data generation templates, or may correspond to the same data generation template. For example, if interface A and interface B contain the same data type, it means that interface A and interface B can share a certain data generation template. Optionally, one interface may generate templates corresponding to one or more data. It should be noted that, in general, one interface corresponds to one data generation template; however, if the test data required by an interface includes multiple data types, it includes multiple data generation templates.

以目标接口为A进行说明。具体的,接口自动化测试平台在对目标接口A进行自动化测试时,若检测到目标接口A所需测试数据的数据类型与本地存储的测试数据的数据类型相同,如已完成自动化测试的接口B的测试数据,则可以直接获取接口B的测试数据的数据生成模板作为目标接口A的数据生成模板,进而构建目标接口A所需的测试数据,并基于所构建的测试数据对目标接口A进行测试。即接口自动化测试平台可以直接根据目标接口的数据类型,构建目标接口的数据生成模板。The target interface is A for description. Specifically, when the automated interface testing platform performs automated testing on the target interface A, if it detects that the data type of the test data required by the target interface A is the same as the data type of the locally stored test data, such as the data type of the interface B that has completed the automated test Test data, you can directly obtain the data generation template of the test data of interface B as the data generation template of target interface A, and then construct the test data required by the target interface A, and test the target interface A based on the constructed test data. That is, the interface automation test platform can directly construct the data generation template of the target interface according to the data type of the target interface.

若本地存储的测试数据的数据类型与目标接口A所需测试数据的数据类型完全不匹配或部分匹配,接口自动化测试平台则需要先获取目标接口的修改的编程语句;而后依据目标接口的修改的编程语句或者,目标接口的修改的编程语句和目标接口的数据类型,构建目标接口的数据生成模板。If the data type of the locally stored test data does not match or partially matches the data type of the test data required by the target interface A, the interface automation test platform needs to obtain the modified programming statement of the target interface; The programming statement or, the modified programming statement of the target interface and the data type of the target interface, construct the data generation template of the target interface.

示例性的,构建目标接口的数据生成模板之前,还可以包括:通过嗅探器基于主从数据库同步原理,实时从主数据库获取目标接口的修改的编程语句。Exemplarily, before constructing the data generation template of the target interface, the method may further include: acquiring the modified programming statement of the target interface from the master database in real time based on the principle of master-slave database synchronization through a sniffer.

其中,嗅探器是一种监视网络数据运行的软件设备。本实施例中,嗅探器可配置于接口自动化测试平台中;也可以独立于接口自动化测试平台,作为伪装从数据库监视主数据库中的数据变化。本实施例中,主从数据库同步原理可选为MySQL主从数据库同步原理,从数据库(嗅探器)基于异步复制特性从主数据库中实时获取修改的编程语句。具体的,接口自动化测试平台可以通过配置于其上的嗅探器实时从主数据库中获取目标接口的修改的编程语句;还可以是接收独立的嗅探器作为伪装从数据库,从主数据库实时获取的目标接口的修改的编程语句。Among them, a sniffer is a software device that monitors the operation of network data. In this embodiment, the sniffer may be configured in the interface automated testing platform; it may also be independent of the interface automated testing platform, as a camouflage slave database to monitor data changes in the master database. In this embodiment, the master-slave database synchronization principle can be selected as the MySQL master-slave database synchronization principle, and the slave database (sniffer) acquires the modified programming statement from the master database in real time based on the asynchronous replication feature. Specifically, the interface automation test platform can obtain the modified programming statements of the target interface from the main database in real time through the sniffer configured on it; it can also receive an independent sniffer as a disguised slave database, and obtain the modified programming statements from the main database in real time. The modified programming statement of the target interface.

具体的,若本地存储的测试数据的数据类型与目标接口A所需测试数据的数据类型完全不匹配,接口自动化测试平台则需要先获取目标接口的修改的编程语句;而后基于语义语法分析对获取的目标接口的修改的编程语句进行分析,从该修改的编程语句中提取中关键属性,进而基于该关键属性构建该目标接口A的数据生成模板。若本地存储的测试数据的数据类型与目标接口A所需测试数据的数据类型部分不匹配,则只需获取不匹配部分关联的目标接口的修改的编程语句;而后依据获取的目标修改的编程语句构建目标接口A的第一数据生成模板,从本地获取相同数据类型部分关联的数据生成模板作为目标接口A的第二数据生成模板,将第一数据生成模板和第二数据生成模板作为目标接口A的数据生成模板。Specifically, if the data type of the locally stored test data does not match the data type of the test data required by the target interface A at all, the interface automation test platform needs to obtain the modified programming statement of the target interface first; The modified programming statement of the target interface is analyzed, and the key attribute is extracted from the modified programming statement, and then the data generation template of the target interface A is constructed based on the key attribute. If the data type of the locally stored test data does not match the data type part of the test data required by the target interface A, it is only necessary to obtain the modified programming statement of the target interface associated with the mismatched part; then the modified programming statement according to the acquired target Build the first data generation template of the target interface A, obtain the data generation template associated with the same data type part locally as the second data generation template of the target interface A, and use the first data generation template and the second data generation template as the target interface A data generation template.

S120,依据数据生成模板构建目标接口的自动化测试数据,用于对目标接口进行测试。S120: Build automated test data of the target interface according to the data generation template, so as to test the target interface.

具体的,在根据目标接口的修改的编程语句和/或目标接口的数据类型,构建目标接口的数据生成模板之后,可以依据构建的数据生成模板以及测试目标接口实际所需的数据量等,构建目标接口的自动化测试数据;而后基于所构建的目标接口的自动化测试数据,对目标接口进行测试。Specifically, after the data generation template of the target interface is constructed according to the modified programming statement of the target interface and/or the data type of the target interface, the template can be generated according to the constructed data and the amount of data actually required for testing the target interface. The automated test data of the target interface; and then based on the constructed automated test data of the target interface, the target interface is tested.

示例性的,依据数据生成模板构建目标接口的自动化测试数据之后,还可以包括:从本地存储的接口文档中获取目标接口;通过目标接口请求自动化测试数据,并调用接口自动化测试引擎,执行目标接口的自动化测试。Exemplarily, after constructing the automated test data of the target interface according to the data generation template, it may further include: obtaining the target interface from the locally stored interface document; requesting the automated test data through the target interface, and calling the interface automated test engine to execute the target interface of automated tests.

本实施例中,接口文档是指接口自动化测试平台本地存储的,用于清楚记载某一系统服务上所有接口信息的文档,可以是excel表、word或网页等形式。自动化测试引擎可以是一种用于进行自动化测试的工具。In this embodiment, the interface document refers to a document stored locally by the interface automated testing platform and used to clearly record all interface information on a system service, which may be in the form of an excel sheet, a word, or a web page. An automated testing engine can be a tool for conducting automated testing.

具体的,依据构建的数据生成模板以及测试目标接口实际所需的数据量等,构建目标接口的自动化测试数据之后,接口自动化测试平台将目标接口的自动化测试数据存储于指定位置处,并从本地预先存储的接口文档中获取目标接口;而后通过目标接口请求其对应的自动化测试数据,并调用接口自动化测试引擎,以使该自动化测试引擎通过调用具体的dubbo服务,执行该目标接口的自动化测试,并将正确的执行结果保存起来作为基准,使得后面的执行和此次比对,如果正确,则认为案例通过。此外,为了防止案例之间的相互干扰,每执行一个案例都会将主数据库中的所有数据清除。Specifically, according to the constructed data generation template and the actual amount of data required to test the target interface, etc., after the automated test data of the target interface is constructed, the interface automated test platform stores the automated test data of the target interface in the specified location, and from the local Obtain the target interface from the pre-stored interface document; then request its corresponding automated test data through the target interface, and call the interface automated test engine, so that the automated test engine executes the automated test of the target interface by calling the specific dubbo service, And save the correct execution result as a benchmark, so that the subsequent execution is compared with this time, if it is correct, the case is considered to be passed. In addition, to prevent mutual interference between cases, each execution of a case will clear all data in the main database.

本发明实施例提供的技术方案,在需要对目标接口进行测试时,可根据目标接口的修改的编程语句和/或目标接口的数据类型,构造该目标接口的数据生成模板;而后依据所构造的数据生成模板构建该目标接口的自动化测试数据,进而采用所构建的自动化测试数据对目标接口进行自动化测试。本方案,相比于现有的接口自动化测试方案,能够根据不同接口自动构造不同的测试数据,以便进行接口自动化测试使用,无需耗费大量的人力。According to the technical solution provided by the embodiment of the present invention, when the target interface needs to be tested, a data generation template of the target interface can be constructed according to the modified programming statement of the target interface and/or the data type of the target interface; The data generation template constructs the automated test data of the target interface, and then uses the constructed automated test data to perform automated tests on the target interface. Compared with the existing interface automation test solution, this solution can automatically construct different test data according to different interfaces, so as to use the interface automation test without consuming a lot of manpower.

实施例二Embodiment 2

图2为本发明实施例二提供的一种接口自动化测试数据构造方法的流程图,本实施例在上述实施例的基础上,进一步的对根据目标接口的修改的编程语句,构建目标接口的数据生成模板进行解释说明。参见图2,该方法具体包括:FIG. 2 is a flowchart of a method for constructing interface automation test data according to Embodiment 2 of the present invention. On the basis of the above-mentioned embodiment, this embodiment further constructs the data of the target interface according to the modified programming statement of the target interface. Generate templates for explanation. Referring to Figure 2, the method specifically includes:

S210,从编程语句中抽取编程语句模块。S210, extract the programming statement module from the programming statement.

本实施例中,编程语句模块是指从编程语句中提取出的组成该编程语句的主体,可以包括操作函数如insert函数或update函数等,以及操作函数操作的对象或表,以及表的至少一个属性或参数等。In this embodiment, the programming statement module refers to the main body of the programming statement extracted from the programming statement, which may include operation functions such as the insert function or the update function, and the objects or tables operated by the operation functions, and at least one of the tables. properties or parameters, etc.

例如,从嗅探器获取的编程语句为:insert into teacher(id,grade_id,name,t_field1,t_field2)values(1,1,"教师A","教师A字段1","教师A字段2");insert intoteacher(id,grade_id,name,t_field1,t_field2)values(2,1,"教师B","教师B字段1","教师B字段2")。对上述编程语句进行分析,得到操作函数为insert函数,teacher为操作函数操作的表,其对应的属性包括教师id,班级grade_id,name,t_field1,t_field2;对应的编程语句模块为:insert into teacher(id,grade_id,name,t_field1,t_field2)values(id,grade_id,"教师X","教师X字段1","教师X字段2")。For example, the programming statement obtained from the sniffer is: insert into teacher(id, grade_id, name, t_field1, t_field2) values(1, 1, "Teacher A", "Teacher A Field 1", "Teacher A Field 2" ); insert intoteacher(id, grade_id, name, t_field1, t_field2) values(2, 1, "Teacher B", "Teacher B Field 1", "Teacher B Field 2"). After analyzing the above programming statement, it is found that the operation function is the insert function, and the teacher is the table operated by the operation function, and its corresponding attributes include teacher id, class grade_id, name, t_field1, t_field2; the corresponding programming statement module is: insert into teacher( id, grade_id, name, t_field1, t_field2) values(id, grade_id, "Teacher X", "Teacher X Field 1", "Teacher X Field 2").

S220,根据编程语句模块中包括的表以及表的至少一个属性,确定编程语句的关键属性。S220: Determine the key attribute of the programming statement according to the table included in the programming statement module and at least one attribute of the table.

本实施例中,关键属性是指编程语句模块中表的关键参数,对接口的测试结果起关键作用的属性,可以包括一个或多个。由于接口自动化测试时,表的很多属性不是关注的重点,就算不同测试案例属性关联的值相同,也不会对测试结果产生影响。In this embodiment, the key attribute refers to the key parameter of the table in the programming statement module, and may include one or more attributes that play a key role in the test result of the interface. Since many attributes of the table are not the focus of the interface automation test, even if the values associated with the attributes of different test cases are the same, it will not affect the test results.

例如,编程语句模块insert into teacher(id,grade_id,name,t_field1,t_field2)values(id,grade_id,"教师X","教师X字段1","教师X字段2"),表的属性id,grade_id,name,t_field1,t_field2中,name,t_field1,t_field2这三个属性关联的值并不是测试的关注点。因此从编程语句模块中提取出的编程语句的关键属性为:teacherId及gradeId。For example, the programming statement module insert into teacher(id, grade_id, name, t_field1, t_field2) values(id, grade_id, "Teacher X", "Teacher X Field 1", "Teacher X Field 2"), attribute id of the table, In grade_id, name, t_field1, t_field2, the values associated with the three attributes of name, t_field1, and t_field2 are not the focus of the test. Therefore, the key attributes of the programming statement extracted from the programming statement module are: teacherId and gradeId.

S230,依据编程语句模块以及编程语句的关键属性,构建数据生成模板。S230, construct a data generation template according to the programming statement module and the key attributes of the programming statement.

例如,编程语句模块为insert into teacher(id,grade_id,name,t_field1,t_field2)values(id,grade_id,"教师X","教师X字段1","教师X字段2"),编程语句的关键属性为:teacherId及gradeId,构建目标接口的数据生成模板为:insert into teacher(id,grade_id,name,t_field1,t_field2)values([teacherId],[gradeId],"教师X","教师X字段1","教师X字段2")。For example, the programming statement module is insert into teacher(id, grade_id, name, t_field1, t_field2) values(id, grade_id, "Teacher X", "Teacher X Field 1", "Teacher X Field 2"), the key of the programming statement The attributes are: teacherId and gradeId, and the data generation template for building the target interface is: insert into teacher(id, grade_id, name, t_field1, t_field2) values([teacherId], [gradeId], "teacher X", "teacher X field 1 ", "Teacher X Field 2").

S240,依据数据生成模板构建目标接口的自动化测试数据,用于对目标接口进行测试。S240, build automated test data of the target interface according to the data generation template, so as to test the target interface.

具体的,若目标接口的自动化测试数据的数量为10,则可以采用for循环进行自动化测试数据的构造。例如在上面的teacher有10条数据的情况下,则可以采用循环的方式进行自动化测试数据的构造。Specifically, if the number of automated test data of the target interface is 10, a for loop may be used to construct the automated test data. For example, in the case where the teacher above has 10 pieces of data, the automated test data can be constructed in a loop.

示例性的,相同的编程语句模块,所确定的关键属性不同,生成的自动化测试数据也就不同。例如,从编程语句模块insert into teacher(id,grade_id,name,t_field1,t_field2)values(id,grade_id,"教师X","教师X字段1","教师X字段2")中抽取出的关键属性为:teacherId及gradeId,则可以认为所构造的自动化测试数据可以是基于相同的gradeId,不同teacherId构造的数据。Exemplarily, for the same programming statement module, the determined key attributes are different, and the generated automated test data is also different. For example, the key extracted from the programming statement module insert into teacher(id, grade_id, name, t_field1, t_field2) values(id, grade_id, "Teacher X", "Teacher X Field 1", "Teacher X Field 2") If the attributes are: teacherId and gradeId, it can be considered that the constructed automated test data can be data constructed based on the same gradeId and different teacherIds.

若从编程语句模块insert into teacher(id,grade_id,name,t_field1,t_field2)values(id,grade_id,"教师X","教师X字段1","教师X字段2")中抽取的关键属性为teacherId,则可以认为所构造的自动化测试数据可以是基于不同teacherId构造的数据,也不限定班级gradeId是否相同。If the key attributes extracted from the programming statement module insert into teacher(id, grade_id, name, t_field1, t_field2) values(id, grade_id, "Teacher X", "Teacher X Field 1", "Teacher X Field 2") are teacherId, it can be considered that the constructed automated test data can be constructed based on different teacherIds, and does not limit whether the class gradeIds are the same.

本发明实施例提供的技术方案,在需要对目标接口进行测试时,可根据目标接口的修改的编程语句,构造该目标接口的数据生成模板;而后依据所构造的数据生成模板构建该目标接口的自动化测试数据,进而采用所构建的自动化测试数据对目标接口进行自动化测试。本方案,相比于现有的接口自动化测试方案,能够根据不同接口自动构造不同的测试数据,以便进行接口自动化测试使用,无需耗费大量的人力。According to the technical solution provided by the embodiment of the present invention, when the target interface needs to be tested, a data generation template of the target interface can be constructed according to the modified programming statement of the target interface; and then a data generation template of the target interface can be constructed according to the constructed data generation template. Automated test data, and then use the constructed automated test data to perform automated testing on the target interface. Compared with the existing interface automation test solution, this solution can automatically construct different test data according to different interfaces, so as to use the interface automation test without consuming a lot of manpower.

不同接口,若所需测试数据的数据类型相同的情况,则可以共用一个数据生成模板,进而加快了自动化测试的速度。示例性的,根据目标接口的数据类型,构建目标接口的数据生成模板可以包括:若检测到测试目标接口所需的自动化测试数据的数据类型,与本地存储的测试数据的数据类型相同,则将相同数据类型的数据生成模板作为目标接口的数据生成模板。Different interfaces, if the data types of the required test data are the same, can share a data generation template, thereby speeding up the automated test. Exemplarily, according to the data type of the target interface, the data generation template for constructing the target interface may include: if it is detected that the data type of the automated test data required for testing the target interface is the same as the data type of the locally stored test data, then The data generation template of the same data type is used as the data generation template of the target interface.

具体的,接口自动化测试平台在对目标接口进行自动化测试时,则可以检测目标接口所需测试数据的数据类型与本地存储的测试数据的数据类型是否相同,若相同,则可以将相同数据类型的数据生成模板作为目标接口的数据生成模板,构建目标接口的自动化测试数据,或者直接将相同数据类型的测试数据作为目标接口的自动化测试数据。本实施例中,通过在不同接口所需数据类型相同的情况,只需构建一次数据生成模板,即可构造不同即接口的测试数据,进而完成对不同接口的自动化测试,增加了方案的灵活性,也简化了构造数据的复杂度。Specifically, when the interface automated test platform performs automated testing on the target interface, it can detect whether the data type of the test data required by the target interface is the same as the data type of the locally stored test data. The data generation template is used as the data generation template of the target interface to construct the automated test data of the target interface, or directly use the test data of the same data type as the automated test data of the target interface. In this embodiment, when the data types required by different interfaces are the same, the data generation template only needs to be constructed once, and then the test data of different interfaces can be constructed, and the automatic testing of different interfaces can be completed, thereby increasing the flexibility of the solution. , which also simplifies the complexity of constructing data.

实施例三Embodiment 3

图3A为本发明实施例三提供的一种接口自动化测试数据构造方法的流程图,图3B为本发明实施例三提供的一种接口自动化测试系统结构框图。本实施例在上述实施例的基础上,进一步的优化。参见图3A和3B,该方法具体包括:FIG. 3A is a flowchart of a method for constructing interface automated test data according to Embodiment 3 of the present invention, and FIG. 3B is a structural block diagram of an interface automated test system according to Embodiment 3 of the present invention. This embodiment is further optimized on the basis of the above-mentioned embodiment. 3A and 3B, the method specifically includes:

S310,通过嗅探器基于主从数据库同步原理,实时从主数据库获取目标接口的修改的编程语句。S310 , based on the principle of master-slave database synchronization, the sniffer acquires the modified programming statement of the target interface from the master database in real time.

例如,用户在数据操作后台编辑了一条班级数据、一条教师数据及两条学生数据如表1至表3所示,其中,表2和表3中的grade_id为班级id,对应grade表id,并进行数据操作转化为SQL语句存储为数据库中,该数据库相当于主数据库;嗅探器作为伪装从数据库,基于主从数据库同步原理,实时从主数据库中嗅探目标接口的修改的SQL语句,并将嗅探到的SQL语句传输至接口自动化测试平台的数据操作SQL中。For example, the user edits one class data, one teacher data and two student data in the data operation background as shown in Table 1 to Table 3, where grade_id in Table 2 and Table 3 is the class id, corresponding to the grade table id, and Data operations are converted into SQL statements and stored in a database, which is equivalent to the main database; the sniffer acts as a disguised slave database, based on the principle of master-slave database synchronization, sniffs the modified SQL statements of the target interface from the master database in real time, and then The sniffed SQL statement is transmitted to the data operation SQL of the interface automation test platform.

嗅探器嗅探到的SQL语句或存储于数据操作SQL中的SQL语句为:The SQL statement sniffed by the sniffer or the SQL statement stored in the data manipulation SQL is:

insert into grade(id,name,c_field1,c_field_2)values(1,"班级A","班级字段1","班级字段2");insert into grade(id, name, c_field1, c_field_2) values(1, "Class A", "Class Field 1", "Class Field 2");

insert into teacher(id,grade_id,name,t_field1,t_field2)values(1,1,"教师A","教师A字段1","教师A字段2");insert into teacher(id, grade_id, name, t_field1, t_field2) values(1, 1, "Teacher A", "Teacher A Field 1", "Teacher A Field 2");

insert into student(id,grade_id,name,t_field1,t_field2)values(1,1,"学生A","学生A字段1","学生A字段2");insert into student(id, grade_id, name, t_field1, t_field2) values(1, 1, "Student A", "Student A Field 1", "Student A Field 2");

insert into student(id,grade_id,name,t_field1,t_field2)values(2,1,"学生B","学生B字段1","学生B字段2")。insert into student(id, grade_id, name, t_field1, t_field2) values(2, 1, "student B", "student B field 1", "student B field 2").

表1 grade表Table 1 grade table

idid 11 namename 班级Aclass A c_field1c_field1 班级字段1class field 1 c_field2c_field2 班级字段2class field 2

表2 teacher表table 2 teacher table

idid 11 grade_idgrade_id 11 namename 教师Ateacher A t_field1t_field1 教师A字段1Faculty A Field 1 t_field2t_field2 教师A字段2Teacher A Field 2

表3 student表table 3 student table

idid 11 22 grade_idgrade_id 11 11 namename 学生Astudent A 学生Bstudent B s_field1s_field1 学生A字段1Student A Field 1 学生B字段1Student B Field 1 s_field2s_field2 学生A字段2Student A Field 2 学生B字段2Student B Field 2

S320,根据目标接口的修改的编程语句,构建目标接口的数据生成模板。S320, construct a data generation template of the target interface according to the modified programming statement of the target interface.

具体的,接口自动化测试平台从数据操作SQL中获取目标接口的修改的SQL语句,并对其进行语义语法分析,从中抽取编程语模块及关键属性。对于上述修改的SQL语句,抽取的关键属性可以为:gradeId,teacherId,studentId。而后基于抽取的编程语句及关键属性构建目标接口的数据生成模板。Specifically, the interface automation test platform obtains the modified SQL statement of the target interface from the data operation SQL, performs semantic syntax analysis on it, and extracts programming language modules and key attributes from it. For the above modified SQL statement, the extracted key attributes can be: gradeId, teacherId, studentId. Then, the data generation template of the target interface is constructed based on the extracted programming statements and key attributes.

例如,对于班级grade而言,构建的数据生成模板为:insert into grade(id,name,c_field1,c_field_2)values([gradeId],"班级A","班级字段1","班级字段2");For example, for class grade, the constructed data generation template is: insert into grade(id, name, c_field1, c_field_2) values([gradeId], "class A", "class field 1", "class field 2") ;

对于教师teacher而言,构建的数据生成模板为:insert into teacher(id,grade_id,name,t_field1,t_field2)values([teacherId],[gradeId],"教师A","教师A字段1","教师A字段2");For teacher teacher, the constructed data generation template is: insert into teacher(id, grade_id, name, t_field1, t_field2) values([teacherId], [gradeId], "teacher A", "teacher A field 1", " Teacher A Field 2");

对于学生student而言,构建的数据生成模板为:insert into student(id,grade_id,name,t_field1,t_field2)values([studentId]+N,1,"学生N","学生N字段1","学生N字段2")。其中,N的取值为0至N的正整数。For student students, the constructed data generation template is: insert into student(id, grade_id, name, t_field1, t_field2) values([studentId]+N, 1, "student N", "student N field 1", " Student N Field 2"). The value of N is a positive integer from 0 to N.

S330,依据数据生成模板构建目标接口的自动化测试数据,用于对目标接口进行测试。S330: Build automated test data of the target interface according to the data generation template, so as to test the target interface.

例如,在构造出学生的数据生成模板后,可根据实际测试中对学生数据的需求,采用循环的方式进行自动化测试数据的构造。For example, after constructing the student's data generation template, the automated test data can be constructed in a circular manner according to the demand for the student's data in the actual test.

S340,从本地存储的接口文档中获取目标接口。S340, obtain the target interface from the locally stored interface document.

S350,通过目标接口请求自动化测试数据,并调用接口自动化测试引擎,执行目标接口的自动化测试。S350 , request the automated test data through the target interface, and call the interface automated test engine to execute the automated test of the target interface.

本发明实施例提供的技术方案,在需要对目标接口进行测试时,可根据目标接口的修改的编程语句,构造该目标接口的数据生成模板;而后依据所构造的数据生成模板构建该目标接口的自动化测试数据,进而采用所构建的自动化测试数据对目标接口进行自动化测试。本方案,相比于现有的接口自动化测试方案,能够根据不同接口自动构造不同的测试数据,以便进行接口自动化测试使用,无需耗费大量的人力。According to the technical solution provided by the embodiment of the present invention, when the target interface needs to be tested, a data generation template of the target interface can be constructed according to the modified programming statement of the target interface; and then a data generation template of the target interface can be constructed according to the constructed data generation template. Automated test data, and then use the constructed automated test data to perform automated testing on the target interface. Compared with the existing interface automation test solution, this solution can automatically construct different test data according to different interfaces, so as to use the interface automation test without consuming a lot of manpower.

实施例四Embodiment 4

图4为本发明实施例四提供的一种接口自动化测试数据构造装置的结构框图,该装置可执行本发明任意实施例所提供的接口自动化测试数据构造方法,具备执行方法相应的功能模块和有益效果。如图4所示,该装置可以包括:FIG. 4 is a structural block diagram of an interface automated test data construction apparatus provided in Embodiment 4 of the present invention. The apparatus can execute the interface automated test data construction method provided by any embodiment of the present disclosure, and has corresponding functional modules and beneficial functions for the execution method. Effect. As shown in Figure 4, the apparatus may include:

模板构建模块410,用于根据目标接口的修改的编程语句和/或目标接口的数据类型,构建目标接口的数据生成模板;A template construction module 410, configured to construct a data generation template of the target interface according to the modified programming statement of the target interface and/or the data type of the target interface;

测试数据生成模块420,用于依据数据生成模板构建目标接口的自动化测试数据,用于对目标接口进行测试。The test data generation module 420 is used for constructing the automated test data of the target interface according to the data generation template, so as to test the target interface.

本发明实施例提供的技术方案,在需要对目标接口进行测试时,可根据目标接口的修改的编程语句和/或目标接口的数据类型,构造该目标接口的数据生成模板;而后依据所构造的数据生成模板构建该目标接口的自动化测试数据,进而采用所构建的自动化测试数据对目标接口进行自动化测试。本方案,相比于现有的接口自动化测试方案,能够根据不同接口自动构造不同的测试数据,以便进行接口自动化测试使用,无需耗费大量的人力。According to the technical solution provided by the embodiment of the present invention, when the target interface needs to be tested, a data generation template of the target interface can be constructed according to the modified programming statement of the target interface and/or the data type of the target interface; The data generation template constructs the automated test data of the target interface, and then uses the constructed automated test data to perform automated tests on the target interface. Compared with the existing interface automation test solution, this solution can automatically construct different test data according to different interfaces, so as to use the interface automation test without consuming a lot of manpower.

示例性的,上述装置还可以包括:Exemplarily, the above-mentioned apparatus may further include:

编程语句获取模块,用于在根据目标接口的修改的编程语句之前,通过嗅探器基于主从数据库同步原理,实时从主数据库获取目标接口的修改的编程语句。The programming statement obtaining module is used to obtain the modified programming statement of the target interface from the master database in real time through the sniffer based on the principle of master-slave database synchronization before the modified programming statement according to the target interface.

示例性的,模板构建模块410还可以用于:Exemplarily, template building module 410 may also be used to:

从编程语句中抽取编程语句模块;Extract programming statement modules from programming statements;

根据编程语句模块中包括的对象以及对象的至少一个属性,确定编程语句的关键属性;Determine the key attribute of the programming statement according to the object included in the programming statement module and at least one attribute of the object;

依据编程语句模块以及编程语句的关键属性,构建数据生成模板。According to the programming statement module and the key attributes of the programming statement, construct the data generation template.

示例性的,模板构建模块410还可以用于:Exemplarily, template building module 410 may also be used to:

若检测到测试目标接口所需的自动化测试数据的数据类型,与本地存储的测试数据的数据类型相同,则将相同数据类型的数据生成模板作为目标接口的数据生成模板。If it is detected that the data type of the automated test data required to test the target interface is the same as the data type of the locally stored test data, the data generation template of the same data type is used as the data generation template of the target interface.

示例性的,上述装置还可以包括:Exemplarily, the above-mentioned apparatus may further include:

目标接口获取模块,用于在依据数据生成模板构建目标接口的自动化测试数据之后,从本地存储的接口文档中获取目标接口;The target interface obtaining module is used to obtain the target interface from the locally stored interface document after the automated test data of the target interface is constructed according to the data generation template;

测试模块,用于通过目标接口请求自动化测试数据,并调用接口自动化测试引擎,执行目标接口的自动化测试。The test module is used to request automated test data through the target interface, and call the interface automated test engine to execute the automated test of the target interface.

实施例五Embodiment 5

图5为本发明实施例五提供的一种平台的结构示意图。图5示出了适于用来实现本发明实施方式的示例性平台12的框图。图5显示的平台12仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。FIG. 5 is a schematic structural diagram of a platform according to Embodiment 5 of the present invention. Figure 5 shows a block diagram of an exemplary platform 12 suitable for use in implementing embodiments of the present invention. The platform 12 shown in FIG. 5 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present invention.

如图5所示,该平台12以通用计算设备的形式表现。该平台12的组件可以包括但不限于:一个或者多个处理器或者处理单元16,系统存储器28,连接不同系统组件(包括系统存储器28和处理单元16)的总线18。As shown in FIG. 5, the platform 12 takes the form of a general-purpose computing device. Components of the platform 12 may include, but are not limited to, one or more processors or processing units 16, a system memory 28, and a bus 18 that connects the various system components, including the system memory 28 and the processing unit 16.

总线18表示几类总线结构中的一种或多种,包括存储器总线或者存储器控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(ISA)总线,微通道体系结构(MAC)总线,增强型ISA总线、视频电子标准协会(VESA)局域总线以及外围组件互连(PCI)总线。Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. By way of example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect ( PCI) bus.

平台12典型地包括多种计算机系统可读介质。这些介质可以是任何能够被平台12访问的可用介质,包括易失性和非易失性介质,可移动的和不可移动的介质。Platform 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by platform 12, including both volatile and non-volatile media, removable and non-removable media.

系统存储器28可以包括易失性存储器形式的计算机系统可读介质,例如随机存取存储器(RAM)30和/或高速缓存存储器32。平台12可以进一步包括其它可移动/不可移动的、易失性/非易失性计算机系统存储介质。仅作为举例,存储系统34可以用于读写不可移动的、非易失性磁介质(图5未显示,通常称为“硬盘驱动器”)。尽管图5中未示出,可以提供用于对可移动非易失性磁盘(例如“软盘”)读写的磁盘驱动器,以及对可移动非易失性光盘(例如CD-ROM,DVD-ROM或者其它光介质)读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据介质接口与总线18相连。系统存储器28可以包括至少一个程序产品,该程序产品具有一组(例如至少一个)程序模块,这些程序模块被配置以执行本发明各实施例的功能。System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and/or cache memory 32 . Platform 12 may further include other removable/non-removable, volatile/non-volatile computer system storage media. For example only, storage system 34 may be used to read and write to non-removable, non-volatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard disk drive"). Although not shown in Figure 5, a disk drive may be provided for reading and writing to removable non-volatile magnetic disks (eg "floppy disks"), as well as removable non-volatile optical disks (eg CD-ROM, DVD-ROM) or other optical media) to read and write optical drives. In these cases, each drive may be connected to bus 18 through one or more data media interfaces. System memory 28 may include at least one program product having a set (eg, at least one) of program modules configured to perform the functions of various embodiments of the present invention.

具有一组(至少一个)程序模块42的程序/实用工具40,可以存储在例如系统存储器28中,这样的程序模块42包括但不限于操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。程序模块42通常执行本发明所描述的实施例中的功能和/或方法。A program/utility 40 having a set (at least one) of program modules 42, which may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and programs Data, each or some combination of these examples may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods of the described embodiments of the present invention.

平台12也可以与一个或多个外部设备14(例如键盘、指向设备、显示器24等)通信,还可与一个或者多个使得用户能与该设备交互的设备通信,和/或与使得该平台12能与一个或多个其它计算设备进行通信的任何设备(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口22进行。并且,平台12还可以通过网络适配器20与一个或者多个网络(例如局域网(LAN),广域网(WAN)和/或公共网络,例如因特网)通信。如图所示,网络适配器20通过总线18与平台12的其它模块通信。应当明白,尽管图中未示出,可以结合平台12使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RAID系统、磁带驱动器以及数据备份存储系统等。Platform 12 may also communicate with one or more external devices 14 (eg, keyboards, pointing devices, display 24, etc.), with one or more devices that enable a user to interact with the devices, and/or with the platform 12 Any device (eg, network card, modem, etc.) capable of communicating with one or more other computing devices. Such communication may take place through input/output (I/O) interface 22 . Also, the platform 12 may communicate with one or more networks (eg, a local area network (LAN), a wide area network (WAN), and/or a public network such as the Internet) through a network adapter 20 . As shown, network adapter 20 communicates with other modules of platform 12 via bus 18 . It should be understood that, although not shown, other hardware and/or software modules may be used in conjunction with platform 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and Data backup storage system, etc.

处理单元16通过运行存储在系统存储器28中的程序,从而执行各种功能应用以及数据处理,例如实现本发明实施例所提供的接口自动化测试数据构造方法。The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28 , for example, implements the interface automated test data construction method provided by the embodiments of the present invention.

实施例六Embodiment 6

本发明实施例六还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时可实现上述实施例中任一所述的接口自动化测试数据构造方法。Embodiment 6 of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method for constructing interface automation test data described in any of the foregoing embodiments can be implemented.

本发明实施例的计算机存储介质,可以采用一个或多个计算机可读的介质的任意组合。计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质。计算机可读存储介质例如可以是但不限于:电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本文件中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。The computer storage medium in the embodiments of the present invention may adopt any combination of one or more computer-readable mediums. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination of the above. More specific examples (a non-exhaustive list) of computer readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。A computer-readable signal medium may include a propagated data signal in baseband or as part of a carrier wave, with computer-readable program code embodied thereon. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device .

计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。Program code embodied on a computer readable medium may be transmitted using any suitable medium including, but not limited to, wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

可以以一种或多种程序设计语言或其组合来编写用于执行本发明操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络包括局域网(LAN)或广域网(WAN)连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for carrying out operations of the present invention may be written in one or more programming languages, including object-oriented programming languages—such as Java, Smalltalk, C++, but also conventional Procedural programming language - such as the "C" language or similar programming language. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. Where a remote computer is involved, the remote computer may be connected to the user's computer through any kind of network including a local area network (LAN) or wide area network (WAN), or may be connected to an external computer (eg, using an Internet service provider to connect over the Internet) .

上述实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments are only for description, and do not represent the advantages and disadvantages of the embodiments.

本领域普通技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个计算装置上,或者分布在多个计算装置所组成的网络上,可选地,他们可以用计算机装置可执行的程序代码来实现,从而可以将它们存储在存储装置中由计算装置来执行,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件的结合。Those of ordinary skill in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device, and they can be centralized on a single computing device, or distributed on a network composed of multiple computing devices. Optionally, they may be implemented in program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be separately fabricated into individual integrated circuit modules, or a plurality of modules of them Or the steps are made into a single integrated circuit module to realize. As such, the present invention is not limited to any specific combination of hardware and software.

本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间的相同或相似的部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments may be referred to each other.

以上所述仅为本发明的优选实施例,并不用于限制本发明,对于本领域技术人员而言,本发明可以有各种改动和变化。凡在本发明的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims (7)

1.一种接口自动化测试数据构造方法,其特征在于,包括:1. an interface automation test data construction method, is characterized in that, comprises: 基于目标接口所需测试数据的数据类型与本地存储的测试数据的数据类型的匹配情况,根据目标接口的修改的编程语句和/或目标接口的数据类型,构建目标接口的数据生成模板;Based on the matching situation between the data type of the test data required by the target interface and the data type of the locally stored test data, according to the modified programming statement of the target interface and/or the data type of the target interface, construct the data generation template of the target interface; 依据所述数据生成模板构建目标接口的自动化测试数据,用于对所述目标接口进行测试;constructing the automated test data of the target interface according to the data generation template, for testing the target interface; 根据目标接口的修改的编程语句,构建目标接口的数据生成模板,包括:According to the modified programming statement of the target interface, construct the data generation template of the target interface, including: 从所述编程语句中抽取编程语句模块;Extract a programming statement module from the programming statement; 根据所述编程语句模块中包括的表以及表的至少一个属性,确定编程语句的关键属性;Determine the key attribute of the programming statement according to the table included in the programming statement module and at least one attribute of the table; 依据所述编程语句模块以及所述编程语句的关键属性,构建所述数据生成模板;constructing the data generation template according to the programming statement module and the key attributes of the programming statement; 关键属性是编程语句模块中表的关键参数,对接口的测试结果起关键作用的属性,其中关键属性包括一个或多个;The key attribute is the key parameter of the table in the programming statement module, which plays a key role in the test result of the interface, and the key attribute includes one or more; 根据目标接口的数据类型,构建目标接口的数据生成模板,包括:According to the data type of the target interface, construct the data generation template of the target interface, including: 若检测到测试目标接口所需的自动化测试数据的数据类型,与本地存储的测试数据的数据类型相同,则将相同数据类型的数据生成模板作为目标接口的数据生成模板。If it is detected that the data type of the automated test data required to test the target interface is the same as the data type of the locally stored test data, the data generation template of the same data type is used as the data generation template of the target interface. 2.根据权利要求1所述的方法,其特征在于,构建目标接口的数据生成模板之前,还包括:2. method according to claim 1 is characterized in that, before the data generation template of building target interface, also comprises: 通过嗅探器基于主从数据库同步原理,实时从主数据库获取目标接口的修改的编程语句。Based on the principle of master-slave database synchronization, the sniffer obtains the modified programming statements of the target interface from the master database in real time. 3.根据权利要求1所述的方法,其特征在于,依据所述数据生成模板构建目标接口的自动化测试数据之后,还包括:3. The method according to claim 1, characterized in that, after the automated test data of the target interface is constructed according to the data generation template, further comprising: 从本地存储的接口文档中获取所述目标接口;Obtain the target interface from the locally stored interface document; 通过所述目标接口请求所述自动化测试数据,并调用接口自动化测试引擎,执行所述目标接口的自动化测试。The automated test data is requested through the target interface, and the interface automated test engine is invoked to execute the automated test of the target interface. 4.一种接口自动化测试数据构造装置,其特征在于,包括:4. an interface automatic test data construction device, is characterized in that, comprises: 模板构建模块,用于基于目标接口所需测试数据的数据类型与本地存储的测试数据的数据类型的匹配情况,根据目标接口的修改的编程语句和/或目标接口的数据类型,构建目标接口的数据生成模板;The template building module is used to construct the target interface based on the matching of the data type of the test data required by the target interface and the data type of the locally stored test data, according to the modified programming statement of the target interface and/or the data type of the target interface. Data generation template; 测试数据生成模块,用于依据所述数据生成模板构建目标接口的自动化测试数据,用于对所述目标接口进行测试;a test data generation module for constructing automated test data of a target interface according to the data generation template, for testing the target interface; 模板构建模块,还用于:Template building blocks, also used to: 从编程语句中抽取编程语句模块;Extract programming statement modules from programming statements; 根据编程语句模块中包括的对象以及对象的至少一个属性,确定编程语句的关键属性;Determine the key attribute of the programming statement according to the object included in the programming statement module and at least one attribute of the object; 依据编程语句模块以及编程语句的关键属性,构建数据生成模板;According to the programming statement module and the key attributes of the programming statement, construct the data generation template; 若检测到测试目标接口所需的自动化测试数据的数据类型,与本地存储的测试数据的数据类型相同,则将相同数据类型的数据生成模板作为目标接口的数据生成模板;If it is detected that the data type of the automated test data required to test the target interface is the same as the data type of the locally stored test data, the data generation template of the same data type is used as the data generation template of the target interface; 关键属性是编程语句模块中表的关键参数,对接口的测试结果起关键作用的属性,其中关键属性包括一个或多个。The key attribute is the key parameter of the table in the programming statement module, and the attribute that plays a key role in the test result of the interface, wherein the key attribute includes one or more. 5.根据权利要求4所述的装置,其特征在于,还包括:5. The apparatus of claim 4, further comprising: 编程语句获取模块,用于在根据目标接口的修改的编程语句之前,通过嗅探器基于主从数据库同步原理,实时从主数据库获取目标接口的修改的编程语句。The programming statement obtaining module is used to obtain the modified programming statement of the target interface from the master database in real time through the sniffer based on the principle of master-slave database synchronization before the modified programming statement according to the target interface. 6.一种平台,其特征在于,所述平台包括:6. A platform, characterized in that the platform comprises: 一个或多个处理器;one or more processors; 存储装置,用于存储一个或多个程序;a storage device for storing one or more programs; 当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-3中任一所述的接口自动化测试数据构造方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the interface automated test data construction method according to any one of claims 1-3. 7.一种存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如权利要求1-3中任一所述的接口自动化测试数据构造方法。7. A storage medium on which a computer program is stored, characterized in that, when the program is executed by a processor, the method for constructing interface automation test data according to any one of claims 1-3 is implemented.
CN201811359053.7A 2018-11-15 2018-11-15 Interface automation test data construction method, device, platform and storage medium Active CN109522228B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811359053.7A CN109522228B (en) 2018-11-15 2018-11-15 Interface automation test data construction method, device, platform and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811359053.7A CN109522228B (en) 2018-11-15 2018-11-15 Interface automation test data construction method, device, platform and storage medium

Publications (2)

Publication Number Publication Date
CN109522228A CN109522228A (en) 2019-03-26
CN109522228B true CN109522228B (en) 2022-06-24

Family

ID=65778043

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811359053.7A Active CN109522228B (en) 2018-11-15 2018-11-15 Interface automation test data construction method, device, platform and storage medium

Country Status (1)

Country Link
CN (1) CN109522228B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112286783A (en) * 2019-07-23 2021-01-29 北京中关村科金技术有限公司 Method and device for generating database insert statement and system testing
CN111190811A (en) * 2019-12-05 2020-05-22 东方微银科技(北京)有限公司 Method, device, equipment and storage medium for testing resource allocation system
CN111611174B (en) * 2020-05-28 2023-08-11 北京火山引擎科技有限公司 Method and device for constructing test data, computer equipment and storage medium
CN112181832B (en) * 2020-09-28 2023-04-11 中国平安财产保险股份有限公司 Test data generation method and device, computer equipment and storage medium
CN112199300B (en) * 2020-11-13 2022-08-19 新华三大数据技术有限公司 Interface testing method and device, electronic equipment and storage medium
CN115437903A (en) * 2021-06-01 2022-12-06 京东科技控股股份有限公司 Interface test method, device, apparatus, storage medium, and program
CN113535543A (en) * 2021-06-09 2021-10-22 卡斯柯信号有限公司 Test data generation method, device, equipment and medium for TACS system
CN113568838B (en) * 2021-08-02 2025-02-07 工银科技有限公司 Test data generation method, device, equipment, storage medium and program product
CN115328785A (en) * 2022-08-16 2022-11-11 中国银行股份有限公司 A data filling method, device and related products
CN116627851B (en) * 2023-07-24 2023-10-20 恒生电子股份有限公司 Interface testing method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101430661B (en) * 2008-11-18 2011-06-01 阿里巴巴集团控股有限公司 Method, system and apparatus for test data batch generation
CN104123227A (en) * 2014-08-13 2014-10-29 广东电网公司信息中心 Method for automatically generating testing cases
CN106649082A (en) * 2016-09-05 2017-05-10 中国银行股份有限公司 Test data generation method and apparatus

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10037266B2 (en) * 2016-04-01 2018-07-31 Sony Interactive Entertainment America Llc Game stream fuzz testing and automation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101430661B (en) * 2008-11-18 2011-06-01 阿里巴巴集团控股有限公司 Method, system and apparatus for test data batch generation
CN104123227A (en) * 2014-08-13 2014-10-29 广东电网公司信息中心 Method for automatically generating testing cases
CN106649082A (en) * 2016-09-05 2017-05-10 中国银行股份有限公司 Test data generation method and apparatus

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向网络游戏的自动化接口测试系统设计;周绍凯 等;《现代计算机》;20180430(第10期);全文 *

Also Published As

Publication number Publication date
CN109522228A (en) 2019-03-26

Similar Documents

Publication Publication Date Title
CN109522228B (en) Interface automation test data construction method, device, platform and storage medium
US9934129B1 (en) Determining application test results using screenshot metadata
CN108519967B (en) Chart visualization method and device, terminal and storage medium
US10423445B2 (en) Composing and executing workflows made up of functional pluggable building blocks
US8490050B2 (en) Automatic generation of user interfaces
US8745641B1 (en) Automatic verification and anomaly detection in a representational state transfer (REST) application programming interface
CN107665171B (en) Automatic regression testing method and device
US11263113B2 (en) Cloud application to automatically detect and solve issues in a set of code base changes using reinforcement learning and rule-based learning
CN109558525B (en) Test data set generation method, device, equipment and storage medium
CN113392024B (en) Method, device, equipment and medium for testing storage process
CN111026670B (en) Test case generation method, test case generation device and storage medium
CN108459850B (en) Method, device and system for generating test script
US20200104246A1 (en) Continuous automation with test suite engine
JP2016105270A (en) Lean product modeling system and method
US20250077204A1 (en) Software library usage optimization
CN111831542B (en) API application debugging method and device, storage medium
CN113778897A (en) Automatic test method, device, equipment and storage medium of interface
CN104899141A (en) Test case selecting and expanding method facing network application system
CN113886485A (en) Data processing method, apparatus, electronic device, system and storage medium
CN114356322B (en) Communication mapping method, device, equipment and storage medium for device configuration
CN116955140A (en) SDK test method, device, equipment and storage medium
CN113641628B (en) Data quality detection method, device, equipment and storage medium
CN108595656B (en) Data processing method and system
CN114490337A (en) Commissioning method, commissioning platform, equipment and storage medium
CN112115052A (en) Automatic walkthrough method and system for graphical user interface and interface walkthrough tool

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