接口自动化python3+requests+pytest/unitest

 unittest编写规范

 1. 引用import unittest

2.继承unittest.TestCase

3.测试方法以test_开头

 htmltestrunner生成测试报告

pytest优势:

 

pytest-sugar: 调试的时候看进度条

pytest-assume:自动化测试报错的时候不中断,执行完所有的测试用例

pytest-ordering:设置测试用例的执行顺序,但是建议测试用例之间最好不要有依赖关系

pytest-selenium: 可以进程web端的兼容性测试

pytest-play: 对selenium的补充 不用写代码就可以实现web测试

pytest-returnfailures: 失败重试

pytest-allure-adaptor:生成测试报告

pytest-datadir: 数据管理

pytest-datafiles:

import pytest
'''
  pytest传参
'''

@pytest.mark.parametrize("x,y",[("1.1","2.2"),("1","1")])

def test_01(x,y):
    assert x==y

  

https://blog.csdn.net/cyjs1988/article/details/74641407

https://blog.csdn.net/sxyzwq/article/details/62039952?utm_medium=distribute.pc_relevant_right.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_right.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase



原文地址:https://www.cnblogs.com/hqsbrx/p/13368642.html