CN109815107B - Method and device for automatic testing - Google Patents

Method and device for automatic testing Download PDF

Info

Publication number
CN109815107B
CN109815107B CN201711172013.7A CN201711172013A CN109815107B CN 109815107 B CN109815107 B CN 109815107B CN 201711172013 A CN201711172013 A CN 201711172013A CN 109815107 B CN109815107 B CN 109815107B
Authority
CN
China
Prior art keywords
interface
test
data
protocol
tested
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
CN201711172013.7A
Other languages
Chinese (zh)
Other versions
CN109815107A (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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201711172013.7A priority Critical patent/CN109815107B/en
Publication of CN109815107A publication Critical patent/CN109815107A/en
Application granted granted Critical
Publication of CN109815107B publication Critical patent/CN109815107B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses an automatic testing method and device, and relates to the field of computers. One embodiment of the method comprises: determining a data template of an interface to be tested belonging to a target protocol by using interface analysis logic; wherein the interface resolution logic is determined solely according to the target protocol; adding test input data into the data template, generating a test request conforming to the target protocol based on the data template comprising the test input data, and sending the test request to a server side where the interface to be tested is located; and receiving a response aiming at the test request to realize the test of the interface to be tested. The embodiment can reduce the maintenance workload of the test tool and improve the test efficiency.

Description

Method and device for automatic testing
Technical Field
The invention relates to the technical field of computers, in particular to an automatic testing method and device.
Background
In the field of software testing, the back-end service often uses a non-standard communication protocol, so that the automation testing difficulty for the back-end service is high. In the prior art, the automatic test based on the non-standard communication protocol is generally realized by the following steps:
1. the tester converts the definition source data of the tested interface into description data and adds the description data into the test tool.
2. The tester adds protocol call logic to the test tool and hard-codes the interface under test call logic in the test tool.
3. And (4) making a test case by a tester for testing.
In the process of implementing the invention, the inventor finds that the prior art has at least the following problems:
1. when a tester needs to test a newly-added interface or an upgraded interface (i.e. an upgraded untested interface), the definition source data of the interface needs to be converted first, then hard coding of the interface calling logic needs to be performed in a test tool, and meanwhile, the test tool needs to be recompiled before testing, so that the test tool has the disadvantages of large maintenance workload, poor expandability and extremely low test efficiency.
2. The tester needs to understand the protocol call logic to hard code within the test tool, which puts high demands on the tester, while leaving the tester without being dedicated to the production of test cases.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for automated testing, which can obtain interface parsing logic applicable to all interfaces under a protocol according to the protocol to which a tested interface belongs, and implement automatic parsing of the interface by using the interface parsing logic, so that when a new interface or an upgraded interface is tested, a tester does not need to perform conversion of interface definition source data, and does not need to perform hard coding of interface calling logic, thereby reducing maintenance workload of a test tool and improving test efficiency.
To achieve the above objects, according to one aspect of the present invention, there is provided a method of automated testing.
The automatic test method of the embodiment of the invention comprises the following steps: determining a data template of an interface to be tested belonging to a target protocol by using interface analysis logic; wherein the interface resolution logic is determined solely according to the target protocol; adding test input data into the data template, generating a test request conforming to the target protocol based on the data template comprising the test input data, and sending the test request to a server side where the interface to be tested is located; and receiving a response aiming at the test request to realize the test of the interface to be tested.
Optionally, the data template is in a JSON format or an XML format, and includes an entry structure and an exit structure of the interface to be tested.
Optionally, the determining, by using the interface parsing logic, a data template of the interface to be tested belonging to the target protocol includes: and receiving definition source data of the interface to be tested, and converting the definition source data into the data template by using interface analysis logic.
Optionally, the generating a test request conforming to the target protocol based on a data template including test input data includes: converting a data template comprising test input data into available data for an implementation language of the target protocol; encoding the available data by using protocol calling logic to generate the test request; wherein the protocol invocation logic is determined solely according to the target protocol.
Optionally, the receiving a response to the test request to implement the test of the interface to be tested includes: receiving the response; decoding the response by using a protocol calling logic to obtain test output data; and comparing the test output data with expected data to obtain a test result.
Optionally, the interface parsing logic and the protocol calling logic are stored in a plug-in.
Optionally, the insert is: a C dynamic library, a C + + dynamic library, a Java Jar package, a Java Class file, a PHP source file, a Shell script, or a Python script.
Optionally, the target protocol is a non-standard protocol.
To achieve the above object, according to still another aspect of the present invention, there is provided an apparatus for automated testing.
The automated testing device of the embodiment of the invention can comprise: the device comprises a preparation unit, a data analysis unit and a data analysis unit, wherein the preparation unit can be used for determining a data template of an interface to be detected belonging to a target protocol by using interface analysis logic; wherein the interface resolution logic is determined solely according to the target protocol; the execution unit is used for adding test input data into the data template, generating a test request conforming to the target protocol based on the data template comprising the test input data, and sending the test request to a server side where the interface to be tested is located; and the test unit can be used for receiving the response aiming at the test request so as to realize the test of the interface to be tested.
Optionally, the data template is in a JSON format or an XML format, and includes an entry structure and an exit structure of the interface to be tested.
Optionally, the preparation unit may be further configured to: and receiving definition source data of the interface to be tested, and converting the definition source data into the data template by using interface analysis logic.
Optionally, the execution unit may be further configured to: converting a data template comprising test input data into available data for an implementation language of the target protocol; encoding the available data by using protocol calling logic to generate the test request; wherein the protocol invocation logic is determined solely according to the target protocol.
Optionally, the test unit may be further configured to: receiving the response; decoding the response by using a protocol calling logic to obtain test output data; and comparing the test output data with expected data to obtain a test result.
Optionally, the interface parsing logic and the protocol calling logic are stored in a plug-in.
Optionally, the insert is: a C dynamic library, a C + + dynamic library, a Java Jar package, a Java Class file, a PHP source file, a Shell script, or a Python script.
Optionally, the target protocol is a non-standard protocol.
To achieve the above object, according to still another aspect of the present invention, there is provided an electronic apparatus.
An electronic device of the present invention includes: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method for the automatic test provided by the invention.
To achieve the above object, according to still another aspect of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of the invention has stored thereon a computer program which, when executed by a processor, implements the method of automated testing provided by the invention.
According to the technical scheme of the invention, one embodiment of the invention has the following advantages or beneficial effects: the interface analysis logic suitable for all the interfaces under the protocol is obtained through the protocol to which the tested interface belongs, the interface analysis logic is utilized to realize the automatic analysis of the interface definition source data to the data template, and then the automatic test of the interface to be tested is realized based on the data template, so that when a new interface or an upgraded interface is tested, the conversion of the interface definition source data is not needed by a tester, the hard coding of the interface calling logic is not needed, and only the interface definition source data is uploaded, thereby realizing the support of dynamic update of the interface, improving the test efficiency, simultaneously ensuring that the tester does not need to understand the protocol calling logic and being capable of concentrating on the manufacture of test cases; the interface analysis logic and the protocol calling logic are stored in the form of the plug-in, when an interface of a newly added protocol or an upgraded protocol is tested, the plug-in for storing the interface analysis logic and the protocol calling logic is only needed to be provided for a test tool, and the test tool and the plug-in do not need to be changed when the interface is required to be newly added or upgraded subsequently, so that the hot plug-in characteristic of the protocol is realized, the expandability of the test tool is improved, and the maintenance workload of the test tool is reduced.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of automated testing according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a specific implementation of a method for automated testing according to a first embodiment of the present invention;
FIG. 3 is a schematic diagram of a main portion of an apparatus for automated testing according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic structural diagram of an electronic device for implementing the method for automated testing according to the embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The technical scheme of the embodiment of the invention obtains the interface analysis logic suitable for all the interfaces under the protocol through the protocol to which the tested interface belongs, realizes the automatic analysis of the interface definition source data to the data template by utilizing the interface analysis logic, and further realizes the automatic test of the interface to be tested based on the data template, so that when testing a newly added interface or an upgraded interface, a tester does not need to convert the interface definition source data and does not need to carry out hard coding of interface calling logic, and only the interface definition source data is uploaded, thereby realizing the support of dynamic update of the interface, improving the test efficiency, and simultaneously ensuring that the tester does not need to understand the protocol calling logic and can concentrate on the manufacture of test cases; the interface analysis logic and the protocol calling logic are stored in the form of the plug-in, when an interface of a newly added protocol or an upgraded protocol is tested, the plug-in for storing the interface analysis logic and the protocol calling logic is only needed to be provided for a test tool, and the test tool and the plug-in do not need to be changed when the interface is required to be newly added or upgraded subsequently, so that the hot plug-in characteristic of the protocol is realized, the expandability of the test tool is improved, and the maintenance workload of the test tool is reduced.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic diagram of main steps of a method of automated testing according to an embodiment of the present invention.
As shown in fig. 1, the method for automated testing according to the embodiment of the present invention may be performed according to the following steps:
step S101: the test tool utilizes the interface parsing logic to determine a data template of the interface under test that is attributed to the target protocol.
In this step, the interface to be tested refers to an application Programming interface (api) to be tested, and the interface to be tested is located at the server and belongs to the target protocol. The server refers to a service program or a software system where an interface to be tested is located. It should be noted that, in the embodiment of the present invention, the server is not limited to the service program or the software system for providing the service for the client, and in fact, as long as the computer program contains the API and can provide the service for the outside, the server may be the server in the present invention.
Aiming at the problem that the realization difficulty of the automatic test based on the non-standard protocol in the prior art is high, the automatic test method provided by the embodiment of the invention can solve the problem that the target protocol can be the non-standard protocol. The non-standard protocol refers to a communication protocol which is established by enterprises or individuals and applied to a smaller range. It can be understood that the invention can also realize the automatic test based on the standard protocols such as hypertext Transfer Protocol (http), Transmission Control Protocol/Internet Protocol (TCP/IP), etc.
In the embodiment of the present invention, the interface parsing logic refers to a code for parsing definition source data of the interface to be tested, and the data template refers to specific data that includes a reference structure and a reference structure of the interface to be tested and is capable of loading test input data. The entry structure refers to a specific setting rule of an interface entry parameter, for example, which fields are set, and a specific requirement of each field, and the exit structure refers to a specific setting rule of an interface exit parameter.
In practical application, the interface resolution logic is determined by the target protocol separately, and the separately determining refers to: is uniquely determined by the target protocol and is independent of any interface under the target protocol. That is, after the target protocol is determined, the interface parsing logic applicable to all interfaces under the target protocol can be determined according to the encoding specification of the target protocol.
In the embodiment of the present invention, when the test tool tests the interface to be tested for the first time, it is first required to receive definition source data of the interface to be tested, which is uploaded by a tester. Wherein, defining the source data refers to defining the source code by the interface. Then, the definition source data of the interface to be tested is analyzed by using the interface analysis protocol to obtain a data template in a JSON format or an extensible Markup language xml (extensible Markup language) format, which will be mainly described below by taking the data template in the JSON format as an example.
The following is an example of a data template in json (javascript Object notation) format for JS objects. It should be noted that the following examples are merely illustrative and are not data used in actual applications.
Figure BDA0001477433610000081
The data template in the JSON format illustrated in the above example includes an identifier (id), an interface name (name), a protocol (protocol), a reference structure (reqParam), and a reference structure (rspExpected), where "type", "name", "value", "needCheck", and "exposed" in the reference structure and the reference structure are specific fields of parameters. It will be appreciated that the value field in the reference structure is empty, thereby enabling test input data to be added to the data template.
Step S102: the test tool adds test input data into the data template, generates a test request conforming to a target protocol based on the data template including the test input data, and sends the test request to a server side where the interface to be tested is located.
As a preferred scheme, the test tool adds test input data in a test case made for the interface to be tested to a data template in a JSON format to obtain JSON data which meets the interface requirements and includes the test input data, and converts the obtained JSON data into usable data of a realization language for a target protocol to realize coding of the JSON data based on the target protocol.
The implementation language of the target protocol refers to a programming language used for implementing the target protocol in the test tool. In practical application, the definition source data of the interface to be tested and the protocol calling logic of the target protocol are written by adopting the implementation language of the target protocol.
Specifically, the protocol call logic refers to encoding data obtained by adding test input data to the data template according to a target protocol in the test tool, and then sending a test request, and decoding a response returned by a server where the interface to be tested is located according to the target protocol, and then obtaining an execution code of test output data. In an embodiment of the invention, the protocol call logic is determined solely by the target protocol. That is, the protocol call logic is uniquely determined by the target protocol, independent of any interface under that target protocol. That is, after the target protocol is determined, the protocol call logic applicable to all interfaces under the target protocol can be determined according to the encoding specification of the target protocol. It will be appreciated that the protocol invocation logic may also include translation logic that translates data resulting from the addition of a data template to test input data into data available to the implementation language of the target protocol.
Preferably, in practical application, the protocol call logic may reuse a protocol implementation logic of the service end of the interface to be tested, and an implementation language of the target protocol may also be the same as a programming language used by the service end of the interface to be tested to implement the target protocol.
For example: if the server side where the interface to be tested is located adopts Java language to realize the target protocol, the realization language of the target protocol in the test tool can adopt Java language. At this time, the tester is required to upload definition source data of the interface to be tested written in the Java language, and meanwhile, the protocol calling logic of the test tool is also written in the Java language. After the test tool obtains JSON data that meets the interface requirements and includes test input data, the JSON data needs to be converted into usable data for the Java language. Specifically, the value of the value field can be converted into data recognizable by the Java language according to the description information of the type field in the JSON data.
In this step, after the test tool obtains the available data of the implementation language for the target protocol, the available data may be encoded by using the protocol call logic, and a test request conforming to the target protocol is generated and sent to the server where the interface to be tested is located. It is understood that the test request is sent according to the data packet transceiving requirement specified by the target protocol.
Step S103: the test tool receives a response to the test request to implement the test of the interface to be tested.
In this step, after receiving the response returned by the server where the interface to be tested is located, the test tool may decode the response by using the protocol call logic, and obtain the test output data carried in the response. Preferably, the test output data is JSON data. And the test tool compares the test output data with expected data in the test case to obtain a test result.
Thus, in the embodiment of the present invention, interface parsing logic and protocol calling logic suitable for all interfaces under a target protocol are obtained according to the target protocol, automatic parsing of interface definition source data to a data template is realized by using the interface parsing logic, parsed data is encoded by using the protocol calling logic and a test request conforming to the target protocol is sent, and then a returned response is decoded to realize automatic testing of an interface to be tested. In specific application, if the target protocol is not changed, when the interface to be tested is newly added or upgraded, the logic in the test tool does not need to be changed, only definition source data of the interface to be tested is uploaded, and meanwhile, the test tool does not need to be compiled again to realize automatic test of the interface to be tested, so that support for dynamic updating of the interface is realized, the test efficiency is improved, and meanwhile, a tester does not need to understand protocol calling logic and can concentrate on manufacturing of a test case.
In particular, in practical applications, the interface parsing logic and the protocol calling logic may be deployed in a test tool in the form of a plug-in to implement interface parsing and protocol calling. Where a plug-in refers to a functional module implemented according to a particular extensible framework specification. In the embodiment of the present invention, the interface parsing logic and the protocol calling logic may be stored in two plug-ins for each protocol. Also, preferably, the present invention can support the following multi-language based plug-ins: the system comprises a C dynamic library, a C + + dynamic library, a Java Jar package, a Java Class file, a PHP source file, a Shell script and a Python script, so that the development cost of the plug-in is reduced. C, C + +, Java, PHP, Shell and Python are all programming languages, a Java Class file is a Java Class file, and a jar package is a pre-written Java code for realizing a certain function.
Therefore, the interface analysis logic and the protocol calling logic are stored in the form of the plug-in, when the interface of a newly added protocol or an upgraded protocol is tested, the plug-in for storing the interface analysis logic and the protocol calling logic is only needed to be provided for the test tool, and the test tool and the plug-in do not need to be changed when the interface is required to be newly added or upgraded subsequently, so that the dynamic identification and the undifferentiated calling of the interface are realized, the expandability of the test tool is improved, and the maintenance workload of the test tool is reduced.
It can be understood that, in practical application, if the interface to be tested is tested before, the corresponding data template may be directly obtained for testing. If the target protocol to which the interface to be tested belongs is tested before, and the interface to be tested is a newly added interface or an upgraded interface, uploading the definition source data of the interface to be tested to perform testing. If the target protocol to which the interface to be tested belongs is a newly added protocol or an upgraded protocol, the interface analysis plug-in of the storage interface analysis logic and the protocol calling plug-in of the storage protocol calling logic need to be packaged, and the two plug-ins are uploaded.
Fig. 2 is a schematic diagram of a specific implementation of the method for automated testing according to the first embodiment of the present invention.
In fig. 2, the extensible plug-in management module is used to encapsulate the interface analysis plug-in and the protocol call plug-in, establish a plug-in management framework, and manage the plug-ins of different protocols in an extensible manner according to the framework specification.
Specifically, for an interface analysis plug-in of any protocol, the definition source data of the interface to be tested can be analyzed into a data template in a JSON format, and then the test input data is assigned in the data template to obtain JSON data. For example: an interface resolution plug-in for a protocol may implement the following APIs:
JSON parseInterfaces(File protocolDefFile)
the File protocol defFile is definition source data of the interface to be tested, and the return value of the API is a data template in a JSON format.
For a protocol calling plug-in of any protocol, coding is carried out by taking JSON data as an input parameter, and then a test request is initiated to a server; and receiving the returned response, decoding the response, and converting the response into JSON (Java Server object notation) reference. For example: a protocol calling plug-in for a protocol may implement the following APIs:
int invoke(JSON req,JSON resp);
wherein req is input JSON data, resp is output JSON format test output data, a return value is smaller than zero to represent calling abnormity, and a return value is larger than or equal to zero to represent calling success.
In the test flow management module:
the test data management module is used for assigning the test input data to the data template and comparing the test output data with the expected data to obtain a test result.
The test case management module is used for manufacturing and managing test cases.
The test task management module is used for managing a test process, can support timing regression test, multi-dimensional state statistics and monitoring of protocols and interfaces, and can support diversified application scenarios such as online verification, release verification, capacity expansion verification, environment migration verification and the like.
The test report management module is used for presenting the test result.
In the technical scheme of the embodiment of the invention, the interface analysis logic suitable for all interfaces under the protocol is obtained through the protocol to which the tested interface belongs, the interface analysis logic is utilized to realize the automatic analysis of the interface definition source data to the data template, and further the automatic test of the interface to be tested is realized based on the data template, so that when a new interface or an upgrade interface is tested, the conversion of the interface definition source data is not required to be carried out by a tester, the hard coding of the interface calling logic is not required, only the interface definition source data is uploaded, the support of dynamic update of the interface is realized, the test efficiency is improved, and meanwhile, the tester does not need to understand the protocol calling logic and can concentrate on the manufacture of a test case; the interface analysis logic and the protocol calling logic are stored in the form of the plug-in, when an interface of a newly added protocol or an upgraded protocol is tested, the plug-in for storing the interface analysis logic and the protocol calling logic is only needed to be provided for a test tool, and the test tool and the plug-in do not need to be changed when the interface is required to be newly added or upgraded subsequently, so that the hot plug-in characteristic of the protocol is realized, the expandability of the test tool is improved, and the maintenance workload of the test tool is reduced.
Fig. 3 is a schematic diagram of a main part of an apparatus for automated testing according to an embodiment of the present invention.
As shown in fig. 3, an apparatus 300 for automated testing according to an embodiment of the present invention may include: a preparation unit 301, an execution unit 302, and a test unit 303. Wherein:
the preparation unit 301 may be configured to determine, by using the interface parsing logic, a data template of the interface to be tested belonging to the target protocol; wherein the interface resolution logic is determined solely according to the target protocol;
the execution unit 302 may be configured to add test input data into the data template, generate a test request meeting the target protocol based on the data template including the test input data, and send the test request to a server where the interface to be tested is located;
the test unit 303 may be configured to receive a response to the test request to enable testing of the interface under test.
In the embodiment of the invention, the data template is in a JSON format or an XML format and comprises an input parameter structure and an output parameter structure of the interface to be tested.
Preferably, the preparing unit 301 is further configured to: and receiving definition source data of the interface to be tested, and converting the definition source data into the data template by using interface analysis logic.
As a preferred solution, the execution unit 302 may further be configured to: converting a data template comprising test input data into available data for an implementation language of the target protocol; encoding the available data by using protocol calling logic to generate the test request; wherein the protocol invocation logic is determined solely according to the target protocol.
In practical applications, the test unit 303 may further be configured to: receiving the response; decoding the response by using a protocol calling logic to obtain test output data; and comparing the test output data with expected data to obtain a test result.
In a specific application, the interface parsing logic and the protocol calling logic are stored in a plug-in.
In particular, the insert may be: a C dynamic library, a C + + dynamic library, a Java Jar package, a Java Class file, a PHP source file, a Shell script, or a Python script.
Furthermore, in the embodiment of the present invention, the target protocol is a non-standard protocol.
According to the technical scheme of the embodiment of the invention, the interface analysis logic suitable for all the interfaces under the protocol is obtained through the protocol to which the tested interface belongs, the interface analysis logic is utilized to realize the automatic analysis of the interface definition source data to the data template, and further the automatic test of the interface to be tested is realized based on the data template, so that when a new interface or an upgrade interface is tested, the conversion of the interface definition source data is not required to be carried out by a tester, the hard coding of the interface calling logic is not required to be carried out, only the interface definition source data is uploaded, the support of dynamic update of the interface is realized, the test efficiency is improved, and meanwhile, the tester does not need to understand the protocol calling logic and can concentrate on the manufacture of test cases; the interface analysis logic and the protocol calling logic are stored in the form of the plug-in, when an interface of a newly added protocol or an upgraded protocol is tested, the plug-in for storing the interface analysis logic and the protocol calling logic is only needed to be provided for a test tool, and the test tool and the plug-in do not need to be changed when the interface is required to be newly added or upgraded subsequently, so that the hot plug-in characteristic of the protocol is realized, the expandability of the test tool is improved, and the maintenance workload of the test tool is reduced.
Fig. 4 illustrates an exemplary system architecture 400 of a method of automated testing or an apparatus of automated testing to which embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405 (this architecture is merely an example, and the components included in a particular architecture may be adapted according to application specific circumstances). The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 401, 402, 403. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for automated testing provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, the apparatus for automated testing is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The invention also provides the electronic equipment.
The electronic device of the embodiment of the invention comprises: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method for the automatic test provided by the invention.
Referring now to FIG. 5, there is illustrated a block diagram of a computer system 500 suitable for use with an electronic device implementing the automated testing method of an embodiment of the present invention. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the computer system 500 are also stored. The CPU501, ROM 502, and RAM503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, the processes described in the main step diagrams above may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the invention include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the main step diagram. In the above-described embodiment, the computer program can be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the central processing unit 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present invention may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a preparation unit, an execution unit, and a test unit. Where the names of these units do not in some cases constitute a limitation on the unit itself, for example, the preparation unit may also be described as a "unit sending a data template to the execution unit".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to perform steps comprising: determining a data template of an interface to be tested belonging to a target protocol by using interface analysis logic; wherein the interface resolution logic is determined solely according to the target protocol; adding test input data into the data template, generating a test request conforming to the target protocol based on the data template comprising the test input data, and sending the test request to a server side where the interface to be tested is located; and receiving a response aiming at the test request to realize the test of the interface to be tested.
According to the technical scheme of the embodiment of the invention, the interface analysis logic suitable for all the interfaces under the protocol is obtained through the protocol to which the tested interface belongs, the interface analysis logic is utilized to realize the automatic analysis of the interface definition source data to the data template, and further the automatic test of the interface to be tested is realized based on the data template, so that when a new interface or an upgrade interface is tested, the conversion of the interface definition source data is not required to be carried out by a tester, the hard coding of the interface calling logic is not required to be carried out, only the interface definition source data is uploaded, the support of dynamic update of the interface is realized, the test efficiency is improved, and meanwhile, the tester does not need to understand the protocol calling logic and can concentrate on the manufacture of test cases; the interface analysis logic and the protocol calling logic are stored in the form of the plug-in, when an interface of a newly added protocol or an upgraded protocol is tested, the plug-in for storing the interface analysis logic and the protocol calling logic is only needed to be provided for a test tool, and the test tool and the plug-in do not need to be changed when the interface is required to be newly added or upgraded subsequently, so that the hot plug-in characteristic of the protocol is realized, the expandability of the test tool is improved, and the maintenance workload of the test tool is reduced.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (9)

1. A method of automated testing, comprising:
receiving definition source data of an interface to be tested belonging to a target protocol, and converting the definition source data into a data template of the interface to be tested by using interface analysis logic; the interface analysis logic is independently determined according to the target protocol, and the data template comprises a parameter input structure and a parameter output structure of the interface to be detected;
adding test input data into the data template, generating a test request conforming to the target protocol based on the data template comprising the test input data, and sending the test request to a server side where the interface to be tested is located;
receiving a response aiming at the test request to realize the test of the interface to be tested;
the generating a test request conforming to the target protocol based on a data template including test input data includes:
converting a data template comprising test input data into available data for an implementation language of the target protocol; encoding the available data by using protocol calling logic to generate the test request; the protocol calling logic is determined independently according to the target protocol, and the protocol calling logic refers to encoding data obtained by adding test input data to a data template according to the target protocol in a test tool and then sending a test request, and decoding a response returned by a service end where an interface to be tested is located according to the target protocol and then obtaining an execution code of test output data.
2. The method of claim 1, wherein the data template is in a JSON format or an XML format.
3. The method of claim 1, wherein receiving the response to the test request to enable testing of the interface under test comprises:
receiving the response; decoding the response by using a protocol calling logic to obtain test output data;
and comparing the test output data with expected data to obtain a test result.
4. The method of claim 1, wherein the interface parsing logic and the protocol calling logic are stored in a plug-in.
5. The method of claim 4, wherein the insert is: a C dynamic library, a C + + dynamic library, a Java Jar package, a Java Class file, a PHP source file, a Shell script, or a Python script.
6. The method of any of claims 1-5, wherein the target protocol is a non-standard protocol.
7. An apparatus for automated testing, comprising:
the device comprises a preparation unit, a data processing unit and a data processing unit, wherein the preparation unit is used for receiving definition source data of an interface to be tested belonging to a target protocol and converting the definition source data into a data template of the interface to be tested by using interface analysis logic; the interface analysis logic is independently determined according to the target protocol, and the data template comprises a parameter input structure and a parameter output structure of the interface to be detected;
the execution unit is used for adding test input data into the data template, generating a test request conforming to the target protocol based on the data template comprising the test input data, and sending the test request to a server side where the interface to be tested is located;
the test unit is used for receiving a response aiming at the test request so as to realize the test of the interface to be tested;
the execution unit is further to: converting a data template comprising test input data into available data for an implementation language of the target protocol; encoding the available data by using protocol calling logic to generate the test request; the protocol calling logic is determined independently according to the target protocol, and the protocol calling logic refers to encoding data obtained by adding test input data to a data template according to the target protocol in a test tool and then sending a test request, and decoding a response returned by a service end where an interface to be tested is located according to the target protocol and then obtaining an execution code of test output data.
8. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN201711172013.7A 2017-11-22 2017-11-22 Method and device for automatic testing Active CN109815107B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711172013.7A CN109815107B (en) 2017-11-22 2017-11-22 Method and device for automatic testing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711172013.7A CN109815107B (en) 2017-11-22 2017-11-22 Method and device for automatic testing

Publications (2)

Publication Number Publication Date
CN109815107A CN109815107A (en) 2019-05-28
CN109815107B true CN109815107B (en) 2022-06-07

Family

ID=66601095

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711172013.7A Active CN109815107B (en) 2017-11-22 2017-11-22 Method and device for automatic testing

Country Status (1)

Country Link
CN (1) CN109815107B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110232027B (en) * 2019-06-18 2020-12-11 中汇信息技术(上海)有限公司 Method and system for performing system test based on editable data
CN110532185B (en) * 2019-08-29 2023-09-19 中国工商银行股份有限公司 Test method, test device, electronic equipment and computer readable storage medium
CN111488285B (en) * 2020-04-15 2023-05-12 抖音视界有限公司 Interface testing method, device, electronic equipment and computer readable storage medium
CN113806211A (en) * 2020-06-17 2021-12-17 北京同邦卓益科技有限公司 Data processing method and device for interface test
CN112491645B (en) * 2020-11-11 2022-08-30 深圳数联天下智能科技有限公司 Automatic test method and automatic test equipment
CN114721929A (en) * 2021-01-04 2022-07-08 腾讯科技(深圳)有限公司 Test method, test device, storage medium and equipment
CN114124748B (en) * 2021-10-15 2024-04-19 青岛海尔科技有限公司 Device and method for debugging hypertext transfer protocol interface based on IDEA platform
CN115967660B (en) * 2022-08-18 2024-05-03 山东有人物联网股份有限公司 Method, device, terminal equipment and storage medium for testing CAN protocol conversion

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201601678U (en) * 2010-03-08 2010-10-06 和记奥普泰通信技术有限公司 Service node interface index test system
CN102866944A (en) * 2012-06-12 2013-01-09 中国联合网络通信集团有限公司 Pressure testing system and method
CN103198009A (en) * 2012-01-04 2013-07-10 中国移动通信集团公司 Universal testing method, system and corresponding device
CN104424095A (en) * 2013-08-26 2015-03-18 卓望数码技术(深圳)有限公司 Automatic testing method and system of mobile terminal
CN106648945A (en) * 2016-09-30 2017-05-10 北京金山安全软件有限公司 Interface data testing method and device and electronic equipment
CN107291608A (en) * 2016-03-31 2017-10-24 阿里巴巴集团控股有限公司 The generation method of test script, subscription/register method of interface and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103136095A (en) * 2011-11-28 2013-06-05 阿里巴巴集团控股有限公司 Method, device and system of test application program interface
CN107133160B (en) * 2016-02-26 2020-06-30 北京京东尚科信息技术有限公司 Server and client

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201601678U (en) * 2010-03-08 2010-10-06 和记奥普泰通信技术有限公司 Service node interface index test system
CN103198009A (en) * 2012-01-04 2013-07-10 中国移动通信集团公司 Universal testing method, system and corresponding device
CN102866944A (en) * 2012-06-12 2013-01-09 中国联合网络通信集团有限公司 Pressure testing system and method
CN104424095A (en) * 2013-08-26 2015-03-18 卓望数码技术(深圳)有限公司 Automatic testing method and system of mobile terminal
CN107291608A (en) * 2016-03-31 2017-10-24 阿里巴巴集团控股有限公司 The generation method of test script, subscription/register method of interface and device
CN106648945A (en) * 2016-09-30 2017-05-10 北京金山安全软件有限公司 Interface data testing method and device and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于XML的通用数据接口测试工具;苏春梅 等;《兵工自动化》;20121101;第31卷(第08期);72-77 *

Also Published As

Publication number Publication date
CN109815107A (en) 2019-05-28

Similar Documents

Publication Publication Date Title
CN109815107B (en) Method and device for automatic testing
CN110019350B (en) Data query method and device based on configuration information
CN107277153B (en) Method, device and server for providing voice service
CN105718540B (en) Data loading method and device
CN113076153B (en) Interface calling method and device
CN111786939A (en) Method, device and system for testing management platform of Internet of things
CN112507005A (en) Method and device for processing message
CN110753020A (en) Network request processing method and device
CN113821352A (en) Remote service calling method and device
CN113946816A (en) Cloud service-based authentication method and device, electronic equipment and storage medium
CN113778499B (en) Method, apparatus, device and computer readable medium for publishing services
CN110795328A (en) Interface testing method and device
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN112948138A (en) Method and device for processing message
CN113779122B (en) Method and device for exporting data
CN110830427A (en) Method and device for message encoding and message decoding in netty environment
CN112929453B (en) Method and device for sharing session data
CN113992641A (en) Data processing method, device, equipment and storage medium
CN112860447B (en) Interaction method and system between different applications
CN113973139A (en) Message processing method and device
CN112131095B (en) Pressure testing method and device
CN113779018A (en) Data processing method and device
CN113722115A (en) Method, device, equipment and computer readable medium for calling interface
CN113704079A (en) Interface testing method and device based on Protobuf
CN112099841A (en) Method and system for generating configuration file

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