CN117609081A - Method and device for constructing test data, electronic equipment and storage medium - Google Patents

Method and device for constructing test data, electronic equipment and storage medium Download PDF

Info

Publication number
CN117609081A
CN117609081A CN202311651678.1A CN202311651678A CN117609081A CN 117609081 A CN117609081 A CN 117609081A CN 202311651678 A CN202311651678 A CN 202311651678A CN 117609081 A CN117609081 A CN 117609081A
Authority
CN
China
Prior art keywords
test
interfaces
data
test flow
flow
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.)
Pending
Application number
CN202311651678.1A
Other languages
Chinese (zh)
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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202311651678.1A priority Critical patent/CN117609081A/en
Publication of CN117609081A publication Critical patent/CN117609081A/en
Pending legal-status Critical Current

Links

Classifications

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

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 application discloses a method and a device for constructing test data, electronic equipment and a storage medium; the method comprises the following steps: acquiring interfaces and message information related to each test flow; the interfaces related to each test flow are connected in series, and a serial result of the interfaces related to each test flow is obtained; carrying out parameterization configuration on interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow; generating a test script according to message information related to each test flow, serial connection results of interfaces related to each test flow, parameterized configuration results of interfaces related to each test flow and test preparation data acquired in advance; and generating final test data through the test script. According to the embodiment of the application, the test data can be generated in batches, manual participation is not needed, the test manpower is saved, and the test preparation efficiency is improved.

Description

