CN112241369B - Automatic interface testing method based on python - Google Patents

Automatic interface testing method based on python Download PDF

Info

Publication number
CN112241369B
CN112241369B CN202011111342.2A CN202011111342A CN112241369B CN 112241369 B CN112241369 B CN 112241369B CN 202011111342 A CN202011111342 A CN 202011111342A CN 112241369 B CN112241369 B CN 112241369B
Authority
CN
China
Prior art keywords
interface
creating
importing
parameter
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011111342.2A
Other languages
Chinese (zh)
Other versions
CN112241369A (en
Inventor
黄钰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric 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 Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN202011111342.2A priority Critical patent/CN112241369B/en
Publication of CN112241369A publication Critical patent/CN112241369A/en
Application granted granted Critical
Publication of CN112241369B publication Critical patent/CN112241369B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • 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 invention discloses an automatic interface testing method based on python, which is used for inquiring the bill state of a database and comprises the following steps: separating data from use cases by python; separating an interface from a use case; inquiring the bill state of the database; generating a test report; and automatically sending a test report. The invention avoids the inflexibility and single structure of other tools for interface automation, and also solves the problems of troublesome maintenance and incompleteness of the common Python interface automation framework.

Description

Automatic interface testing method based on python
Technical Field
The invention relates to the technical field of automatic testing, in particular to an automatic interface testing method based on python.
Background
The interface test is a test for testing interfaces between components of the system, and is mainly used for testing interfaces between the system and other external systems and interfaces between submodules in the system. The key points of the test are to check the correctness of the interface parameter transmission, the correctness of the interface function realization, the correctness of the output result, and the integrity and the rationality of the fault-tolerant processing of various abnormal conditions.
Interface automation is an automatic execution interface use case, and there may be an association relationship between multiple interfaces, such as an interface for submitting an order, which needs to be called by a login interface, and a token used for submitting an order interface is a value returned by the login interface.
Interface testing can be realized through soupoui, postman, meter, robotframe work and other tools at present, postman can only realize the test of single interface, meter and robotframe work can realize the test of single interface, also can realize interface automation. The Robot Framework is a functional automation test Framework written in python. The method has good expandability, supports keyword driving, can test various types of clients or interfaces simultaneously, can perform distributed test execution, can write each step into a basic keyword, combines the basic keywords into a service keyword, directly calls the service keyword when compiling a test case, and transmits parameters to generate different cases. The Jmeter can realize multi-user concurrent stress test while realizing interface automation, and generate a stress test report.
The tool test has the advantages of being easy to operate and high in efficiency. But the use of tools for interface automation, single test data structure, poor expansibility and inflexibility. Moreover, the common python interface automation framework not only needs to independently package a method for reading and writing excel; the read interface parameters are required to be assembled into a json format again in the script, so that the code amount is increased, the data maintenance is more troublesome, and the whole framework logic is not concise enough. Although the methods for realizing the interface automation are various, none of the methods is suitable for all projects, because each project has own characteristics, a corresponding interface automation test scheme is needed, and it is important to customize the interface test automation scheme for different test projects.
The receipt tool module is an important module of a cloud fashion system of Changhong electrical appliance corporation in Sichuan, realizes the receipt preprocessing, the ticket distribution and the selection of different receipt templates of the order, and the receipt can enter different states, such as identification, to-do, element and type confirmation, and the like. The cloud fashion publishes one version every day, and smoking test needs to be carried out on the version, so that the problem that the test work of testers is influenced due to the occurrence of a large problem is avoided. Such repeated labor of daily smoking tests takes a significant amount of time, so interface automation is especially important. At present, manual testing is adopted, a large amount of manpower is occupied, and the efficiency is quite low.
Disclosure of Invention
In order to solve the problems in the prior art, the invention aims to provide an automatic interface testing method based on Python, which avoids the problems of inflexibility and single structure of interface automation of other tools and solves the problems of troublesome maintenance and incompactness of a common Python interface automation frame.
In order to realize the purpose, the invention adopts the technical scheme that: an automated interface testing method based on python is used for inquiring the bill state of a database and comprises the following steps:
separating actual data from use cases:
storing interface data in a py format, wherein the interface data is in a dictionary format and comprises an incoming parameter and a value thereof as well as a parameter and a value expected to be returned, comparing the parameter and the value returned by the interface with the parameter and the value expected to be returned, if the parameter and the value are consistent, the pass is obtained, otherwise, the execution result is fail;
separating an interface from a use case:
creating a folder for storing each interface py file, importing the API into a requests library, defining a class, and defining an interface function for sending a request in the class; creating a case folder for storing a test case py file, importing a required package, importing a data file, importing an interface file, creating a new class, calling an interface api, importing parameters, acquiring a return value, inquiring a bill state and asserting the bill state into the test case py file;
and inquiring the bill state:
importing a ReadDB class, newly building a function get _ conn, connecting a database, obtaining a cursor object method package, defining a get _ sql _ one function, obtaining a cursor object, calling an execute (sql) method, wherein an sql statement is a query bill state, and the bill state corresponding to the sql statement can be queried.
As a further improvement of the invention, the inquiring of the bill status further comprises:
creating config.ini to store information of a mailbox, a sender and a receiver which are used for sending a report, and creating readconfig.py to read configuration information in the config.ini;
py, defining a function for sending an email, assembling a test suite, specifying a report storage path and a report name, operating the test suite and generating a report, sending an email function to execute the run _ suite.
The beneficial effects of the invention are:
according to the method, data separation and bill state query by connecting the data base are realized through the py file storage interface parameters, and the labor cost consumed by smoking test after the current cloud project bill tool module is released in every day version is avoided.
Drawings
Fig. 1 is a block diagram of the interface automation test according to the embodiment of the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
Examples
As shown in fig. 1, an automated interface testing method based on python is used for querying a ticket status of a database, and a specific service execution flow is as follows:
1) creating an api catalog, compiling an api interface and storing each use case api;
2) newly building a data directory, writing a py file, and storing a dictionary required by each use case;
3) creating a tool catalog, compiling a ReadDB class and realizing the function of inquiring the bill state; importing HTMLTestRunner.py for generating a test report; creating config.ini to store information of a mailbox, a sender and a receiver which are used for sending a report, and creating readconfig.py to read configuration information in the config.ini;
4) creating a case catalog, compiling a use case py, importing a needed library, calling corresponding api, importing parameters, realizing the functions of each use case, and inquiring whether the bill state is expected or not, wherein the bill state is Pass or fail;
5) py, defining a function for sending a mail, assembling a test suite, specifying a report storage path and a report name, operating the test suite, generating a report, sending a mail function, executing the py, operating a test case, generating a report and automatically sending the mail.
The above-mentioned embodiments only express the specific embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention.

