pytest Framework_pytest.ini

pytest.ini
(1)定義
はpytestユニットテストフレームワークの構成ファイルであり、実行モードの変更などの機能を実装します
(2)場所は
プロジェクトのルートディレクトリにあります
(3)使用法
ここに画像の説明を挿入します

[pytest]
addopts = -vs --html D:/se_frame/Reports/report.html
testpaths = D:/se_frame/TestCases
python_files = test*
python_classes = Test*
python_functions = test*
markers =
    smoke
    usermange
    product

このパスは絶対パスである必要があります。そうでない場合、生成されたテストレポートパスに問題が発生します
。addopts:pytest.main()の実行時に一般的に使用されるいくつかの関数を追加しました
。testpaths:D:\ se_frame \ TestCasesのテストケースを
特定します。python_files:TestCasesを特定します。ディレクトリ
testpython_classesで始まる次のファイル:Test
python_functionsで始まるクラスを識別するため
テストマーカーで始まるメソッドを識別するため:主に@ pytest.mark.xxxテストケースを分類するために使用されます。たとえば、最初のものは喫煙のユースケースです

一般的な機能は次のとおりです。

    """
    pytest参数详解:
    -s 表示输出陶氏信息,包括print打印的信息
    -v 表示更相信的信息
    -vs 一般一起用
    -n 支持分布式运行测试用例
    -k 根据用例的部分字符串指定测试用例
    --html 路径 生成测试报告
    """

実用例:
-vsを使用しないpytest.iniの出力:

collected 13 items

test_1.py ..........Xs.                                                  [100%]

- generated html file: file://D:\se_frame\Cases\MapAaaCases\Reports\report.html -
================== 11 passed, 1 skipped, 1 xpassed in 0.33s ===================

-vsを使用したpytest.iniの出力:

collected 13 items

test_1.py::Testlogin001::test_case_12 
启动浏览器
---进入要执行模块的的界面---
---3号用例完成---
---4号用例完成---
---5号用例完成---
---12号用例完成---
XPASS (该功能尚未完善,还在调测中)
退出浏览器

test_1.py::Testlogin001::test_case_13 SKIPPED (test_case_13用例还在...)
test_1.py::Testlogin2::test_case_14 
启动浏览器
---进入要执行模块的的界面---
---14号用例完成---
PASSED
退出浏览器

- generated html file: file://D:\se_frame\Cases\MapAaaCases\Reports\report.html -
================== 11 passed, 1 skipped, 1 xpassed in 0.13s ===================

おすすめ

転載: blog.csdn.net/weixin_45451320/article/details/113916427