
pytest
木一亢
这个作者很懒,什么都没留下…
展开
-
Pytest运行脚本小结
run.pyimport sysimport pytestimport osROOT_DIR=os.path.dirname(os.path.abspath(__file__))def main(): print(ROOT_DIR) if ROOT_DIR not in sys.path: sys.path.append(ROOT_DIR) # 执行用例 # args = ['--reruns', '1', '--html=' + './repo原创 2020-05-27 17:26:34 · 676 阅读 · 0 评论 -
pytest parametrize参数化数据
pytest.mark.parametrize装饰器可以实现测试用例参数化@pytest.mark.parametrize("num1,num2", [ ("3+7", 10), ("4+4", 8), # ("9*9", 82), #通过mark.xfail标记为失败运行时跳过原创 2020-05-09 11:08:24 · 435 阅读 · 0 评论 -
pytest conftest小结
pytest里面默认读取conftest.py里面的配置conftest.py配置需要注意以下点:conftest.py配置脚本名称是固定的,不能改名称conftest.py与运行的用例要在同一个pakage下,并且有init.py文件不需要import导入 conftest.py,pytest用例会自动查找ps:如果module级别的,在py文件中第一个未调用,第二个调用,module会在第二个调用时执行通过yield实现teardown:@pytest.fixture(scope="mod原创 2020-05-09 10:52:13 · 826 阅读 · 0 评论 -
pytest命令和测试用例规则
测试用例规则:测试文件以test_开头(以_test结尾也可以)测试类以Test开头,并且不能带有 init 方法测试函数以test_开头断言使用基本的assert即可所有的包pakege必须要有__init__.py文件#创建JUnitXML格式文件(可被Jenkins或其他持续集成服务器读取的结果文件)pytest --junitxml=path#创建纯文本机器可读的结果文件,计划在pytest 6.0中删除pytest --resultlog=path#生成html报告pytes原创 2020-05-09 10:41:20 · 652 阅读 · 0 评论