CN115437954A - Interface automation test data separation method - Google Patents

Interface automation test data separation method Download PDF

Info

Publication number
CN115437954A
CN115437954A CN202211243388.9A CN202211243388A CN115437954A CN 115437954 A CN115437954 A CN 115437954A CN 202211243388 A CN202211243388 A CN 202211243388A CN 115437954 A CN115437954 A CN 115437954A
Authority
CN
China
Prior art keywords
data
interface
test
calling
format
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
CN202211243388.9A
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.)
Shanghai Jike Intelligent Technology Group Co ltd
Original Assignee
Shanghai Jike Intelligent Technology Group 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 Shanghai Jike Intelligent Technology Group Co ltd filed Critical Shanghai Jike Intelligent Technology Group Co ltd
Priority to CN202211243388.9A priority Critical patent/CN115437954A/en
Publication of CN115437954A publication Critical patent/CN115437954A/en
Pending legal-status Critical Current

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
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • 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/3692Test management for test results analysis

Landscapes

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

Abstract

The invention relates to the technical field of interface testing, in particular to an interface automatic testing data separation method, which comprises the following steps of S1: reading configuration information of the configuration file, connecting a system database according to the configuration information, calling a DB function method, and creating basic test data; s2: calling a pre-packaged method to read the csv file service test case information, and returning the result in a character string and json data format. According to the method, jenkins is adopted to execute the test cases according to the configured timing task or manually in batches, csv file test case data is read through a python method, interface test requests are generated in batches, the test results, the interface response messages and the database data comparison results are stored in the specified path, and an all test report is output.

Description

