CN107026773B - Automatic association method for interface automation test - Google Patents

Automatic association method for interface automation test Download PDF

Info

Publication number
CN107026773B
CN107026773B CN201710343838.4A CN201710343838A CN107026773B CN 107026773 B CN107026773 B CN 107026773B CN 201710343838 A CN201710343838 A CN 201710343838A CN 107026773 B CN107026773 B CN 107026773B
Authority
CN
China
Prior art keywords
interface
data
module
association
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710343838.4A
Other languages
Chinese (zh)
Other versions
CN107026773A (en
Inventor
严金勇
师洛蓓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN201710343838.4A priority Critical patent/CN107026773B/en
Publication of CN107026773A publication Critical patent/CN107026773A/en
Application granted granted Critical
Publication of CN107026773B publication Critical patent/CN107026773B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0807Network architectures or network communication protocols for network security for authentication of entities using tickets, e.g. Kerberos

Abstract

The invention discloses an automatic association method for interface automatic test, which comprises a data module, an association module and a request module, wherein the data module is used for providing interface test data of each interface, the association module is used for analyzing the interface test data transmitted by the data module to generate an association file, association judgment and association processing, and the request module is used for processing interface requests and responses. The invention adopts a mode of separating data from service, and the interface tester can realize the automatic association of the interface only by preparing interface test data. In addition, the test data of the invention is easy to maintain, the requirement on the code capability is low, the difficulty of the automatic test of the interface is greatly reduced, and the working efficiency is improved.

Description

Automatic association method for interface automation test
Technical Field
The invention relates to the field of automatic testing, in particular to an automatic association method for automatic interface testing.
Background
With the development of cloud computing and big data, a plurality of manufacturers provide services in a form based on the services, and the validity, reliability and the like of the services need to be ensured through interface testing, so that the interface automatic testing is carried forward. In the existing interface automation test schemes, most of the interface automation test schemes are provided with a set of system methods, and a solution is not provided for how to realize the automatic association of the interfaces, so that the difficulty in developing the interface automation test is caused.
In the implementation of the interface automation test, it is no longer a simple single interface test, and there is a need for association between interfaces, such as:
1) the input of one interface needs a certain field or a certain part of the return message of the other interface as a parameter, and the returned parameter is dynamically changed.
2) With the enhancement of software security, many services are based on a token authentication mechanism, and after a corresponding token is obtained by accessing, the corresponding API can be accessed by holding the corresponding token and request parameters.
For the above scenarios, most of the existing implementations are implemented by code codes, which undoubtedly increases the difficulty for interface testers and takes a lot of time to write and debug codes.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide an automatic association method for interface automatic test, which is based on data drive and adopts a mode of separating data from service, automatically generates an association file according to interface test data, and realizes the automatic association of interfaces; interface testing personnel only need prepare the test data, and can realize the interface testing without any codes, thereby greatly reducing the difficulty of the interface testing.
The purpose of the invention is realized by the following technical scheme:
an automatic association method for interface automation test comprises a data module, an association module and a request module, wherein the data module is used for providing interface test data of each interface, the association module is used for analyzing the interface test data transmitted by the data module to generate an association file, association judgment and association processing, the request module is used for processing interface requests and responses, and the automatic association method comprises the following steps:
A. interface test data of each interface are prepared in the data module, each interface in the data module comprises one piece of interface test data, specific content of the interface test data comprises request data and associated data, and the request data comprises an address, a parameter, a response message and a message body;
if the request data of the interface needs to be associated with other interfaces, setting the value of partial data of the request data of the interface as a variable name;
if the data in the response message of the interface provides parameters for other interfaces, setting variable names and acquisition modes in the associated data of the interface;
B. the correlation module analyzes the interface test data transmitted by the data module to generate a correlation file, and all interfaces needing to be correlated are recorded in the correlation file; all interfaces are divided into two types of interfaces, and the first type of interface needs the associated variable name of each associated interface; the interface from which the associated variable of the second type of interface comes and the way of acquiring the value of the associated variable from the response;
C. the request module judges whether the interface exists in the associated file according to the currently executed interface a and the associated file analyzed by the associated module;
D. if the interface exists in the association file, indicating that the interface needs to be associated;
E. judging which variables are associated with the interface in the association file;
F. judging which correlation interface the variable comes from in the correlation file, and acquiring the value of the variable;
G. the request module executes the association interface request and processes the response to assign the variable according to the acquisition mode of the association variable value;
H. replacing the value of the corresponding variable in the interface a request data according to the value of the associated variable;
I. judging whether the variable is associated completely, if so, executing the step J, otherwise, repeating the steps F to H;
J. the request module executes an interface a request; the request module then processes the response.
Compared with the prior art, the invention has the following advantages and beneficial effects:
the invention adopts a mode of separating data from service, and the interface tester can realize the automatic association of the interface only by preparing interface test data. In addition, the test data of the invention is easy to maintain, the requirement on the code capability is low, the difficulty of the automatic test of the interface is greatly reduced, and the working efficiency is improved.
Drawings
FIG. 1 is a block diagram illustrating a flow structure of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the following examples:
example one
As shown in fig. 1, an automatic association method for interface automation test includes a data module, an association module and a request module, where the data module is used to provide interface test data of each interface, the association module is used to analyze the interface test data transmitted by the data module to generate an association file, association judgment and association processing, the request module is used to process an interface request and response, and the automatic association method includes:
A. interface test data of each interface are prepared in the data module, each interface in the data module comprises one piece of interface test data, specific content of the interface test data comprises request data and associated data, and the request data comprises an address, a parameter, a response message and a message body;
if the request data of the interface needs to be associated with other interfaces, setting the value of partial data of the request data of the interface as a variable name;
if the data in the response message of the interface provides parameters for other interfaces, setting variable names and acquisition modes in the associated data of the interface; the acquisition mode is determined according to how to acquire data from the response, and can be regular expression acquisition, left and right boundary acquisition, jsonnpath acquisition and the like; taking the example of obtaining the value of a certain node from the json message in response, the obtained value is transmitted to the json path of the corresponding node, for example, "$.
B. The correlation module analyzes the interface test data transmitted by the data module to generate a correlation file, and all interfaces needing to be correlated are recorded in the correlation file; all interfaces are divided into two types of interfaces, and the first type of interface needs the associated variable name of each associated interface; the interface from which the associated variable of the second type of interface comes and the way of acquiring the value of the associated variable from the response;
C. the request module judges whether the interface exists in the associated file according to the currently executed interface a and the associated file analyzed by the associated module;
D. if the interface exists in the association file, indicating that the interface needs to be associated;
E. judging which variables are associated with the interface in the association file;
F. judging which correlation interface the variable comes from in the correlation file, and acquiring the value of the variable;
G. the request module executes the association interface request and processes the response to assign the variable according to the acquisition mode of the association variable value;
H. replacing the value of the corresponding variable in the interface a request data according to the value of the associated variable;
I. judging whether the variable is associated completely, if so, executing the step J, otherwise, repeating the steps F to H;
J. the request module executes an interface a request; the request module then processes the response.
Example two
As shown in fig. 1, an automatic association method for interface automation test includes a data module, an association module and a request module, where the data module is used to provide interface test data of each interface, the association module is used to analyze the interface test data transmitted by the data module to generate an association file, association judgment and association processing, the request module is used to process an interface request and response, and the automatic association method includes:
step 1, interface test data is prepared in the data module, and the interface data can be data in a json format, as follows:
1.1, each piece of interface information includes request data (headers, url, method, body), an interface name (name) and assertion information (tests), wherein if the request data of the interface needs to be associated with other interfaces, a value of the data needing to be associated is set to be "{ { variable name } } in the request data, and if a response message of the interface provides associated data for other interfaces, a value of" setVariable ("variable name", acquisition mode) "is set in the associated data;
1.2, if the json file contains data of two interfaces, one is a user login interface, and the other is an interface for acquiring all information of a user, wherein the interface for acquiring all information of the user is associated with the user login interface, and the token is taken to access the interface for acquiring all information of the user after the interface for acquiring all information of the user is executed and the user login interface is executed first before the interface for acquiring all information of the user is executed;
1.3, if the token in the interface body for acquiring all the information of the user needs to be associated with the interface for logging in by the user, setting the token in the body as 'token \': \ '{ { token } }'; token is obtained by jsonnpath in the response message of the interface of "user login", and is set as setVariable (\ "token \ in, jsonndata. data. token) in the assertion information of the interface of" user login ";
step 2, the correlation module analyzes the interface test data to generate a correlation file, all the interfaces needing to be correlated are recorded in the correlation file, and all the interfaces comprise two parts: one part is the variable name associated with each interface needing to be associated; the other part is the interface from which the associated variable comes and the acquisition mode of the value of the associated variable from the response; the generated json format association file is as follows:
2.1, generating an association file, wherein a node pre _ val represents which interfaces need to be associated and variable names associated with the interfaces and exists in a JSONObject form; the node environment _ val represents which interface the associated variable comes from and the acquisition mode of the value of the variable;
2.2, if the variable needing to be associated with the interface for acquiring all the information of the user is token, the token is from the interface for logging in the user, and the token is acquired from the response message through jsonnpath;
step 3, the request module judges whether the interface exists in the associated file according to the associated file analyzed by the currently executed interface A;
3.1, if an interface of 'acquiring all information of a user' is executed, judging whether the interface exists in the associated file or not through jsonnpath '$ pre _ val' and 'acquiring all information of the user';
step 4, if the interface exists in the association file, indicating that the interface needs to be associated;
step 5, judging which variables are associated with the interface in the association file;
5.1, if the information of the user is obtained through jsonnpath "$. pre _ val.," obtaining all variables needing to be associated of the interface ", wherein the obtained variables needing to be associated are token;
step 6, judging which correlation interface the variable comes from in the correlation file, and acquiring the value of the variable;
6.1, if the token is from the interface of ' user login ' through jsonnpath ' $, environment _ val, token.test _ case _ name ', the token is obtained from the json response message through jsonnpath ' $.
Step 7, the request module executes the association interface request and processes the response to assign the variable according to the acquisition mode of the association variable value;
7.1, if a user login interface is executed, and data is passed through jsonnpath "$. token", the content in the response message is given to the token;
step 8, replacing the value of the corresponding variable in the interface A request data according to the value of the associated variable;
8.1, judging that the { { token } } is positioned in the body of the interface for acquiring all information of the user, and replacing the { { token }' in the body with the value of token in the step 7;
step 9, judging whether the variables are associated completely, if so, executing step ten, otherwise, repeating the steps from six to eight;
step 10, a request module executes an interface A request;
10.1, executing an interface of 'acquiring all information of a user';
step 11, requesting the module to process the response;
the above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (1)

1. An automatic association method for interface automation test, characterized in that: the system comprises a data module, an association module and a request module, wherein the data module is used for providing interface test data of each interface, the association module is used for analyzing the interface test data transmitted by the data module to generate an association file, association judgment and association processing, the request module is used for processing interface requests and responses, and the automatic association method comprises the following steps:
A. interface test data of each interface are prepared in the data module, each interface in the data module comprises one piece of interface test data, specific content of the interface test data comprises request data and associated data, and the request data comprises an address, a parameter, a response message and a message body;
if the request data of the interface needs to be associated with other interfaces, setting the value of partial data of the request data of the interface as a variable name;
if the data in the response message of the interface provides parameters for other interfaces, setting variable names and acquisition modes in the associated data of the interface;
B. the correlation module analyzes the interface test data transmitted by the data module to generate a correlation file, and all interfaces needing to be correlated are recorded in the correlation file; all interfaces are divided into two types of interfaces, and the first type of interface needs the associated variable name of each associated interface; the interface from which the associated variable of the second type of interface comes and the way of acquiring the value of the associated variable from the response;
C. the request module judges whether the interface exists in the associated file according to the currently executed interface a and the associated file analyzed by the associated module;
D. if the interface exists in the association file, indicating that the interface needs to be associated;
E. judging which variables are associated with the interface in the association file;
F. judging which correlation interface the variable comes from in the correlation file, and acquiring the value of the variable;
G. the request module executes the association interface request and processes the response to assign the variable according to the acquisition mode of the association variable value;
H. replacing the value of the corresponding variable in the interface a request data according to the value of the associated variable;
I. judging whether the variable is associated completely, if so, executing the step J, otherwise, repeating the steps F to H;
J. the request module executes an interface a request; the request module then processes the response.
CN201710343838.4A 2017-05-16 2017-05-16 Automatic association method for interface automation test Active CN107026773B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710343838.4A CN107026773B (en) 2017-05-16 2017-05-16 Automatic association method for interface automation test

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710343838.4A CN107026773B (en) 2017-05-16 2017-05-16 Automatic association method for interface automation test

Publications (2)

Publication Number Publication Date
CN107026773A CN107026773A (en) 2017-08-08
CN107026773B true CN107026773B (en) 2020-03-17

Family

ID=59529724

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710343838.4A Active CN107026773B (en) 2017-05-16 2017-05-16 Automatic association method for interface automation test

Country Status (1)

Country Link
CN (1) CN107026773B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109992499A (en) * 2017-12-29 2019-07-09 北京奇虎科技有限公司 Interface test method, device and computer readable storage medium
CN108108305A (en) * 2018-01-02 2018-06-01 中国银行股份有限公司 A kind of environment availability testing method and system
CN108563539A (en) * 2018-03-21 2018-09-21 广州视源电子科技股份有限公司 Interface test method, server, readable storage medium storing program for executing and system
CN111324526B (en) * 2018-12-14 2024-04-26 北京金山云网络技术有限公司 Interface test system, method and server
CN110166469B (en) * 2019-05-28 2022-03-15 深圳市六度人和科技有限公司 Authentication method, device and storage device
CN110990280B (en) * 2019-12-03 2023-09-12 中国工商银行股份有限公司 Automatic test data generation system and method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101330329A (en) * 2008-07-29 2008-12-24 中兴通讯股份有限公司 Self-adapting testing method and system
CN104615534A (en) * 2015-01-28 2015-05-13 广州酷狗计算机科技有限公司 Interface test method and device
CN104866422A (en) * 2015-05-20 2015-08-26 中国互联网络信息中心 Web Service automatic test system and method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150058826A1 (en) * 2013-08-26 2015-02-26 The Trustees Of Columbia University In The City Of New York Systems and methods for efficiently and effectively detecting mobile app bugs

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101330329A (en) * 2008-07-29 2008-12-24 中兴通讯股份有限公司 Self-adapting testing method and system
CN104615534A (en) * 2015-01-28 2015-05-13 广州酷狗计算机科技有限公司 Interface test method and device
CN104866422A (en) * 2015-05-20 2015-08-26 中国互联网络信息中心 Web Service automatic test system and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《基于接口语义契约的WEB服务测试数据生成》;候可佳等;《软件学报》;20131128;第24卷(第9期);全文 *

Also Published As

Publication number Publication date
CN107026773A (en) 2017-08-08

Similar Documents

Publication Publication Date Title
CN107026773B (en) Automatic association method for interface automation test
CN110287109B (en) Protocol interface testing method and device, computer equipment and storage medium thereof
EP3534263A1 (en) Systems and methods for web analytics testing and web development
CN107273269B (en) Log analysis method and device
CN111221743A (en) Automatic testing method and system
CN105373478B (en) Automated testing method and system
CN108628748B (en) Automatic test management method and automatic test management system
US9846781B2 (en) Unused parameters of application under test
CN108459850B (en) Method, device and system for generating test script
CN110750458A (en) Big data platform testing method and device, readable storage medium and electronic equipment
CN107659455B (en) Method, storage medium, device and system for Mock data of iOS (internet operating system) end
US10069855B1 (en) Automated security analysis of software libraries
CN106972983B (en) Automatic testing device and method for network interface
CN111124937B (en) Method and system for assisting in improving test case generation efficiency based on instrumentation function
CN106649110A (en) Software test method and system
CN115470152B (en) Test code generation method, test code generation device, and storage medium
CN116431522A (en) Automatic test method and system for low-code object storage gateway
CN116257223A (en) Data isolation development method, device, equipment, readable storage medium and product
CN115934559A (en) Testing method of intelligent form testing system
CN114721969A (en) Method and device for separating interface automation test data and test codes
CN111813665A (en) Big data platform interface data testing method and system based on python
CN110347589A (en) A kind of software unit testing automated detection method and system
CN111026631A (en) Automatic interface detection method and device and server
CN112799956B (en) Asset identification capability test method, device and system device
CN114691475A (en) Software testing method based on objective function

Legal Events

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