Claims (2)

1. An automatic interface testing method based on python is used for inquiring the bill state of a database, and is characterized by comprising the following steps:
separating actual data from use cases:
storing interface data in a py format, wherein the interface data is in a dictionary format and comprises an incoming parameter, a value of the incoming parameter and the value of the incoming parameter, and a parameter and a value expected to be returned, comparing the parameter and the value returned by the interface with the parameter and the value expected to be returned, and if the parameter and the value are consistent, determining that pass is obtained, otherwise, determining that fail is obtained;
separating an interface from a use case:
creating a folder for storing each interface py file, importing the API into a requests library, defining a class, and defining an interface function for sending a request in the class; creating a case folder for storing a test case py file, importing a required package, importing a data file, importing an interface file, creating a new class, calling an interface api, importing parameters, acquiring a return value, inquiring a bill state and asserting the bill state into the test case py file;
and inquiring the bill state:
importing a ReadDB class, newly building a function get _ conn, connecting a database, obtaining a cursor object method package, defining a get _ sql _ one function, obtaining a cursor object, calling an execute (sql) method, wherein an sql statement is a query bill state, and the bill state corresponding to the sql statement can be queried.
2. The python-based interface automated testing method of claim 1, wherein querying a ticket status further comprises:
creating config.ini to store information of a mailbox, a sender and a receiver which are used for sending a report, and creating readconfig.py to read configuration information in the config.ini;
the method comprises the steps of creating run _ suite, defining a function for sending an email, assembling a test suite, specifying a report storage path and a report name, operating the test suite and generating a report, sending an email function to execute run _ suite, operating a test case, generating a report and automatically sending an email.
CN202011111342.2A 2020-10-16 2020-10-16 Automatic interface testing method based on python Active CN112241369B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011111342.2A CN112241369B (en) 2020-10-16 2020-10-16 Automatic interface testing method based on python

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011111342.2A CN112241369B (en) 2020-10-16 2020-10-16 Automatic interface testing method based on python

Publications (2)

