import
pytest
import
allure
class
Test_all():
@allure
.step(title
=
"allure通過注解方式完成內容的展示,setp表示測試步驟1..."
)
def
test_setup(
self
):
print
(
"我就是打醬油的setup"
)
@allure
.step(title
=
"run就是一個正常的方法."
)
def
test_run(
self
):
allure.attach(
"自定義描述1"
,
"描述內容,自定義"
)
print
(
"我要運行"
)
assert
True
def
test_skip(
self
):
print
(
"我要跳過"
)
@allure
.severity(allure.severity_level.BLOCKER)
#嚴重級別
@allure
.testcase(
"http://www.baidu.com/"
,
"測試用例的地址"
)
@allure
.issue(
"http://music.migu.cn/v3/music/player/audio"
,
"點擊可跳轉到bug地址"
)
def
test_error(
self
):
with allure.attach(
"自定義描述1"
,
"我需要讓他進行錯誤"
):
print
(
"我錯誤了"
)
assert
False

運行命令方式
使用cmd運行,或者使用pycharm運行都是可以的,以下我使用pycharm的環境運行
1.進入運行項目的目錄下 執行命令 pytest 運行的py文件
2.上圖有一個F就是表示有錯誤日志,執行完后,就會直接打印到了屏幕上
3.我們使用命令生成報告
4.在我進入的目錄中就可以看到生成了文件