Method and device for constructing test data, electronic equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of software testing, in particular to a method and a device for constructing test data, electronic equipment and a storage medium.
Background
As the traffic of electronic business draft increases, the functions of electronic business draft systems become more and more huge and the business rules become more and more complicated. Because the electronic business draft business flow is long, the dependency relationship among businesses is strong, a tester can only prepare one piece of test data at a time when preparing the test data, and meanwhile, the operation flow is long, so that the dependency on unnecessary functions and related systems is increased. For example: when a tester tests the electronic business draft system, the bill is basic data with great demand in the test process, any operation can be performed by the bill, and the bill can be generated by finishing several processes of bill drawing application, prompting acceptance application, acceptance reply, prompting receipt application, prompting receipt reply and the like. For example, a tester tests the prompt payment transaction of a bill, and the prompt payment operation can be performed only after finishing the flows of ticket issuing application, prompt acceptance application, acceptance reply, prompt ticket collecting application, prompt ticket collecting reply and the like, and the state of the bill is changed once the prompt payment is completed, so that the operations such as prompt payment can not be performed again.
Therefore, the prior art mainly adopts a manual mode to carry out the construction of test data, and the test preparation efficiency is low.
Disclosure of Invention
The method, the device, the electronic equipment and the storage medium for constructing the test data can generate the test data in batches without manual participation, so that the test manpower is saved, and the test preparation efficiency is improved.
In a first aspect, an embodiment of the present application provides a method for constructing test data, where the method includes:
acquiring interfaces and message information related to each test flow;
the interfaces related to each test flow are connected in series, and a serial result of the interfaces related to each test flow is obtained;
carrying out parameterization configuration on interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow;
generating a test script according to message information related to each test flow, serial connection results of interfaces related to each test flow, parameterized configuration results of interfaces related to each test flow and test preparation data acquired in advance; and generating final test data through the test script.
In a second aspect, an embodiment of the present application further provides a device for constructing test data, where the device includes: the device comprises an acquisition module, a serial module, a configuration module and a generation module; wherein,
The acquisition module is used for acquiring interfaces and message information related to each test flow;
the serial module is used for connecting the interfaces related to each test flow in series to obtain a serial result of the interfaces related to each test flow;
the configuration module is used for carrying out parameterization configuration on the interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow;
the generating module is used for generating a test script according to the message information related to each test flow, the serial connection result of the interfaces related to each test flow, the parameterized configuration result of the interfaces related to each test flow and the pre-acquired test preparation data; and generating final test data through the test script.
In a third aspect, an embodiment of the present application provides an electronic device, including:
one or more processors;
a memory 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 building test data described in any of the embodiments of the present application.
In a fourth aspect, embodiments of the present application provide a storage medium having stored thereon a computer program which, when executed by a processor, implements the method for constructing test data according to any of the embodiments of the present application.
The embodiment of the application provides a method, a device, electronic equipment and a storage medium for constructing test data, wherein when the test data is generated, interfaces and message information related to each test flow are acquired first; then, the interfaces related to each test flow are connected in series, and a series result of the interfaces related to each test flow is obtained; carrying out parameterization configuration on interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow; and finally, generating a test script according to the message information related to each test flow, the serial connection result of the interfaces related to each test flow, the parameterized configuration result of the interfaces related to each test flow and the pre-acquired test preparation data, and generating final test data through the test script. That is, in the technical solution of the present application, a data base may be provided for generating a test script later by acquiring the interface and the message information related to each test flow. And interfaces related to each test flow are connected in series, so that the working efficiency is improved, the test reliability is enhanced, and the maintenance cost is reduced. And then, the maintainability and the expandability are improved by carrying out parameterization configuration on interfaces related to each test flow, the program expansion is easy, and the program coupling is reduced. And finally, generating a test script according to the message information, the serial connection result of the interfaces, the parameterized configuration result of the interfaces and the test preparation data acquired in advance, and generating final test data through the test script. The separation of the test data and the script is realized, so that a tester can customize the data without manually participating in the data generation process, thereby saving a large amount of test manpower and improving the test preparation efficiency. Therefore, compared with the prior art, the method, the device, the electronic equipment and the storage medium for constructing the test data can generate the test data in batches, so that manual participation is not needed, the test manpower is saved, and the test preparation efficiency is improved; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a first flow chart of a method for constructing test data according to an embodiment of the present disclosure;
FIG. 2 is a second flow chart of a method for constructing test data according to an embodiment of the present disclosure;
FIG. 3 is a third flow chart of a method for constructing test data according to an embodiment of the present disclosure;
FIG. 4 is a schematic structural diagram of a device for constructing test data according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present application are shown in the drawings.
Example 1
Fig. 1 is a schematic flow chart of a first procedure of a method for constructing test data according to an embodiment of the present application, where the method may be performed by a device for constructing test data or an electronic device, where the device or the electronic device may be implemented in software and/or hardware, and the device or the electronic device may be integrated into any intelligent device with a network communication function. As shown in fig. 1, the method for constructing test data may include the steps of:
step 110, obtaining interfaces and message information related to each test flow.
The interface information may include an interface name or identifier, input and output parameters of the interface, a call address of the interface, and/or a request and response message of the interface, which is not limited in the embodiment of the present application. The message information may include a message format, a message content, and/or message error handling, which is not limited in the embodiments of the present application.
Specifically, a test flow for acquiring interface and message information is determined first. For example: if the electronic commercial draft is tested, the test flow of the test comprises the flows of ticket issuing application, prompt acceptance application, acceptance reply, prompt ticket collecting application, prompt ticket collecting reply and the like. And then running the test cases aiming at each test flow and ensuring that the test cases contain the tests related to the interfaces. A network packet-grabbing tool is then used, for example: wireshark to capture network traffic during testing, including data packets related to interface calls. And analyzing the message content in the captured data packet according to the requirement. The system or test execution log may then be checked to obtain detailed information about the interface call and message transfer, such as: time stamps of requests and responses, interface names, request parameters, response results, etc. And integrating the obtained information to form a complete record of the interface and message information related to each test flow. Finally, whether the acquired interface and message information is accurate or not is verified, for example: whether the acquired interface and message information is accurate may be verified by comparing the source document or using a plurality of test tools. And is adjusted or supplemented according to actual conditions or requirements.
In this embodiment, by acquiring the interfaces and the message information related to each test flow, a data base is provided for generating the test script later.
And 120, connecting the interfaces related to each test flow in series to obtain a serial result of the interfaces related to each test flow.
Specifically, the function and definition of each interface is first known, for example: information such as input parameters, output parameters, request header, request body, dependency relation and the like of the interface; then determining the calling sequence of the interfaces according to the dependency relationship between the interfaces; the interfaces involved in each test flow may then be connected in series using the associated test tools, for example: JMeter or Postman, etc.; and obtaining serial connection results of interfaces related to each test flow.
In this embodiment, the interfaces related to each test flow are connected in series, so that the working efficiency is improved, the test reliability is enhanced, and the maintenance cost is reduced.
And 130, carrying out parameterization configuration on the interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow.
Specifically, after the interfaces related to each test flow are connected in series, according to the serial connection result of the interfaces related to each test flow, different parameterization configuration methods can be used to perform parameterization configuration on the interfaces related to each test flow, so as to obtain parameterization configuration results of the interfaces related to each test flow. The parameterized configuration method may be a method using user parameters, using a CSV data file, using a plug-in, or using a thread group, which is not limited in the embodiment of the present application.
For example, according to the serial connection result of the interfaces related to each test flow, the corresponding configuration file may be used to store parameters, such as JSON, XML, and the like, and refer to these parameters in the test case, so as to implement parameterized configuration of the interfaces.
In this embodiment, the interfaces related to each test flow are configured in a parameterized manner, so that maintainability and expandability are improved, program expansion is easy, and program coupling is reduced.
And 140, generating a test script according to the message information related to each test flow, the serial connection result of the interfaces related to each test flow, the parameterized configuration result of the interfaces related to each test flow and the pre-acquired test preparation data, and generating final test data through the test script.
The pre-acquired test preparation data may include test requirements, test scenarios, and/or test environment information, which is not limited in this embodiment of the present application.
Specifically, before starting to generate a test script, test preparation data needs to be collected, for example: test requirements, test scenes, output forms of test data, system dates, random number generation rules, interface public URL values, server IP, port numbers and other information.
When the test script is generated, the interfaces are connected in series according to the serial connection results of the interfaces related to the test flows, parameter values in the test preparation data are replaced to request parameters of the interfaces according to the parameterization configuration results of the interfaces related to the test flows, then the format and structure of the test script are determined according to the test requirements and the test scenes, and then the test script is generated through a test tool based on the message information and other test preparation data, wherein the test tool can be Postman or JMeter and the like.
Finally, the generated test script is run through an automatic test tool or manually to generate final test data. For example: the test script is run using a Selenium automated test tool or command line. And the generated test data are arranged and recorded according to a certain format so as to be convenient for subsequent use. For example: the test data may be recorded using a table, CSV, JSON, or the like format.
In this embodiment, a test script is generated according to the message information, the serial connection result of the interfaces, the parameterized configuration result of the interfaces, and the test preparation data acquired in advance, and final test data is generated through the test script. The separation of the test data and the script is realized, so that a tester can customize the data without manually participating in the data generation process, thereby saving a large amount of test manpower and improving the test preparation efficiency.
The method for constructing the test data provided by the embodiment of the application comprises the steps of firstly acquiring interfaces and message information related to each test flow when the test data are generated; then, the interfaces related to each test flow are connected in series, and a series result of the interfaces related to each test flow is obtained; carrying out parameterization configuration on interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow; and finally, generating a test script according to the message information related to each test flow, the serial connection result of the interfaces related to each test flow, the parameterized configuration result of the interfaces related to each test flow and the pre-acquired test preparation data, and generating final test data through the test script. That is, in the technical solution of the present application, a data base may be provided for generating a test script later by acquiring the interface and the message information related to each test flow. And interfaces related to each test flow are connected in series, so that the working efficiency is improved, the test reliability is enhanced, and the maintenance cost is reduced. And then, the maintainability and the expandability are improved and the program coupling is reduced by carrying out parameterization configuration on interfaces related to each test flow. And finally, generating a test script according to the message information, the serial connection result of the interfaces, the parameterized configuration result of the interfaces and the test preparation data acquired in advance, and generating final test data through the test script. The separation of the test data and the script is realized, so that a tester can customize the data without manually participating in the data generation process, thereby saving a large amount of test manpower and improving the test preparation efficiency. Therefore, compared with the prior art, the method for constructing the test data provided by the embodiment of the application can generate the test data in batches, does not need to be manually participated, saves the test manpower and improves the test preparation efficiency; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example two
Fig. 2 is a second flow chart of a method for constructing test data according to an embodiment of the present application. Further optimization and expansion based on the above technical solution can be combined with the above various alternative embodiments.
As shown in fig. 2, the method for constructing test data may include the steps of:
step 210, obtaining interfaces and message information related to each test flow.
And 220, analyzing the business logic of the interfaces related to each test flow to obtain the business logic relation of the interfaces related to each test flow.
The business logic of the interface refers to a specific description of the functions and implementation carried by the interface. The business logic relationship of the interfaces refers to a logic relationship among different interfaces in a business process, and the business logic relationship of the interfaces can be a sequential relationship, a concurrent relationship, a dependency relationship, a shared resource relationship or the like, which is not limited in the embodiment of the present application.
Specifically, the function and service scenario of the tested system are known first, including the conditions of service flow, data flow, interface call and the like related to each test flow. For example: the relevant information can be known by reading the document. And then analyzing interfaces related to each test flow according to the functions and service scenes of the tested system, wherein the interfaces comprise input and output parameters of the interfaces, implementation modes of the interfaces, calling relations among the interfaces and the like. And determining the business logic relation of the interfaces related to each test flow according to the analysis result of the interfaces. For example, if the processing result of a certain interface depends on the output result of other interfaces, the processing needs to be continued after the processing of other interfaces is completed, and the business logic relationship of the interface is a dependency relationship.
In this embodiment, by determining the service logic relationship of the interfaces involved in each test flow, a data base is provided for the task of executing the serial interfaces later.
Step 230, according to the business logic relationship of the interfaces related to each test flow, the interfaces related to each test flow are connected in series, so as to obtain the serial connection result of the interfaces related to each test flow.
Specifically, according to the service logic relationship of the interfaces related to each obtained test flow, determining the calling sequence of the interfaces. And writing interface calling codes according to the calling sequence of the interfaces, and connecting the interfaces related to each test flow in series, so as to obtain the serial connection result of the interfaces related to each test flow.
For example, assume that there is one e-commerce system that includes three test flows, shopping cart flow, order flow, and user flow. The interface calling sequence of each flow is that the interface of adding commodity to shopping cart is called in the shopping cart flow, then the interface of updating commodity quantity in shopping cart is called, and finally the interface of deleting commodity in shopping cart is called. The order creation interface is called in the order flow, the order payment interface is called, and the order cancellation interface is called. In the user flow, firstly, a 'register new user' interface is called, then a 'login system' interface is called, and finally, an 'update user information' interface is called. And then according to the calling sequence of the interfaces, interface calling codes can be written by using a python programming language, so that the interfaces related to each test flow are connected in series, and the serial connection result of the interfaces related to each test flow is obtained.
In this embodiment, according to the business logic relationship of the interfaces related to each test flow, the interfaces related to each test flow are connected in series, so that not only can the test coverage rate be improved, but also the test speed can be increased, and the test efficiency can be improved.
And 240, carrying out parameterization configuration on the interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow.
Step 250, adding the message information related to each test flow to the first data area of the test script, adding the serial result of the interface related to each test flow and the parameterized configuration result of the interface related to each test flow to the second data area of the test script, and adding the test preparation data to the third data area of the test script, thereby obtaining the test script.
Wherein the test preparation data includes: system data and transaction data. The system data includes, but is not limited to: the output form of test preparation data, system date, random number generation rule, interface public URL value, server IP, port number; transaction data includes, but is not limited to: ticket issuer information, payee information, contractor information, and transaction amount. The data area refers to a specific portion divided in the test script in order to store related data for generating the test script. The first data area is used for storing message information related to each test flow. The second data area is used for storing serial results of interfaces related to each test flow and parameterized configuration results of the interfaces. The third data area is used for storing test preparation data.
Specifically, a framework of test scripts may be created first, including necessary data structures such as variables, arrays, lists, etc., and divided into three data areas for storing different types of data. And then adding the message information related to each test flow into a first data area of the test script, adding the serial connection result of the interfaces related to each test flow and the parameterized configuration result of the interfaces related to each test flow into a second data area of the test script, and adding test preparation data into a third data area of the test script to obtain the test script.
In this embodiment, the message information related to each test flow, the serial connection result of the interface and the parameterized configuration result of the interface are added to different data areas of the test script, so that the mutual interference and collision of different types of data can be avoided, the stability and accuracy of the test script are ensured, the maintainability, reusability and automation degree of the test script can be improved, and the debugging and error checking are facilitated, thereby improving the efficiency and quality of the whole test work.
Step 260, generating final test data through the test script.
Specifically, after the test script is generated, test data is generated by running the test script. It should be noted that in running the test script, it is necessary to ensure that the test environment, database connection, test tools, etc. are properly configured. After the test data is generated, the data needs to be validated to ensure accuracy and integrity of the data. In addition, in the verification process, the type, format, range and other aspects of the data need to be verified to ensure that the data meets the expected requirements. And then storing the generated test data into a corresponding file or database according to actual conditions or requirements for subsequent use.
In the embodiment, final test data is generated through the test script, so that the test efficiency can be improved, human errors are reduced, the data format and type are unified, the automation degree is high, the repeated use is realized, and the data security is improved.
Further, generating final test data by the test script includes:
receiving the circulation operation times input by a tester;
and controlling the test script to run according to the cycle operation times to obtain final test data.
The cycle operation times are the operation times of the test script set according to the actual requirements or conditions.
Specifically, the number of cyclic operations input by the tester is received first, for example: a variable may be used to receive the number of cyclic runs entered by the tester. And then controlling the determined test script to run according to the cycle operation times, for example: in a test script, a loop structure may be used to control the number of executions of the test script. After each cycle of executing the test script, the test script needs to store the generated test data so as to obtain final test data. For example: the data may be stored in files, databases, or other suitable data storage locations as the case may be.
In the embodiment, the test script is controlled to run according to the number of circulating running times, so that test data can be generated in batches, test preparation can be rapidly and accurately performed, and test efficiency is improved.
The method for constructing the test data provided by the embodiment of the application comprises the steps of firstly acquiring interfaces and message information related to each test flow when the test data are generated; then analyzing the business logic of the interfaces related to each test flow to obtain the business logic relation of the interfaces related to each test flow; and then according to the business logic relation of the interfaces related to each test flow, the interfaces related to each test flow are connected in series to obtain the serial connection result of the interfaces related to each test flow. Then carrying out parameterization configuration on the interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow; and finally, adding the message information related to each test flow into a first data area of the test script, adding the serial connection result of the interfaces related to each test flow and the parameterized configuration result of the interfaces related to each test flow into a second data area of the test script, adding test preparation data into a third data area of the test script to obtain the test script, and generating final test data through the test script. That is, in the technical solution of the present application, a data base may be provided for generating a test script later by acquiring the interface and the message information related to each test flow. And then, by determining the business logic relation of the interfaces related to each test flow, a data basis is provided for executing tasks of the serial interfaces. And then, according to the business logic relation of the interfaces related to each test flow, the interfaces related to each test flow are connected in series, so that the test coverage rate is improved, the test speed is increased, and the test efficiency is improved. And then, the maintainability is improved, the expandability is enhanced and the program coupling is reduced by carrying out parameterization configuration on interfaces related to each test flow. And then, message information related to each test flow, serial connection results of interfaces and parameterized configuration results of the interfaces are added into different data areas of the test script, so that mutual interference and conflict of different types of data are avoided, stability and accuracy of the test script are ensured, maintainability, reusability and automation degree of the test script are improved, debugging and error checking are facilitated, and therefore efficiency and quality of the whole test work are improved. And finally, generating final test data through the test script, thereby improving the test efficiency, reducing human errors, unifying the data format and type and improving the data security. Therefore, compared with the prior art, the method for constructing the test data provided by the embodiment of the application can generate the test data in batches, does not need to be manually participated, saves the test manpower and improves the test preparation efficiency; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example III
Fig. 3 is a third flow chart of a method for constructing test data according to an embodiment of the present application. Further optimization and expansion based on the above technical solution can be combined with the above various alternative embodiments.
As shown in fig. 3, the method for constructing test data may include the steps of:
step 310, obtaining interfaces and message information related to each test flow.
Step 320, the interfaces related to each test procedure are connected in series, so as to obtain the serial result of the interfaces related to each test procedure.
And 330, extracting the return values of the interfaces related to the test flows through the regular expressions corresponding to the return values of the interfaces related to the pre-constructed test flows.
Each pre-built test flow is a required test flow determined according to actual conditions or requirements.
Specifically, the corresponding regular expression is determined according to the format and the content of the return value of the interface related to each pre-constructed test flow. For example: the interface returns a JSON array, each element is a JSON object, and the regular expression corresponding to the interface may be [..x ]. The format and content of the return value of the interface related to each pre-constructed test flow can be obtained by consulting related interface documents or calling interfaces, which are not limited in the embodiment of the application, and the regular expression is used for matching and extracting specific information in the return value of the interface. Test scripts are then written using a programming language that will call the interfaces involved in each test flow and extract the return values using regular expressions. The interfaces related to each test procedure can be obtained through serial results of the interfaces related to each test procedure, and the test script can use an existing test framework or tool to simplify the writing process, for example: a Selenium framework. And then, running the test script to call the interfaces related to each test flow, and acquiring the return values of the interfaces. In the test script, the regular expression is used to match and extract the return value of the interface. Specifically, a required return value may be extracted according to the matching result of the regular expression. These return values may include specific fields, data or status codes, etc. And finally, processing and storing the extracted return value. It may be stored in a file, database or memory as needed for later analysis and use.
In this embodiment, by acquiring the return values of the interfaces related to each test flow, a data base is provided for performing parameterization configuration on the interfaces related to each test flow later.
And 340, carrying out parameterization configuration on the interfaces related to each test flow according to the return values of the interfaces related to each test flow, and obtaining parameterization configuration results of the interfaces related to each test flow.
Specifically, after the return values of the interfaces related to each test flow are obtained, the return values of the interfaces related to each test flow are analyzed, and the fields, the data types and the structures of the return values are analyzed to determine which fields are used for parameterized configuration. And meanwhile, according to the analysis result of the interface return value, the requirement for parameterized configuration is determined. This may include different input parameters, request header, request body, etc. And then, corresponding parameterized configuration scripts can be written according to parameterized configuration requirements, and parameterized configuration is carried out on interfaces related to each test flow through the parameterized configuration scripts, so that parameterized configuration results of the interfaces related to each test flow are obtained.
In this embodiment, the interfaces related to each test procedure are configured in a parameterized manner according to the return values of the interfaces related to each test procedure, so that the test quality can be improved, the repeated work can be reduced, the maintainability can be enhanced, and the test effect can be improved.
Further, the parameterized configuration of the interfaces related to each test flow is performed according to the return values of the interfaces related to each test flow, so as to obtain parameterized configuration results of the interfaces related to each test flow, including:
extracting two interfaces with connection relations from the interfaces related to each test flow to be respectively used as a current first interface and a current second interface;
extracting a return value from the current return value of the first interface as a current return value;
filling the current return value into an input value corresponding to the current return value in the current second interface; and repeatedly executing the operations until the return values of the interfaces are filled in the corresponding input values, and obtaining parameterized configuration results of the interfaces related to the test flows.
Specifically, according to the serial connection result of the interfaces related to each test flow, extracting two interfaces with a connection relationship from the interfaces related to each test flow as a current first interface and a current second interface respectively, extracting a return value from the return value of the current first interface as a current return value, and filling the current return value into an input value corresponding to the current return value in the current second interface; and repeatedly executing the operations until the return values of the interfaces are filled in the corresponding input values, and obtaining parameterized configuration results of the interfaces related to the test flows.
For example, three interfaces are assumed to be an interface a, an interface B and an interface C respectively, and the return values of the interface a are O1.1, O1.2 and O1.3; the input values of the interface B are I2.1 and I2.2; the return value of the interface B is O2.1; the input values of the interface C are I3.1 and I3.2; the return value of the interface C is O3.1; wherein, the return values O1.1 and O1.2 of the interface a are respectively used as the input values I2.1 and I2.2 of the interface B; the return value O1.3 of interface a is taken as the input value I3.1 of interface C; the return value O2.1 of interface B serves as the input value I3.1 of interface C. The present application may extract O1.1, O1.2, O1.3, O2.1, and O3.1 using regular expressions.
In this embodiment, the above method obtains the parameterized configuration result of the interface related to each test flow, so that time can be saved, and thus the test data preparation efficiency is improved.
And 350, generating a test script according to the message information related to each test flow, the serial connection result of the interfaces related to each test flow, the parameterized configuration result of the interfaces related to each test flow and the pre-acquired test preparation data, and generating final test data through the test script.
The method for constructing the test data provided by the embodiment of the application comprises the steps of firstly acquiring interfaces and message information related to each test flow when the test data are generated; then, the interfaces related to each test flow are connected in series, and a series result of the interfaces related to each test flow is obtained; extracting the return values of the interfaces related to the test flows through regular expressions corresponding to the return values of the interfaces related to the pre-constructed test flows; performing parameterization configuration on the interfaces related to each test flow according to the return values of the interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow; and finally, generating a test script according to the message information related to each test flow, the serial connection result of the interfaces related to each test flow, the parameterized configuration result of the interfaces related to each test flow and the pre-acquired test preparation data, and generating final test data through the test script. That is, in the technical solution of the present application, a data base may be provided for generating a test script later by acquiring the interface and the message information related to each test flow. And interfaces related to each test flow are connected in series, so that the working efficiency is improved, the test reliability is enhanced, and the maintenance cost is reduced. And then, by acquiring the return values of the interfaces related to each test flow, a data basis is provided for the parameterization configuration of the interfaces related to each test flow, and the parameterization configuration of the interfaces related to each test flow is performed according to the return values of the interfaces related to each test flow, so that the test quality is improved, the repeated work is reduced, the maintainability is enhanced, and the test effect is improved. And finally, generating a test script according to the message information, the serial connection result of the interfaces, the parameterized configuration result of the interfaces and the test preparation data acquired in advance, and generating final test data through the test script. The separation of the test data and the script is realized, so that a tester can customize the data without manually participating in the data generation process, thereby saving a large amount of test manpower and improving the test preparation efficiency. Therefore, compared with the prior art, the method for constructing the test data provided by the embodiment of the application can generate the test data in batches, does not need to be manually participated, saves the test manpower and improves the test preparation efficiency; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example IV
Fig. 4 is a schematic structural diagram of a device for constructing test data according to an embodiment of the present application. As shown in fig. 4, the test data constructing apparatus includes: an acquisition module 410, a concatenation module 420, a configuration module 430, and a generation module 440; wherein,
the acquiring module 410 is configured to acquire interface and message information related to each test procedure;
the serial module 420 is configured to connect the interfaces related to each test procedure in series, so as to obtain a serial result of the interfaces related to each test procedure;
the configuration module 430 is configured to perform parameterization configuration on the interfaces related to each test flow, so as to obtain parameterization configuration results of the interfaces related to each test flow;
the generating module 440 is configured to generate a test script according to the message information related to each test procedure, the serial connection result of the interface related to each test procedure, the parameterized configuration result of the interface related to each test procedure, and the pre-acquired test preparation data; and generating final test data through the test script.
Further, the serial module 420 is specifically configured to analyze the service logic of the interface related to each test flow, so as to obtain the service logic relationship of the interface related to each test flow; and according to the business logic relation of the interfaces related to each test flow, connecting the interfaces related to each test flow in series to obtain the serial connection result of the interfaces related to each test flow.
Further, the configuration module 430 is specifically configured to extract the return value of the interface related to each test flow through the regular expression corresponding to the return value of the interface related to each test flow constructed in advance; and carrying out parameterization configuration on the interfaces related to each test flow according to the return values of the interfaces related to each test flow, and obtaining parameterization configuration results of the interfaces related to each test flow.
Further, the configuration module 430 is specifically configured to extract, from the interfaces related to each test flow, two interfaces having a connection relationship as a current first interface and a current second interface, respectively; extracting a return value from the return value of the current first interface as a current return value; filling the current return value into an input value corresponding to the current return value in the current second interface; and repeatedly executing the operations until the return values of the interfaces are filled in the corresponding input values, and obtaining parameterized configuration results of the interfaces related to the test flows.
Further, the generating module 440 is specifically configured to add the message information related to each test flow to the first data area of the test script, add the serial result of the interface related to each test flow and the parameterized configuration result of the interface related to each test flow to the second data area of the test script, and add the test preparation data to the third data area of the test script, so as to obtain the test script.
Further, the test preparation data includes: system data and transaction data; wherein the system data includes, but is not limited to: the output form of the test preparation data, the system date, the random number generation rule, the interface public URL value, the server IP and the port number; the transaction data includes, but is not limited to: ticket issuer information, payee information, contractor information, and transaction amount.
Further, the generating module 440 is specifically configured to receive the number of circulation operations input by the tester; and controlling the test script to run according to the cycle operation times to obtain the final test data.
The test data constructing device can execute the method provided by any embodiment of the application, and has the corresponding functional modules and beneficial effects of executing the method. Technical details not described in detail in this embodiment may be referred to the method for constructing test data provided in any embodiment of the present application.
Example five
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Fig. 5 illustrates a block diagram of an exemplary electronic device suitable for use in implementing embodiments of the present application. The electronic device 5 shown in fig. 5 is only an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present application.
As shown in fig. 5, the electronic device 5 is in the form of a general purpose computing device. The components of the electronic device 5 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, a bus 18 that connects the various system components, including the system memory 28 and the processing units 16.
Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, and a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
The electronic device 5 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by the electronic device 5 and includes both volatile and non-volatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache memory 32. The electronic device 5 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard disk drive"). Although not shown in fig. 5, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of the embodiments of the present application.
A program/utility 40 having a set (at least one) of program modules 42 may be stored in, for example, memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods in the embodiments described herein.
The electronic device 5 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 5, and/or any devices (e.g., network card, modem, etc.) that enable the electronic device 5 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. Also, the electronic device 5 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through the network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 5 via the bus 18. It should be appreciated that although not shown in fig. 5, other hardware and/or software modules may be used in connection with the electronic device 5, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, for example, implementing the test data construction method provided in the embodiment of the present application.
Example six
Embodiments of the present application provide a computer storage medium.
Any combination of one or more computer readable media may be employed in the computer readable storage media of the embodiments herein. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. 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 (a non-exhaustive list) of the computer-readable storage medium would include the following: 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 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.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. 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.
Computer program code for carrying out operations of the present application may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present application and the technical principle applied. Those skilled in the art will appreciate that the present application is not limited to the particular embodiments described herein, but is capable of numerous obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the present application. Therefore, while the present application has been described in connection with the above embodiments, the present application is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the present application, the scope of which is defined by the scope of the appended claims.

