当前位置:网站首页>pytest(1) 用例收集规则
pytest(1) 用例收集规则
2022-07-02 06:22:00 【bthtth】
1\pytest收集用例的规则
(1) pytest自动收集执行pytest -m命令时,所在目录下的所有测试用,如下
a\将收集在bth目录下的测试用例
b\ 将收集在users目录下的测试用例

(2) 收集test_*.py或*_test.py中的测试用例. 测试用例所在的文件必须是.py类型的文件,文件应该以test_开头或是以test_结尾
(3) 如果用例,类中以test_开头的函数将被识别未测试用例
(4)如果用例在类中,测试类应以Test开头,必须是Test.类中的函数要以test_开头
# 文件名以test_开头test_study_pytest.py
# 文件名以_test结尾 study_pytest_test.py
# 以test开头函数被识别为测试用例
def test_case_1():
print(第一个测试用例)
# 没有以test_开头,不被识别为测试用例
def not_case():
pass
# 以Test开头类被识别为测试类
class Test_case:
# 测试类中以test_开头的函数 测试用例
def test_case_2(self):
print("第二个测试用例")
def test_case_3(self):
print("第三个测试用例")
# 测试类中,不以test_开头,不能被识别为测试用例
def case(self):
print("我在Test_case中,但不是测试用例")边栏推荐
猜你喜欢
随机推荐
Is there a really free applet?
Arduino Wire 库使用
Golang--map扩容机制(含源码)
日志(常用的日志框架)
Bgp Routing preference Rules and notice Principles
浅谈三点建议为所有已经毕业和终将毕业的同学
Introduce two automatic code generators to help improve work efficiency
LeetCode 27. Removing Elements
The Chinese word segmentation task is realized by using traditional methods (n-gram, HMM, etc.), neural network methods (CNN, LSTM, etc.) and pre training methods (Bert, etc.)
It is said that Kwai will pay for the Tiktok super fast version of the video? How can you miss this opportunity to collect wool?
Network related knowledge (Hardware Engineer)
TensorRT的功能
实习生跑路留了一个大坑,搞出2个线上问题,我被坑惨了
Common means of modeling: combination
ctf-web之练习赛
PgSQL学习笔记
构建学习tensorflow
Redis——缓存击穿、穿透、雪崩
Redis---1.数据结构特点与操作
The difference between session and cookies









