pytest框架的allure报告怎么去看
pytest框架的allure报告怎么去看
一、安装jdk和allure
1.1安装jdk(自行找资料)
1.2安装Allure
https://blog.csdn.net/m0_72252544/article/details/140682247
二、编写pytest代码
import pytest
import allure
# Simulated login function
def login(username, password):
# Predefined username and password for testing
valid_username = "test_user"
valid_password = "password123"
# Check if the provided credentials match the valid ones
return username == valid_username and password == valid_password
@allure.feature('用户功能')
@allure.story('登录')
@allure.title('成功登录测试')
def test_login_success():
username = "test_user"
password = "password123"
# Call the login function to check for successful login
assert login(username, password) == True
@allure.feature('用户功能')
@allure.story('登录')
@allure.title('失败登录测试')
def test_login_failure():
username = "test_user"
password = "wrong_password"
# Call the login function to check for failed login
assert login(username, password) == False
三、执行脚本
3.1 运行测试并生成 Allure 结果
pytest --alluredir=allure-results
执行成功后,会有想过的json和txt内容
3.2 你可以使用以下命令来查看生成的报告
allure serve D:\python_test\pythonProject\allure-results
#执行是在win+dos下,必须要java和allure安装成功
3.3生成的视图
原文地址:https://blog.csdn.net/weixin_41665637/article/details/143077215
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!