CN113886221A - Test script generation method and device, storage medium and electronic equipment - Google Patents

Test script generation method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN113886221A
CN113886221A CN202111070868.5A CN202111070868A CN113886221A CN 113886221 A CN113886221 A CN 113886221A CN 202111070868 A CN202111070868 A CN 202111070868A CN 113886221 A CN113886221 A CN 113886221A
Authority
CN
China
Prior art keywords
interface
target data
parameter
key
target
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.)
Granted
Application number
CN202111070868.5A
Other languages
Chinese (zh)
Other versions
CN113886221B (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.)
Qianhai Feisuan Yunzhi Software Technology Shenzhen Co ltd
Original Assignee
Qianhai Feisuan Yunzhi Software Technology Shenzhen 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 Qianhai Feisuan Yunzhi Software Technology Shenzhen Co ltd filed Critical Qianhai Feisuan Yunzhi Software Technology Shenzhen Co ltd
Priority to CN202111070868.5A priority Critical patent/CN113886221B/en
Publication of CN113886221A publication Critical patent/CN113886221A/en
Application granted granted Critical
Publication of CN113886221B publication Critical patent/CN113886221B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Abstract

The disclosure relates to a test script generation method, a test script generation device, a storage medium and electronic equipment, which automatically establish parameter association of two interfaces to realize automatic generation of a test script. The method comprises the following steps: recording parameter information of all interface requests associated with service test operation; classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, and sequentially analyzing input parameters and result parameters included in the target parameter information corresponding to the interface into first target data and second target data in a key-value pair form; comparing the value corresponding to each key in the first target data and the second target data with the value corresponding to each key in the first target data and the second target data corresponding to other interfaces, and establishing parameter association between the interfaces and the other interfaces according to a comparison result to obtain target interface information, thereby generating a test script.

Description