Interface automation test data separation method
Technical Field
The invention relates to the technical field of interface testing, in particular to an interface automatic test data separation method.
Background
The interface test is an important test link for testing interfaces between components of a system, the interface is a bridge for transmitting data between a front end and a back end in popular terms, the principle is that a simulation client sends a request to a server, the server receives the request and then processes the response request and returns a corresponding result to the client, and the client receives the result in a process, the complexity of the current system continuously rises, the efficiency of the traditional function test method greatly decreases, so the interface test is particularly important in the development period of software, meanwhile, the interface test is relatively easy to realize automatic continuous integration, the investment of test labor cost and time cost can be reduced, and the system has higher stability and reusability, the interface mainly based on an http protocol is called by the front end and the back end of the current mainstream project in the market, so the http request is mainly sent and received by a tool or a code during the interface test, and the tools are many as follows: postman, jmeter, etc., interface testing tool, the threshold is low, the hands are fast, cross platform, but can't operate the file relevant operation, can't read the database, can't encapsulate the public function, do not support the jump among the use cases, lack the convenience to the management and maintenance of the test script, the change of interface or test assembly can influence the executive result of other test assemblies, the test script frequently changes and can influence the accuracy of the test result, the maintenance cost is very high, although the interface testing tool and scheme that can select on the market are more, but all need carry on the customization development of certain extent and can meet the project needs, therefore need develop a more flexible interface testing framework to meet the needs that this project tests oneself.
Disclosure of Invention
The invention aims to solve the defects in the prior art and provides an interface automation test data separation method.
In order to achieve the above object, the present invention adopts the following technical solution, and an interface automation test data separation method includes the following steps:
s1: reading configuration information of the configuration file, connecting a system database according to the configuration information, calling a DB function method, and creating basic test data;
s2: calling a pre-packaged method to read the csv file service test case information and returning a result in a character string and json data format;
s3: requesting an HTTP interface of a tested system, calling different HTTP interface requests according to the read service test case data and obtaining results;
s4: comparing results obtained by calling different interface requests with expected result data in the csv file by regular judgment, and recording the judgment results;
s5: and calling the use cases in batches by using jenkins, executing and generating an all test report.
As a further aspect of the present invention, in S1, the reading configuration information of the configuration file includes:
s101: the system comprises an import package, a database, a domain name, a configuration file reading method, an initialization data method, an SYS module, an os module and the like;
s102: defining a class method by using python, customizing a database operation method, including methods of deleting, inserting and initializing table data, and initializing interface test data;
s103: and according to different systems, uniformly initializing the call of the precondition interface, and acquiring related token, session and cookie information.
As a further aspect of the present invention, in S1, the configuration information includes host, db, user, password, and port of the test database.
As a further scheme of the present invention, in S2, the invoking a pre-packaged method to read csv file service test case information, and returning a result in a string and json data format includes:
s201: defining a reading function class for reading csv file data;
s202: converting the read data content into a dictionary format according to a key-value key value pair, then defining an array format, adding dictionary data into an array, returning in a json format, judging whether the format content is empty, and returning to None if the format content is empty.
As a further scheme of the present invention, in S3, the requesting a tested system HTTP interface calls different HTTP interface requests according to the read service test case data and obtains a result, including:
s301: establishing a class method, defining Requests function, and realizing the interface request of the tested system;
s302: acquiring the transmission parameters and the request address from the read business test case data table, calling different interface request functions according to different request texts in a request mode, returning an interface request result, and returning in a json format.
As a further scheme of the present invention, in S4, the results obtained by calling different interface requests and the expected result data in the csv file are subjected to regular judgment and comparison, the judgment results are recorded, specifically, the results obtained by calling different interface requests are assembled into data in the JSON format, the expected result data in the csv table is obtained at the same time, the two results are subjected to judgment and comparison, and the comparison result is stored in the designated all directory.
As a further aspect of the present invention, in S5, the using jenkins to call the use case in batch, executing and generating an all test report includes:
s501: configuring and using an all plug-in to generate a report;
s502: configuring a source code management git to obtain an automation code;
s503: and constructing an execution shell command and executing the test case.
Compared with the prior art, the invention has the advantages and positive effects that:
according to the method, jenkins is adopted to execute test cases according to configured timing tasks or manual batch, csv file test case data is read through a python method, interface test requests are generated in batch, test results, interface response messages and database data comparison results are stored in a specified path, and an all test report is output; the business test case uses csv to maintain data, and can cover various test scenes, input and output boundary analysis, parameter combination test, test for comparing with database data and the like; the tester can execute the automatic interface test regularly or in time only by maintaining the scene data and the parameter data of the tested system in the csv test case, and can make corresponding adjustment and optimization of the test case according to the test result, thereby improving the efficiency and the accuracy of the test and saving a large amount of labor time.
Drawings
FIG. 1 is a flowchart illustrating a method for separating interface automation test data according to the present invention;
fig. 2 is a flowchart of an automated test case execution method for separating interface automated test data according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention.
In the description of the present invention, it is to be understood that the terms "length," "width," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," and the like are used in the orientations and positional relationships indicated in the drawings, which are based on the orientations and positional relationships indicated in the drawings, and are used for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore, are not to be construed as limiting the present invention. Further, in the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
Example one
Referring to fig. 1, the present invention provides a technical solution, a method for separating interface automation test data, including the following steps:
s1: reading configuration information of the configuration file, connecting a system database according to the configuration information, calling a DB function method, and creating basic test data;
s2: calling a pre-packaged method to read csv file service test case information, and returning a result in a character string and json data format;
s3: requesting an HTTP interface of a tested system, calling different HTTP interface requests according to the read service test case data and obtaining results;
s4: comparing results obtained by calling different interface requests with expected result data in the csv file by regular judgment, and recording the judgment results;
s5: and calling the use cases in batches by using jenkins, executing and generating an all test report.
In S1, reading configuration information of the configuration file, including:
s101: the system comprises an import package, a database, a domain name, a configuration file reading method, an initialization data method, an SYS module, an os module and the like;
s102: defining a class method by using python, customizing a database operation method, including methods of deleting, inserting and initializing table data, and initializing interface test data;
s103: and according to different systems, uniformly initializing the call of the precondition interface, and acquiring related token, session and cookie information.
In S1, the configuration information includes host, db, user, password and port of the test database.
In S2, calling a pre-packaged method to read csv file service test case information, and returning a result in a character string and json data format, wherein the method comprises the following steps:
s201: defining a reading function class for reading csv file data;
s202: converting the read data content into a dictionary format according to a key-value key value pair, then defining an array format, adding dictionary data into an array, returning in a json format, judging whether the format content is empty, and returning to None if the format content is empty.
In S3, requesting an HTTP interface of the tested system, calling different HTTP interface requests according to the read service test case data and obtaining results, and the method comprises the following steps:
s301: establishing a class method, defining Requests function, and realizing the interface request of the tested system;
s302: acquiring the transmission parameters and the request address from the read business test case data table, calling different interface request functions according to different request texts in a request mode, returning an interface request result, and returning in a json format.
And S4, performing regular judgment and comparison on results obtained by calling different interface requests and expected result data in the csv file, recording judgment results, specifically, assembling the results obtained by calling different interface requests into data in a JSON format, simultaneously acquiring the expected result data in the csv table, performing judgment and comparison on the results, and storing the comparison result into a specified all directory.
In S5, the cases are called in batches by jenkins, and an all test report is executed and generated, wherein the method comprises the following steps:
s501: configuring and using an all plug-in to generate a report;
s502: configuring a source code management git to obtain an automation code;
s503: and configuring, using and constructing an execution shell command, and executing the test case.
The working principle is as follows: the invention does not need frequent script parameter modification, only needs to maintain the interface test parameters and assertion of the tested system in the test case, can execute the system interface in batch through jenkins, presents the test results such as the interface automatic test execution success rate, the passing failure number and the like in a chart form, concretely, firstly adopts jenkins to execute the test case according to the configured timing task or manual batch, executes the test cases of all the interfaces in batch, configures and uses an all plug-in, generates a report, configures and uses a source code management git, acquires an automatic code, configures and uses a construction execution shell command, executes the test case, then reads the configuration information of the configuration file, connects a system database according to the configuration information, calls a DB function method, and creates basic test data, and comprises the following steps: creating a link (a driver accesses a MySQL database, configuration parameters are host, DB, user, password and port), creating basic test data by using a DB function method (SELECT, INSERT, UPDATE and DELETE), generating data required by a test case, calling and reading a Csv file method, acquiring related data of an interface test case, and returning a result in a character string and json data format, wherein a field in the Csv file comprises a title (1) a case name (str format); 2, interface/class/method, using interface name (str format), 3, requesting mode, calling method, post, get, put, DELETE (str format), 4, requesting address, requesting path (str format), 5, requesting text, requesting message (str format), 6, environment, testing environment, production environment (str format), 7, anticipating assertion, data (json format) comparing with interface return value, 8, precondition, calling method (str format), 9, postcondition, precondition, calling method (str format), 10, prepositive sql, calling method (str format), 11, anticipating assertion sql, database data (json format) comparing with interface return value, converting read data content into dictionary format according to key-value pair, then defining a format, adding data array into dictionary format, returning in json format, judging whether the dictionary content is empty, if yes, judging whether there is a test case, if there is a test case, reinitializing the preposed result and related data in a test case, then calling an api test request, and calling different interface requests and obtaining results according to read service test case data (request mode, request address and request text) by a HTTP interface of a test system based on python design, wherein the interface automatic test method comprises the following steps: establishing a class method, defining Requests function for realizing the interface request of the tested system, obtaining the transmission and request address from the read business test case data table, requesting mode, calling different interface request functions according to different request texts, returning interface request result, returning in JSON format, and returning in JSON format, based on the python designed interface automatic test method, assembling the result obtained by calling different interface Requests into data in JSON format, meanwhile, testing the expected assertion data in the case, judging and comparing the two by a packaged comparison method, storing the comparison result into an appointed all directory, judging whether a preposed sql exists according to the test case, if the preposed sql is called, comparing the preposed sql result with the expected assertion sql in the test case, storing the comparison result into the appointed all directory, calling the test cases in jenkins batch, executing the all test report, sending the all test report to an appointed mailbox module, and checking all report information in a mail or jenkins platform module.
Although the present invention has been described with reference to specific embodiments, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.

