How to Learn Python stroke TestPRO automation [Music]

With the development of the Internet, automated test challenges facing also will be growing. When the item you want to do frequent regression testing, manual testing method has been unable to cope, automated testing to be the silver bullet to solve the problem.
Python With its flexibility, has been widely used in automated testing can greatly improve test efficiency. So, software test automation in the end what knowledge needs to learn it?

Stage one: to master the basic syntax of Python

Here Insert Picture Description

Phase II: Mastering Python automated test commonly used library

Public knowledge week, Python has a very rich third-party libraries, one of the reasons this is a simple and elegant Python code, then the automated testing software commonly used library What?
1. Basic library:
SYS programs and interactive Python parser
os start a new process; manipulating files and directories
re regular expressions, string matching
string basic string manipulation
inspect provide introspection and reflection functionality
importlib support dynamic import
bitstring binary data processing
zipfile compression decompression file
tarfile file compression decompression
random random numbers, probability

2. command line, read the configuration:
optparse processing command line options
glob file path to find
yaml yaml access data files
ConfigParser reads the configuration file
xml XML library
pickle serialized
json serialization

3. 网络请求相关:
libxml2 XML解析器
urlparse URL解析
urllib 访问URL资源
urllib2 访问URL资源
cookielib http客户端的cookie处理
requests 神器,用于发送网络请求,常用于接口测试
httplib http请求客户端
BeautifulSoup 从HTML或XML文件中提取数据的Python库

4. 大数据和数据库相关:
avro avro是一个数据序列化系统
etcd etcd访问库
pyspark spark库
hdfs hdfs库
pyhive hive库
redis 访问redis数据库
rediscluster 访问redis集群
pymongo 访问mongodb
kafka 访问kafka
pykafka 访问kafka
sqlalchemy ORM库
MySQLdb 访问MySQL数据库

阶段三:自动化测试常用框架

unittest:比较基础,二次开发方便,适合高手使用,是python自带的单元测试框架,可以用来作为我们自动化测试框架的用例组织执行框架unittest流程:写好TestCase,然后由TestLoader加载TestCase到TestSuite,然后由TextTestRunner来运行TestSuite,运行的结果保存在TextTestResult中,我们通过命令行或者unittest.main()执行时,main会调用TextTestRunner中的run来执行,或者我们可以直接通过TextTestRunner来执行用例。

pytest/nose:更加方便快捷,效率更高,适合小白及追求效率的公司,且pytest的信息更加详细
如果你的项目比较小、复杂度比较低,Pytest 是最适合的自动化测试平台。非常多的 Python
开发者都喜欢它,他们大部分用它来进行单元测试。它也具有 Robot Framework 所闻名的验收测试能力。Pytest
最好的特性之一是,它提供了测试用例的详细失败信息,使得开发者可以快速准确地改正问题。它兼容最新版本的 Python。它还兼容
unittest、doctest 和 nose,开箱即用。它还有包含更多功能的插件和多样化的现有测试技术和测试用例。事实上,有 300
多个可用插件来自它的活跃社区。该平台设计用于编写更简单错误率更小的代码。你可以将 Pytest 与诸如 Selenium 和
Splinter 之类的图形用户界面一起使用,来使得测试工作更轻松。

RobotFramework: As the report interface and beautiful, better ease of use, flexibility and customization slightly worse Robot Framework is the most popular
Python automated test framework. It was developed entirely in Python, is very useful for acceptance testing. This framework can run on both Java and .NET
environments. It also supports cross-platform, such as Windows, MacOS and
Linux. This product was created by some of the world famous testers with keywords drive scheme. It has so many available tools and libraries, makes this a very advanced and robust framework. It is an open source framework and leaving
API
expansion. Table test data syntax and keyword-driven test format makes it very popular in the world of test personnel. It is undoubtedly the most easy to use automated testing framework, and allows you to perform parallel test.

Add V core: leboruanjianceshi (music software testing stroke Pinyin) to receive automated testing primary video syntax information Oh ~
Here Insert Picture Description

Published 90 original articles · won praise 68 · views 10000 +

Guess you like

Origin blog.csdn.net/leboxy/article/details/103927453