[go: up one dir, main page]

CN111026629B - A method and device for automatically generating test scripts - Google Patents

A method and device for automatically generating test scripts Download PDF

Info

Publication number
CN111026629B
CN111026629B CN201811171370.6A CN201811171370A CN111026629B CN 111026629 B CN111026629 B CN 111026629B CN 201811171370 A CN201811171370 A CN 201811171370A CN 111026629 B CN111026629 B CN 111026629B
Authority
CN
China
Prior art keywords
node
parameters
interface
binary search
search tree
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
CN201811171370.6A
Other languages
Chinese (zh)
Other versions
CN111026629A (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 CN201811171370.6A priority Critical patent/CN111026629B/en
Publication of CN111026629A publication Critical patent/CN111026629A/en
Application granted granted Critical
Publication of CN111026629B publication Critical patent/CN111026629B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

Landscapes

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

Abstract

The invention discloses a method and a device for automatically generating a test script, and relates to the technical field of computers. The method comprises the steps of obtaining a precursor binary search tree generated according to parameters of a tested interface to traverse the precursor binary search tree, obtaining an entry of the tested interface according to the traversed parameters to generate a call statement of the tested interface, and generating a test script of the tested interface according to the entry of the tested interface and the call statement of the tested interface. The implementation mode can solve the problem that the interface test script cannot be automatically generated in the prior art.

Description

Method and device for automatically generating test script
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for automatically generating a test script.
Background
With the continuous development of automated testing technology, interface automation technology has become an indispensable detection means in any information system testing life cycle. In the current various interface test frameworks, all workflow testers write test scripts according to the specifications of the test frameworks, design parameter pools and run the test scripts for testing. In the workflow of the automated interface test script, the maintenance work of the test script becomes a brake that affects the automated test quality of all interfaces due to the rapid update and rapid iteration of the tested interfaces.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
at present, the script of the interface test is also completely dependent on the manual generation of a tester according to a test framework, so that the generation of the test script is time-consuming and labor-consuming and has low efficiency.
Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for automatically generating test scripts, which can solve the problem that the prior art cannot automatically generate interface test scripts.
In order to achieve the above object, according to one aspect of the embodiment of the present invention, there is provided a method for automatically generating a test script, including obtaining a precursor binary search tree generated according to parameters of a tested interface to traverse the precursor binary search tree, obtaining an entry of the tested interface according to the traversed parameters to generate a call statement of the tested interface, and generating the test script of the tested interface according to the entry of the tested interface and the call statement of the tested interface.
Optionally, obtaining a precursor binary search tree generated according to the tested interface parameters includes:
defining a storage structure of a precursor binary search tree;
and reading parameters of the tested interface, and generating a precursor binary search tree according to the storage structure.
Optionally, traversing the precursor binary search tree includes:
Traversing and storing the precursor binary search tree according to the parameter sequence preset by the tested interface.
Optionally, obtaining the parameter of the tested interface according to the traversed parameter to generate a call statement of the tested interface, including:
reading the traversed parameters based on logic rules of the basic type and the complex type;
and obtaining the entry of the tested interface, and further generating a call statement of the tested interface.
In addition, according to one aspect of the embodiment of the invention, an apparatus for automatically generating a test script is provided, which comprises an acquisition module for acquiring a precursor binary search tree generated according to parameters of a tested interface to traverse the precursor binary search tree, a traversing module for acquiring parameters of the tested interface to generate a call statement of the tested interface according to the traversed parameters, and a generation module for generating the test script of the tested interface according to the parameters of the tested interface and the call statement of the tested interface.
Optionally, the acquiring module acquires a precursor binary search tree generated according to the tested interface parameter, including:
defining a storage structure of a precursor binary search tree;
and reading parameters of the tested interface, and generating a precursor binary search tree according to the storage structure.
Optionally, the traversing module traverses the precursor binary search tree, including:
Traversing and storing the precursor binary search tree according to the parameter sequence preset by the tested interface.
Optionally, the generating module obtains the parameter of the tested interface according to the traversed parameter to generate a call statement of the tested interface, including:
reading the traversed parameters based on logic rules of the basic type and the complex type;
obtaining the entry of the tested interface, and further generating a call statement of the tested interface
According to another aspect of an embodiment of the present invention, there is also provided an electronic device including:
one or more processors;
storage means for storing one or more programs,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of the embodiments of automatic generation of test scripts described above.
According to another aspect of an embodiment of the present invention, there is also provided a computer readable medium having stored thereon a computer program, which when executed by a processor, implements the method according to any of the above embodiments based on automatic generation of test scripts.
The method has the advantages that the precursor binary search tree generated according to the parameters of the tested interface is obtained to traverse the precursor binary search tree, the parameter entering of the tested interface is obtained according to the traversed parameters to generate the call statement of the tested interface, and the test script of the tested interface is generated according to the parameter entering of the tested interface and the call statement of the tested interface. Therefore, the invention provides a storage structure based on the precursor binary search tree and a corresponding traversal algorithm thereof, solves the problem of automatic generation of the test script, and achieves the purposes of quickly generating the script and quickly testing.
Further effects of the above-described non-conventional alternatives are 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 flow of a method for automatically generating test scripts according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main flow of a method for automatically generating test scripts according to a referenceable embodiment of the invention;
FIG. 3 is a schematic diagram of the main flow of generating a precursor binary search tree according to a referenceable embodiment of the invention;
FIG. 4 is a schematic diagram of the main flow of generating a precursor binary search tree subtree according to a referenceable embodiment of the invention;
FIG. 5 is a schematic diagram of the major modules of an apparatus for automatic generation of test scripts according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
Fig. 7 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered 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.
FIG. 1 is a schematic diagram of the main flow of a method for automatically generating test scripts according to an embodiment of the present invention, which may include:
step S101, a precursor binary search tree generated according to tested interface parameters is obtained to traverse the precursor binary search tree.
In an embodiment, a precursor binary search tree generated from measured interface parameters may be obtained by:
Firstly, defining a storage structure of a precursor binary search tree, then reading parameters of a tested interface, and generating the precursor binary search tree according to the storage structure. Wherein, binary search tree refers to a tree structure with at most two subtrees per node. While predecessor refers to each node having a pointer to its parent node.
In a preferred embodiment, a precursor binary search tree may be traversed in order to store the parameters of the traversal in sequence. The middle-order traversal of the binary search tree refers to traversing the left subtree, then traversing the root node and finally traversing the right subtree. It should be noted that, whether other traversal methods such as middle-order traversal, front-order traversal, or back-order traversal are adopted, the purpose is that the parameter sequence obtained after traversal can conform to the parameter sequence specified when the tested interface is developed.
In addition, the precursor binary search tree can be traversed in order to sequentially store the traversed parameters into Map classes. The Map class is a container for storing several elements, and the elements are composed of Key Value and mapping Value (Mapped Value) pairs. It should be noted that, by storing the traversed parameters into the Map class with the key value pair rule, the traversed parameters can be more accurately and effectively sorted, and of course, the traversed parameters can be stored into any other form.
Step S102, obtaining the parameters of the tested interface according to the traversed parameters so as to generate a call statement of the tested interface.
In an embodiment, map classes may be traversed based on logic rules that initialize basic types first and then complex types. And then, obtaining the parameters of the tested interface according to the parameters obtained after the Map class is traversed, and further generating a call statement of the tested interface.
Step S103, generating a test script of the tested interface according to the input of the tested interface and the call statement of the tested interface.
According to the various embodiments described above, the invention solves the analysis of the call structure of the tested interface by the storage structure of the precursor binary search tree, and then completes the automatic generation of the interface automatic test script and the test parameter file by the intermediate traversal of the binary search tree. That is, the invention can rapidly complete the automatic test script of the tested interface, and saves a lot of time. In addition, the invention modifies the script completely according to the call relation tree of the tested interface, thereby ensuring the correctness of the automatic test script logic.
FIG. 2 is a schematic diagram of the main flow of a method for automatically generating test scripts according to a referenceable embodiment of the invention, which may include:
step S201, defining a storage structure of a precursor binary search tree.
In an embodiment, the storage structure of the defined precursor binary search tree may be:
Name Type Leftchild Rightchild Father
The method comprises the steps of storing a Name as an interface Name of a field storage tested interface if the Name is a storage of a root node of a precursor binary search tree, storing a Type as a field storage return value Type, enabling LEFTCHLID to point to a first basic Type node of a first tested interface, if the node is not a null, enabling RIGHTCHLID to point to a first load Type node of the first tested interface, if the node is not a null, and enabling Father (father node) to be a null.
The method comprises the steps of storing a basic Type parameter of a precursor binary search tree, wherein the Name is expressed as a storage variable Name, the Type is expressed as a storage traversal Type, LEFTCHILD points to a basic Type Node in the same-layer call, RIGHTCHLID is null, father points to a Node of the last Node of the same-layer call or a father Node of a complex Type of the same-layer call, and points to a root Node if the Node is a second-layer Node of the binary search tree.
The storing of the complex object node of the precursor binary search tree may include storing Java object type parameters, storing Map type parameters and storing List type parameters, and specifically defined as:
The storage of Java object type parameters requires newly creating two types of nodes, namely Java object nodes and Java object node nodes. The method comprises the following steps:
For Java object nodes, name is expressed as a storage object variable Name, type is expressed as a storage Java object, LEFTCHILD points to the corresponding object Node, RIGHTCHLID points to the complex object Node of the same layer, father points to the last Node called by the same layer or the Node of the father Node of the complex Type, and if the Node is the second layer Node of the binary tree, the Node points to the root Node.
For the Node of the object, name is indicated as a storage null, type is indicated as a storage null, LEFTCHILD points to the first basic Type Node nested by the Node, if not, null, RIGHTCHLID points to the first complex object Node nested by the Node, if not, null, father points to the Java object Node corresponding to the Node.
And storing Map type parameters, namely, building two types of nodes, namely, map type nodes and Map type node nodes. The method comprises the following steps:
For Map Type nodes, name is expressed as a storage object variable Name, type is expressed as a storage Map mark, LEFTCHILD points to the corresponding Map Type Node, RIGHTCHLID points to the complex object Node of the same layer, father points to the last Node called by the same layer or points to the Node of the father Node of the complex Type, and if the Node is the second layer Node of the binary tree, the Node points to the root Node.
For Map Type Node nodes, name is indicated as storage null, type is indicated as storage null, LEFTCHILD points to the first key Node, keys are processed according to specific types, RIGHTCHLID points to the first value Node, the value Node is processed according to specific types, and Father points to the corresponding Map Type Node.
And storing List type parameters, namely creating two types of nodes, namely a List type node and a List type node. The method comprises the following steps:
For a List Type Node, name is expressed as a storage object variable Name, type is expressed as a storage Map mark, LEFTCHILD points to a corresponding List Type Node, RIGHTCHLID points to a complex object Node of the same layer, father points to a last Node called by the same layer or points to a Node of a father Node of the complex Type, and if the Node is a second layer Node of the binary tree, the Node points to a root Node.
For List Type Node nodes, name is denoted as storage null, type is denoted as storage null, LEFTCHILD is denoted as indicating that Lefchlid points to its corresponding base Type Node if the List is a base Type, RIGHTCHLID is null, RIGHTCHLID is denoted as indicating that RIGHTCHLID points to its corresponding complex Type Node if the List is a complex Type, LEFTCHILD is null, father points to its corresponding List Type Node.
Step S202, a precursor binary search tree is generated. As shown in fig. 3, the specific implementation process includes:
Step S301, a root node is established.
Step S302, a flag i of the current node is set.
Step S303, judging whether the mark i of the current node is smaller than the number of parameters, if yes, proceeding to step S304, otherwise, exiting the flow.
And S304, acquiring an ith parameter node.
Step S305, judging whether the ith parameter node is of a basic type, if so, proceeding to step S306, otherwise proceeding to step S307.
Step 306. The left child of the ith parameter node points to the new node and is reassigned from increment i to i, returning to step 303.
Step S307, generating subtrees according to the ith parameter node.
In a further embodiment, as shown in fig. 4, the process of generating a subtree according to the ith parameter node includes:
step S401, creating node nodes of complex objects according to the marks i of the parameter nodes.
Step S402, judging whether the mark i of the parameter node is smaller than the node attribute number, if yes, proceeding to step S403, otherwise, exiting the flow.
Step S403, newly creating a node ith attribute node.
Step S404, judging whether the ith attribute node is of a basic type, if so, proceeding to step S405, otherwise, returning to step S401.
Step S405, the left child of the ith attribute node points to the new node, and is reassigned to i by self-increment i, returning to step S402.
Step S203, performing medium-order traversal on the precursor binary search tree, and sequentially storing the traversed parameters into Map types.
In an embodiment, the left subtree is traversed first, then the root node is traversed, and finally the right subtree is traversed, after a middle-order traversal of the precursor binary search tree. In the traversing process, the traversed parameters are sequentially stored in the Map class, so that the calling relation among the parameters can be obtained.
Step S204, obtaining the entry of the tested interface by traversing the Map class, and further generating a call statement of the tested interface.
In an embodiment, when traversing the Map class, a logic rule of a complex type may be initialized after initializing a basic type. Further, according to the traversal of Map class, the parameter of the tested interface can be obtained, so that the call statement of the tested interface can be obtained.
Step S205, generating a test script of the tested interface according to the input of the tested interface and the call statement of the tested interface.
Fig. 5 is an apparatus for automatically generating a test script according to an embodiment of the present invention, and as shown in fig. 5, the apparatus for automatically generating a test script includes an acquisition module 501, a traversal module 502, and a generation module 503. Wherein, the acquisition module 501 acquires a precursor binary search tree generated according to the tested interface parameters to traverse the precursor binary search tree. The traversal module 502 obtains the parameters of the tested interface according to the traversed parameters to generate the call statement of the tested interface. The generating module 503 generates a test script of the tested interface according to the entry of the tested interface and the call statement of the tested interface.
Preferably, when the obtaining module 501 obtains the precursor binary search tree generated according to the parameters of the tested interface, it may define the storage structure of the precursor binary search tree first, further read the parameters of the tested interface, and generate the precursor binary search tree according to the storage structure.
As another embodiment, the traversing module 502 may traverse the precursor binary search tree in a medium order while traversing the precursor binary search tree, and sequentially store the traversed parameters into Map classes. Further, the generating module 503 obtains the parameter of the tested interface according to the parameter obtained after traversing the Map class, so as to generate the call statement of the tested interface.
Further, the generating module 503 uses logic rules based on initializing basic types and then initializing complex types to traverse Map classes. And then, obtaining the parameters of the tested interface according to the parameters obtained after the Map class is traversed, and further generating a call statement of the tested interface.
The specific implementation of the device for automatically generating a test script according to the present invention is described in detail in the method for automatically generating a test script, and thus, the description thereof will not be repeated here.
FIG. 6 illustrates an exemplary system architecture 600 of a method of automatically generating test scripts or an apparatus of automatically generating test scripts to which embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 is used as a medium to provide communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 605 via the network 604 using the terminal devices 601, 602, 603 to receive or send messages, etc. Various communication client applications such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only) may be installed on the terminal devices 601, 602, 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using terminal devices 601, 602, 603. The background management server may analyze and process the received data such as the product information query request, and feedback the processing result (e.g., the target push information, the product information—only an example) to the terminal device.
It should be noted that, the method for automatically generating the test script provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the device for automatically generating the test script is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, there is illustrated a schematic diagram of a computer system 700 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM703, various programs and data required for the operation of the system 700 are also stored. The CPU701, ROM 702, and RAM703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Connected to the I/O interface 705 are an input section 706 including a keyboard, a mouse, and the like, an output section 707 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, a storage section 708 including a hard disk, and the like, and a communication section 709 including a network interface card such as a LAN card, a modem, and the like. The communication section 709 performs communication processing via a network such as the internet. The drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read therefrom is mounted into the storage section 708 as necessary.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure 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 shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 709, and/or installed from the removable medium 711. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 701.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a 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 context of this document, 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, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts 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 modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, which may be described as, for example, a processor comprising an acquisition module, a traversal module, and a generation module. The names of these modules do not constitute a limitation on the module itself in some cases.
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by the device, cause the device to include obtaining a precursor binary search tree generated according to the tested interface parameters to traverse the precursor binary search tree, obtaining the entry of the tested interface according to the traversed parameters to generate a call statement of the tested interface, and generating a test script of the tested interface according to the entry of the tested interface and the call statement of the tested interface.
According to the technical scheme provided by the embodiment of the invention, the problem that the interface test script cannot be automatically generated in the prior art can be solved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (8)

