1. 程式人生 > 其它 >002、pytest命令列執行用例規則

002、pytest命令列執行用例規則

1、cmd執行pytest 有以下3個:

  pytest (推薦使用)

  py.test

  python -m pytest

  不帶引數,在某個資料夾下執行時,它會在該資料夾下查詢所有符合規則的用例 。

D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06>pytest -sv
=================================================================================== test session starts ====================================================================================
platform win32 
-- Python 3.8.6, pytest-5.4.3, py-1.10.0, pluggy-0.13.1 -- c:\skyworkspace\worktools\python\python38\python.exe cachedir: .pytest_cache metadata: {'Python': '3.8.6', 'Platform': 'Windows-10-10.0.19041-SP0', 'Packages': {'pytest': '5.4.3', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins': {'allure-pytest': '2.9.43
', 'html': '2.1.1', 'metadata': '1.11.0'}, 'JAVA_HOME': 'C:\\SkyWorkSpace\\WorkTools\\Java\\jdk1.8\\jdk1.8.0_271'} rootdir: D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06 plugins: allure-pytest-2.9.43, html-2.1.1, metadata-1.11.0 collected 4 items aa/test_aa.py::Testaa::test_aa =============test_aa============== PASSED aa
/test_aa.py::Testaa::test_bbb =============test_aab============== PASSED bb/test_bb.py::Testbb::test_bb =============test_bb============== PASSED cc/test_cc.py::Testcc::test_cc =============test_cc============== PASSED ==================================================================================== 4 passed in 0.08s ===================================================================================== D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06>py.test -sv =================================================================================== test session starts ==================================================================================== platform win32 -- Python 3.8.6, pytest-5.4.3, py-1.10.0, pluggy-0.13.1 -- c:\skyworkspace\worktools\python\python38\python.exe cachedir: .pytest_cache metadata: {'Python': '3.8.6', 'Platform': 'Windows-10-10.0.19041-SP0', 'Packages': {'pytest': '5.4.3', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins': {'allure-pytest': '2.9.43', 'html': '2.1.1', 'metadata': '1.11.0'}, 'JAVA_HOME': 'C:\\SkyWorkSpace\\WorkTools\\Java\\jdk1.8\\jdk1.8.0_271'} rootdir: D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06 plugins: allure-pytest-2.9.43, html-2.1.1, metadata-1.11.0 collected 4 items aa/test_aa.py::Testaa::test_aa =============test_aa============== PASSED aa/test_aa.py::Testaa::test_bbb =============test_aab============== PASSED bb/test_bb.py::Testbb::test_bb =============test_bb============== PASSED cc/test_cc.py::Testcc::test_cc =============test_cc============== PASSED ==================================================================================== 4 passed in 0.05s ===================================================================================== D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06>python -m pytest =================================================================================== test session starts ==================================================================================== platform win32 -- Python 3.8.6, pytest-5.4.3, py-1.10.0, pluggy-0.13.1 rootdir: D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06 plugins: allure-pytest-2.9.43, html-2.1.1, metadata-1.11.0 collected 4 items aa\test_aa.py .. [ 50%] bb\test_bb.py . [ 75%] cc\test_cc.py . [100%] ==================================================================================== 4 passed in 0.06s ===================================================================================== D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06>
View Code