一、单个目录运行
运行单个目录下的所有测试,以目录作为pytest的参数即可
(venv_dome) F:\TESTING\BlogPosts\ReadPytest>pytest ch2 --tb=no
================================================================================== test session starts ===================================================================================
collected 9 items
ch2\test_eight.py .. [ 22%]
ch2\test_nine.py .. [ 44%]
ch2\test_seven.py .. [ 66%]
ch2\test_six.py . [ 77%]
ch2\test_ten.py .. [100%]
=================================================================================== 9 passed in 0.12s ====================================================================================
二、单个测试文件/模块运行
运行单个文件里的全部测试,以路径加文件名作为pytest参数即可
(venv_dome) F:\TESTING\BlogPosts\ReadPytest>pytest ch2/test_ten.py
================================================================================== test session starts ===================================================================================
collected 2 items
ch2\test_ten.py .. [100%]
=================================================================================== 2 passed in 0.06s ====================================================================================