Pytest
作者:互联网
测试文件的命名规则
1.测试文件应该命名为test_<something>.py
或者<something>_test.py
2.测试类应该命名为Test<something>.py
3.测试函数和测试类方法应该命名为test_<something>
Pytest 基础命令
pytest --hlep
可以查看pytest相关命令
import pytest
@pytest.mark.smoke
def test_mark_smoke():
print('the aim is test mark smoke')
@pytest.mark.get
@pytest.mark.smoke
def test_mark_get_smoke():
print('the aim is testing mark smoke and get')
只需要在命令中指定-m mark_name 就可以运行
比如Pycharm 的Terminal中输入pytest -v -m smoke test.py
跳过测试pytest.mark.skip(reason='misunderstood the API')
标记预期失败的测试pytest.mark.xfail(reason= misunderstood the API)
xfail
表示的是预期会失败,但实际上也失败了,xpass
表示的是预期会失败,但实际上是运行并没有失败
标签:测试,py,pytest,mark,Pytest,smoke,test 来源: https://www.cnblogs.com/ning-010/p/15779562.html