badge_svr_test.py 执行命令
项目根目录:D:\study\project\hiyoo\chatchillgrpc
1. 首次运行(安装依赖)
Set-Location "D:\study\project\hiyoo\chatchillgrpc"
py -3.10 -m pip install -r ProjectPackage/requirements.txt
2. 运行全部用例(推荐)
Set-Location "D:\study\project\hiyoo\chatchillgrpc"
py -3.10 -m pytest testcases/user_svr/badge_svr_test.py -v
3. 运行单个用例
# 获取已获得勋章列表
py -3.10 -m pytest testcases/user_svr/badge_svr_test.py::TestBadge::test_get_obtained_list -v
# 获取佩戴的勋章列表
py -3.10 -m pytest testcases/user_svr/badge_svr_test.py::TestBadge::test_get_wear_list -v
4. 显示 print 输出
py -3.10 -m pytest testcases/user_svr/badge_svr_test.py -v -s
5. 生成 Allure 报告
py -3.10 -m pytest testcases/user_svr/badge_svr_test.py -v --alluredir=report/allure-results
allure serve report/allure-results
说明
- 必须在项目根目录执行,保证
BaseApi、Case等模块能正确导入 - 建议使用
py -3.10;若已配置好虚拟环境,也可直接用pytest

image.png