WO2019153472A1 - Automated interface testing method, device, equipment, and storage medium - Google Patents

Automated interface testing method, device, equipment, and storage medium Download PDF

Info

Publication number
WO2019153472A1
WO2019153472A1 PCT/CN2018/081545 CN2018081545W WO2019153472A1 WO 2019153472 A1 WO2019153472 A1 WO 2019153472A1 CN 2018081545 W CN2018081545 W CN 2018081545W WO 2019153472 A1 WO2019153472 A1 WO 2019153472A1
Authority
WO
WIPO (PCT)
Prior art keywords
test
json
test case
interface
automatically
Prior art date
Application number
PCT/CN2018/081545
Other languages
French (fr)
Chinese (zh)
Inventor
贾江丽
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019153472A1 publication Critical patent/WO2019153472A1/en

Links

Images

Classifications

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

Definitions

  • This application belongs to the field of software testing, and more specifically to an interface automatic test method, apparatus, device and storage medium.
  • Interface testing is a test of the interface between test system components. It is mainly used to detect the interaction between external systems and systems and internal subsystems, focusing on data exchange, transfer and control management processes, and inter-system Mutual logical dependencies, etc.
  • the present application provides an interface automatic test method, apparatus, device, and storage medium, which can improve the degree of automation and the efficiency of testing.
  • a first aspect of the present application provides an interface automation testing method, the method comprising the following steps:
  • the second party of the present application provides an interface automatic testing device, the device comprising:
  • a sample generation module an interface document for acquiring different interfaces, and automatically generating a Json test sample of different interfaces according to the interface document;
  • a script generation module configured to automatically generate a test case template according to the Json test sample, automatically generate a Json test case according to the test case template, and automatically generate a Jmeter test script according to the Json test case;
  • the interface test module is configured to generate an integrated test case according to the Jmeter test script, invoke the integrated test case by using a test tool, and trigger the Jmeter test script to test by the integrated test case, and automatically output the test result.
  • a third aspect of the present application provides a terminal device including a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, wherein the processor executes the computer The following steps are implemented when the instructions are readable:
  • a fourth aspect of the present application provides one or more non-transitory readable storage mediums storing computer readable instructions, the computer readable instructions being executed by one or more processors such that the one or more processes Perform the following steps:
  • the interface automatic test method, device, device and storage medium provided by the application automatically generate test samples, test sample sets, test case templates, Json test cases, Jmeter test scripts and integrated test cases through interface documents, and then pass the test.
  • the tool calls the Jmeter test script to test, automatically outputs the test result, and the degree of automation is high, which improves the efficiency of the test.
  • a new test script can be quickly generated for testing, and the interface test process is easy to maintain.
  • FIG. 1 is a flowchart of an interface automatic testing method according to an embodiment of the present application
  • FIG. 2 is a diagram showing an example of a request message and a response message in the embodiment shown in FIG. 1;
  • FIG. 3 is a diagram showing an example of a test sample set of the embodiment shown in FIG. 1;
  • FIG. 4 is a diagram showing an example of a test case template of the embodiment shown in FIG. 1;
  • Figure 5 is a flow chart showing the sub-steps of the step S103 of the embodiment shown in Figure 1;
  • FIG. 6 is a schematic structural diagram of an interface automatic testing apparatus according to another embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a terminal device according to another embodiment of the present disclosure.
  • FIG. 1 is a flowchart of an interface automatic testing method provided by an embodiment of the present application.
  • Interface testing refers to testing the application program interface (API), including two types: one is the external interface, that is, the call between the system and the system, such as the interface call between the Taobao order system and the payment system; the other is the internal interface. It refers to the call of the upper layer service to the lower layer service or the call between the service and the service.
  • API application program interface
  • the business layer calls the data layer, the business layer is the upper layer service, the data layer is the lower layer service, and for example, the goods are selected and the order is created.
  • the role of interface testing is to check whether the data exchange, delivery, and management processes between interfaces are normal.
  • the interface automatic testing method provided by the embodiment of the present application includes the following steps:
  • Step S101 Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document.
  • the interface document refers to the interface parameters provided by the developer of the application for different interface tests.
  • the interface document mainly includes four parts of the request method, the URI, the request parameter and the return parameter.
  • the request method usually includes: GET/PUT/POST/DELETE; the URI is a Uniform Resource Identifier (URI), which is a string for identifying the name of an Internet resource, starting with /a, if you need to log in.
  • the interface to be called (such as adding, modifying; user information of the foreground, fund information, etc.) needs to add /u, ie: /a/u; generally put the table name or the word that can express this interface; request parameters and return Parameters usually include: field, description, type, comment, required or not.
  • the data of the interface document can be called according to the outer field name in the interface description table of an interface document, and a test sample in the Json format is automatically generated.
  • the interface description table refers to a table that generalizes the interface, including the name, field name, type, format, and the like of the interface document information; the outer field name refers to the field of the outermost interface in the interface document.
  • the information of the inspector is used as an outer field name, and the name, gender, ID number, etc. of the inspected person can be called from the interface document according to the information of the inspected person.
  • Information data is used as an outer field name, and the name, gender, ID number, etc.
  • the names of the outer field names of the interface description document mainly include: system code, salesperson code, effective date, hierarchical information, information of the inspected person, the total number of inspected persons, and the like.
  • the Json test sample generation tool can be used to call various information data in the interface document through these outer field names.
  • the JSON format is generated by the test sample, mainly because the data between the interfaces is transmitted in the Json format; optionally, the Json test sample automatic generation tool is generated by the VBA script.
  • the test sample of the Json format mainly includes a request message and a response message.
  • FIG. 2 shows an example diagram of the request message and the response message, as shown in FIG. 2(a)
  • the request message The request method in the text is a method for sending a request to the interface, requesting the field name as the outer field name, and calling the data of the interface document according to the outer field name to make a specific request for the interface, “non-empty”, “length”, “ The type is to limit the format of the request message; as shown in Figure 2(b), the returned result in the response message is the result returned by the interface, and the return field name is the outer field name, according to the outer field name.
  • the data of the calling interface document returns the specific result.
  • Non-empty "length”, and “type” are used to define the format of the response message.
  • the interface receives the request packet, searches for the resource to be requested in the system or the platform according to the request packet, and converts the resource into a response packet after the resource is found.
  • Step S102 automatically generate a test case template according to the Json test sample, and automatically generate a Json test case according to the test case template, and then automatically generate a Jmeter test script according to the Json test case.
  • Interface testing includes testing many different interfaces. For example, in the interface test for purchasing insurance, you need to test the interfaces such as "customer authentication”, “insurance information verification”, “mobile phone number change”, “insured” and so on. Therefore, the Json test samples of all interfaces can be gathered together to generate a Json test sample set, which facilitates centralized management of interface tests and subsequent integration tests, making the interface test process more intuitive.
  • FIG. 3 shows an example diagram of a test sample set. As shown in FIG.
  • the interface test includes testing of N interfaces
  • the interface name refers to a process of the system under test
  • the interface description means that the interface name is The corresponding process direction in the system
  • the data following the interface description is the request message and the response message corresponding to the Json sample generated by each interface document.
  • Json test sample is automatically generated according to each interface document, and then all Json test samples are grouped in a table to form a Json test sample set.
  • the test case template mainly includes the request message and the result verification corresponding to the request message, please refer to FIG. It shows an example diagram of a test case template.
  • Figure 4 is an example of a Json test sample with the request field name "Customer Authentication", where the call field name is a request with the request field name "Customer Authentication”.
  • the field name called by the method parameter, including "customer name”, “gender”, "date of birth”, “document type”, “document number”, and then set the result verification according to the data of each call field name.
  • the result is a security test on the interface, so that the interface can run normally in various scenarios.
  • the result verification can be set according to the pre-defined interface test strategy and actual situation.
  • Jmeter test case generation tool After inputting the value verified by the result, click the Json test case generation tool, you can generate a JSON format test case based on the test case module of an interface, and then click the Jmeter test case generation tool to generate the Jmeter format according to the Json format test case.
  • the test script, jmx. is the suffix file; the Jmeter test script named after the interface name is generated in the preset storage path while generating the test script, for example, according to the "customer authentication" interface in the predetermined storage path (eg D hard drive) Generate a Jmeter test script for "Customer Authentication.jmx".
  • Jmeter is a Java-based stress testing tool developed by the Apache organization, which can be applied to interface testing.
  • the Json test case generation tool and the Jmeter test case generation tool are also generated by VBA scripts.
  • Step S103 generating an integrated test case according to the Jmeter test script, calling the integration test case through the test tool, and triggering the Jmeter test script to test through the integrated test case, and automatically outputting the test result.
  • the integration test case refers to the integration of all modules according to the design requirements (such as according to the structure diagram) into subsystems or systems for integration testing; the role of integration testing is that each unit and module can work normally. Under the premise, verify that the connection works for global operation.
  • test cases are written into the integration test case of the integration test tool so that integration tests can be performed.
  • the integration test tool uses the Ant integration test tool.
  • Ant is a tool that automates the steps of compiling, testing, and deploying software. Most of them are used for software development in the Java environment.
  • step S103 the following sub-steps are further included:
  • Step S1031 Generate an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script.
  • Step S1032 running the Ant integration test tool to call the integration test case, so that the integration test case triggers the Jmeter test script to test through the storage path of the Jmeter test script.
  • step S1033 the test response message is automatically compared with the response message, and the test result is output according to the result output path.
  • BUILD.xml create an integration test case named BUILD.xml, generate a test case according to the format of the Ant integration tool, and input the storage path of the Jmeter test script and the test result path to be output into the BUILD.xml integration test case.
  • test result is that the response message obtained after running the test is automatically compared with the response message in the Json sample. If the test result is consistent with the expected result, the interface meets the usage requirements and can be used normally, if the test result and expectation If the results are inconsistent, the interface is faulty and needs to be further improved.
  • the Jmeter test tool can be used to directly call the Jmeter test case to perform interface test.
  • Jmeter can only perform interface test on one interface. That is, integration testing cannot be performed, but testing with Jmeter can simulate stress testing by means of concurrent threads, and has better effect on performance testing of interface testing. Therefore, Jmeter can be used to perform interface testing of a single interface before integration. Testing to make interface testing more complete.
  • the performance test mainly includes: response speed, interface fault tolerance, interface load and other performance tests.
  • the specific maintenance process is: obtaining a modified interface document from a developer, and then sequentially generating a Json test sample, a Json test case, and a Jmeter test case according to the modified interface file, and then writing the Jmeter test case.
  • the test tool is called to test the test case and output the test result.
  • the interface automatic test method provided by the embodiment of the present application can make the whole maintenance process relatively simple and high in efficiency.
  • the template automatically generates Json test cases, and then clicks the Jmeter test case generation tool to automatically generate Jmeter test cases.
  • the interface automatic test method provided by the embodiment of the present application automatically generates a test case from the interface document through an automated generation tool, and then uses the integrated test tool to call the test case for interface test, automatically outputs the test result, and verifies the performance and security of the test result.
  • the test case can be automatically generated only by modifying the interface part, and the test cases of other interfaces need not be regenerated, the maintenance process is relatively simple and the efficiency is high;
  • the corresponding automatic data generation tool automatically generates the corresponding transition data, which reduces the requirements of the interface tester, improves the degree of automation, and improves the interface test efficiency.
  • FIG. 6 is a schematic structural diagram of an interface automatic testing apparatus provided by an embodiment of the present application.
  • the interface automation test apparatus 20 includes a sample generation module 201, a script generation module 202, and an interface test module 203.
  • the sample generation module 201 is configured to obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document.
  • the sample generation module 201 can automatically generate a test sample of the Json format according to the outer field name in the interface description table of an interface document by running the Json test sample automatic generation tool, Json.
  • the test samples of the format mainly include request messages and response messages.
  • the Json test sample auto-generation tool is generated by a VBA script.
  • the script generation module 202 is configured to automatically generate a test case template according to the Json test sample, automatically generate a Json test case according to the test case module, and automatically generate a Jmeter test script according to the Json test case.
  • the sample generation module 201 automatically generates a Json test sample according to each interface document, and then the script generation module 202 sets all the Json test samples in a table to form a Json test sample set.
  • the script generation module 202 can automatically generate a test case template of all interfaces according to the test sample set by running the test case template generation tool.
  • the test case template mainly includes the request message and the result verification corresponding to the request message.
  • the script generation module 202 obtains the specific value of the result verification.
  • the Json test case generation tool By running the Json test case generation tool, the JSON format test case can be generated according to the test case module of an interface, and then the Jmeter test case generation tool can be executed according to the Jmeter test case generation tool. Test cases in Json format generate test scripts in Jmeter format.
  • the Json test case generation tool and the Jmeter test case generation tool are also generated by VBA scripts.
  • the interface test module 203 is configured to generate an integrated test case according to the Jmeter test script, invoke the integration test case through the test tool, and trigger the Jmeter test script to test through the integrated test case, and automatically output the test result.
  • the interface test module 203 writes the Jmeter test script into an integrated test case of the integrated test tool.
  • the integration test tool adopts an Ant integration test tool
  • the interface test module 203 creates an integration test case named BUILD.xml, generates a test case according to the format of the Ant integration tool, and simultaneously stores the storage path of the Jmeter test script and outputs The test result path is entered into the BUILD.xml integration test case.
  • the interface test module 203 calls the integration test case of BUILD.xml by running Ant's integrated test tool, so that the integration test case triggers the Jmeter test case to perform the integration test through the storage path of the Jmeter test script, and outputs the path according to the input test result after the test is completed. Test Results.
  • the interface test module 203 can directly call the Jmeter test case to test the interface by using the Jmeter test tool. It should be understood that the Jmeter can only be used for one interface. Interface testing, that is, integration testing is not possible, but testing with Jmeter can simulate stress testing by means of concurrent threads, and has better effect on performance testing of interface testing. Therefore, interface testing module 203 can use Jmeter for single testing. After the interface test of the interface, the integration test is performed to make the interface test more complete.
  • the specific maintenance process is: the interface automation testing device 20 obtains the modified interface document through the sample generation module 201, generates a modified Json test sample, and then the script generation module 202 sequentially according to the Json test sample. The test case template, the Json test case, and the Jmeter test case are generated. Finally, the modified Jmeter test case is written into the integrated test case by the interface test module 203, and the test tool is called to test the test case and output the test result.
  • the interface automatic testing device provided by the embodiment of the present application automatically generates test cases step by step from the interface document through the automatic generation tool, and then uses the integrated test tool to call the test case for interface test, automatically outputs the test result, and verifies the performance and security of the test result.
  • the test case can be automatically generated only by modifying the interface part, and the test cases of other interfaces need not be regenerated, the maintenance process is relatively simple and the efficiency is high;
  • the corresponding automatic data generation tool automatically generates the corresponding transition data, which reduces the requirements of the interface tester, improves the degree of automation, and improves the interface test efficiency.
  • Another embodiment of the present application provides one or more non-volatile readable storage media storing computer readable instructions that, when executed by one or more processors, cause one or more processors
  • the interface automatic test method in the foregoing embodiment is executed. To avoid repetition, details are not described herein again.
  • the computer readable instructions are executed by one or more processors, the one or more processors are configured to perform the functions of the modules/units in the interface automation test apparatus in the above embodiments. To avoid repetition, details are not described herein again.
  • FIG. 7 shows a schematic diagram of a terminal device of the present embodiment.
  • the terminal device 60 includes a processor 61, a memory 62, and computer readable instructions 63 stored in the memory 62 and executable on the processor 61.
  • the processor 61 executes the computer readable instructions 63 to implement the various steps of the interface automation test method of the above-described embodiments, such as steps S101, S102, and S103 shown in FIG.
  • the processor 61 executes the computer readable instructions 63
  • the functions of the modules/units of the interface automation test apparatus in the above embodiments are implemented, for example, the functions of the sample generation module 201, the script generation module 202, and the interface test module 203 shown in FIG. .

