Directory
1 , write in front
2 , Development Environment
3 , Approximate process
4 , Introduction to the framework
5 , Run results show
6 , File and Configuration
7 , Test Interface Instance
N 1. Login interface
N 2. Payment Password Change interface
8 , Database Design
9 , test case, test data preparation
Ten , module and class, function design
One , Code Implementation
A) class congfighttp. Confighttp
b) Class Getdb. Getdb
c) Class Configrunmode. Configrunmode
D) class GlobalConfig. Global
E) class datastruct. Datastruct
f) class Test_interface_case. Testinterfacecase,test_interface_case. Parametrizedtestcase
g) class Runcase. Runcase
h) htmlreport. Htmlreport
i) Main
A , Source Download
1. write in front
For reference only
2. Development Environment
Win7 64-bit
JetBrains Pycharm 4.0.5
Python 3.3.5
Mariadb-5.5.45-centos6-x86_64
Files: http://pan.baidu.com/s/1sj1Lzw5
CentOS 6.5-x86_64
: http://www.centoscn.com/CentosSoft/iso/2013/1205/2196.html
Mysql Connector/python Windows (x86, 64-bit), MSI Installer Python 3.3
: http://dev.mysql.com/downloads/connector/python/
Other: Company Linux MySQL database server, application server
3. Approximate process
Demonstrates the business process of framework implementation
4. Introduction to the framework
1, through the configuration file Http_config.ini, to test the interface server IP, domain name, and port information can be flexibly configured.
2, through the configuration file Db_config.ini, the test database, application database server host IP, port, user name, password and other flexible configuration.
3. Configurable file Run_case_config.ini Flexible configuration requires use case run mode, need to run a list of use case ID
4, the common HTTP Post,get Request method Encapsulation (support free expansion to add other methods
5, support JSON (including nested object format JSON data, such as {"Ordertotalprice": "Goods": [{"Shopid": 987654354, "Goodsid": 108, "Goodsnumber": 1}]}) Format Data Submission
6, through the database of interface test cases, pre-set (data) conditions to manage, each use case can be independent of each other, non-dependent
7, for the interface return results, support database-level data validation
8, according to the test time and the given file name, generate the corresponding time of the HTML visual report, the report content contains the test time, the total number of test execution cases, the success of the execution, failure, the number of error cases statistics, as well as the execution of a single use case (ID, use case name, (custom) interface name, Interface URL, interface parameters, run results, etc.)
9, according to the actual situation, on the basis of this framework to modify, expand
5. Run results show
Space problem, omit the remainder here, if you want to see more, please download the document and source code:
Python-based automated test framework for HTTP interfaces (utility improved version). pdf
Python-based HTTP Interface Automation testing Framework source code (utility improved version). zip
Python-based Python implementation of the Http+json Protocol Interface Automation test framework source code (utility improved version)