1.pytest安装
安装命令:pip install -U pytest 安装后查看pytest版本:pytest -version
2.在pycharm中设置pytest
新建一个工程后,左上角file->Setting->Tools->Python Integrated Tools,
选择py.test
3.了解下pytest的用例设计原则
- 文件名以test_*.py文件和*_test.py
- 以test_开头的函数
- 以Test开头的类,并且不能带有 init 方法
- 以test_开头的方法
- 所有的包pakege必须要有__init__.py文件
在命名是需要注意
4.一个简单的例子
在同一层级下封装一个登录的方法: