第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何使用 pytest-html 將測試步驟寫入生成的 html 報(bào)告?

如何使用 pytest-html 將測試步驟寫入生成的 html 報(bào)告?

忽然笑 2021-09-24 15:11:40
我找不到將字符串添加到代表我的測試步驟的 HTML 報(bào)告的方法。我在https://pypi.org/project/pytest-html/ 看到我應(yīng)該嘗試:extra.text('Add some simple Text')但似乎它不起作用。from pytest_html import extrasclass FirstFeatureTests:    def setup_class(self):        print("\n------------ in setup_class ------------")    def teardown_class(self):        print("------------ in teardown_class ------------")    @mark.example    def test_1_first_feature(self):        print("starting test !!!!!")        extras.text("step 1: ")        extras.text('step 2: ')        assert True我希望每個(gè)測試都包含表示為帶有信息描述的字符串的測試步驟。有什么辦法嗎?
查看完整描述

2 回答

?
泛舟湖上清波郎朗

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊

Allure 當(dāng)然更適合您的需求,因?yàn)樗哂?pytest 的所有測試報(bào)告功能(步驟、功能、故事等)。但它是用 java 編寫的,您需要在本地安裝 pytest allure 以及 allure 二進(jìn)制文件才能使其工作。而且您可能需要跳幾下才能使其在您現(xiàn)有的 pytest 代碼庫中工作。


如果您想使用 pytest-html 生成測試步驟,這是一個(gè)可能的解決方案:


# Contents of top level conftest.py

import pytest


@pytest.fixture(scope='session', autouse=True)

def step(request):

    @pytest.mark.optionalhook

    def pytest_html_results_table_html(request, report, data):

        data.append(html.div(str(request.param), class_='Step'))


#Contents of fixture or test code

def test_a(step):

    step("abc")

    assert True

我沒有在本地運(yùn)行代碼,但這就是添加步驟的最終代碼應(yīng)該是什么樣子。


查看完整回答
反對(duì) 回復(fù) 2021-09-24
?
寶慕林4294392

TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊

在這種情況下,我建議您嘗試allure而不是 pytest-html 。它很容易與 pytest 集成,而且 api 使用起來非常舒服。

查看此存儲(chǔ)庫以獲取更多信息。

這一個(gè)是使用示例。


查看完整回答
反對(duì) 回復(fù) 2021-09-24
  • 2 回答
  • 0 關(guān)注
  • 472 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)