-n参数
// FileName: HelloWorld.python# -*- coding:utf-8 -*-# auth:shichao # Email:695214599@qq.comimport pytestimport timeclass TestLogin: def test_01_shichao(self): time.sleep(2) print('这是第1条测试用例') assert 1 < 2 def test_02_shichao(self): time.sleep(2) print('这是第2条测试用例') a = "测试" assert "测" in a def test_03_shichao(self): time.sleep(2) print('这是第3条测试用例') def test_04_shichao(self): time.sleep(2) print('这是第4条测试用例') def test_05_shichao(self): time.sleep(2) print('这是第5条测试用例') def test_06_shichao(self): time.sleep(2) print('这是第6条测试用例')if __name__ == '__main__': pytest.main()pytest -vs test_one_case.py 运行参数正常运行,未加多线程执行参数测试用例运行总耗时12s+,-reruns参数
这里我们将第三条测试用例写一个错误的断言,先进行运行看是否报错,再看看我们运用重试参数-reruns的效果
// FileName: HelloWorld.python# -*- coding:utf-8 -*-# auth:shichao # Email:695214599@qq.comimport pytestimport timeclass TestLogin: def test_01_shichao(self): time.sleep(2) print('这是第1条测试用例') assert 1 < 2 def test_02_shichao(self): time.sleep(2) print('这是第2条测试用例') a = "测试" assert "测" in a def test_03_shichao(self): time.sleep(2) print('这是第3条测试用例') assert 1 == 2 print('这里有个错误的断言,来试试我们的重试机制') def test_04_shichao(self): time.sleep(2) print('这是第4条测试用例') def test_05_shichao(self): time.sleep(2) print('这是第5条测试用例') def test_06_shichao(self): time.sleep(2) print('这是第6条测试用例')if __name__ == '__main__': pytest.main()pytest -vs test_one_case.py 运行参数正常运行,未加-reruns重试参数,正常运行到第三条测试用例进行报错了最后我也整理了一些软件测试学习资料,对于学软件测试的小伙伴来说应该会很有帮助,为了更好地整理每个模块
需要的私信我关键字【555】免费获取哦 注意关键字是:555
全套软件测试自动化测试教学视频
300G教程资料下载【视频教程+PPT+项目源码】
全套软件测试自动化测试大厂面经
版权声明:我们致力于保护作者版权,注重分享,被刊用文章【软件测试案例设计(Pytest框架)】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!;
工作时间:8:00-18:00
客服电话
电子邮件
beimuxi@protonmail.com
扫码二维码
获取最新动态
