一.安装依赖库:
1.pytest依赖库:
1.pip install pytest
2.allure依赖库:
1.pip install allure-pytest
2.下载allure-commandline
链接: https://github.com/allure-framework/allure2/releases.
3.下载完把bin所在的文件夹路径加入环境变量
二.编写代码:
1.代码目录:
其中test_005.py代码包含运行代码的主函数
2.运行代码
#test_005.py的代码
import pytest, os, allure, subprocess
class Test_Pytest():
@allure.feature('test_module_01')# 用于定义被测试的功能,被测产品的需求点
@allure.story('test_story_01')# 用于定义被测功能的用户场景,即子功能点
def test_01(self):
print("test_01方法执行")
assert 1 == 1
@allure.feature('test_