Claims (10)

1. A method of constructing test data, the method comprising:
acquiring interfaces and message information related to each test flow;
the interfaces related to each test flow are connected in series, and a serial result of the interfaces related to each test flow is obtained;
carrying out parameterization configuration on interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow;
generating a test script according to message information related to each test flow, serial connection results of interfaces related to each test flow, parameterized configuration results of interfaces related to each test flow and test preparation data acquired in advance; and generating final test data through the test script.
2. The method of claim 1, wherein the step of concatenating the interfaces of each test flow to obtain a concatenation result of the interfaces of each test flow comprises:
analyzing the business logic of the interfaces related to each test flow to obtain the business logic relation of the interfaces related to each test flow;
and according to the business logic relation of the interfaces related to each test flow, connecting the interfaces related to each test flow in series to obtain the serial connection result of the interfaces related to each test flow.
3. The method of claim 1, wherein parameterizing the interfaces involved in each test flow to obtain parameterized configuration results of the interfaces involved in each test flow comprises:
extracting the return values of the interfaces related to the test flows through regular expressions corresponding to the return values of the interfaces related to the pre-constructed test flows;
and carrying out parameterization configuration on the interfaces related to each test flow according to the return values of the interfaces related to each test flow, and obtaining parameterization configuration results of the interfaces related to each test flow.
4. A method according to claim 3, wherein performing parameterization configuration on the interfaces related to each test procedure according to the return values of the interfaces related to each test procedure to obtain parameterized configuration results of the interfaces related to each test procedure comprises:
extracting two interfaces with connection relations from the interfaces related to each test flow to be respectively used as a current first interface and a current second interface;
extracting a return value from the return value of the current first interface as a current return value;
filling the current return value into an input value corresponding to the current return value in the current second interface; and repeatedly executing the operations until the return values of the interfaces are filled in the corresponding input values, and obtaining parameterized configuration results of the interfaces related to the test flows.
5. The method of claim 1, wherein generating the test script based on the message information related to each test flow, the serial connection result of the interface related to each test flow, the parameterized configuration result of the interface related to each test flow, and the pre-acquired test preparation data, comprises:
And adding message information related to each test flow into a first data area of the test script, adding a serial connection result of an interface related to each test flow and a parameterized configuration result of an interface related to each test flow into a second data area of the test script, and adding the test preparation data into a third data area of the test script to obtain the test script.
6. The method of claim 5, wherein the test preparation data comprises: system data and transaction data; wherein the system data includes, but is not limited to: the output form of the test preparation data, the system date, the random number generation rule, the interface public URL value, the server IP and the port number; the transaction data includes, but is not limited to: ticket issuer information, payee information, contractor information, and transaction amount.
7. The method of claim 1, wherein generating final test data by the test script comprises:
receiving the circulation operation times input by a tester;
and controlling the test script to run according to the cycle operation times to obtain the final test data.
8. A test data construction apparatus, the apparatus comprising: the device comprises an acquisition module, a serial module, a configuration module and a generation module; wherein,
the acquisition module is used for acquiring interfaces and message information related to each test flow;
the serial module is used for connecting the interfaces related to each test flow in series to obtain a serial result of the interfaces related to each test flow;
the configuration module is used for carrying out parameterization configuration on the interfaces related to each test flow to obtain parameterization configuration results of the interfaces related to each test flow;
the generating module is used for generating a test script according to the message information related to each test flow, the serial connection result of the interfaces related to each test flow, the parameterized configuration result of the interfaces related to each test flow and the pre-acquired test preparation data; and generating final test data through the test script.
9. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of constructing test data as claimed in any one of claims 1 to 7.
10. A storage medium having stored thereon a computer program, which when executed by a processor implements a method of constructing test data according to any one of claims 1 to 7.
CN202311651678.1A 2023-12-04 2023-12-04 Method and device for constructing test data, electronic equipment and storage medium Pending CN117609081A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311651678.1A CN117609081A (en) 2023-12-04 2023-12-04 Method and device for constructing test data, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311651678.1A CN117609081A (en) 2023-12-04 2023-12-04 Method and device for constructing test data, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117609081A true CN117609081A (en) 2024-02-27

