国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

這篇具有很好參考價值的文章主要介紹了全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。


前言

pytest配置文件可以改變pytest的運行方式,它是一個固定的文件pytest.ini文件,讀取配置信息,按指定的方式去運行

非test文件
pytest里面有些文件是非test文件
pytest.ini:pytest的主配置文件,可以改變pytest的默認行為
conftest.py:測試用例的一些fixture配置
init.py:識別該文件夾為python的package包

查看pytest.ini的配置選項
cmd執(zhí)行

pytest --help

找到這部分內(nèi)容

[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:

  markers (linelist):   markers for test functions
  empty_parameter_set_mark (string):
                        default marker for empty parametersets
  norecursedirs (args): directory patterns to avoid for recursion
  testpaths (args):     directories to search for tests when no files or directories are given in the command line.
  usefixtures (args):   list of default fixtures to be used with this project
  python_files (args):  glob-style file patterns for Python test module discovery
  python_classes (args):
                        prefixes or glob names for Python test class discovery
  python_functions (args):
                        prefixes or glob names for Python test function and method discovery
  disable_test_id_escaping_and_forfeit_all_rights_to_community_support (bool):
                        disable string escape non-ascii characters, might cause unwanted side effects(use at your own
                        risk)
  console_output_style (string):
                        console output: "classic", or with additional progress information ("progress" (percentage) |
                        "count").
  xfail_strict (bool):  default for the strict parameter of xfail markers when not given explicitly (default: False)
  enable_assertion_pass_hook (bool):
                        Enables the pytest_assertion_pass hook.Make sure to delete any previously generated pyc cache
                        files.
  junit_suite_name (string):
                        Test suite name for JUnit report
  junit_logging (string):
                        Write captured log messages to JUnit report: one of no|log|system-out|system-err|out-err|all
  junit_log_passing_tests (bool):
                        Capture log information for passing tests to JUnit report:
  junit_duration_report (string):
                        Duration time to report: one of total|call
  junit_family (string):
                        Emit XML for schema: one of legacy|xunit1|xunit2
  doctest_optionflags (args):
                        option flags for doctests
  doctest_encoding (string):
                        encoding used for doctest files
  cache_dir (string):   cache directory path.
  filterwarnings (linelist):
                        Each line specifies a pattern for warnings.filterwarnings. Processed after -W/--pythonwarnings.
  log_print (bool):     default value for --no-print-logs
  log_level (string):   default value for --log-level
  log_format (string):  default value for --log-format
  log_date_format (string):
                        default value for --log-date-format
  log_cli (bool):       enable log display during test run (also known as "live logging").
  log_cli_level (string):
                        default value for --log-cli-level
  log_cli_format (string):
                        default value for --log-cli-format
  log_cli_date_format (string):
                        default value for --log-cli-date-format
  log_file (string):    default value for --log-file
  log_file_level (string):
                        default value for --log-file-level
  log_file_format (string):
                        default value for --log-file-format
  log_file_date_format (string):
                        default value for --log-file-date-format
  log_auto_indent (string):
                        default value for --log-auto-indent
  faulthandler_timeout (string):
                        Dump the traceback of all threads if a test takes more than TIMEOUT seconds to finish. Not
                        available on Windows.
  addopts (args):       extra command line options
  minversion (string):  minimally required pytest version
  rsyncdirs (pathlist): list of (relative) paths to be rsynced for remote distributed testing.
  rsyncignore (pathlist):
                        list of (relative) glob-style paths to be ignored for rsyncing.
  looponfailroots (pathlist):
                        directories to check for changes

pytest.ini應該放哪里?
就放在項目根目錄下 ,不要亂放,不要亂起其他名字

常用的配置項

marks

作用:測試用例中添加了 @pytest.mark.webtest 裝飾器,如果不添加marks選項的話,就會報warnings

格式:list列表類型
寫法:

[pytest]
markers =
    weibo: this is weibo page
    toutiao: toutiao
    xinlang: xinlang

xfail_strict

作用:設置xfail_strict = True可以讓那些標記為@pytest.mark.xfail但實際通過顯示XPASS的測試用例被報告為失敗

格式:True 、False(默認),1、0

寫法:

[pytest]

# mark標記說明
markers =
    weibo: this is weibo page
    toutiao: toutiao
    xinlang: xinlang

xfail_strict = True

具體代碼例子
未設置 xfail_strict = True 時,測試結(jié)果顯示XPASS

@pytest.mark.xfail()
def test_case1():
    a = "a"
    b = "b"
    assert a != b
collecting ... collected 1 item

02斷言異常.py::test_case1 XPASS [100%]

============================= 1 xpassed in 0.02s ==============================

已設置 xfail_strict = True 時,測試結(jié)果顯示failed

collecting ... collected 1 item

02斷言異常.py::test_case1 FAILED                                         [100%]
02斷言異常.py:54 (test_case1)
[XPASS(strict)] 

================================== FAILURES ===================================
_________________________________ test_case1 __________________________________
[XPASS(strict)] 
=========================== short test summary info ===========================
FAILED 02斷言異常.py::test_case1
============================== 1 failed in 0.02s ==============================

addopts

作用:addopts參數(shù)可以更改默認命令行選項,這個當我們在cmd輸入一堆指令去執(zhí)行用例的時候,就可以用該參數(shù)代替了,省去重復性的敲命令工作

比如:想測試完生成報告,失敗重跑兩次,一共運行兩次,通過分布式去測試,如果在cmd中寫的話,命令會很長

pytest -v --rerun=2 --count=2 --html=report.html --self-contained-html -n=auto

每次都這樣敲不太現(xiàn)實,addopts就可以完美解決這個問題

[pytest]

# mark
markers =
    weibo: this is weibo page
    toutiao: toutiao
    xinlang: xinlang

xfail_strict = True

# 命令行參數(shù)
addopts = -v --reruns=1 --count=2 --html=reports.html --self-contained-html -n=auto

加了addopts之后,我們在cmd中只需要敲pytest就可以生效了。

norecursedirs

作用:pytest 收集測試用例時,會遞歸遍歷所有子目錄,包括某些你明知道沒必要遍歷的目錄,遇到這種情況,可以使用 norecursedirs 參數(shù)簡化 pytest 的搜索工作。

默認設置:

norecursedirs = .* build dist CVS _darcs {arch} *.egg 

正確寫法:多個路徑用空格隔開

[pytest]

norecursedirs = .* build dist CVS _darcs {arch} *.egg venv src resources log report util

更改測試用例收集規(guī)則:

pytest默認的測試用例收集規(guī)則
文件名以 test_*.py 文件和 *test.py
以 test
開頭的函數(shù)
以 Test 開頭的類,不能包含 init 方法
以 test_ 開頭的類里面的方法

我們是可以修改或者添加這個用例收集規(guī)則的;當然,是建議在原有的規(guī)則上添加的,如下配置

[pytest]

python_files =     test_*  *_test  test*
python_classes =   Test*   test*
python_functions = test_*  test*
下面是我整理的2023年最全的軟件測試工程師學習知識架構體系圖

一、Python編程入門到精通

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

二、接口自動化項目實戰(zhàn)

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

三、Web自動化項目實戰(zhàn)

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

四、App自動化項目實戰(zhàn)

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

五、一線大廠簡歷

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

六、測試開發(fā)DevOps體系

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

七、常用自動化測試工具

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

八、JMeter性能測試

全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))