Claims (7)

1. An interface automation test data separation method is characterized by comprising the following steps:
s1: reading configuration information of the configuration file, connecting a system database according to the configuration information, calling a DB function method, and creating basic test data;
s2: calling a pre-packaged method to read csv file service test case information, and returning a result in a character string and json data format;
s3: requesting an HTTP interface of a tested system, calling different HTTP interface requests according to the read service test case data and obtaining results;
s4: comparing results obtained by calling different interface requests with expected result data in the csv file by regular judgment, and recording the judgment results;
s5: and calling the use cases in batches by using jenkins, executing and generating an all test report.
2. The method according to claim 1, wherein in S1, the reading configuration information of the configuration file includes:
s101: the system comprises an import package, a database, a domain name, a configuration file reading method, an initialization data method, an SYS module, an os module and the like;
s102: defining a class method by using python, customizing a database operation method, including methods of deleting, inserting and initializing table data, and initializing interface test data;
s103: and according to different systems, uniformly initializing the call of the precondition interface, and acquiring related token, session and cookie information.
3. The method for separating interface automation test data according to claim 1, wherein in S1, the configuration information includes host, db, user, password, and port of the test database.
4. The method for separating interface automation test data according to claim 1, wherein in S2, the calling of the pre-packaged method reads csv file service test case information, and returns a result in a string and json data format, including:
s201: defining a reading function class for reading csv file data;
s202: converting the read data content into a dictionary format according to the key-value key value pair, then defining an array format, adding the dictionary data into the array, returning in a json format, judging whether the format content is empty or not, and returning to None if the format content is empty.
5. The method for separating interface automation test data according to claim 1, wherein in S3, the requesting tested system HTTP interface calls different HTTP interface requests and obtains results according to the read service test case data, and the method includes:
s301: establishing a class method, defining Requests function, and realizing the interface request of the tested system;
s302: acquiring the transmission parameters and the request address from the read business test case data table, calling different interface request functions according to different request texts in a request mode, returning an interface request result, and returning in a json format.
6. The method for separating interface automation test data according to claim 1, wherein in S4, the results obtained by calling different interface requests and the expected result data in the csv file are compared by regular judgment, the judgment results are recorded, specifically, the results obtained by calling different interface requests are assembled into data in a JSON format, the expected result data in the csv table are obtained at the same time, the results and the data are compared by judgment, and the comparison results are stored in a designated all directory.
7. The method according to claim 1, wherein in S5, the using jenkins to call cases in batch, executing and generating an all test report includes:
s501: configuring and using an all plug-in to generate a report;
s502: configuring a source code management git to obtain an automation code;
s503: and constructing an execution shell command and executing the test case.
CN202211243388.9A 2022-10-11 2022-10-11 Interface automation test data separation method Pending CN115437954A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211243388.9A CN115437954A (en) 2022-10-11 2022-10-11 Interface automation test data separation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211243388.9A CN115437954A (en) 2022-10-11 2022-10-11 Interface automation test data separation method

