上一篇已经介绍了如何在cmd执行pytest用例,那么pycharm下如何运行pytest用例呢?
pycharm运行三种方式
1.以xx.py脚本方式直接执行,当写的代码里面没用到unittest和pytest框架时,并且脚本名称不是以test_开头命名的,此时pycharm会以xx.py脚本方式运行。
2.当脚本命名为test_xx.py时,用到unittest框架,此时运行代码,pycharm会自动识别到以unittest方式运行
3.以pytest方式运行,需要改设置默认的运行器:file—>Settings—>Tools—>Python Integrated Tools—>Default test runner—>选择pytest