已经学习过unittest了,现在学习pytest,跟着悠老师学,自己想总结

 

一:用例设计原则

1、文件名以test_*.py

2、test开头的函数

3、Test开头的类

4、所在的包必须要有__init__.py文件

二:代码结构

1、用例目录结构如下:

pytest运行规则

2、test_class.py代码如下:

pytest运行规则

3、test_sample.py 代码如下:

 pytest运行规则

三:cmd运行方式

1、pytest

pytest运行规则

2、py.test

pytest运行规则

3、python -m pytest

pytest运行规则

4、执行某个目录下的所有用例

pytest运行规则

5、执行某一个py文件

pytest运行规则

6、按节点运行

运行py文件中的某个函数

pytest运行规则

运行py文件类里面的某个方法

pytest运行规则

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-02-16
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
相关资源
相似解决方案