如果你还想从头学起Pytest,可以看看这个系列的文章哦!
https://www.cnblogs.com/poloyy/category/1690628.html
下面两个栗子都是这个目录结构
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ =
__Time__ = 2020/10/28 11:03
__Author__ = 小菠萝测试笔记
__Blog__ = https://www.cnblogs.com/poloyy/
"""
def test_1():
print("test_1 文件的测试用例1")
def test_2():
print("test_1 文件的测试用例2")
进入该目录下,cmd 运行
pytet test_1.py --alluredir=./allure
只有两条用例
def test_11():
print("test_1 文件的测试用例1")
def test_22():
print("test_1 文件的测试用例2")
四条用例,包含了历史的两条,这不是我们希望看到的
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ =
__Time__ = 2020/10/28 11:03
__Author__ = 小菠萝测试笔记
__Blog__ = https://www.cnblogs.com/poloyy/
"""
def test_1():
print("test_1 文件的测试用例1")
def test_2():
print("test_1 文件的测试用例2")
# 先运行第一个
pytet test_1.py --alluredir=./allure
# 再运行第二个,此时应该希望 allure 报告只有 test_2.py 的测试用例
pytet test_2.py --alluredir=./allure
出现了 test_1.py 的测试用例,这不是想要的结果
--clean-alluredir
pytest -h
# 先运行第一个
pytet test_1.py --alluredir=./allure
# 再运行第二个,此时应该希望 allure 报告只有 test_2.py 的测试用例
pytet test_2.py --alluredir=./allure --clean-alluredir