pytest的测试样例及报告

上一篇 / 下一篇  2018-12-03 16:23:48 / 个人分类:python



如何编写pytest测试样例

通过上面2个实例,我们发现编写pytest测试样例非常简单,只需要按照下面的规则:

  • 测试文件以test_开头(以_test结尾也可以)
  • 测试类以Test开头,并且不能带有 init 方法
  • 测试函数以test_开头
  • 断言使用基本的assert即可

安装pytest-html:

pip install -U pytest-html

运行模式:

pytest --html=report.html

TAG:

 

评分:0

我来说两句

Open Toolbar