pytest --collect-only 搜集要运行的测试用例,不运行
匹配表达式 -k
D:\tools\pycharm\autotest>pytest -k "test_create_article or test_article_edit_alias" --collect-only 匹配包含test_create_article 或 test_article_edit_alias的用例
========================================================================================================== test session starts ===========================================================================================================
platform win32 -- Python 3.8.0, pytest-7.1.3, pluggy-1.0.0
rootdir: D:\tools\pycharm\autotest
plugins: html-3.1.1, metadata-2.0.2
collected 7 items / 3 deselected / 4 selected
<Package testcases>
<Module test_abnormal.py>
<Function test_create_article[article_data0-None]>
<Function test_create_article[article_data1-java.sql.SQLException: Incorrect integer value: 'AAA' for column 'typeId' at row 1]>
<Module test_article_create.py>
<Function test_create_article>
<Module test_article_update.py>
<Function test_article_edit_alias>
============================================================================================== 4/7 tests collected (3 deselected) in 1.88s ===============================================================================================
D:\tools\pycharm\autotest>pytest -k "test_ and _alias" --collect-only 匹配包含test_ 和 _alias的用例
========================================================================================================== test session starts ===========================================================================================================
platform win32 -- Python 3.8.0, pytest-7.1.3, pluggy-1.0.0
rootdir: D:\tools\pycharm\autotest
plugins: html-3.1.1, metadata-2.0.2
collected 7 items / 6 deselected / 1 selected
<Package testcases>
<Module test_article_update.py>
<Function test_article_edit_alias>
============================================================================================== 1/7 tests collected (6 deselected) in 1.75s ====================================&#