1.一种测试脚本自动生成的方法,其特征在于,包括:1. A method for automatically generating a test script, comprising: 获取根据被测接口参数生成的前驱二叉搜索树,以遍历所述前驱二叉搜索树;其中,生成前驱二叉搜索树的过程包括:建立根节点;设置当前节点的标志i;判断当前节点的标志i是否小于参数个数,若是则获取第i个参数节点,否则退出流程;判断第i个参数节点是否为基本类型,若是则第i个参数节点的左孩子指向新节点,并且自增i重新赋给i,重新执行判断逻辑;否则根据第i个参数节点,生成子树;Obtain a predecessor binary search tree generated according to the interface parameters under test to traverse the predecessor binary search tree; wherein the process of generating the predecessor binary search tree includes: establishing a root node; setting a flag i of the current node; judging whether the flag i of the current node is less than the number of parameters, if so, obtaining the i-th parameter node, otherwise exiting the process; judging whether the i-th parameter node is a basic type, if so, the left child of the i-th parameter node points to a new node, and i is reassigned to i by self-increment, and the judgment logic is re-executed; otherwise, generating a subtree according to the i-th parameter node; 根据第i个参数节点生成子树的过程,包括:根据该参数节点的标志i,创建复杂对象的node节点;判断该参数节点的标志i是否小于node属性个数,若是则新建node节点第i个属性节点,否则退出流程;判断第i个属性节点是否为基本类型,若是则第i个属性节点的左孩子指向新节点,并且自增i重新赋给i,之后判断该参数节点的标志i是否小于node属性个数;The process of generating a subtree according to the i-th parameter node includes: creating a node node of a complex object according to the flag i of the parameter node; judging whether the flag i of the parameter node is less than the number of node attributes, if so, creating a new i-th attribute node of the node node, otherwise exiting the process; judging whether the i-th attribute node is a basic type, if so, the left child of the i-th attribute node points to the new node, and reassigns i by incrementing i, and then judging whether the flag i of the parameter node is less than the number of node attributes; 根据遍历后的参数,获得被测试接口的入参,以生成被测试接口的调用语句,包括:基于先初始化基本类型再初始化复杂类型的逻辑规则读取遍历后的参数;获得被测试接口的入参,进而生成被测试接口的调用语句;其中,遍历后获得的参数顺序符合被测接口开发时规定的参数顺序;According to the traversed parameters, the input parameters of the tested interface are obtained to generate a call statement of the tested interface, including: reading the traversed parameters based on the logical rule of initializing basic types first and then initializing complex types; obtaining the input parameters of the tested interface, and then generating a call statement of the tested interface; wherein the order of parameters obtained after traversal conforms to the order of parameters specified when the tested interface is developed; 根据被测试接口的入参和被测试接口的调用语句,生成被测试接口的测试脚本。Generate a test script for the interface under test based on the input parameters of the interface under test and the calling statements of the interface under test. 2.根据权利要求1所述的方法,其特征在于,获取根据被测接口参数生成的前驱二叉搜索树,包括:2. The method according to claim 1, characterized in that obtaining a predecessor binary search tree generated according to the measured interface parameters comprises: 定义前驱二叉搜索树的存储结构;Define the storage structure of the predecessor binary search tree; 读取被测接口的参数,根据所述存储结构生成前驱二叉搜索树。The parameters of the interface under test are read, and a predecessor binary search tree is generated according to the storage structure. 3.根据权利要求1所述的方法,其特征在于,遍历所述前驱二叉搜索树,包括:3. The method according to claim 1, characterized in that traversing the predecessor binary search tree comprises: 根据被测接口预设的参数顺序,对前驱二叉搜索树进行遍历并存储。According to the parameter sequence preset by the interface under test, the predecessor binary search tree is traversed and stored. 4.一种测试脚本自动生成的装置,其特征在于,包括:4. A device for automatically generating a test script, characterized by comprising: 获取模块,用于获取根据被测接口参数生成的前驱二叉搜索树,以遍历所述前驱二叉搜索树;其中,生成前驱二叉搜索树的过程包括:建立根节点;设置当前节点的标志i;判断当前节点的标志i是否小于参数个数,若是则获取第i个参数节点,否则退出流程;判断第i个参数节点是否为基本类型,若是则第i个参数节点的左孩子指向新节点,并且自增i重新赋给i,重新执行判断逻辑;否则根据第i个参数节点,生成子树;The acquisition module is used to acquire a predecessor binary search tree generated according to the interface parameters under test, so as to traverse the predecessor binary search tree; wherein, the process of generating the predecessor binary search tree includes: establishing a root node; setting a flag i of the current node; judging whether the flag i of the current node is less than the number of parameters, if so, acquiring the i-th parameter node, otherwise exiting the process; judging whether the i-th parameter node is a basic type, if so, the left child of the i-th parameter node points to a new node, and i is reassigned to i by self-increment, and the judgment logic is re-executed; otherwise, a subtree is generated according to the i-th parameter node; 根据第i个参数节点生成子树的过程,包括:根据该参数节点的标志i,创建复杂对象的node节点;判断该参数节点的标志i是否小于node属性个数,若是则新建node节点第i个属性节点,否则退出流程;判断第i个属性节点是否为基本类型,若是则第i个属性节点的左孩子指向新节点,并且自增i重新赋给i,之后判断该参数节点的标志i是否小于node属性个数;The process of generating a subtree according to the i-th parameter node includes: creating a node node of a complex object according to the flag i of the parameter node; judging whether the flag i of the parameter node is less than the number of node attributes, if so, creating a new i-th attribute node of the node node, otherwise exiting the process; judging whether the i-th attribute node is a basic type, if so, the left child of the i-th attribute node points to the new node, and reassigns i by incrementing i, and then judging whether the flag i of the parameter node is less than the number of node attributes; 遍历模块,用于根据遍历后的参数,获得被测试接口的入参,以生成被测试接口的调用语句,包括:基于先初始化基本类型再初始化复杂类型的逻辑规则读取遍历后的参数;获得被测试接口的入参,进而生成被测试接口的调用语句;其中,遍历后获得的参数顺序符合被测接口开发时规定的参数顺序;The traversal module is used to obtain the input parameters of the tested interface according to the traversed parameters to generate the call statement of the tested interface, including: reading the traversed parameters based on the logical rule of initializing the basic types first and then the complex types; obtaining the input parameters of the tested interface, and then generating the call statement of the tested interface; wherein the order of the parameters obtained after the traversal conforms to the order of the parameters specified when the tested interface is developed; 生成模块,用于根据被测试接口的入参和被测试接口的调用语句,生成被测试接口的测试脚本。The generation module is used to generate a test script for the interface under test based on the input parameters of the interface under test and the calling statements of the interface under test. 5.根据权利要求4所述的装置,其特征在于,所述获取模块获取根据被测接口参数生成的前驱二叉搜索树,包括:5. The device according to claim 4, characterized in that the acquisition module acquires the predecessor binary search tree generated according to the measured interface parameters, comprising: 定义前驱二叉搜索树的存储结构;Define the storage structure of the predecessor binary search tree; 读取被测接口的参数,根据所述存储结构生成前驱二叉搜索树。The parameters of the interface under test are read, and a predecessor binary search tree is generated according to the storage structure. 6.根据权利要求4所述的装置,其特征在于,所述遍历模块遍历前驱二叉搜索树,包括:6. The device according to claim 4, characterized in that the traversal module traverses the predecessor binary search tree, comprising: 根据被测接口预设的参数顺序,对前驱二叉搜索树进行遍历并存储。According to the parameter sequence preset by the interface under test, the predecessor binary search tree is traversed and stored. 7.一种电子设备,其特征在于,包括:7. An electronic device, comprising: 一个或多个处理器;one or more processors; 存储装置,用于存储一个或多个程序,a storage device for storing one or more programs, 当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-3中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3. 8.一种计算机可读介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现如权利要求1-3中任一所述的方法。8. A computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
CN201811171370.6A 2018-10-09 2018-10-09 A method and device for automatically generating test scripts Active CN111026629B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811171370.6A CN111026629B (en) 2018-10-09 2018-10-09 A method and device for automatically generating test scripts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811171370.6A CN111026629B (en) 2018-10-09 2018-10-09 A method and device for automatically generating test scripts

