Time will tell.
一、用例设计原则
文件名以test_*.py
文件和*_test.py
- 以
test_
开头的函数 - 以
Test
开头的类 - 以
test_
开头的方法 - 所有的包 pakege 必须要有
__init__.py
文件
二、help帮助
查看 pytest 命令行参数,可以用pytest -h
或pytest —help
查看。
C:\Users\admin>pytest -h
usage: pytest [options] [file_or_dir] [file_or_dir] [...]
positional arguments:
file_or_dir
general:
-k EXPRESSION only run tests which match the given substring
expression. An expression is a python evaluatable
expression where all names are substring-matched
against test names and their parent classes. Example:
-k 'test_method or test_other' matches all test
functions and classes whose name contains
'test_method' or 'test_other', while -k 'not
test_method' matches those that don't contain
'test_method' in their names. Additionally keywords
are matched to classes and functions containing extra
names in their 'extra_keyword_matches' set, as well as
functions which have names assigned directly to them.
-m MARKEXPR only run tests matching given mark expression.
example: -m 'mark1 and not mark2'.
--markers show markers (builtin, plugin and per-project ones).
-x, --exitfirst exit instantly on first error or failed test
reporting:
-v, --verbose increase verbosity.
-q, --quiet decrease verbosity.