入门3-Pytest测试用例运行方式(1)Main方法运行

蜗牛果果 / 2023-05-03 / 原文

通过主函数main方式执行

  1. 运行所有case:pytest.main()
  2. 运行模块: pytest.main(['test_company.py','test_school.py'])
  3. 指定目录:pytest.main(['./testcases'])

If __name__ ==  ‘__main__’:

   pytest.main({“--vs”})

一般run.py里用main()方法,里边可以加参数

单独模块里:

 单独run.py文件

 以上两种方式都会运行所有py文件。