Test script generation method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a test script generation method and apparatus, an electronic device, and a storage medium.
Background
A test script is a series of instructions for performing a particular test, including the instructions and corresponding order of operations required to complete the test script. In the automatic testing process of the interface of the large-scale software system, because the system has huge architecture and numerous functions, a large amount of test scripts need to be manufactured for the system.
In the related art, the test scenarios are manually created one by one for each test script, and when the test scenarios need to be locally adjusted, the test scenarios need to be modified one by one, so that the workload is large, the steps are complicated, the efficiency is low, and the error rate is high.
Disclosure of Invention
The purpose of the present disclosure is to provide a test script generation method, device, electronic device, and storage medium, which implement automatic generation of a test script by analyzing and judging parameter information requested by all interfaces in a certain test scenario and establishing a parameter association between two interfaces according to a judgment result.
In order to achieve the above object, in a first aspect, the present disclosure provides a test script generation method, where the method includes:
responding to a service test operation in a service system, and recording parameter information of all interface requests related to the service test operation, wherein the parameter information comprises input parameters of an interface corresponding to the interface request and result parameters output by the interface;
classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyzing input parameters included in the target parameter information corresponding to the interface into first target data in a key-value pair form, and analyzing result parameters included in the target parameter information corresponding to the interface into second target data in the key-value pair form;
aiming at the first target data and the second target data corresponding to any interface, comparing the value corresponding to each key in the first target data and the second target data with the value corresponding to each key in the first target data and the second target data corresponding to other interfaces, and establishing parameter association between the interfaces and the other interfaces according to the comparison result to obtain target interface information;
and generating a test script based on the target interface information.
Optionally, the establishing, according to the comparison result, a parameter association between the interface and the other interfaces to obtain target interface information includes:
if the value corresponding to each key in the first target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information; or
And if the value corresponding to each key in the second target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information.
Optionally, the parsing, by the interface, the input parameter included in the target parameter information corresponding to the interface into first target data in a key-value pair format, and parsing, by the interface, the result parameter included in the target parameter information into second target data in a key-value pair format includes:
and analyzing the input parameters included in the target parameter information corresponding to the interface into first target data of a MAP structure, and analyzing the result parameters included in the target parameter information corresponding to the interface into second target data of the MAP structure.
Optionally, the method further comprises:
adding an identification variable to the first target data and the second target data obtained through analysis based on the interface type associated with the target parameter information, wherein the identification variable is used for uniquely marking the first target data or the second target data;
the comparing, for the first target data and the second target data corresponding to any interface, a value corresponding to each key in the first target data and the second target data with a value corresponding to each key in the first target data and the second target data corresponding to another interface includes:
and aiming at each identification variable, comparing the value corresponding to each key in the first target data and the second target data corresponding to the identification variable with the value corresponding to each key in the first target data and the second target data corresponding to other identification variables.
Optionally, the recording, in response to the service test operation in the service system, parameter information of all interface requests associated with the service test operation includes:
responding to the service test operation in the service system, and recording the parameter information of all interface requests related to the service test operation through a Jmeter recording tool.
Optionally, the input parameters include a header parameter, a query parameter, a form parameter, and a body parameter of an HTTP request associated with the interface.
In a second aspect, the present disclosure provides a test script generating apparatus, the apparatus comprising:
a recording module, configured to record, in response to a service test operation in a service system, parameter information of all interface requests associated with the service test operation, where the parameter information includes an input parameter of an interface corresponding to the interface request and a result parameter output by the interface;
the analysis module is used for classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyzing input parameters included in the target parameter information corresponding to the interface into first target data in a key-value pair form, and analyzing result parameters included in the target parameter information corresponding to the interface into second target data in the key-value pair form;
the establishing module is used for comparing a value corresponding to each key in the first target data and the second target data with a value corresponding to each key in the first target data and the second target data corresponding to other interfaces aiming at the first target data and the second target data corresponding to any interface, and establishing parameter association between the interfaces and the other interfaces according to a comparison result to obtain target interface information;
and the generating module is used for generating a test script based on the target interface information.
Optionally, the establishing module is configured to:
when the value corresponding to each key in the first target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information; or
And when the value corresponding to each key in the second target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information.
In a third aspect, the present disclosure provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of any one of the first aspect.
In a fourth aspect, the present disclosure provides an electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of any one of the first aspect.
By the technical scheme, the parameter information of all interface requests associated with the service test operation can be recorded, then classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyzing the input parameter included in the target parameter information corresponding to the interface into first target data in a key-value pair form, analyzing the result parameter included in the target parameter information corresponding to the interface into second target data in the key-value pair form, comparing the value corresponding to each key in the first target data and the second target data with the value corresponding to each key in the first target data and the second target data corresponding to other interfaces, and according to the comparison result, establishing parameter association between the interface and other interfaces to obtain target interface information, and finally automatically generating a complete and available test script based on the target interface information. Therefore, parameter association among the interfaces can be automatically established, the workload of testers is reduced, the working efficiency is improved, meanwhile, errors caused by manual writing or modification of test scripts by the testers can be avoided, the writing difficulty of the test scripts is reduced, and the local adjustment of a test scene is quicker when needed.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow chart illustrating a method of test script generation according to an exemplary embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating a test script generation method according to another exemplary embodiment of the present disclosure;
FIG. 3 is a block diagram illustrating a test script generating apparatus according to an exemplary embodiment of the present disclosure;
fig. 4 is a block diagram illustrating an electronic device according to an exemplary embodiment of the present disclosure.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
As background art shows, in the related art, manual creation of a test scenario is performed for each test script one by one, which has the disadvantages of large workload, complicated steps, low efficiency and high error rate, and when a test scenario needs to be locally adjusted, the test scenario needs to be modified one by one.
In view of this, embodiments of the present disclosure provide a method and an apparatus for generating a test script, a storage medium, and an electronic device, so as to implement automatic generation of a test script and improve test efficiency.
FIG. 1 is a flow diagram illustrating a method of test script generation in accordance with an exemplary embodiment. Referring to fig. 1, the test script generating method includes:
step 101, responding to the service test operation in the service system, recording the parameter information of all interface requests associated with the service test operation. The parameter information comprises an input parameter of an interface corresponding to the interface request and a result parameter output by the interface.
And 102, classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyzing input parameters included in the target parameter information corresponding to the interface into first target data in a key-value pair form, and analyzing result parameters included in the target parameter information corresponding to the interface into second target data in the key-value pair form.
Step 103, aiming at the first target data and the second target data corresponding to any interface, comparing the value corresponding to each key in the first target data and the second target data with the value corresponding to each key in the first target data and the second target data corresponding to other interfaces, and establishing parameter association between the interface and other interfaces according to the comparison result to obtain target interface information.
Step 104, generating a test script based on the target interface information.
It should be understood that the test scripts are the basis of the interface test, and due to the diversity and variability of the test requirements, the test scripts may also be changed, and each test script needs to correspond to one or more test scenarios for setting the number of users to be simulated during the operation of each test script, the operation performed by the user, and the load parameters of the used computer equipment. Therefore, in the test process of a large-scale software system, a large number of interface test scripts need to be compiled, and when a plurality of interfaces exist in a test scene, a certain parameter or parameters in the interface called first may be transmitted to the interface called later as input parameters. However, the inventors have found that data in a test script file derived by an automation tool in the related art is static data, and parameter variables and the like cannot be associated with each other, so that a tester is required to perform association between parameter variable setting and result extraction, and a lot of time and error are required.
Therefore, the embodiment of the present disclosure provides a new test script generation method, which dynamically and automatically associates associated parameters in interfaces to establish parameter association between the interfaces, and compared with manually creating test scenarios for each test script one by one, the method can automatically generate accurate, complete, and highly flexible interface test scripts, thereby avoiding errors caused by manually modifying or compiling the test scripts by testers, reducing the compiling difficulty of the test scripts, reducing the workload of the testers, and improving the working efficiency.
In order to make those skilled in the art understand the device communication method provided by the embodiments of the present disclosure, the following detailed description illustrates the above steps.
Illustratively, the business system is any one of large software systems. The service test operation is a test performed on an interface between test system components of a large-scale software system, and is mainly used for detecting interaction points between an external system and the system and between internal subsystems. All interface requests associated with the business test operations are any operations performed by the user in the large-scale software system. For example, the business system may be an enterprise information management system, the business test operation may be used to perform security test on the enterprise information management system, and all interface requests associated with the business test operation may be, for example, HTTP requests of the data query interface when a user submits a data query operation in a browser, which is not limited in this disclosure.
In a possible manner, according to the comparison result, the interface and other interfaces are associated by establishing parameters, and the obtaining of the target interface information may be: if the value corresponding to each key in the first target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and other interfaces to obtain target interface information; or if the value corresponding to each key in the second target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and other interfaces to obtain target interface information.
It should be understood that, when a test scenario of a business test operation includes multiple interfaces, there may be a calling order between the interfaces, so that in the calling order, there may be one or more parameters in input parameters and output result parameters of a certain interface, which may be used as input parameters of other interfaces. Therefore, when the values of the key value pairs in the target data of the two interfaces are compared, the value of the key value pair corresponding to each parameter in the input parameter and the output result parameter of a certain interface can be taken out to be compared with the value of the key value pair corresponding to each parameter in the input parameter and the output result parameter of other interfaces, and if the values of the key value pairs corresponding to two parameters in the input parameter and the output result parameter of the two interfaces are equal, the calling association of the two parameters is established between the two interfaces.
For example, a certain service test operation includes a first interface and a second interface, input parameters of the first interface include a first parameter, a second parameter, and a third parameter, a result parameter output by the first interface includes a fourth parameter, and input parameters of the second interface include a fifth parameter and a sixth parameter. Assuming that the calling sequence of the two interfaces is that the first interface is called first and then the second interface is called, one or more of the first parameter, the second parameter, the third parameter and the fourth parameter can be used as input parameters of the second interface, so that values of key-value pairs corresponding to the first parameter, the second parameter, the third parameter and the fourth parameter can be respectively taken out to be compared with values of key-value pairs corresponding to the fifth parameter and the sixth parameter, and if the value of the key-value pair of the certain parameter of the first interface is equal to the value of the key-value pair of the certain parameter of the second interface, the calling association of the two parameters is established between the two interfaces.
It should also be understood that the number of the parameters of the interface is plural, and when the value comparison of the key value pair between the parameters is performed, all the parameters of the first interface including the input parameter and the output result parameter may be pairwise corresponding to the input parameters of the second interface, and compared one by one.
Illustratively, establishing a parameter association may be replacing the value of the key-value pair with a unique identification of the parameter, depending on the comparison result. Therefore, the target interface information is obtained, and the test script file which can be identified by the test tool is generated based on the target interface information, so that the test script is automatically generated, the manual participation is reduced, and the test efficiency can be improved.
In a possible manner, the parsing the input parameter included in the target parameter information corresponding to the interface into the first target data in the form of a key-value pair, and the parsing the result parameter included in the target parameter information corresponding to the interface into the second target data in the form of a key-value pair may be: and analyzing the input parameters included in the target parameter information corresponding to the interface into first target data of the MAP structure, and analyzing the result parameters included in the target parameter information corresponding to the interface into second target data of the MAP structure.
It will be appreciated that the MAP structure is a set of key-value pairs, and the first target data is a set of key-value pairs comprising all of the parameters of the input parameters of the interface, and the second target data is a set of key-value pairs comprising all of the parameters of the result parameters of the output of the interface.
In an example, the input parameters and the output result parameters of the first interface and the second interface are analyzed to obtain a MAP structure of two key value pairs of the input parameter ParamMap and the output result parameter ResultMap of the first interface and a MAP structure of two key value pairs of the input parameter ParamMap and the output result parameter ResultMap of the second interface, and then a value of each key value pair in the input parameter ParamMap and the output result parameter ResultMap of the first interface is taken out and compared with a value of each key value pair in the input parameter ParamMap of the second interface.
In a possible manner, an identification variable may be added to the first target data and the second target data obtained through the analysis based on the interface type associated with the target parameter information, where the identification variable is used to uniquely identify the first target data or the second target data. Correspondingly, for the first target data and the second target data corresponding to any interface, comparing the value corresponding to each key in the first target data and the second target data with the value corresponding to each key in the first target data and the second target data corresponding to other interfaces may be: and aiming at each identification variable, comparing the value corresponding to each key in the first target data and the second target data corresponding to the identification variable with the value corresponding to each key in the first target data and the second target data corresponding to other identification variables.
It should be understood that, when parameter information of all interface requests associated with the service test operation is obtained, the parameter information includes all interfaces, input parameters corresponding to all interfaces, and output result parameters, which interface each parameter belongs to cannot be identified, and parameters with the same parameter name may exist, and each parameter cannot be accurately located, so that the parameter information may be processed, and an identification variable is added to target data obtained by analysis.
For example, the interface may be uniquely identified first to identify the input parameter or output result of which interface each parameter belongs to, e.g., the first interface may be identified as "$ first interface", and the second interface may be identified as "$ second interface"; classifying the parameters to avoid errors caused by the same parameter name, for example, if the same parameter name possibly exists in the header parameter of the first interface and the parameter of the query parameter, the parameters need to be classified according to the parameter type; the parameter is uniquely identified, for example, the header parameter userId of the first interface may be identified as "$ first interface.
The identification variables are added to the target data through the steps, when a certain identification variable is selected, all parameters are subjected to cycle traversal, namely the identification variables of all the parameters are read in sequence until the required parameters are found, so that the values of the key value pairs of the parameters can be compared.
In a possible manner, in response to a service test operation in the service system, parameter information of all interface requests associated with the service test operation may be recorded through a recording tool of the meter.
It should be understood that the meter tool is an interface testing tool, and can be applied to performance testing of various servers, software systems, software interfaces, and the like. The complete meter script should include at least test plans, thread groups, external parameterization files, HTTP requests, request response reads, result reports, and the like. The present disclosure is applied to a test scenario including a plurality of interfaces, and may be applied to any interface test tool including a meter tool, and correspondingly, any recording tool that can record parameter information of all interface requests associated with a service test operation may also be used.
In a possible approach, the input parameters may include a header parameter, a query parameter, a form parameter, and a body parameter of the HTTP request associated with the interface.
It should be understood that, in order to improve the comprehensiveness and accuracy of establishing the parameter association between the interfaces, the input parameters of the present disclosure include parameters of the HTTP request, including a header parameter, a query parameter, a form parameter, and a body parameter, and when performing parameter comparison of the two interfaces, instead of comparing parameter names of the two parameters, the parameter value of each parameter is taken out for comparison, that is, the value of the key value pair corresponding to each parameter is taken out, and then the parameter association of the two interfaces is established according to the comparison result.
The following describes a test script generation method provided by the present disclosure with another exemplary embodiment. Referring to fig. 2, the test script generating method includes:
step 201, responding to the service test operation in the service system, recording the parameter information of all interface requests associated with the service test operation by a Jmeter recording tool. The parameter information includes an input parameter of an interface corresponding to the interface request and a result parameter output by the interface.
Step 202, classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyzing the input parameter included in the target parameter information corresponding to the interface into first target data in a key-value pair form, and analyzing the result parameter included in the target parameter information corresponding to the interface into second target data in the key-value pair form.
Step 203, adding an identification variable to the first target data and the second target data obtained by analysis based on the interface type associated with the target parameter information, wherein the identification variable is used for uniquely marking the first target data or the second target data.
Step 204, aiming at each identification variable, comparing the value corresponding to each key in the first target data and the second target data corresponding to the identification variable with the value corresponding to each key in the first target data and the second target data corresponding to other identification variables.
Step 205, if the value corresponding to each key in the first target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to the other interface, step 207 is executed.
Step 206, if the value corresponding to each key in the second target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to the other interface, step 207 is executed.
Step 207, establishing parameter association between the interface and other interfaces to obtain target interface information.
At step 208, a test script is generated based on the target interface information.
The detailed description of the above steps is given above for illustrative purposes, and will not be repeated here. It will also be appreciated that for simplicity of explanation, the above-described method embodiments are all presented as a series of acts or combination of acts, but those skilled in the art will recognize that the present disclosure is not limited by the order of acts or combination of acts described above. Further, those skilled in the art will also appreciate that the embodiments described above are preferred embodiments and that the steps involved are not necessarily required for the present disclosure.
By the method, the parameter information of all interface requests associated with the business test operation is recorded by the recording tool, the associated parameters in the interfaces are dynamically and automatically associated, the parameter association between the interfaces is established, then the test script file which can be identified by the corresponding test tool is generated, and finally the complete and available test script is generated, so that the workload of testers is reduced, the working efficiency is improved, meanwhile, errors caused by manual writing or modification of the test script by the testers are avoided, the writing difficulty of the test script is reduced, and the local adjustment of the test scene is quicker.
Based on the same inventive concept, the embodiment of the present disclosure further provides a test script generating apparatus, which may be a part or all of an electronic device through software, hardware, or a combination of the two. Referring to fig. 3, the apparatus 300 includes:
a recording module 301, configured to record, in response to a service test operation in a service system, parameter information of all interface requests associated with the service test operation, where the parameter information includes an input parameter of an interface corresponding to the interface request and a result parameter output by the interface.
The analysis module 302 is configured to classify the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyze an input parameter included in the target parameter information corresponding to the interface as first target data in a key-value pair format, and analyze a result parameter included in the target parameter information corresponding to the interface as second target data in the key-value pair format.
An establishing module 303, configured to compare, for the first target data and the second target data corresponding to any interface, a value corresponding to each key in the first target data and the second target data with a value corresponding to each key in the first target data and the second target data corresponding to another interface, and establish parameter association between the interface and the another interface according to a comparison result, so as to obtain target interface information.
A generating module 304, configured to generate a test script based on the target interface information.
Optionally, the establishing module 303 is configured to:
when the value corresponding to each key in the first target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information; or
And when the value corresponding to each key in the second target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information.
Optionally, the parsing module 302 is configured to:
and analyzing the input parameters included in the target parameter information corresponding to the interface into first target data of a MAP structure, and analyzing the result parameters included in the target parameter information corresponding to the interface into second target data of the MAP structure.
Optionally, the apparatus 300 further comprises:
the processing module is used for adding an identification variable to the first target data and the second target data obtained through analysis based on the interface type associated with the target parameter information, wherein the identification variable is used for uniquely marking the first target data or the second target data;
optionally, the establishing module 303 is configured to:
and aiming at each identification variable, comparing the value corresponding to each key in the first target data and the second target data corresponding to the identification variable with the value corresponding to each key in the first target data and the second target data corresponding to other identification variables.
Optionally, the recording module 301 is configured to:
responding to the service test operation in the service system, and recording the parameter information of all interface requests related to the service test operation through a Jmeter recording tool.
Optionally, the input parameters include a header parameter, a query parameter, a form parameter, and a body parameter of an HTTP request associated with the interface.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Based on the same inventive concept, an embodiment of the present disclosure provides an electronic device, including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of any of the above test script generation methods.
In a possible manner, a block diagram of the electronic device is shown in fig. 4. Referring to fig. 4, as shown in fig. 4, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input/output (I/O) interface 704, and a communication component 705.
The processor 701 is configured to control the overall operation of the electronic device 700, so as to complete all or part of the steps in the test script generation method. The memory 702 is used to store various types of data to support operation at the electronic device 700, such as instructions for any application or method operating on the electronic device 700 and application-related data, such as contact data, transmitted and received messages, pictures, audio, video, and the like. The Memory 702 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk, or optical disk. The multimedia components 703 may include screen and audio components. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 702 or transmitted through the communication component 705. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 704 provides an interface between the processor 701 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, which is not limited herein. The corresponding communication component 705 may thus include: Wi-Fi module, Bluetooth module, NFC module, etc.
In an exemplary embodiment, the electronic Device 700 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the test script generation method described above.
In another exemplary embodiment, there is also provided a computer readable storage medium including program instructions which, when executed by a processor, implement the steps of the test script generation method described above. For example, the computer readable storage medium may be the above-mentioned memory 702 comprising program instructions executable by the processor 701 of the electronic device 700 to perform the above-mentioned test script generation method.
In another exemplary embodiment, a computer program product is also provided, which comprises a computer program executable by a programmable apparatus, the computer program having code portions for performing the test script generation method described above when executed by the programmable apparatus.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (10)

1. A method for generating a test script, the method comprising:
responding to a service test operation in a service system, and recording parameter information of all interface requests related to the service test operation, wherein the parameter information comprises input parameters of an interface corresponding to the interface request and result parameters output by the interface;
classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyzing input parameters included in the target parameter information corresponding to the interface into first target data in a key-value pair form, and analyzing result parameters included in the target parameter information corresponding to the interface into second target data in the key-value pair form;
aiming at the first target data and the second target data corresponding to any interface, comparing the value corresponding to each key in the first target data and the second target data with the value corresponding to each key in the first target data and the second target data corresponding to other interfaces, and establishing parameter association between the interfaces and the other interfaces according to the comparison result to obtain target interface information;
and generating a test script based on the target interface information.
2. The method of claim 1, wherein the obtaining target interface information by establishing parameter association between the interface and the other interfaces according to the comparison result comprises:
if the value corresponding to each key in the first target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information; or
And if the value corresponding to each key in the second target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information.
3. The method of claim 1, wherein parsing the input parameters included in the target parameter information corresponding to the interface into first target data in the form of key-value pairs and parsing the result parameters included in the target parameter information corresponding to the interface into second target data in the form of key-value pairs comprises:
and analyzing the input parameters included in the target parameter information corresponding to the interface into first target data of a MAP structure, and analyzing the result parameters included in the target parameter information corresponding to the interface into second target data of the MAP structure.
4. The method according to any one of claims 1-3, further comprising:
adding an identification variable to the first target data and the second target data obtained through analysis based on the interface type associated with the target parameter information, wherein the identification variable is used for uniquely marking the first target data or the second target data;
the comparing, for the first target data and the second target data corresponding to any interface, a value corresponding to each key in the first target data and the second target data with a value corresponding to each key in the first target data and the second target data corresponding to another interface includes:
and aiming at each identification variable, comparing the value corresponding to each key in the first target data and the second target data corresponding to the identification variable with the value corresponding to each key in the first target data and the second target data corresponding to other identification variables.
5. A method according to any of claims 1-3, wherein said recording parameter information of all interface requests associated with a service test operation in response to the service test operation in a service system comprises:
responding to the service test operation in the service system, and recording the parameter information of all interface requests related to the service test operation through a Jmeter recording tool.
6. The method of any of claims 1-3, wherein the input parameters include a header parameter, a query parameter, a form parameter, and a body parameter of an HTTP request associated with the interface.
7. An apparatus for generating a test script, the apparatus comprising:
a recording module, configured to record, in response to a service test operation in a service system, parameter information of all interface requests associated with the service test operation, where the parameter information includes an input parameter of an interface corresponding to the interface request and a result parameter output by the interface;
the analysis module is used for classifying the parameter information based on the interface type and the parameter type corresponding to the parameter information to obtain target parameter information corresponding to the interface, analyzing input parameters included in the target parameter information corresponding to the interface into first target data in a key-value pair form, and analyzing result parameters included in the target parameter information corresponding to the interface into second target data in the key-value pair form;
the establishing module is used for comparing a value corresponding to each key in the first target data and the second target data with a value corresponding to each key in the first target data and the second target data corresponding to other interfaces aiming at the first target data and the second target data corresponding to any interface, and establishing parameter association between the interfaces and the other interfaces according to a comparison result to obtain target interface information;
and the generating module generates a test script based on the target interface information.
8. The apparatus of claim 7, wherein the establishing module is configured to:
when the value corresponding to each key in the first target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information; or
And when the value corresponding to each key in the second target data corresponding to the interface is consistent with the value corresponding to the key in the first target data corresponding to other interfaces in comparison, establishing parameter association between the interface and the other interfaces to obtain target interface information.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
10. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 6.
CN202111070868.5A 2021-09-13 2021-09-13 Test script generation method and device, storage medium and electronic equipment Active CN113886221B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111070868.5A CN113886221B (en) 2021-09-13 2021-09-13 Test script generation method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111070868.5A CN113886221B (en) 2021-09-13 2021-09-13 Test script generation method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN113886221A true CN113886221A (en) 2022-01-04
CN113886221B CN113886221B (en) 2022-09-23