Publications (2)

Publication Number Publication Date
CN111026629A CN111026629A (en) 2020-04-17
CN111026629B true CN111026629B (en) 2025-04-18

Family

ID=70190689

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811171370.6A Active CN111026629B (en) 2018-10-09 2018-10-09 A method and device for automatically generating test scripts

Country Status (1)

Country Link
CN (1) CN111026629B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111694729B (en) * 2020-04-29 2024-08-02 北京三快在线科技有限公司 Application testing method, device, electronic equipment and computer readable medium
CN112148601A (en) * 2020-09-16 2020-12-29 京东数字科技控股股份有限公司 Interface testing method, device, electronic device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106681903A (en) * 2015-11-11 2017-05-17 阿里巴巴集团控股有限公司 Method and device for generating test case
CN108470004A (en) * 2018-04-09 2018-08-31 平安普惠企业管理有限公司 Test script generation method, test method, device, equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8850407B2 (en) * 2012-05-23 2014-09-30 Hewlett-Packard Development Company, L.P. Test script generation
CN105068929B (en) * 2015-08-06 2018-02-13 网易(杭州)网络有限公司 Test script generation method and device, method of testing, test device and test system
CN105718372B (en) * 2016-01-22 2018-05-18 珠海市精实测控技术有限公司 A kind of electric-controlled plate Black-box testing Cases generation and automatic test approach

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106681903A (en) * 2015-11-11 2017-05-17 阿里巴巴集团控股有限公司 Method and device for generating test case
CN108470004A (en) * 2018-04-09 2018-08-31 平安普惠企业管理有限公司 Test script generation method, test method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111026629A (en) 2020-04-17

