Pytest初体验

Pytest安装,导入相关依赖哭

Pip3 install –U pytest U表示升级
Pip3 install pytestsugar
pip3 install pytest-rerunfailures
Pip3 install pytest-xdist

Pip3 install pytest-assume

Pip3 install pytest-html ......
Pip3 list查看

Pytest –h 帮助

pytest框架结构

模块级 (setup_module/teardown_module) 不在类中的函数有用

函数级 (setup_function/teardown_function) 不在类中的函数有用

类级 (setup_class/teardown_class)只在 类中前后运行一次。

方法级 (setup_method/teardown_methond) 运行在类中方法始末

pytest执行方式:Pytest/py.test(终端,命令行,pycharm可配置pytest方式执行)

1. Pytest –v (最高级别信息—verbose)

2. pytest -v -s filename(输出打印)

3.Pytest-q (静默)

1.pytest将在当前目录及其子目录中运行test _ * .py或* _test.py形 式的所有文件。

2.以test_开头的函数,以Test开头的类,以test_开头的方法。所有包 package都要有__init__.py文件。

3.Pytest可以执行unittest框架写的用例和方法

猜你喜欢

转载自www.cnblogs.com/QaStudy/p/11562982.html
今日推荐