Family

ID=79009332

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111070868.5A Active CN113886221B (en) 2021-09-13 2021-09-13 Test script generation method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN113886221B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453577A (en) * 2023-12-25 2024-01-26 湖南兴盛优选网络科技有限公司 Method, device and computer equipment for generating interface automation use case based on flow recording

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140365830A1 (en) * 2013-06-11 2014-12-11 Wipro Limited System and method for test data generation and optimization for data driven testing
CN106155891A (en) * 2015-04-02 2016-11-23 阿里巴巴集团控股有限公司 Interface test method, interface description data library generating method and device
CN106383786A (en) * 2016-09-27 2017-02-08 北京金山安全软件有限公司 Interface pressure performance testing method and device and electronic equipment
CN107122297A (en) * 2017-04-18 2017-09-01 上海雷腾软件股份有限公司 The method and apparatus that request message for test interface is generated
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device
CN107608889A (en) * 2017-09-15 2018-01-19 杭州销冠网络科技有限公司 A kind of test script automatic generation method and system
CN110221948A (en) * 2019-04-18 2019-09-10 深圳壹账通智能科技有限公司 Test script generation method, device, computer installation and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140365830A1 (en) * 2013-06-11 2014-12-11 Wipro Limited System and method for test data generation and optimization for data driven testing
CN106155891A (en) * 2015-04-02 2016-11-23 阿里巴巴集团控股有限公司 Interface test method, interface description data library generating method and device
CN106383786A (en) * 2016-09-27 2017-02-08 北京金山安全软件有限公司 Interface pressure performance testing method and device and electronic equipment
CN107122297A (en) * 2017-04-18 2017-09-01 上海雷腾软件股份有限公司 The method and apparatus that request message for test interface is generated
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device
CN107608889A (en) * 2017-09-15 2018-01-19 杭州销冠网络科技有限公司 A kind of test script automatic generation method and system
CN110221948A (en) * 2019-04-18 2019-09-10 深圳壹账通智能科技有限公司 Test script generation method, device, computer installation and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453577A (en) * 2023-12-25 2024-01-26 湖南兴盛优选网络科技有限公司 Method, device and computer equipment for generating interface automation use case based on flow recording
CN117453577B (en) * 2023-12-25 2024-03-22 湖南兴盛优选网络科技有限公司 Method, device and computer equipment for generating interface automation use case based on flow recording

