py.test ## run all tests below current dirpy.test test_mod.py # run tests in modulepy.test somepat
h # run all tests below somepathpy.test - k stringexpr # only run tests with names that match the# the "s
tring expression", e.g. "MyClass and not method"# will select TestMyClass.test_something# but not TestMyCl
ass.test_method_simplepy.test test_mod.py:
:
test_func # only run tests that match the "node ID",
# e.g "test_mod.py::test_func" will select
# only test_func in test_mod.py
7、测试报告
pytest 可以方便的生成测试报告,即可以生成 HTML 的测试报告,也可以生成 XML 格式的测试报告用来与持
续集成工具集成。
生成 HTML 格式报告:
py.test - -resultlog = path
生成 XML 格式的报告:
py.test - -junitxml = path
8、如何获取帮助信息
py.test - -version # shows where pytest was imported frompy.test - -fixtures # show available builtin functio
n argumentspy.test - h | --help # show help on command line and config file options
9、最佳实践