测试用例的识别

pytest识别用例规则:

测试文件 test_.py 或者 test.py
以Test*格式的类,类中所有的test
的方法。测试类不能包含有__init__方法
不在class中的所有的test_
方法

用例的执行

pytest常用参数

-v 打印详细的运行日志信息
-s 可以打印print方法,打印到终端上。

指定运行范围

文件名.py::类名 运行某个模块里面某个类
文件名.py::类名::方法名 运行某个模块里面某个类里面的方法
-v -k "类名 and not 方法名" 跳过运行某个用例
-m [标记名] @pytest.mark.[标记名]将运行有这个标记的测试用例
-x 文件名 一旦运行到报错就停止运行
-maxfai=[num] 当运行错误达到num的时候停止运行

posted on 2021-04-13 22:35  zazeh  阅读(51)  评论(0)    收藏  举报