九、總結(jié)(尾部小驚喜)

只有不斷超越自己的勇氣,才能在追逐夢想的路上綻放璀璨;只有堅持不懈的努力,才能創(chuàng)造屬于自己的輝煌。相信自己,擁抱每一次挑戰(zhàn),奮斗不止,未來必將壯麗!

只有經(jīng)歷風雨,才能見彩虹;只有磨礪自己,才能成鉆石。堅持奮斗,勇往直前,追逐夢想的旅程中,每一步都是成功的催化劑。相信自己,你可以戰(zhàn)勝一切困難,成就非凡的人生!

只有拼盡全力,才能看到未來的光芒;只有堅持不懈,才能抵達成功的彼岸;只有敢于奮斗,才能創(chuàng)造出自己的輝煌。相信自己,勇往直前,你就是無敵的!文章來源地址http://www.zghlxwxcb.cn/news/detail-511711.html

到了這里,關于全網(wǎng)超全,pytest自動化測試框架pytest.ini配置文件詳細(實戰(zhàn))的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 自動化測試(三):接口自動化pytest測試框架

    自動化測試(三):接口自動化pytest測試框架

    API:Application Programming Interface 接口自動化按照自動化的工具可分為 基于 接口測試工具 的接口自動化 eg1:Postman+Newman+git/Svn+Jenkins(基于Javascript語言)接口自動化 Postman :創(chuàng)建和發(fā)送 API 請求,并對響應進行斷言和驗證。 Newman : Postman 的命令行工具,它允許測試人員在沒有界

    2024年02月10日
    瀏覽(94)
  • Pytest自動化測試框架---(單元測試框架)

    Pytest自動化測試框架---(單元測試框架)

    unittest是python自帶的單元測試框架,它封裝好了一些校驗返回的結(jié)果方法和一些用例執(zhí)行前的初始化操作,使得單元測試易于開展,因為它的易用性,很多同學也拿它來做功能測試和接口測試,只需簡單開發(fā)一些功能(報告,初始化webdriver,或者http請求方法)便可實現(xiàn)。 但自

    2024年02月14日
    瀏覽(120)
  • pytest 框架自動化測試

    pytest 框架自動化測試

    隨筆記錄 目錄 1. 安裝? 2. 安裝pytest 相關插件 2.1 準備階段 2.2 安裝? 2.3 驗證安裝成功? 3. pytest測試用例的運行方式 3.1 主函數(shù)模式 3.1.1 主函數(shù)執(zhí)行指定文件 ?3.1.2?主函數(shù)執(zhí)行指定模塊 3.1.3 主函數(shù)執(zhí)行某個文件中的某個類、方法、函數(shù) 3.1.4?主函數(shù)執(zhí)行生成allure報告 3.2 命令

    2024年02月19日
    瀏覽(98)
  • 從0到1精通自動化測試,pytest自動化測試框架,doctest測試框架(十四)

    從0到1精通自動化測試,pytest自動化測試框架,doctest測試框架(十四)

    doctest從字面意思上看,那就是文檔測試。doctest是python里面自帶的一個模塊,它實際上是單元測試的一種。 官方解釋:doctest 模塊會搜索那些看起來像交互式會話的 Python 代碼片段,然后嘗試執(zhí)行并驗證結(jié)果 doctest測試用例可以放在兩個地方 函數(shù)或者方法下的注釋里面 模塊的

    2024年02月11日
    瀏覽(91)
  • 全網(wǎng)最強,Python+Appium+pytest自動化測試,多設備并發(fā)+多線程(實戰(zhàn)詳細)

    全網(wǎng)最強,Python+Appium+pytest自動化測試,多設備并發(fā)+多線程(實戰(zhàn)詳細)

    Appium+python 實現(xiàn)單設備的 app 自動化測試 啟動 appium server,占用端口 4723; 電腦與一個設備連接,通過 adb devices 獲取已連接的設備; 在 python 代碼當中,編寫啟動參數(shù),通過 pytest 編寫測試用例,來進行自動化測試。 若要多設備并發(fā),同時執(zhí)行自動化測試 需要: 確定設備個數(shù)

    2024年02月02日
    瀏覽(20)
  • 自動化測試框架 —— pytest框架入門篇

    今天就給大家說一說pytest框架。 今天這篇文章呢,會從以下幾個方面來介紹: 1、首先介紹一下pytest框架 2、帶大家安裝Pytest框架 3、使用pytest框架時需要注意的點 4、pytest的運行方式 5、pytest框架中常用的插件 pytest 是 python 的第三方單元測試框架,比自帶 unittest 更簡潔和高效

    2024年02月03日
    瀏覽(97)
  • pytest接口測試自動化框架

    目錄 pytest簡介及安裝 pytest的使用規(guī)則 pytest運行方式 主函數(shù)方式 命令行方式 跳過、標記及預期失敗特殊場景處理 pytest前后置、夾具 pytest高級用法fixture pytest接口斷言 pytest結(jié)合allure-pytest生成allure測試報告 ????????談起用例管理框架:python中的unittest、pytest;java中的test

    2024年02月06日
    瀏覽(101)
  • 【自動化測試教程】 —— pytest 框架詳解 ~

    【自動化測試教程】 —— pytest 框架詳解 ~

    特點: 容易上手, 入門簡單, 文檔豐富, 文檔中有很多參考案例 支持簡單的單元測試和復雜的功能測試 支持參數(shù)化 執(zhí)行測試用例過程中, 支持跳過操作 支持重復失敗的case 支持運行Nose, unittest編寫測試用例 pytest支持很多第三方插件 方便和持續(xù)集成工具集成 斷言方法: assert res

    2024年02月12日
    瀏覽(104)
  • Selenium+Pytest自動化測試框架

    Selenium+Pytest自動化測試框架

    selenium自動化+ pytest測試框架 本章你需要 一定的python基礎——至少明白類與對象,封裝繼承 一定的selenium基礎——本篇不講selenium,不會的可以自己去看selenium中文翻譯網(wǎng) 測試框架有什么優(yōu)點呢: 代碼復用率高,如果不使用框架的話,代碼會很冗余 可以組裝日志、報告、郵件

    2024年02月07日
    瀏覽(87)
  • Selenium+Pytest自動化測試框架詳解

    Selenium+Pytest自動化測試框架詳解

    selenium自動化+ pytest測試框架 本章你需要 一定的python基礎——至少明白類與對象,封裝繼承; 一定的selenium基礎——本篇不講selenium,不會的可以自己去看selenium中文翻譯網(wǎng) 測試框架有什么優(yōu)點 代碼復用率高,如果不使用框架的話,代碼會很冗余 可以組裝日志、報告、郵件等

    2024年02月08日
    瀏覽(25)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包