Abstract

The present application relates to the field of software testing. Provided are an automated interface testing method, a device, equipment, and a storage medium. The method comprises the following steps: acquiring interface files of different interfaces, automatically generating JSON test samples of the different interfaces on the basis of the interface files; automatically generating a test case template on the basis of the JSON test samples, automatically generating a JSON test case on the basis of the test case template, and then automatically generating a JMeter test script on the basis of the JSON test case; generating an integrated test case on the basis of the JMeter test script, calling the integrated test case via a test tool, triggering the JMeter test script via the integrated test case for testing, and automatically outputting the test result. The automated interface testing method, the device, the equipment, and the storage medium provided in the present application increase the degree of automation of interface testing and facilitate the maintenance of a test case when modifying an interface.

Description

接口自动化测试方法、装置、设备及存储介质Interface automation test method, device, device and storage medium
本申请以2018年2月7日提交的申请号为201810121971.X,名称为“接口自动化测试方法、装置、设备及存储介质”的中国发明专利申请为基础,并要求其优先权。This application is based on the Chinese Patent Application No. 201101121971.X filed on February 7, 2018, entitled "Interface Automation Test Method, Apparatus, Equipment, and Storage Medium", and requires priority.
技术领域Technical field
本申请属于软件测试领域,更具体地说,是涉及一种接口自动化测试方法、装置、设备及存储介质。This application belongs to the field of software testing, and more specifically to an interface automatic test method, apparatus, device and storage medium.
背景技术Background technique
接口测试是测试系统组件间接口的一种测试,主要用于检测外部系统与系统之间以及内部各个子系统之间的交互点,重点检查数据的交换、传递和控制管理过程,以及系统间的相互逻辑依赖关系等。Interface testing is a test of the interface between test system components. It is mainly used to detect the interaction between external systems and systems and internal subsystems, focusing on data exchange, transfer and control management processes, and inter-system Mutual logical dependencies, etc.
现有技术中,当接口测试中的某个接口或者某个接口需要增加、删除或者修改时,需要一个个代码进行维护,在postman(一个接口自动化测试的工具)里跑接口,或者一个一个导入到现有的接口测试工具里执行看结果,花费的时间较长,自动化程度不高,效率较低。In the prior art, when an interface or an interface in an interface test needs to be added, deleted, or modified, one code is required for maintenance, and the interface is run in a postman (a tool for automated test of an interface), or one by one. Executing the results in the existing interface test tool takes a long time, is not automated, and is inefficient.
发明内容Summary of the invention
针对现有技术的不足,本申请提供一种接口自动化测试方法、装置、设备及存储介质,可以提高自动化程度和测试的效率。In view of the deficiencies of the prior art, the present application provides an interface automatic test method, apparatus, device, and storage medium, which can improve the degree of automation and the efficiency of testing.
本申请是这样实现的:This application is implemented as follows:
本申请第一方面提供一种接口自动化测试方法,所述方法包括以下步骤:A first aspect of the present application provides an interface automation testing method, the method comprising the following steps:
获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document;
根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;Generating a test case template automatically according to the Json test sample, and automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果。Generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, and triggering the Jmeter test script to test by the integrated test case, and automatically outputting the test result.
本申请第二方提供一种接口自动化测试装置,所述装置包括:The second party of the present application provides an interface automatic testing device, the device comprising:
样例生成模块:用于获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;a sample generation module: an interface document for acquiring different interfaces, and automatically generating a Json test sample of different interfaces according to the interface document;
脚本生成模块:用于根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;a script generation module: configured to automatically generate a test case template according to the Json test sample, automatically generate a Json test case according to the test case template, and automatically generate a Jmeter test script according to the Json test case;
接口测试模块:用于根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果。The interface test module is configured to generate an integrated test case according to the Jmeter test script, invoke the integrated test case by using a test tool, and trigger the Jmeter test script to test by the integrated test case, and automatically output the test result.
本申请第三方面提供一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:A third aspect of the present application provides a terminal device including a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, wherein the processor executes the computer The following steps are implemented when the instructions are readable:
获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document;
根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;Generating a test case template automatically according to the Json test sample, and automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果。Generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, and triggering the Jmeter test script to test by the integrated test case, and automatically outputting the test result.
本申请第四方面提供一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:A fourth aspect of the present application provides one or more non-transitory readable storage mediums storing computer readable instructions, the computer readable instructions being executed by one or more processors such that the one or more processes Perform the following steps:
获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document;
根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;Generating a test case template automatically according to the Json test sample, and automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果。Generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, and triggering the Jmeter test script to test by the integrated test case, and automatically outputting the test result.
本申请提供的接口自动化测试方法、装置、设备及存储介质,通过接口文档自动依次生成测试样例、测试样例集、测试用例模板、Json测试用例、Jmeter测试脚本和集成测试用例,再通过测试工具调用Jmeter测试脚本进行测试,自动输出测试结果,自动化的程度高,提升了测试的效率,当接口有修改时,也能快速生成新的测试脚本进行测试,使接口测试过程易于维护。The interface automatic test method, device, device and storage medium provided by the application automatically generate test samples, test sample sets, test case templates, Json test cases, Jmeter test scripts and integrated test cases through interface documents, and then pass the test. The tool calls the Jmeter test script to test, automatically outputs the test result, and the degree of automation is high, which improves the efficiency of the test. When the interface is modified, a new test script can be quickly generated for testing, and the interface test process is easy to maintain.
附图说明DRAWINGS
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description are only the present application. For some embodiments, other drawings may be obtained from those of ordinary skill in the art in light of the inventive workability.
图1为本申请一实施例提供的接口自动化测试方法的流程图;FIG. 1 is a flowchart of an interface automatic testing method according to an embodiment of the present application;
图2为图1所示实施例的请求报文和响应报文的示例图;2 is a diagram showing an example of a request message and a response message in the embodiment shown in FIG. 1;
图3为图1所示实施例的测试样例集的示例图;3 is a diagram showing an example of a test sample set of the embodiment shown in FIG. 1;
图4为图1所示实施例的测试用例模板的示例图;4 is a diagram showing an example of a test case template of the embodiment shown in FIG. 1;
图5为图1所示实施例的S103步骤的子步骤的流程图;Figure 5 is a flow chart showing the sub-steps of the step S103 of the embodiment shown in Figure 1;
图6为本申请又一实施例提供的接口自动化测试装置的结构示意图;6 is a schematic structural diagram of an interface automatic testing apparatus according to another embodiment of the present application;
图7为本申请又一实施例提供的终端设备的结构示意图。FIG. 7 is a schematic structural diagram of a terminal device according to another embodiment of the present disclosure.
具体实施方式Detailed ways
为了使本申请所要解决的技术问题、技术方案及有益效果更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the technical problems, technical solutions and beneficial effects to be solved by the present application more clear, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
请参考图1,其示出了本申请实施例提供的接口自动化测试方法的流程图。Please refer to FIG. 1 , which is a flowchart of an interface automatic testing method provided by an embodiment of the present application.
接口测试是指对应用程序接口(API)进行测试,包括两类:一类是外部接口,即系统与系统之间的调用,例如淘宝订单系统和支付系统之间接口调用;一类是内部接口,是指上层服务对下层服务的调用或者是服务与服务之间的调用,例如业务层调用数据层,业务层是上层服务,数据层是下层服务,又例如选择商品和创建订单等。Interface testing refers to testing the application program interface (API), including two types: one is the external interface, that is, the call between the system and the system, such as the interface call between the Taobao order system and the payment system; the other is the internal interface. It refers to the call of the upper layer service to the lower layer service or the call between the service and the service. For example, the business layer calls the data layer, the business layer is the upper layer service, the data layer is the lower layer service, and for example, the goods are selected and the order is created.
接口测试的作用是重点检查各个接口之间的数据交换、传递和管理过程等工作是否正常。The role of interface testing is to check whether the data exchange, delivery, and management processes between interfaces are normal.
如图1所示,本申请实施例提供的接口自动化测试方法包括以下步骤:As shown in FIG. 1 , the interface automatic testing method provided by the embodiment of the present application includes the following steps:
步骤S101,获取不同接口的接口文档,根据接口文档自动生成不同接口的Json测试样例。Step S101: Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document.
其中,接口文档是指应用程序的开发人员提供的关于不同接口测试的接口参数,接口文档主要包括请求方法、URI、请求参数和返回参数四个部分的数据。请求方法通常包括:GET/PUT/POST/DELETE;URI为统一资源标识符(Uniform Resource Identifier,简称URI)是一个用于标识某一互联网资源名称的字符串,以/a开头,如果需要登录才能调用的接口(如新增、修改;前台的用户个人信息,资金信息等)后面需要加/u,即:/a/u;中间一般放表名或者能表达这个接口的单词;请求参数和返回参数通常包括:字段、说明、类型、备注、 是否必填等信息。The interface document refers to the interface parameters provided by the developer of the application for different interface tests. The interface document mainly includes four parts of the request method, the URI, the request parameter and the return parameter. The request method usually includes: GET/PUT/POST/DELETE; the URI is a Uniform Resource Identifier (URI), which is a string for identifying the name of an Internet resource, starting with /a, if you need to log in. The interface to be called (such as adding, modifying; user information of the foreground, fund information, etc.) needs to add /u, ie: /a/u; generally put the table name or the word that can express this interface; request parameters and return Parameters usually include: field, description, type, comment, required or not.
具体地,点击Json测试样例自动生成工具,即可根据一个接口文档的接口描述表格中的外层字段名调用接口文档的数据,自动生成Json格式的测试样例。其中,接口描述表格是指对该接口进行概括描述的表格,包括调用接口文档信息的名称、字段名称、类型和格式等等信息;外层字段名是指接口文档中最外层的接口的字段名,以保验业务为例,被保验人的信息作为一个外层字段名,可以根据被保验人的信息从接口文档中调用被保验人的姓名、性别、身份证号等里层的信息数据。Specifically, by clicking the Json test sample automatic generation tool, the data of the interface document can be called according to the outer field name in the interface description table of an interface document, and a test sample in the Json format is automatically generated. The interface description table refers to a table that generalizes the interface, including the name, field name, type, format, and the like of the interface document information; the outer field name refers to the field of the outermost interface in the interface document. For example, in the case of the inspection service, the information of the inspector is used as an outer field name, and the name, gender, ID number, etc. of the inspected person can be called from the interface document according to the information of the inspected person. Information data.
例如,以保验业务系统为例,接口描述文档的外层字段名的名称主要包括:系统代码、业务员代码、生效日期、层级信息、被保验人信息和被保验人总人数等等,运用Json测试样例生成工具通过这些外层的字段名就可以调用接口文档里层的各种信息数据。For example, taking the security service system as an example, the names of the outer field names of the interface description document mainly include: system code, salesperson code, effective date, hierarchical information, information of the inspected person, the total number of inspected persons, and the like. The Json test sample generation tool can be used to call various information data in the interface document through these outer field names.
本申请实施例中,将测试样例生成Json的格式,主要是由于接口之间的数据是以Json格式来传递的;可选地,Json测试样例自动生成工具由VBA脚本生成。In the embodiment of the present application, the JSON format is generated by the test sample, mainly because the data between the interfaces is transmitted in the Json format; optionally, the Json test sample automatic generation tool is generated by the VBA script.
具体地,Json格式的测试样例主要包括请求报文和响应报文,请参考图2,其示出了请求报文和响应报文的示例图,如图2(a)所示,请求报文中的请求方法是对该接口发送请求的方法,请求字段名即外层字段名,根据外层字段名调用接口文档的数据对接口进行具体的请求,“非空”、“长度”、“类型”是对请求报文的格式进行限定;如图2(b)所示,响应报文中的返回结果是对该接口返回的结果,返回字段名即外层字段名,根据外层字段名调用接口文档的数据返回具体的结果,“非空”、“长度”、“类型”是对响应报文的格式进行限定。其中,在实际接口进行数据通信时,通过接口接收请求报文,根据请求报文在系统或者平台中寻找所要请求的资源,找到资源后将这些资源转换为响应报文返回。Specifically, the test sample of the Json format mainly includes a request message and a response message. Please refer to FIG. 2, which shows an example diagram of the request message and the response message, as shown in FIG. 2(a), the request message The request method in the text is a method for sending a request to the interface, requesting the field name as the outer field name, and calling the data of the interface document according to the outer field name to make a specific request for the interface, “non-empty”, “length”, “ The type is to limit the format of the request message; as shown in Figure 2(b), the returned result in the response message is the result returned by the interface, and the return field name is the outer field name, according to the outer field name. The data of the calling interface document returns the specific result. "Non-empty", "length", and "type" are used to define the format of the response message. When the actual interface performs data communication, the interface receives the request packet, searches for the resource to be requested in the system or the platform according to the request packet, and converts the resource into a response packet after the resource is found.
步骤S102,根据Json测试样例自动生成测试用例模板,并根据测试用例 模板自动生成Json测试用例,再根据Json测试用例自动生成Jmeter测试脚本。Step S102: automatically generate a test case template according to the Json test sample, and automatically generate a Json test case according to the test case template, and then automatically generate a Jmeter test script according to the Json test case.
接口测试中包括对很多不同的接口进行测试,例如,在购买保险的接口测试中,需要对“客户身份验证”、“投保信息验证”、“手机号变更”、“投保”等等接口进行测试,因此,可以将所有接口的Json测试样例集中起来,生成一个Json测试样例集,方便对接口测试的集中管理和后续的集成测试,使接口测试的流程更加直观。请参考图3,其示出了测试样例集的示例图,如图3所示,接口测试包括N个接口的测试,接口名称是指被测试系统的一个流程,接口描述是指接口名称在系统中对应的流程走向,接口描述后面的数据为每个接口文档生成的Json样例对应的请求报文和响应报文。Interface testing includes testing many different interfaces. For example, in the interface test for purchasing insurance, you need to test the interfaces such as "customer authentication", "insurance information verification", "mobile phone number change", "insured" and so on. Therefore, the Json test samples of all interfaces can be gathered together to generate a Json test sample set, which facilitates centralized management of interface tests and subsequent integration tests, making the interface test process more intuitive. Please refer to FIG. 3, which shows an example diagram of a test sample set. As shown in FIG. 3, the interface test includes testing of N interfaces, the interface name refers to a process of the system under test, and the interface description means that the interface name is The corresponding process direction in the system, the data following the interface description is the request message and the response message corresponding to the Json sample generated by each interface document.
具体地,根据每一个接口文档分别自动生成Json测试样例,再将所有的Json测试样例集在一个表格里面组成一个Json测试样例集。Specifically, a Json test sample is automatically generated according to each interface document, and then all Json test samples are grouped in a table to form a Json test sample set.
然后,点击测试用例模板生成工具,就可以根据测试样例集同时自动生成所有接口的测试用例模板,测试用例模板主要包括请求报文和与请求报文相对应的结果验证,请参考图4,其示出了测试用例模板的示例图,图4是以请求字段名为“客户身份验证”的Json测试样例为例,其中,调用字段名是以请求字段名为“客户身份验证”的请求方法参数调用的字段名,包括“客户姓名”、“性别”、“出生日期”、“证件类型”、“证件号码”,然后根据每个调用字段名的数据分别设置结果验证。结果验证是对接口进行一个安全性方面的测试,使接口在各个场景下都能运行正常,结果验证可以根据预先制定的接口测试策略和实际情况进行具体的设定。Then, by clicking the test case template generation tool, the test case template of all interfaces can be automatically generated according to the test sample set. The test case template mainly includes the request message and the result verification corresponding to the request message, please refer to FIG. It shows an example diagram of a test case template. Figure 4 is an example of a Json test sample with the request field name "Customer Authentication", where the call field name is a request with the request field name "Customer Authentication". The field name called by the method parameter, including "customer name", "gender", "date of birth", "document type", "document number", and then set the result verification according to the data of each call field name. The result is a security test on the interface, so that the interface can run normally in various scenarios. The result verification can be set according to the pre-defined interface test strategy and actual situation.
在输入结果验证的数值以后,点击Json测试用例生成工具,就可以根据一个接口的测试用例模块生成Json格式的测试用例,再点击Jmeter测试用例生成工具,就可以根据Json格式的测试用例生成Jmeter格式的测试脚本,即jmx.为后缀的文件;在生成测试脚本的同时在预设的存储路径生成以接口名称来命名的Jmeter测试脚本,例如,根据“客户身份验证”这个接口在预定的存储路径(如D硬盘)生成“客户身份验证.jmx”的Jmeter测试脚本。其中,Jmeter 是Apache组织开发的基于Java的压力测试工具,可以应用于接口测试中。After inputting the value verified by the result, click the Json test case generation tool, you can generate a JSON format test case based on the test case module of an interface, and then click the Jmeter test case generation tool to generate the Jmeter format according to the Json format test case. The test script, jmx. is the suffix file; the Jmeter test script named after the interface name is generated in the preset storage path while generating the test script, for example, according to the "customer authentication" interface in the predetermined storage path (eg D hard drive) Generate a Jmeter test script for "Customer Authentication.jmx". Among them, Jmeter is a Java-based stress testing tool developed by the Apache organization, which can be applied to interface testing.
可选地,Json测试用例生成工具和Jmeter测试用例生成工具也是由VBA脚本生成。Optionally, the Json test case generation tool and the Jmeter test case generation tool are also generated by VBA scripts.
步骤S103,根据Jmeter测试脚本生成集成测试用例,通过测试工具调用集成测试用例,并通过集成测试用例触发Jmeter测试脚本进行测试,自动输出测试结果。Step S103, generating an integrated test case according to the Jmeter test script, calling the integration test case through the test tool, and triggering the Jmeter test script to test through the integrated test case, and automatically outputting the test result.
其中,集成测试用例是指在单元测试的基础上,将所有模块按照设计要求(如根据结构图)组装成为子系统或系统,进行集成测试;集成测试的作用是各个单元、模块都能正常工作的前提下验证连接起来进行全局运作时是否能正常运作。Among them, the integration test case refers to the integration of all modules according to the design requirements (such as according to the structure diagram) into subsystems or systems for integration testing; the role of integration testing is that each unit and module can work normally. Under the premise, verify that the connection works for global operation.
具体地,将测试用例编写进集成测试工具的集成测试用例中,从而可以进行集成测试。Specifically, test cases are written into the integration test case of the integration test tool so that integration tests can be performed.
可选地,集成测试工具采用Ant集成测试工具,Ant是一个将软件编译、测试、部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发。Optionally, the integration test tool uses the Ant integration test tool. Ant is a tool that automates the steps of compiling, testing, and deploying software. Most of them are used for software development in the Java environment.
具体地,请参考图5,在步骤S103中,还包括以下子步骤:Specifically, referring to FIG. 5, in step S103, the following sub-steps are further included:
步骤S1031,根据所述Jmeter测试脚本的存储路径和结果输出路径生成xml格式的集成测试用例。Step S1031: Generate an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script.
步骤S1032,运行Ant集成测试工具调用集成测试用例,使集成测试用例通过Jmeter测试脚本的存储路径触发Jmeter测试脚本进行测试。Step S1032, running the Ant integration test tool to call the integration test case, so that the integration test case triggers the Jmeter test script to test through the storage path of the Jmeter test script.
步骤S1033,将测试后的响应报文自动与响应报文进行比较,根据结果输出路径输出测试结果。In step S1033, the test response message is automatically compared with the response message, and the test result is output according to the result output path.
具体地,新建一个名称BUILD.xml的集成测试用例,根据Ant集成工具的格式生成一个测试用例,同时将Jmeter测试脚本的存储路径和要输出的测试结果路径输入到BUILD.xml集成测试用例中。Specifically, create an integration test case named BUILD.xml, generate a test case according to the format of the Ant integration tool, and input the storage path of the Jmeter test script and the test result path to be output into the BUILD.xml integration test case.
运行Ant的集成测试工具,就可以调用BUILD.xml的集成测试用例,集成 测试用例再通过Jmeter测试脚本的存储路径触发Jmeter测试用例进行集成测试,测试完成后根据输入的测试结果路径输出测试结果。By running Ant's integrated test tool, you can call the integrated test case of BUILD.xml. The integration test case then triggers the Jmeter test case to perform the integration test through the storage path of the Jmeter test script. After the test is completed, the test result is output according to the input test result path.
其中,测试结果是将运行测试后得到的响应报文与Json样例中的响应报文进行自动对比,若测试结果与预期结果一致,说明接口符合使用要求,可以正常使用,若测试结果与预期结果不一致,则说明该接口存在问题,需要对该接口进一步完善。The test result is that the response message obtained after running the test is automatically compared with the response message in the Json sample. If the test result is consistent with the expected result, the interface meets the usage requirements and can be used normally, if the test result and expectation If the results are inconsistent, the interface is faulty and needs to be further improved.
进一步地,由于测试用例是Jmeter格式的脚本,因此,作为一种实施方式,可以用Jmeter测试工具直接调用Jmeter测试用例进行接口的测试,应当理解的是,Jmeter只能对一个接口进行接口测试,即无法进行集成测试,但运用Jmeter进行测试可以通过并发线程的方式模拟压力测试,对接口测试的性能方面的测试有比较好的效果,因此,可以运用Jmeter进行单个接口的接口测试后再进行集成测试,使接口测试更加完整。其中,性能方面的测试主要包括:响应速度、接口容错、接口负载等等性能测试。Further, since the test case is a Jmeter format script, as an implementation manner, the Jmeter test tool can be used to directly call the Jmeter test case to perform interface test. It should be understood that Jmeter can only perform interface test on one interface. That is, integration testing cannot be performed, but testing with Jmeter can simulate stress testing by means of concurrent threads, and has better effect on performance testing of interface testing. Therefore, Jmeter can be used to perform interface testing of a single interface before integration. Testing to make interface testing more complete. Among them, the performance test mainly includes: response speed, interface fault tolerance, interface load and other performance tests.
进一步地,当接口有增加、删除或者修改时,需要对测试代码进行维护。在本申请实施例中,具体的维护流程为:从开发人员那里获取修改的接口文档,然后根据修改的接口文档依次生成Json测试样例、Json测试用例和Jmeter测试用例,再将Jmeter测试用例写进集成测试用例中,运行测试工具调用测试用例进行测试,输出测试结果。在进行维护的过程中,采用本申请实施例提供的接口自动化测试方法,可以使整个维护过程比较简单,效率较高。Further, when the interface is added, deleted, or modified, the test code needs to be maintained. In the embodiment of the present application, the specific maintenance process is: obtaining a modified interface document from a developer, and then sequentially generating a Json test sample, a Json test case, and a Jmeter test case according to the modified interface file, and then writing the Jmeter test case. In the integration test case, the test tool is called to test the test case and output the test result. In the process of performing maintenance, the interface automatic test method provided by the embodiment of the present application can make the whole maintenance process relatively simple and high in efficiency.
例如,当新增一个接口时,获取新增的接口文档,点击Json样例生成工具根据新增的接口文档自动生成Json样例,然后点击测试用例模板生成工具,根据Json样例自动生成测试用例模块,可选地,可以将Json样例放进Json样例集里面,便于集中管理,当点击测试用例模板生成工具时,可以只对新增接口生成的Json样例生成测试用例模板,其它接口的不变,这样只需将新增接口的结果验证数据输入到测试用例模板里即可,其它接口的结果验证数据不用再重新输入;接着,点击Json测试用例生成工具根据新增接口的测试用例模板自动 生成Json测试用例,再点击Jmeter测试用例生成工具自动生成Jmeter测试用例,接下来,将新生成的Jmeter测试用例的存储路径加到BUILD.xml的集成测试用例里面,运行Ant集成测试工具,通过集成测试用例调用Jmeter测试用例进行测试,并输出新的测试结果。For example, when adding an interface, obtain a new interface document, click the Json sample generation tool to automatically generate a Json sample based on the newly added interface document, and then click the test case template generation tool to automatically generate a test case based on the Json sample. Module, optionally, you can put the Json sample into the Json sample set for centralized management. When you click the test case template generation tool, you can generate test case templates only for the Json sample generated by the new interface. Other interfaces The same is true, so you only need to input the result verification data of the new interface into the test case template. The result verification data of other interfaces does not need to be re-entered; then, click the Json test case generation tool according to the test case of the new interface. The template automatically generates Json test cases, and then clicks the Jmeter test case generation tool to automatically generate Jmeter test cases. Next, add the newly generated Jmeter test case storage path to the integrated test case of BUILD.xml, and run the Ant integration test tool. Call the Jmeter test case to test by integrating test cases and output new Test Results.
本申请实施例提供的接口自动化测试方法,通过自动化生成工具从接口文档一步步自动生成测试用例,再用集成测试工具调用测试用例进行接口测试,自动输出测试结果,验证测试结果的性能和安全性,指导接口的修正和完善;当有修改的接口时,只对修改接口的部分再次自动生成测试用例即可,不需要对其它接口的测试用例进行重新生成,维护过程比较简便,效率较高;整个测试过程中,由相应的自动生成工具自动生成相应的过渡数据,对接口测试人员的要求降低,提高了自动化的程度,同时提高了接口测试效率。The interface automatic test method provided by the embodiment of the present application automatically generates a test case from the interface document through an automated generation tool, and then uses the integrated test tool to call the test case for interface test, automatically outputs the test result, and verifies the performance and security of the test result. To guide the correction and improvement of the interface; when there is a modified interface, the test case can be automatically generated only by modifying the interface part, and the test cases of other interfaces need not be regenerated, the maintenance process is relatively simple and the efficiency is high; During the whole test process, the corresponding automatic data generation tool automatically generates the corresponding transition data, which reduces the requirements of the interface tester, improves the degree of automation, and improves the interface test efficiency.
以下是本申请的装置实施例,在装置实施例中未详尽描述的细节,可以参考上述对应的方法实施例。The following are device embodiments of the present application. For details that are not described in detail in the device embodiments, reference may be made to the corresponding method embodiments.
请参考图6,其示出了本申请实施例提供的接口自动化测试装置的结构示意图。Please refer to FIG. 6 , which is a schematic structural diagram of an interface automatic testing apparatus provided by an embodiment of the present application.
如图6所示,接口自动化测试装置20包括:样例生成模块201、脚本生成模块202和接口测试模块203。As shown in FIG. 6, the interface automation test apparatus 20 includes a sample generation module 201, a script generation module 202, and an interface test module 203.
样例生成模块201,用于获取不同接口的接口文档,根据接口文档自动生成不同接口的Json测试样例。The sample generation module 201 is configured to obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document.
具体地,样例生成模块201通过运行Json测试样例自动生成工具,即可根据一个接口文档的接口描述表格中的外层字段名调用接口文档的数据,自动生成Json格式的测试样例,Json格式的测试样例主要包括请求报文和响应报文。Specifically, the sample generation module 201 can automatically generate a test sample of the Json format according to the outer field name in the interface description table of an interface document by running the Json test sample automatic generation tool, Json. The test samples of the format mainly include request messages and response messages.
可选地,Json测试样例自动生成工具由VBA脚本生成。Optionally, the Json test sample auto-generation tool is generated by a VBA script.
脚本生成模块202,用于根据Json测试样例自动生成测试用例模板,并根据测试用例模块自动生成Json测试用例,再根据Json测试用例自动生成 Jmeter测试脚本。The script generation module 202 is configured to automatically generate a test case template according to the Json test sample, automatically generate a Json test case according to the test case module, and automatically generate a Jmeter test script according to the Json test case.
具体地,运用样例生成模块201根据每一个接口文档分别自动生成Json测试样例,然后脚本生成模块202将所有的Json测试样例集在一个表格里面组成一个Json测试样例集。Specifically, the sample generation module 201 automatically generates a Json test sample according to each interface document, and then the script generation module 202 sets all the Json test samples in a table to form a Json test sample set.
接着,脚本生成模块202通过运行测试用例模板生成工具,就可以根据测试样例集同时自动生成所有接口的测试用例模板,测试用例模板主要包括请求报文和与请求报文相对应的结果验证。Then, the script generation module 202 can automatically generate a test case template of all interfaces according to the test sample set by running the test case template generation tool. The test case template mainly includes the request message and the result verification corresponding to the request message.
接下来,脚本生成模块202获取结果验证的具体数值,通过运行Json测试用例生成工具,就可以根据一个接口的测试用例模块生成Json格式的测试用例,再通过运行Jmeter测试用例生成工具,就可以根据Json格式的测试用例生成Jmeter格式的测试脚本。Next, the script generation module 202 obtains the specific value of the result verification. By running the Json test case generation tool, the JSON format test case can be generated according to the test case module of an interface, and then the Jmeter test case generation tool can be executed according to the Jmeter test case generation tool. Test cases in Json format generate test scripts in Jmeter format.
可选地,Json测试用例生成工具和Jmeter测试用例生成工具也是由VBA脚本生成。Optionally, the Json test case generation tool and the Jmeter test case generation tool are also generated by VBA scripts.
接口测试模块203,用于根据Jmeter测试脚本生成集成测试用例,通过测试工具调用集成测试用例,并通过集成测试用例触发Jmeter测试脚本进行测试,自动输出测试结果。The interface test module 203 is configured to generate an integrated test case according to the Jmeter test script, invoke the integration test case through the test tool, and trigger the Jmeter test script to test through the integrated test case, and automatically output the test result.
具体地,接口测试模块203将Jmeter测试脚本编写进集成测试工具的集成测试用例中。Specifically, the interface test module 203 writes the Jmeter test script into an integrated test case of the integrated test tool.
可选地,集成测试工具采用Ant集成测试工具,接口测试模块203新建一个名称BUILD.xml的集成测试用例,根据Ant集成工具的格式生成一个测试用例,同时将Jmeter测试脚本的存储路径和要输出的测试结果路径输入到BUILD.xml集成测试用例中。Optionally, the integration test tool adopts an Ant integration test tool, and the interface test module 203 creates an integration test case named BUILD.xml, generates a test case according to the format of the Ant integration tool, and simultaneously stores the storage path of the Jmeter test script and outputs The test result path is entered into the BUILD.xml integration test case.
接口测试模块203通过运行Ant的集成测试工具,调用BUILD.xml的集成测试用例,使集成测试用例通过Jmeter测试脚本的存储路径触发Jmeter测试用例进行集成测试,测试完成后根据输入的测试结果路径输出测试结果。The interface test module 203 calls the integration test case of BUILD.xml by running Ant's integrated test tool, so that the integration test case triggers the Jmeter test case to perform the integration test through the storage path of the Jmeter test script, and outputs the path according to the input test result after the test is completed. Test Results.
进一步地,由于测试用例是Jmeter格式的脚本,因此,作为一种实施方式, 接口测试模块203可以用Jmeter测试工具直接调用Jmeter测试用例进行接口的测试,应当理解的是,Jmeter只能对一个接口进行接口测试,即无法进行集成测试,但运用Jmeter进行测试可以通过并发线程的方式模拟压力测试,对接口测试的性能方面的测试有比较好的效果,因此,接口测试模块203可以运用Jmeter进行单个接口的接口测试后再进行集成测试,使接口测试更加完整。Further, since the test case is a script in the Jmeter format, as an embodiment, the interface test module 203 can directly call the Jmeter test case to test the interface by using the Jmeter test tool. It should be understood that the Jmeter can only be used for one interface. Interface testing, that is, integration testing is not possible, but testing with Jmeter can simulate stress testing by means of concurrent threads, and has better effect on performance testing of interface testing. Therefore, interface testing module 203 can use Jmeter for single testing. After the interface test of the interface, the integration test is performed to make the interface test more complete.
进一步地,当接口有增加、删除或者修改时,需要对测试代码进行维护。在本申请实施例中,具体的维护流程为:接口自动化测试装置20通过样例生成模块201获取修改的接口文档,生成修改后的Json测试样例,然后脚本生成模块202根据Json测试样例依次生成测试用例模板、Json测试用例和Jmeter测试用例,最后通过接口测试模块203将修改的Jmeter测试用例写进集成测试用例中,运行测试工具调用测试用例进行测试,输出测试结果。Further, when the interface is added, deleted, or modified, the test code needs to be maintained. In the embodiment of the present application, the specific maintenance process is: the interface automation testing device 20 obtains the modified interface document through the sample generation module 201, generates a modified Json test sample, and then the script generation module 202 sequentially according to the Json test sample. The test case template, the Json test case, and the Jmeter test case are generated. Finally, the modified Jmeter test case is written into the integrated test case by the interface test module 203, and the test tool is called to test the test case and output the test result.
本申请实施例提供的接口自动化测试装置,通过自动化生成工具从接口文档一步步自动生成测试用例,再用集成测试工具调用测试用例进行接口测试,自动输出测试结果,验证测试结果的性能和安全性,指导接口的修正和完善;当有修改的接口时,只对修改接口的部分再次自动生成测试用例即可,不需要对其它接口的测试用例进行重新生成,维护过程比较简便,效率较高;整个测试过程中,由相应的自动生成工具自动生成相应的过渡数据,对接口测试人员的要求降低,提高了自动化的程度,同时提高了接口测试效率。The interface automatic testing device provided by the embodiment of the present application automatically generates test cases step by step from the interface document through the automatic generation tool, and then uses the integrated test tool to call the test case for interface test, automatically outputs the test result, and verifies the performance and security of the test result. To guide the correction and improvement of the interface; when there is a modified interface, the test case can be automatically generated only by modifying the interface part, and the test cases of other interfaces need not be regenerated, the maintenance process is relatively simple and the efficiency is high; During the whole test process, the corresponding automatic data generation tool automatically generates the corresponding transition data, which reduces the requirements of the interface tester, improves the degree of automation, and improves the interface test efficiency.
本申请另一种实施例提供一个或多个存储有计算机可读指令的非易失性可读存储介质,该计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述实施例中的接口自动化测试方法,为避免重复,这里不再赘述。或者,该计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述实施例中接口自动化测试装置中各模块/单元的功能,为避免重复,这里不再赘述。Another embodiment of the present application provides one or more non-volatile readable storage media storing computer readable instructions that, when executed by one or more processors, cause one or more processors The interface automatic test method in the foregoing embodiment is executed. To avoid repetition, details are not described herein again. Alternatively, when the computer readable instructions are executed by one or more processors, the one or more processors are configured to perform the functions of the modules/units in the interface automation test apparatus in the above embodiments. To avoid repetition, details are not described herein again.
请参考图7,其示出了本实施例的终端设备的示意图,终端设备60包括处理器61、存储器62以及存储在存储器62中并可在处理器61上运行的计算机可读指令63。处理器61执行计算机可读指令63时实现上述实施例中接口自动化测试方法的各个步骤,例如图1所示的步骤S101、S102和S103。或者,处理器61执行计算机可读指令63时实现上述实施例中接口自动化测试装置各模块/单元的功能,例如图6所示样例生成模块201、脚本生成模块202和接口测试模块203的功能。Please refer to FIG. 7, which shows a schematic diagram of a terminal device of the present embodiment. The terminal device 60 includes a processor 61, a memory 62, and computer readable instructions 63 stored in the memory 62 and executable on the processor 61. The processor 61 executes the computer readable instructions 63 to implement the various steps of the interface automation test method of the above-described embodiments, such as steps S101, S102, and S103 shown in FIG. Alternatively, when the processor 61 executes the computer readable instructions 63, the functions of the modules/units of the interface automation test apparatus in the above embodiments are implemented, for example, the functions of the sample generation module 201, the script generation module 202, and the interface test module 203 shown in FIG. .
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。It will be apparent to those skilled in the art that, for convenience and brevity of description, only the division of each functional unit and module described above is exemplified. In practical applications, the above functions may be assigned to different functional units as needed. The module is completed by dividing the internal structure of the device into different functional units or modules to perform all or part of the functions described above.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to explain the technical solutions of the present application, and are not limited thereto; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still implement the foregoing embodiments. The technical solutions described in the examples are modified or equivalently replaced with some of the technical features; and the modifications or substitutions do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in Within the scope of protection of this application.

