日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Pytest脚本中运行用例方式

發(fā)布時間:2025/3/15 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Pytest脚本中运行用例方式 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

腳本樹如下:

test1文件下test_01.py存放test1和test2用例

test1文件下test_02.py存放test1和test2用例

test2文件下test_03.py存放test1和test2用例

test2文件下test_04.py存放test1和test2用例

1、運行所有用例 import pytest if __name__ == "__main__":pytest.main(['-s',''])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py ============================= test session starts ============================= platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0 rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0 collected 8 itemstest1\test_01.py 調(diào)用了獲取token test_01-test1:5 .test_01-test2:5 . test1\test_02.py test_02-test1:5 .test_02-test2:5 . test2\test_03.py test_03-test1:5 .test_04-test2:5 . test2\test_04.py test04-test1:5 .test04-test2:5 .============================== 8 passed in 0.25s ==============================Process finished with exit code 0 --------------------------------------------------------------------------------------2、運行指定文件夾下用例 import pytest if __name__ == "__main__":pytest.main(['-s','test1'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py ============================= test session starts ============================= platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0 rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0 collected 4 itemstest1\test_01.py 調(diào)用了獲取token test_01-test1:5 .test_01-test2:5 . test1\test_02.py test_02-test1:5 .test_02-test2:5 .============================== 4 passed in 0.12s ==============================Process finished with exit code 0-----------------------------------------------------------------------------------3、運行指定py文件下用例 import pytest if __name__ == "__main__":pytest.main(['-s','test1/test_01.py'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py ============================= test session starts ============================= platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0 rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0 collected 2 itemstest1\test_01.py 調(diào)用了獲取token test_01-test1:5 .test_01-test2:5 .============================== 2 passed in 0.04s ==============================Process finished with exit code 04、運行指定類下的用例 import pytest if __name__ == "__main__":pytest.main(['-s','test1/test_01.py::Test'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py ============================= test session starts ============================= platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0 rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0 collected 2 itemstest1\test_01.py 調(diào)用了獲取token test_01-test1:5 .test_01-test2:5 .============================== 2 passed in 0.04s ==============================Process finished with exit code 0-------------------------------------------------------------------------------------5、運行執(zhí)行方法下的用例 import pytest if __name__ == "__main__":pytest.main(['-s','test1/test_01.py::Test::test1'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py ============================= test session starts ============================= platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0 rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0 collected 1 itemtest1\test_01.py 調(diào)用了獲取token test_01-test1:5 .============================== 1 passed in 0.04s ==============================Process finished with exit code 0

?

?

總結(jié)

以上是生活随笔為你收集整理的Pytest脚本中运行用例方式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。