Similar Documents

Publication Publication Date Title
CN114116065B (en) Method and device for acquiring topological graph data object and electronic equipment
CN114491536B (en) Code analysis method and device based on knowledge graph
CN109976999B (en) Method and device for measuring coverage rate of test cases
CN111309721B (en) A method and device for determining data table association relationship
CN108509339A (en) Method for generating test case, device based on browser and mind map and equipment
WO2021023149A1 (en) Method and apparatus for dynamically returning message
CN113111051B (en) Data migration method and device
CN111125064B (en) Method and device for generating database schema definition statement
CN109992496A (en) A kind of data processing method and device for automatic test
CN113419789A (en) Method and device for generating data model script
CN110806967B (en) Unit testing method and unit testing device
CN113760698A (en) Method and device for converting test case file data
CN115454971A (en) Data migration method, device, electronic device and storage medium
CN114816382A (en) Method and device for processing page
CN115033629A (en) Data processing method and device, electronic equipment and storage medium
CN111143408B (en) Event processing method and device based on business rule
CN110795331A (en) Software testing method and device
CN114281697A (en) Method and device for generating test data
CN111026629B (en) A method and device for automatically generating test scripts
CN110851343B (en) A test method and device based on decision tree
JP2021114278A (en) Method and apparatus for generating information
CN114676163B (en) Data query method, device, equipment, system and storage medium
US12086183B2 (en) Graph data structure edge profiling in MapReduce computational framework
CN113760695B (en) A method and device for locating problem code
CN112101399B (en) A data processing method and device

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