Claims (20)

  1. 一种接口自动化测试方法,其特征在于,包括以下步骤:An interface automatic testing method, characterized in that the method comprises the following steps:
    获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document;
    根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;Generating a test case template automatically according to the Json test sample, and automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
    根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果。Generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, and triggering the Jmeter test script to test by the integrated test case, and automatically outputting the test result.
  2. 如权利要求1所述的接口自动化测试方法,其特征在于,所述获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例,包括:The interface automation test method according to claim 1, wherein the obtaining an interface document of a different interface, and automatically generating a Json test sample of different interfaces according to the interface document, comprising:
    获取不同接口的接口文档,根据所述接口文档的外层字段名调用接口文档的数据自动生成不同接口的Json格式的测试样例,所述测试样例包括请求报文和响应报文。The interface document of the interface is obtained, and the data of the interface document is automatically generated according to the outer field name of the interface document to automatically generate a test sample of the Json format of the interface. The test sample includes a request message and a response message.
  3. 如权利要求2所述的接口自动化测试方法,其特征在于,所述根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本,包括:The interface automation test method according to claim 2, wherein said automatically generating a test case template according to said Json test sample, and automatically generating a Json test case according to said test case template, and then according to said Json test Use cases automatically generate Jmeter test scripts, including:
    根据所述Json测试样例自动生成测试用例模板,将结果验证的数值输入到所述测试用例模板中,再根据所述测试用例模板自动生成Json测试用例,最后根据所述Json测试用例自动生成Jmeter测试脚本;Automatically generating a test case template according to the Json test sample, inputting the value of the result verification into the test case template, automatically generating a Json test case according to the test case template, and finally automatically generating a Jmeter according to the Json test case. Test script
    或者,将所述不同接口的Json测试样例集合生成Json测试样例集,根据所述Json测试样例集自动生成所述Json测试样例集包括的接口各自的测试用例模板,将结果验证的数值分别输入到所述测试用例模板中,再根据所述测试用例模板分别自动生成Json测试用例,最后根据所述Json测试用例分别自动生成Jmeter测试脚本。Alternatively, the Json test sample set of the different interfaces is generated to generate a Json test sample set, and the test case template of each interface included in the Json test sample set is automatically generated according to the Json test sample set, and the result is verified. The values are respectively input into the test case template, and then the Json test cases are automatically generated according to the test case templates, and finally the Jmeter test scripts are automatically generated according to the Json test cases.
  4. 如权利要求3所述的接口自动化测试方法,其特征在于,所述根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果,包括:The interface automation test method according to claim 3, wherein the generating an integration test case according to the Jmeter test script, calling the integration test case by a test tool, and triggering the Jmeter by the integration test case Test scripts are tested and automatically output test results, including:
    根据所述Jmeter测试脚本的存储路径和结果输出路径生成xml格式的集成测试用例;Generating an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script;
    运行Ant集成测试工具调用所述xml格式的集成测试用例,使所述集成测试用例通过所述Jmeter测试脚本的存储路径触发Jmeter测试脚本进行测试;Running the Ant integration test tool to invoke the integrated test case in the xml format, so that the integration test case triggers the Jmeter test script to test through the storage path of the Jmeter test script;
    将测试后的响应报文自动与所述响应报文进行比较,根据所述结果输出路径输出测试结果。The test response message is automatically compared with the response message, and the test result is output according to the result output path.
  5. 如权利要求4所述的接口自动化测试方法,其特征在于,所述根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果,之后还包括:The interface automation test method according to claim 4, wherein the generating an integration test case according to the Jmeter test script, calling the integration test case by a test tool, and triggering the Jmeter by the integration test case The test script is tested and the test results are automatically output. After that, it also includes:
    当所述接口发生修改时,获取修改的接口文档,根据所述修改后的接口文档依次生成Json测试样例、测试用例模板、Json测试用例、Jmeter测试用例和集成测试用例,再运行所述测试工具调用所述集成测试用例进行测试,重新自动输出测试结果。When the interface is modified, obtaining the modified interface document, and sequentially generating a Json test sample, a test case template, a Json test case, a Jmeter test case, and an integrated test case according to the modified interface file, and then running the test. The tool calls the integrated test case to test and re-output the test result automatically.
  6. 一种接口自动化测试装置,其特征在于,所述装置包括:An interface automatic test device, characterized in that the device comprises:
    样例生成模块:用于获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;a sample generation module: an interface document for acquiring different interfaces, and automatically generating a Json test sample of different interfaces according to the interface document;
    脚本生成模块:用于根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;a script generation module: configured to automatically generate a test case template according to the Json test sample, automatically generate a Json test case according to the test case template, and automatically generate a Jmeter test script according to the Json test case;
    接口测试模块:用于根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试 脚本进行测试,自动输出测试结果。The interface test module is configured to generate an integrated test case according to the Jmeter test script, invoke the integrated test case by using a test tool, and trigger the Jmeter test script to test by the integrated test case, and automatically output the test result.
  7. 如权利要求6所述的接口自动化测试装置,其特征在于,所述样例生成模块还用于:The interface automation test apparatus according to claim 6, wherein the sample generation module is further configured to:
    获取不同接口的接口文档,根据所述接口文档的外层字段名调用接口文档的数据自动生成不同接口的Json格式的测试样例,所述测试用例包括请求报文和响应报文。The interface document of the interface is obtained, and the data of the interface document is automatically generated according to the outer field name of the interface document to automatically generate a test sample of the Json format of the interface, where the test case includes a request message and a response message.
  8. 如权利要求7所述的接口自动化测试装置,其特征在于,所述脚本生成模块还用于:The interface automation test apparatus according to claim 7, wherein the script generation module is further configured to:
    根据所述Json测试样例自动生成测试用例模板,将结果验证的数值输入到所述测试用例模板中,再根据所述测试用例模板自动生成Json测试用例,最后根据所述Json测试用例自动生成Jmeter测试脚本;Automatically generating a test case template according to the Json test sample, inputting the value of the result verification into the test case template, automatically generating a Json test case according to the test case template, and finally automatically generating a Jmeter according to the Json test case. Test script
    或者,将所述不同接口的Json测试样例集合生成Json测试样例集,根据所述Json测试样例集自动生成所述Json测试样例集包括的接口各自的测试用例模板,将结果验证的数值分别输入到所述测试用例模板中,再根据所述测试用例模板分别自动生成Json测试用例,最后根据所述Json测试用例分别自动生成Jmeter测试脚本。Alternatively, the Json test sample set of the different interfaces is generated to generate a Json test sample set, and the test case template of each interface included in the Json test sample set is automatically generated according to the Json test sample set, and the result is verified. The values are respectively input into the test case template, and then the Json test cases are automatically generated according to the test case templates, and finally the Jmeter test scripts are automatically generated according to the Json test cases.
  9. 如权利要求8所述的接口自动化测试装置,其特征在于,所述接口测试模块还用于:The interface automation test apparatus according to claim 8, wherein the interface test module is further configured to:
    根据所述Jmeter测试脚本的存储路径和结果输出路径生成xml格式的集成测试用例;Generating an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script;
    运行Ant集成测试工具调用所述xml格式的集成测试用例,使所述集成测试用例通过所述Jmeter测试脚本的存储路径触发Jmeter测试脚本进行测试;Running the Ant integration test tool to invoke the integrated test case in the xml format, so that the integration test case triggers the Jmeter test script to test through the storage path of the Jmeter test script;
    将测试后的响应报文自动与所述响应报文进行比较,根据所述结果输出路径输出测试结果。The test response message is automatically compared with the response message, and the test result is output according to the result output path.
  10. 如权利要求9所述的接口自动化测试装置,其特征在于,所述接口自动化测试装置还用于:The interface automation test apparatus according to claim 9, wherein said interface automatic test apparatus is further configured to:
    当所述接口发生修改时,获取修改的接口文档,根据所述修改后的接口文档依次生成Json测试样例、测试用例模板、Json测试用例、Jmeter测试用例和集成测试用例,再运行所述测试工具调用所述集成测试用例进行测试,重新自动输出测试结果。When the interface is modified, obtaining the modified interface document, and sequentially generating a Json test sample, a test case template, a Json test case, a Jmeter test case, and an integrated test case according to the modified interface file, and then running the test. The tool calls the integrated test case to test and re-output the test result automatically.
  11. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:A terminal device comprising a memory, a processor, and computer readable instructions stored in the memory and operable on the processor, wherein the processor executes the computer readable instructions as follows step:
    获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document;
    根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;Generating a test case template automatically according to the Json test sample, and automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
    根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果。Generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, and triggering the Jmeter test script to test by the integrated test case, and automatically outputting the test result.
  12. 如权利要求11所述的终端设备,其特征在于,所述获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例,包括:The terminal device according to claim 11, wherein the obtaining an interface document of a different interface, and automatically generating a Json test sample of different interfaces according to the interface document, comprising:
    获取不同接口的接口文档,根据所述接口文档的外层字段名调用接口文档的数据自动生成不同接口的Json格式的测试样例,所述测试样例包括请求报文和响应报文。The interface document of the interface is obtained, and the data of the interface document is automatically generated according to the outer field name of the interface document to automatically generate a test sample of the Json format of the interface. The test sample includes a request message and a response message.
  13. 如权利要求12所述的终端设备,其特征在于,所述根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本,包括:The terminal device according to claim 12, wherein said automatically generating a test case template according to said Json test sample, and automatically generating a Json test case according to said test case template, and then automatically according to said Json test case Generate Jmeter test scripts, including:
    根据所述Json测试样例自动生成测试用例模板,将结果验证的数值输入到所述测试用例模板中,再根据所述测试用例模板自动生成Json测试用例,最后根据所述Json测试用例自动生成Jmeter测试脚本;Automatically generating a test case template according to the Json test sample, inputting the value of the result verification into the test case template, automatically generating a Json test case according to the test case template, and finally automatically generating a Jmeter according to the Json test case. Test script
    或者,将所述不同接口的Json测试样例集合生成Json测试样例集,根据 所述Json测试样例集自动生成所述Json测试样例集包括的接口各自的测试用例模板,将结果验证的数值分别输入到所述测试用例模板中,再根据所述测试用例模板分别自动生成Json测试用例,最后根据所述Json测试用例分别自动生成Jmeter测试脚本。Alternatively, the Json test sample set of the different interfaces is generated to generate a Json test sample set, and the test case template of each interface included in the Json test sample set is automatically generated according to the Json test sample set, and the result is verified. The values are respectively input into the test case template, and then the Json test cases are automatically generated according to the test case templates, and finally the Jmeter test scripts are automatically generated according to the Json test cases.
  14. 如权利要求13所述的终端设备,其特征在于,所述根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果,包括:The terminal device according to claim 13, wherein said generating an integrated test case according to said Jmeter test script, calling said integrated test case through a test tool, and triggering said Jmeter test script by said integrated test case Test and automatically output test results, including:
    根据所述Jmeter测试脚本的存储路径和结果输出路径生成xml格式的集成测试用例;Generating an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script;
    运行Ant集成测试工具调用所述xml格式的集成测试用例,使所述集成测试用例通过所述Jmeter测试脚本的存储路径触发Jmeter测试脚本进行测试;Running the Ant integration test tool to invoke the integrated test case in the xml format, so that the integration test case triggers the Jmeter test script to test through the storage path of the Jmeter test script;
    将测试后的响应报文自动与所述响应报文进行比较,根据所述结果输出路径输出测试结果。The test response message is automatically compared with the response message, and the test result is output according to the result output path.
  15. 如权利要求14所述的终端设备,其特征在于,在所述根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果的步骤之后,所述处理器执行所述计算机可读指令时还实现如下步骤:The terminal device according to claim 14, wherein the integration test case is generated according to the Jmeter test script, the integration test case is invoked by a test tool, and the Jmeter test is triggered by the integration test case After the script performs the test and automatically outputs the test result, the processor further implements the following steps when executing the computer readable instruction:
    当所述接口发生修改时,获取修改的接口文档,根据所述修改后的接口文档依次生成Json测试样例、测试用例模板、Json测试用例、Jmeter测试用例和集成测试用例,再运行所述测试工具调用所述集成测试用例进行测试,重新自动输出测试结果。When the interface is modified, obtaining the modified interface document, and sequentially generating a Json test sample, a test case template, a Json test case, a Jmeter test case, and an integrated test case according to the modified interface file, and then running the test. The tool calls the integrated test case to test and re-output the test result automatically.
  16. 一个或多个存储有计算机可读指令的非易失性可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:One or more non-transitory readable storage mediums storing computer readable instructions, wherein when the computer readable instructions are executed by one or more processors, cause the one or more processors to execute The following steps:
    获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例;Obtain an interface document of different interfaces, and automatically generate a Json test sample of different interfaces according to the interface document;
    根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本;Generating a test case template automatically according to the Json test sample, and automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
    根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果。Generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, and triggering the Jmeter test script to test by the integrated test case, and automatically outputting the test result.
  17. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述获取不同接口的接口文档,根据所述接口文档自动生成不同接口的Json测试样例,包括:The non-volatile readable storage medium according to claim 16, wherein the obtaining an interface document of a different interface, and automatically generating a Json test sample of different interfaces according to the interface document, comprising:
    获取不同接口的接口文档,根据所述接口文档的外层字段名调用接口文档的数据自动生成不同接口的Json格式的测试样例,所述测试样例包括请求报文和响应报文。The interface document of the interface is obtained, and the data of the interface document is automatically generated according to the outer field name of the interface document to automatically generate a test sample of the Json format of the interface. The test sample includes a request message and a response message.
  18. 如权利要求17所述的非易失性可读存储介质,其特征在于,所述根据所述Json测试样例自动生成测试用例模板,并根据所述测试用例模板自动生成Json测试用例,再根据所述Json测试用例自动生成Jmeter测试脚本,包括:The non-volatile readable storage medium according to claim 17, wherein said automatically generating a test case template according to said Json test sample, and automatically generating a Json test case according to said test case template, and then The Json test case automatically generates a Jmeter test script, including:
    根据所述Json测试样例自动生成测试用例模板,将结果验证的数值输入到所述测试用例模板中,再根据所述测试用例模板自动生成Json测试用例,最后根据所述Json测试用例自动生成Jmeter测试脚本;Automatically generating a test case template according to the Json test sample, inputting the value of the result verification into the test case template, automatically generating a Json test case according to the test case template, and finally automatically generating a Jmeter according to the Json test case. Test script
    或者,将所述不同接口的Json测试样例集合生成Json测试样例集,根据所述Json测试样例集自动生成所述Json测试样例集包括的接口各自的测试用例模板,将结果验证的数值分别输入到所述测试用例模板中,再根据所述测试用例模板分别自动生成Json测试用例,最后根据所述Json测试用例分别自动生成Jmeter测试脚本。Alternatively, the Json test sample set of the different interfaces is generated to generate a Json test sample set, and the test case template of each interface included in the Json test sample set is automatically generated according to the Json test sample set, and the result is verified. The values are respectively input into the test case template, and then the Json test cases are automatically generated according to the test case templates, and finally the Jmeter test scripts are automatically generated according to the Json test cases.
  19. 如权利要求18所述的非易失性可读存储介质,其特征在于,所述根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果,包括:The non-volatile readable storage medium according to claim 18, wherein said generating an integrated test case according to said Jmeter test script, calling said integrated test case through a test tool, and passing said integrated test case Trigger the Jmeter test script to test and automatically output the test results, including:
    根据所述Jmeter测试脚本的存储路径和结果输出路径生成xml格式的集成测试用例;Generating an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script;
    运行Ant集成测试工具调用所述xml格式的集成测试用例,使所述集成测试用例通过所述Jmeter测试脚本的存储路径触发Jmeter测试脚本进行测试;Running the Ant integration test tool to invoke the integrated test case in the xml format, so that the integration test case triggers the Jmeter test script to test through the storage path of the Jmeter test script;
    将测试后的响应报文自动与所述响应报文进行比较,根据所述结果输出路径输出测试结果。The test response message is automatically compared with the response message, and the test result is output according to the result output path.
  20. 如权利要求19所述的非易失性可读存储介质,其特征在于,在所述根据所述Jmeter测试脚本生成集成测试用例,通过测试工具调用所述集成测试用例,并通过所述集成测试用例触发所述Jmeter测试脚本进行测试,自动输出测试结果的步骤之后,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:The non-volatile readable storage medium according to claim 19, wherein said integrated test case is generated according to said Jmeter test script, said integrated test case is invoked by said test tool, and said integration test is passed The use case triggers the Jmeter test script to test, and after the step of automatically outputting the test result, the computer readable instructions are executed by one or more processors, such that the one or more processors further perform the following steps:
    当所述接口发生修改时,获取修改的接口文档,根据所述修改后的接口文档依次生成Json测试样例、测试用例模板、Json测试用例、Jmeter测试用例和集成测试用例,再运行所述测试工具调用所述集成测试用例进行测试,重新自动输出测试结果。When the interface is modified, obtaining the modified interface document, and sequentially generating a Json test sample, a test case template, a Json test case, a Jmeter test case, and an integrated test case according to the modified interface file, and then running the test. The tool calls the integrated test case to test and re-output the test result automatically.