Family

ID=89946049

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311651678.1A Pending CN117609081A (en) 2023-12-04 2023-12-04 Method and device for constructing test data, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117609081A (en)

Similar Documents

Publication Publication Date Title
CN106933745A (en) WEB automatic interface testing methods and system
CN108628748B (en) Automatic test management method and automatic test management system
WO2018184361A1 (en) Application test method, server, terminal, and storage media
CN111324526B (en) Interface test system, method and server
CN110232014A (en) Operation flow automated testing method, device, controller and medium
CN113900958A (en) Test case script generation method, system, medium and electronic device
CN109710810A (en) Change management method, apparatus, equipment and storage medium
CN110727580A (en) Response data generation method, full-flow interface data processing method and related equipment
CN112035363A (en) Automatic interface testing method and device
CN112433944A (en) Service testing method, device, computer equipment and storage medium
CN110659870A (en) Business audit test method, device, equipment and storage medium
CN114880240A (en) Automatic testing system and method for Internet of things equipment, storage medium and equipment
CN106529304B (en) A kind of Android applies concurrent leakage location
CN112561690B (en) Method, system, equipment and storage medium for testing credit card staged service interface
CN116795701A (en) Method and device for generating universal test case of interface program
CN109508204B (en) Front-end code quality detection method and device
CN113238940B (en) Interface test result comparison method, device, equipment and storage medium
CN111339051A (en) Log processing method, system, device and storage medium
CN117609081A (en) Method and device for constructing test data, electronic equipment and storage medium
CN113672501B (en) Parking lot service testing method and device
CN115169578A (en) AI model production method and system based on meta-space data markers
CN110532186B (en) Method, device, electronic equipment and storage medium for testing by using verification code
CN113360365B (en) Flow test method and flow test system
CN114064469A (en) Interface automation test method and storage medium
CN113392002A (en) Test system construction method, device, equipment and storage medium

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