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

1. 安装

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

python pytest

python pytest

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

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

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

python pytest

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

python pytest

python pytest

 

 

相关文章:

  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2021-12-12
猜你喜欢
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2021-12-17
相关资源
相似解决方案