前期准备
此处默认使用
系统:win10
编辑器:pycharm

  • pthon3 编程语言
  • pytest 测试框架
  • allure 测试报告

python的安装

首先进入官网https://www.python.org/

找到官网首页中的Downloads栏目下的windows

pytest框架用例怎么加参数 pytest搭建_pytest框架用例怎么加参数

找到需要安装的版本并点击下载Download Windows installer (64-bit) #此处选择了3.8版本64位

pytest框架用例怎么加参数 pytest搭建_官网_02

进行环境配置,右键桌面的此电脑>属性>高级系统设置>环境变量>系统变量栏下的path,将安装路径粘贴上去并点击确定

pytest框架用例怎么加参数 pytest搭建_环境配置_03

验证是否配置成功,键盘按下win,输入cmd点击回车,输入python

成功安装则会显示版本号等信息:Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32

Type “help”, “copyright”, “credits” or “license” for more information.

pytest框架用例怎么加参数 pytest搭建_pytest框架用例怎么加参数_04

更为详细的可自行百度,教程很多。安装完cmd无法识别的,是因为环境配置方面出了问题。捋清思路重新配置就可以了。

思路解析:

  1. 找到安装包并下载
  2. 环境配置让程序能够识别python解释器

pytest的安装

  1. 可以在cmd中输入pip install pytest 进行安装
  2. 或者在pycharm中左上角处的file>settings>project:xxx>python interpreter中点击+号,左上角的搜索框输入pytest,点击install package

思路解析:推荐第二种方法,可以在列表中查看到已经安装的依赖包

allure的安装
这里采用的是手动安装的方式

pytest框架用例怎么加参数 pytest搭建_python_05

先到官网下载安装包并解压 allure-2.13.10.zip #这里需要选择zip结尾的格式

pytest框架用例怎么加参数 pytest搭建_环境配置_06

进行环境配置:右键桌面的此电脑>属性>高级系统设置>环境变量>系统变量栏下的path,将安装路径粘贴上去。这里的路径只需要粘贴bin下不需要指定程序。

例如: E:\Allure\allure-2.13.10\bin

pytest框架用例怎么加参数 pytest搭建_官网_07

验证是否配置成功:直接按win键输入cmd回车,输入allure,如果正常显示信息,没有报错则配置成功

pytest框架用例怎么加参数 pytest搭建_pytest框架用例怎么加参数_08


或者输入allure --version验证已安装版本号

pytest框架用例怎么加参数 pytest搭建_pytest框架用例怎么加参数_09

除了手动安装外,还需要在pycharm中安装allure-pytest

在pycharm中左上角处的file>settings>project:xxx>python interpreter中点击+号,左上角的搜索框输入allure-pytest,点击install package

pytest框架用例怎么加参数 pytest搭建_环境配置_10


绿色区域显示 installed successfully则是安装成功

思路解析:

  1. allure的安装选择较为简单的手动安装方式
  2. 安装解压后进行环境配置,让程序能够识别解析
  3. 在pycharm中安装则是让pycharm可以导入包进行使用

后续会解析pytes+allure的demo,互相学习和讨论