Publication Number Publication Date
CN112241369A CN112241369A (en) 2021-01-19
CN112241369B true CN112241369B (en) 2022-06-21

Family

ID=74168853

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011111342.2A Active CN112241369B (en) 2020-10-16 2020-10-16 Automatic interface testing method based on python

Country Status (1)

Country Link
CN (1) CN112241369B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115982055B (en) * 2023-02-27 2023-06-23 云筑信息科技(成都)有限公司 Test method special for java language development program

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109815252A (en) * 2018-12-14 2019-05-28 深圳壹账通智能科技有限公司 Test data generating method, device, computer equipment and readable storage medium storing program for executing
CN110347545A (en) * 2019-05-21 2019-10-18 深圳壹账通智能科技有限公司 A kind of test method and device of business platform cache policy

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10424019B2 (en) * 2014-09-15 2019-09-24 Aesthetic Integration Limited System and method for modeling and verifying financial trading platforms
US10838848B2 (en) * 2017-06-01 2020-11-17 Royal Bank Of Canada System and method for test generation
CN107741911A (en) * 2017-11-01 2018-02-27 广州爱九游信息技术有限公司 Interface test method, device, client and computer-readable recording medium
US10540270B1 (en) * 2018-01-25 2020-01-21 Amazon Technologies, Inc. Representation-based automated software testing
CN109189684B (en) * 2018-08-28 2022-02-22 四川长虹电器股份有限公司 Python-based automatic interface testing method
CN110245083A (en) * 2019-06-11 2019-09-17 四川长虹电器股份有限公司 A kind of automatic interface testing method based on python
CN111045921A (en) * 2019-10-12 2020-04-21 平安普惠企业管理有限公司 Automatic interface testing method and device, computer equipment and storage medium
CN110990287A (en) * 2019-12-12 2020-04-10 杭州云徙科技有限公司 Interface testing method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109815252A (en) * 2018-12-14 2019-05-28 深圳壹账通智能科技有限公司 Test data generating method, device, computer equipment and readable storage medium storing program for executing
CN110347545A (en) * 2019-05-21 2019-10-18 深圳壹账通智能科技有限公司 A kind of test method and device of business platform cache policy

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
A performance testing and optimization tool for system developed by Python language;Haojie Fan 等;《International Conference on Cyberspace Technology (CCT 2013)》;20140227;第24-27页 *
基于Python的CRM系统接口自动化测试设计与实现;倪志嘉;《中国优秀博硕士学位论文全文数据库(硕士) 信息科技辑》;20121115(第11期);I138-82 *

Also Published As

Publication number Publication date
CN112241369A (en) 2021-01-19

Similar Documents

Publication Publication Date Title
US6697809B2 (en) Data retrieval and transmission system
CN107958049B (en) Data quality inspection management system
CN109947746A (en) A kind of quality of data management-control method and system based on ETL process
CN112286806B (en) Automatic test method and device, storage medium and electronic equipment
CN114741283A (en) Automatic interface testing method and device based on python design
CN110503408B (en) Business process management system based on custom configuration
CN112199394A (en) Alarm information pushing method and system, intelligent terminal and storage medium
CN112241369B (en) Automatic interface testing method based on python
CN110928796B (en) Automatic test platform
CN112181852A (en) Interface automatic testing method and device, computer equipment and storage medium
CN114880240A (en) Automatic testing system and method for Internet of things equipment, storage medium and equipment
CN104679884A (en) Data analysis method, device and system of database
CN114443468A (en) Excel table-based test comparison method and system
US20200019382A1 (en) Constraint programming using block-based workflows
CN114168421A (en) Customized code compatibility analysis system and method based on micro-service call chain
CN112256555A (en) Automatic test case management system and test case execution state conversion method
CN112486841A (en) Method and device for checking data collected by buried point
CN116010380A (en) Data warehouse automatic management method based on visual modeling
CN113128848A (en) Data quality monitoring method for full-service index, electronic equipment and storage medium
CN114911687A (en) Intelligent electric energy meter test case multiplexing system and multiplexing method
CN111611320A (en) Method for counting data based on log service package and storage medium
CN111861537A (en) Operation analysis method and system
CN115827452B (en) Data processing type test system, method, storage medium and equipment
CN113495831B (en) Method, system, equipment and medium for generating test case based on keywords
CN115600560B (en) Data conversion method, device and system, electronic 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
GR01 Patent grant
GR01 Patent grant