python pytest

之前一直用unittest ,现在学习pytest 看看那个好

1. 安装

  1. pip install -U pytest  
  2. py.test --version  

2. 只需要按照下面的规则:

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

3.可以执行多个文件,注意文件必须test_开头,至执行制定文件就不需要test_开头

4.还有一种方式执行多个文件

原文地址:https://www.cnblogs.com/alamZ/p/6813157.html