随笔分类 - 单元测试框架
unittest pytest
摘要:基础以及安装可以查看这两篇文章,我就直接上如何使用,不理解可以参考这两篇文章 https://blog.csdn.net/liuchunming033/article/details/79624474 https://blog.csdn.net/hh20161314/article/details/
阅读全文
摘要:def init_data(): data = [{"zhang", "123"}, {"lisang", "456"}] return data class test_skip: #单个参数 @pytest.mark.parametrize('name', ["tom", "zhang", "ju
阅读全文
摘要:使用方法: @pytest.mark.skipif(condition,reason=None) 参数: condition:跳过的条件,True(跳过、不执行)/False(不跳过、执行),必传参数 reason:标注原因 class test_skip: n=5 @pytest.mark.ski
阅读全文
摘要:pytest中使用fixture装饰器是来固定的工厂函数,fixture函数可以在测试执行前和执行后进行必要的准备和清理工作 1. fixture做为函数引用使用 比如以下 import pytest # fixture作为函数引用 @pytest.fixture() def before(): p
阅读全文
摘要:使用pytest控制函数运行的函数 需要使用 (1)使用 @pytest.mark.run(order=x) 标记被测试函数 (2)运行的顺序由order传入的参数决定;(order从小到大的顺序执行) import pytest class Calc(object): @classmethod d
阅读全文
摘要:pytest 生成报告,需要提前安装插件 pip install pytest-html 使用方式: 在运行时使用--html=report.html (report就是生成html的文件名) eg:pytest test_rundemo.py --html=reportdemo.html 测试案例
阅读全文
摘要:pytest有几种运行方式 1.全量方式运行 pytest 测试py文件 2.部分方法运行 pytest test_mod.py::test_func 3.运行时显示详细日志 pytest test_mod.py::test_func -v -s 案例展示 全量方式运行 def test_demo1
阅读全文