Skip to content

如何在pycharm 里面使用pytest运行用例

如何在 pycharm 里面使用 pytest 运行用例(默认为 unittest)

当脚本文件命名为 test_xx.py 和用例使用 test 开头时,运行代码 pycharm 会自动识别到以 unittest 方式运行

如果要以 pytest 方式运行,需要修改设置默认的运行器:file->Setting->Tools->Python Integrated Tools->Testing->Default test runner->选择 pytest

修改完成之后,删除所有的 unittest 运行配置

再次右键执行,查看都会显示 pytest 运行器

原文链接