需要安装
pytest
和
pytest-html(
生成
html
测试报告)
pip install pytest
pip install pytest-html
1:
命名规则
Pytest
单元测试中的类名和方法名必须是以
test
开头
,
执行中只能找到
test
开头的类和方法,比
unittest更加严谨
2:Pytest
生成自带的
html
测试报告
前提条件:需要下载
pytest-html
模块
(python
自带的生成测试报告模块
pip install pytest-html
pytest.main("
模块
.py")
【运行指定模块下,运行所有
test
开头的类和测试用例】
pytest
.
main
([
"--html=./report.html"
,
"
模块
.py"
])
运行指定模块指定类指定用例,冒号分割,并生成测试报告
pytest
.
main
([
‘
--<