版权声明:转载请注明出处,谢谢! https://blog.csdn.net/dreamstone_xiaoqw/article/details/86738649
很久没搞自动化测试,有一点怀念。
以前基于Gtest框架,多年没认真写C++的我感觉弄起来好麻烦……
所以,找个相对省事的Python自动化测试框架Pytest试试。
以下是日志,仅保留关键部分。
Pytest运行环境搭建
安装pytest,需已安装Python环境且pip可用。
pip install pytest
正确安装命令行输出如下:
Microsoft Windows [版本 10.0.17763.253]
(c) 2018 Microsoft Corporation。保留所有权利。
D:\yixzm>pip install pytest
Collecting pytest
Downloading https://files.pythonhosted.org/packages/0d/c4/8093b4ffdde66628d4cb138d1d53726e2c21c23ac397cb75494e3f4310c9/pytest-4.2.0-py2.py3-none-any.whl (218kB)
98% |███████████████████████████████▌| 215kB 471kB/s eta 0:00:01
……
Installing collected packages: six, attrs, scandir, pathlib2, funcsigs, py, more-itertools, atomicwrites, colorama, pluggy, pytest
Successfully installed atomicwrites-1.2.1 attrs-18.2.0 colorama-0.4.1 funcsigs-1.0.2 more-itertools-5.0.0 pathlib2-2.3.3 pluggy-0.8.1 py-1.7.0 pytest-4.2.0 scandir-1.9.0 six-1.12.0
升级pip
好久没用啦,提示升级pip。提示信息如下:
You are using pip version 9.0.3, however version 19.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
根据提示,升级命令如下:
python -m pip install --upgrade pip
成功升级命令行输出如下:
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-19.0.1
Pytest执行源码安装
官网地址:https://pypi.org/project/pytest/#files
下载源码安装包,解压后,命令行cd切换至源码目录执行命令python .\setup.py install
安装。
安装时如有报错:
E ImportError: No module named mock
E ImportError: No module named hypothesis
使用命令 pip install mock hypothesis
安装即可。
执行
命令行运行 pytest
即可。
大眼瞅了瞅,这框架里现成的东西还挺多。
装好啦,等将来用的时候再深入研究。