PCT/CN2018/081545 2018-02-07 2018-04-02 Automated interface testing method, device, equipment, and storage medium WO2019153472A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810121971.XA CN108415832B (en) 2018-02-07 2018-02-07 Interface automation test method, device, equipment and storage medium
CN201810121971.X 2018-02-07

Publications (1)

Publication Number Publication Date
WO2019153472A1 true WO2019153472A1 (en) 2019-08-15

Family

ID=63128025

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/081545 WO2019153472A1 (en) 2018-02-07 2018-04-02 Automated interface testing method, device, equipment, and storage medium

Country Status (2)

Country Link
CN (1) CN108415832B (en)
WO (1) WO2019153472A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112069078A (en) * 2020-09-15 2020-12-11 平安银行股份有限公司 ESA interface pressure testing method, device, testing equipment and storage medium
CN112084108A (en) * 2020-08-28 2020-12-15 山东英信计算机技术有限公司 Test script generation method and device and related components
CN114090454A (en) * 2021-11-29 2022-02-25 苏州万店掌网络科技有限公司 Interface automatic testing method, device, equipment and storage medium

Families Citing this family (41)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408370A (en) * 2018-09-18 2019-03-01 深圳壹账通智能科技有限公司 Interface testing document generating method, device, computer equipment and storage medium
CN109408375B (en) * 2018-09-27 2023-06-09 深圳壹账通智能科技有限公司 Method and device for generating interface document
CN109324974A (en) * 2018-10-09 2019-02-12 郑州云海信息技术有限公司 It is a kind of to control the method and device for executing in batches script
CN109522220A (en) * 2018-10-23 2019-03-26 中国银行股份有限公司 A kind of text test method and device
CN109542767B (en) * 2018-10-25 2023-04-11 平安科技(深圳)有限公司 Automatic testing method and device based on block chain, computer equipment and storage medium
CN109634841B (en) * 2018-10-26 2024-03-12 平安科技(深圳)有限公司 Electronic device, interface automatic test method and storage medium
CN109684195A (en) * 2018-10-26 2019-04-26 平安科技(深圳)有限公司 Electronic device, script conversion method and storage medium
CN111124876A (en) * 2018-10-31 2020-05-08 北京国双科技有限公司 Method and device for realizing interface test case, storage medium and processor
CN111198810A (en) * 2018-11-16 2020-05-26 鸿合科技股份有限公司 Software testing method and device and electronic equipment
CN111221718A (en) * 2018-11-23 2020-06-02 鸿合科技股份有限公司 Interface testing method and device
CN111274120B (en) * 2018-12-05 2024-02-02 三六零科技集团有限公司 Interface document verification method and device
CN111290933A (en) * 2018-12-06 2020-06-16 中兴通讯股份有限公司 Software automation software testing method and device
CN109697150A (en) * 2018-12-14 2019-04-30 平安普惠企业管理有限公司 Show method, apparatus, computer equipment and the storage medium of test report
CN111324526B (en) * 2018-12-14 2024-04-26 北京金山云网络技术有限公司 Interface test system, method and server
CN109685626A (en) * 2018-12-27 2019-04-26 北京顺丰同城科技有限公司 A kind of lower single test method and device
CN109710531B (en) * 2018-12-29 2022-07-05 奇安信科技集团股份有限公司 Application program auditing method, device and system, electronic equipment and storage medium
CN109902002B (en) * 2019-02-14 2020-06-02 浙江口碑网络技术有限公司 Generation method and device of combined test case, storage medium and computer equipment
CN109885498A (en) * 2019-02-26 2019-06-14 北京首汽智行科技有限公司 A kind of test script generation method and system
CN110046093A (en) * 2019-03-14 2019-07-23 平安信托有限责任公司 Interface test method, device, computer equipment and storage medium
CN111752823A (en) * 2019-03-29 2020-10-09 北京新能源汽车股份有限公司 Method, device and equipment for testing vehicle-mounted power supply application software
CN110134584A (en) * 2019-04-12 2019-08-16 深圳壹账通智能科技有限公司 A kind of generation method, device, storage medium and the server of interface testing use-case
CN110221948B (en) * 2019-04-18 2023-03-28 深圳壹账通智能科技有限公司 Test script generation method, test script generation device, computer device and storage medium
CN110059011A (en) * 2019-04-22 2019-07-26 泰康保险集团股份有限公司 Interface test method, device, medium and electronic equipment
CN110109837B (en) * 2019-05-06 2023-10-13 上海蔚来汽车有限公司 Integrated test method, integrated test device, controller and medium
CN110232018A (en) * 2019-05-17 2019-09-13 浙江数链科技有限公司 Interface test method, device, computer equipment
CN112131091B (en) * 2019-06-24 2024-04-16 百度在线网络技术(北京)有限公司 Test method and device and electronic equipment
CN110532169A (en) * 2019-07-08 2019-12-03 平安科技(深圳)有限公司 Interface testing case generation method, device, computer equipment and storage medium
CN110471842A (en) * 2019-07-12 2019-11-19 平安普惠企业管理有限公司 A kind of test method, device and computer readable storage medium
CN110377514A (en) * 2019-07-12 2019-10-25 中汇信息技术(上海)有限公司 Management method, device, electronic equipment and the storage medium of software component
CN112395184A (en) * 2019-08-19 2021-02-23 中移(苏州)软件技术有限公司 Information acquisition method, equipment and computer storage medium
CN110716870B (en) * 2019-09-23 2023-01-31 中国建设银行股份有限公司 Automatic service testing method and device
CN111427765B (en) * 2020-02-17 2022-09-20 叮当快药科技集团有限公司 Method and system for automatically starting interface performance test realized based on jmeter
CN111290968A (en) * 2020-03-19 2020-06-16 上海异势信息科技有限公司 Method, device, equipment and storage medium for realizing automatic test
CN111209218A (en) * 2020-04-01 2020-05-29 中电万维信息技术有限责任公司 Automatic performance testing method based on Jmeter
CN111522741B (en) * 2020-04-14 2023-11-14 北京奇艺世纪科技有限公司 Interface test code generation method and device, electronic equipment and readable storage medium
CN111858376A (en) * 2020-07-29 2020-10-30 平安养老保险股份有限公司 Request message generation method and interface test method
CN112328503A (en) * 2020-11-30 2021-02-05 武汉空心科技有限公司 Task acceptance method for software development working platform
CN112486846A (en) * 2020-12-18 2021-03-12 上海中通吉网络技术有限公司 Method, device, equipment and storage medium for automatically generating and executing test case
CN113190445A (en) * 2021-04-29 2021-07-30 中国邮政储蓄银行股份有限公司 Interface test method, interface test device and interface test system
CN113778395A (en) * 2021-08-30 2021-12-10 东风汽车集团股份有限公司 Software automatic integration control method based on software development platform
CN116188107A (en) * 2023-02-16 2023-05-30 上海聚水潭网络科技有限公司 Test order generation method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160283364A1 (en) * 2015-03-24 2016-09-29 Hcl Technologies Limited System and method for automatically testing an application programming interface (api)
CN106021111A (en) * 2016-05-30 2016-10-12 上海携程商务有限公司 Interface testing method and system
CN106294177A (en) * 2016-08-22 2017-01-04 腾讯科技(深圳)有限公司 The method for testing pressure of a kind of interface and test equipment
CN106708676A (en) * 2016-12-01 2017-05-24 广州酷狗计算机科技有限公司 Interface test method and apparatus
CN107239398A (en) * 2017-05-24 2017-10-10 四川长虹电器股份有限公司 A kind of interface testing use-case automatic creation system and method based on Postman
CN107608889A (en) * 2017-09-15 2018-01-19 杭州销冠网络科技有限公司 A kind of test script automatic generation method and system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101996132A (en) * 2009-08-14 2011-03-30 中兴通讯股份有限公司 Method and device for automatically testing common object request broker architecture (CORBA) interfaces
KR101132560B1 (en) * 2010-06-09 2012-04-03 강원대학교산학협력단 System and method for automatic interface testing based on simulation for robot software components
CN107402884A (en) * 2017-07-31 2017-11-28 深圳乐信软件技术有限公司 Generate the method and device of interface testing code

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160283364A1 (en) * 2015-03-24 2016-09-29 Hcl Technologies Limited System and method for automatically testing an application programming interface (api)
CN106021111A (en) * 2016-05-30 2016-10-12 上海携程商务有限公司 Interface testing method and system
CN106294177A (en) * 2016-08-22 2017-01-04 腾讯科技(深圳)有限公司 The method for testing pressure of a kind of interface and test equipment
CN106708676A (en) * 2016-12-01 2017-05-24 广州酷狗计算机科技有限公司 Interface test method and apparatus
CN107239398A (en) * 2017-05-24 2017-10-10 四川长虹电器股份有限公司 A kind of interface testing use-case automatic creation system and method based on Postman
CN107608889A (en) * 2017-09-15 2018-01-19 杭州销冠网络科技有限公司 A kind of test script automatic generation method and system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112084108A (en) * 2020-08-28 2020-12-15 山东英信计算机技术有限公司 Test script generation method and device and related components
CN112069078A (en) * 2020-09-15 2020-12-11 平安银行股份有限公司 ESA interface pressure testing method, device, testing equipment and storage medium
CN112069078B (en) * 2020-09-15 2024-03-19 平安银行股份有限公司 ESA interface pressure test method, ESA interface pressure test device, ESA interface pressure test equipment and storage medium
CN114090454A (en) * 2021-11-29 2022-02-25 苏州万店掌网络科技有限公司 Interface automatic testing method, device, equipment and storage medium
CN114090454B (en) * 2021-11-29 2023-01-24 苏州万店掌网络科技有限公司 Interface automation test method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN108415832A (en) 2018-08-17
CN108415832B (en) 2021-03-02

Similar Documents

Publication Publication Date Title
WO2019153472A1 (en) Automated interface testing method, device, equipment, and storage medium
WO2019072110A1 (en) Method for generating application program, apparatus, system, device, and medium
US9740594B2 (en) Automated debug trace specification
US11010283B2 (en) Mock-based unit test(s) for an end-to-end test of a code snippet
US10114737B2 (en) Methods and systems for computing code coverage using grouped/filtered source classes during testing of an application
US9218269B2 (en) Testing multiple target platforms
US20170075791A1 (en) Methods and systems for executing tests using grouped/filtered test classes during testing of an application
US20200201689A1 (en) System and method for determining a process flow of a software application and for automatically generating application testing code
US10452522B1 (en) Synthetic data generation from a service description language model
US8661356B2 (en) Time application having an intergrated check engine
US20130067439A1 (en) Injecting faults into program for testing
WO2020186680A1 (en) Interface testing method based on modeling platform
CN110879781B (en) Program debugging method, device, electronic equipment and computer readable storage medium
WO2021047240A1 (en) Flink engine-based data parsing method and apparatus
US20210117313A1 (en) Language agnostic automation scripting tool
US20190138429A1 (en) Aggregating data for debugging software
US10459698B2 (en) Framework for generating adapters in an integrated development environment
US10873628B2 (en) System and method for non-intrusive context correlation across cloud services
US7805711B2 (en) Redirection interface system and method for CIM object manager provider
CN111782207A (en) Method, device and equipment for generating task stream code and storage medium
US20140215441A1 (en) Providing directional debugging breakpoints
CN108595656B (en) Data processing method and system
US20100250228A1 (en) Modeling a composite application
CN116841543A (en) Development method for dynamically generating cross-platform multi-terminal application based on Flutter
CN110362294A (en) Development task executes method, apparatus, electronic equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18905091

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 02.11.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18905091

Country of ref document: EP

Kind code of ref document: A1