前提:需要安装pytest和pytest-html(生成html测试报告)
pip install pytest 和 pip install pytest-html
案例一
pytest.main(“模块.py”)【运行指定模块下,运行所有test开头的类和测试用例】
import pytest
class TestDemo():
def test001(self):
print("我是test001")
if __name__ == '__main__':
pytest.main(["--html=./哈哈哈2.html", "demo1_test.py"])
使用@pytest.mark.skip()跳过该用例(函数)
import pytest
class TestDemo():
def test001(self):
assert 2