Preliminary Exploration of the interface testing framework-python Series 7 and python

Source: Internet
Author: User

Preliminary Exploration of the interface testing framework-python Series 7 and python

Click "Blue name" under the title to quickly follow

What we insist on is sharing, moving knowledge, showing everyone's progress, no paid training, no fake information, and paying attention and forwarding if you like (free to help more partners) if you want to know more, please leave a message to bring you more value. We are looking forward to it. If you are more interested, please refer to our subscription number. The contact information is as follows:

More books are coming soon

Background

The python series of courses have been around for a while. We insist that, step by step, today is the last lesson. Let's take a look at the mysteries of the interface testing framework. The little moles will lead everyone to complete the 7th course together, I hope I can read the knowledge point, practice it by myself, compare it with the sample code provided, and finally look at the homework sentiment article. If I want to learn it, I will go on to see it (this is the 7th lesson, the corresponding job is question 6th ).

1. Job content

Question 6:

6th job requirements: (complete the framework of the individual HTTP interface, based on the 5th job)

1. Include GET and POST requests, and take the weather forecast interface as an Example

2. Script data separation, public method encapsulation, and result storage in mysql database. The test case success rate and failure rate are also counted (html format is generated)

3. self-designed database tables. The field requirements are the same as those in excel (the name can be different)

4. Submission time: before noon

5. Reference Information:

Pass in CityName and CountryName to obtain the weather conditions.

URL: http://www.webservicex.net/globalweather.asmx/GetWeather

Parameters: CityName = "beijing" and CountryName = "china"

Method: post

Ideas:

1. Write the result file to the mysql database based on the previous job;

2. Based on the previous job, extract information to generate an html report;

3. python can generate html using a third-party Library: pyH, or a common method, which is purely written.

4. When determining the method: "if method = 'post'":, it is always not true because the value returned for reading excel is text: u'post ', change to TestDataDict ['method']. value.

5. Simple report:

References:Download from QQ group (283440449)

2. colleagues' homework Summary

1. Install MySQLdb

1. Installation Error: pythonversion 2.7 required which was not found in the registry.

According to the method found on the internet, paste a python registration code and install it.

Test import MySQLdb after installation: import_mysql ImportError: DLL load failed: % 1 is not a valid Win32 application.

2. According to the search question, the reason is that 64-bit python and 32-bit MySQLdb are used.

3. Download mysql-python-1.2.3.win-amd64-py2.7.exe.

2. Deal with the database

1. It is too slow to download mysql by yourself. It is commonly used to find a development environment (not a development or test environment.

2. You have created a database and a table.

Create table weatherdata (ID int (4) notnull primary key auto_increment, Description char (20) not null, Method char (20) not null, CityName char (20) not null, countryName char (20) not null, Expchar (20) not null, Act char (20) not null, Result char (20) not null, ResTimedouble (16, 4 ));

3. Add a method to write data to a mysql table

Create an InsertMysqlTable function, obtain the pointer, pass in the compiled SQL statements, execute, and insert data for passing parameters.

4. Add a method to read mysql table output html

1. Create the ReadMysqlTable function, obtain the pointer, pass in the compiled SQL, execute, and read the table content.

2. read each row of the table and write it to html according to the style. In addition, I wrote several small functions to process headers and table tails.

5. modify the original function

1. Add the input Methods judgment in GetRequest, which is divided into POST and GET processing. Handle situations where data cannot be obtained and modify other details.

2. Modify the ReadTable, add the read Method, and input the dictionary.

3. Modify the EditTable and the location selected when the table is operated.

6. Areas to be improved

1. The job is written in a hurry and many details are not taken into consideration, including some fault tolerance Processing.

2. The database structure is too simple. The time field should be added.

3. html output is ugly, and there is no need to consider paging when there is too much data.

3Background

At this point, all the courses in the python series have been shared, and you can carefully review them. This is a step-by-step course that starts from 0 and virtually enters the interface testing framework. Of course, this is just the beginning. We basically involve all the knowledge points required by the framework and practice. We can continue to explore the practices based on the individual and the optimization ideas in the future, we need to share our experiences in the future. We are engaged in python and use our actions to ignite our enthusiasm. We can't afford to participate in the harvest, action. I hope you will be the next one to share. That's right!

Recommended articles

Test Framework of APIS-python Series 1

Test Framework of APIS-python Series 2

Test Framework of APIS-python Series 3

Test Framework of APIS-python Series 4

Test Framework of APIS-python Series 5

Test Framework of APIS-python Series 6

Python crawlers-catch Novels

Wonderful review, everywhere

Jmeter (20) How to synchronously write data to the database when writing a jtl File

Automated interface testing-Basics

Fiddler records jmeter scripts and shares valuable information

Jmeter interface automation, you dare to think, I dare to play

Interface Test practice -- SoapUI Pro5.1.2

On the test road, talk about ideas and methods.

Gentle knowledge-History List

Jenkins Series 1 -- tag automatically

Click "read original". [view more information]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.