python系列之初探Pytest(3) 測試報告

2021-10-09 09:06:33 字數 2050 閱讀 8162

​   測試報告的展現形式,對於後期自動化回歸測試分析還是很有用的。unittest有htmltestrunner外掛程式,同樣的pytest也有第三方外掛程式pytest-html。

安裝:

pip install pytest-html
使用pytest 模組名 --html=測試報告名稱(預設當前路徑,也可以指定路徑)

這裡要注意是「--」

示例:

pytest test_pytestdemo.py -m l1 -s --html=test.html
測試結果展示:

這裡會標記出具體哪一行**報錯的。

其他形式的測試結果輸出

輸入到指定檔案

pytest 模組名 --result-log=檔名

會自動把測試結果日誌輸出到檔案中。

示例:

pytest test_pytestdemo.py -m l1 -s --result-log=test.txt
生成junitxml檔案

pytest 模組名 --junit-xml=檔名.xml

pytest test_pytestdemo.py -m l1 -s --junit-xml=test.xml
示例**:

import pytest@pytest.mark.l1class testdemoaaaa:def test_demoa1(self):print("this is a pytest demo a11111111111")assert truedef test_demoa2(self):print("this is a pytest demo a222222222222")assert truedef test_demoa3(self):print("this is a pytest demo a33333333333")assert false@pytest.mark.l2class testdemobbbb:def test_demob1(self):print("this is a pytest demo b111111111")assert truedef test_demob2(self):print("this is a pytest demo b222222")assert truedef test_demob3(self):print("this is a pytest demo b33333")assert true@pytest.mark.l3def test_demob3():print("this is a pytest demo b33333")assert trueif __name__ == '__main__':pytest.main([("test_pytestdemo.py"),("-s")])
-------------------------------------最後---------------------------------

研磨Kafka之初探

kafka是乙個基於發布 訂閱模式的分布式訊息佇列。1 點對點模式 一對一,消費者主動拉取資料,訊息收到後訊息清除 2 發布 訂閱模式 一對多,消費者消費資料之後不會清除訊息 kafka是屬於發布 訂閱模式的拉取模式 發布 訂閱有兩種資料消費模式 push pull 模式 1 producer 訊息...

CoAP協議之初探(一)

coap 是乙個基於 rest 模型的網路傳輸協議。主要用於輕量級 m2m 通訊。由於物聯網中的很多裝置都是資源受限型的,即只有少量的記憶體空間和有限的計算能力,所以傳統的 http 協議應用在物聯網上就顯得過於龐大而不適用,coap 應運而生。本文介紹物聯網平台支援的coap協議規範 1.概念 2...

C 中文分詞之初探

簡單介紹一下分詞的技術相關的演算法以及對此幾種演算法的比較,最後用其中一種演算法實現乙個中文分詞的小程式。中文分詞的演算法 中文分詞技術發展到今天概括起來可以歸為三類 基於匹配的分詞 基於統計的分詞和基於理解的分詞。a.基於匹配的分詞方法 由於該分詞方法自動化程度較高,因此又常被稱為機械分詞法。該方...