Publications (1)

Publication Number Publication Date
CN115437954A true CN115437954A (en) 2022-12-06

Family

ID=84250841

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211243388.9A Pending CN115437954A (en) 2022-10-11 2022-10-11 Interface automation test data separation method

Country Status (1)

Country Link
CN (1) CN115437954A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117033249A (en) * 2023-10-08 2023-11-10 卓望数码技术(深圳)有限公司 Test case generation method and device, computer equipment and storage medium
CN117708864A (en) * 2024-02-06 2024-03-15 深圳和润达科技有限公司 Intelligent management method and device for medium bit machine applied to cell formation component equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117033249A (en) * 2023-10-08 2023-11-10 卓望数码技术(深圳)有限公司 Test case generation method and device, computer equipment and storage medium
CN117708864A (en) * 2024-02-06 2024-03-15 深圳和润达科技有限公司 Intelligent management method and device for medium bit machine applied to cell formation component equipment

Similar Documents

Publication Publication Date Title
US11144439B2 (en) Emulation-based testing of a microservices architecture
US20200342032A1 (en) Insights into performance of a bot system
CN115437954A (en) Interface automation test data separation method
CN107704395B (en) Cloud platform automation test implementation method and system based on Openstack
US20170286269A1 (en) Local Chat Service Simulator for Bot Development
CN111930635A (en) Swagger-based rapid automatic testing method and system
US20130339931A1 (en) Application trace replay and simulation systems and methods
CN114741283A (en) Automatic interface testing method and device based on python design
CN112463467B (en) Automated integrated test system and method thereof
CN110532182B (en) Automatic testing method and device for virtualization platform
CN109918310A (en) A kind of Modeling Platform interface test method
CN110381101A (en) API gateway control system, control method, equipment and medium
US20230161738A1 (en) Building collaborative data processing flows
CN112181852A (en) Interface automatic testing method and device, computer equipment and storage medium
CN110515514B (en) Data processing method, device and storage medium
CN113821565A (en) Method for synchronizing data of multiple data sources
JP2024508452A (en) Hosting event-based applications
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN109151021B (en) Distributed storage system file lock characteristic testing method and device
CN115470152A (en) Test code generation method, test code generation device, and storage medium
CN109460266A (en) A kind of method and device constructing software analogue data
CN115129596A (en) Automatic interface testing method, system, device and storage medium
CN114328180A (en) Interface automation test method, system, electronic equipment and storage medium
Sreeram Azure Serverless Computing Cookbook: Build and monitor Azure applications hosted on serverless architecture using Azure functions
CN111813659A (en) UI and interface based automatic test method, device, equipment and readable 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