Also Published As

Publication number Publication date
CN113886221B (en) 2022-09-23

Similar Documents

Publication Publication Date Title
CN108897691B (en) Data processing method, device, server and medium based on interface simulation service
CN110209652B (en) Data table migration method, device, computer equipment and storage medium
CN108984389B (en) Application program testing method and terminal equipment
CN107992409A (en) Method for generating test case, device, computer equipment and storage medium
CN111026645B (en) User interface automatic test method and device, storage medium and electronic equipment
CN112765023B (en) Test case generation method and device
CN108628748B (en) Automatic test management method and automatic test management system
CN111190827A (en) Interface automation test method and device, storage medium and electronic equipment
CN111198797B (en) Operation monitoring method and device and operation analysis method and device
CN112069068A (en) Automatic test data processing method, device, equipment and readable storage medium
CN113886221B (en) Test script generation method and device, storage medium and electronic equipment
WO2020232883A1 (en) Script defect scanning method and apparatus, computer device and storage medium
CN114328250A (en) Automatic self-checking method, medium and device for software system
CN113836014A (en) Interface testing method and device, electronic equipment and storage medium
US20050203717A1 (en) Automated testing system, method and program product using testing map
CN111147586B (en) Equipment end control method and device and conference system
CN110717315B (en) System data batch modification method and device, storage medium and electronic equipment
CN114721969A (en) Method and device for separating interface automation test data and test codes
CN110795338B (en) Front-end and back-end interaction-based automatic testing method and device and electronic equipment
CN114371866A (en) Version reconfiguration test method, device and equipment of service system
CN112860585A (en) Test script assertion generation method and device
CN114756217B (en) Plug-in based script generation system
CN112015633A (en) Test excitation multi-platform multiplexing method, device, equipment and storage medium
CN116680171B (en) Test method, device, storage medium and electronic equipment
CN112860587B (en) UI automatic test 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