Pytest单元测试框架 运行测试 (虫师《selenium3自动化测试实战--基于Python语言笔记43》)

1. 运行名称中包含某字符串的测试用例

# 运行名称中包含某字符串的测试用例
pytest -k add test_assert.py

2.减少测试的运行冗长

# 减少测试的运行冗长
pytest -q test_assert.py

pytest --quiet  test_assert.py

3.如果出现一条测试用例失败,就退出测试

# 如果出现一条测试用例失败,就退出测试
pytest -x test_fail.py

4.运行测试目录

pytest ./test_dir

5.指定特定类或方法执行(文件名、类名、方法名间用::)

pytest test_fixtures_01.py::TestMultiply::test_multiply_3_4

6.main()运行测试

if __name__ == '__main__':
    pytest.main(['-s','./test_dir'])
 

猜你喜欢

转载自www.cnblogs.com/kite123/p/11602129.html