1、生成测试用例
- 生成json用例【默认生成】:
hrp convert xxx.har
orhrp convert xxx.har --to-json
- 生成pytest用例:
hrp convert xxx.har --to-pytest
- 生成yaml用例:
hrp convert xxx.har --to-yaml
- 生成gotest用例【待实现】:
hrp convert xxx.har --to-gotest
2、生成测试用例 + 指定用例的路径 + pytest格式的测试用例
hrp convert add_case.har --to-pytest --output-dir ../testcases/project1
- –to-pytest:生成pytest格式测试用例
- –output-dir:生成的测试用例放在哪里
3、生成测试用例 + 指定用例的header + 指定用例的路径
(1)替换header和cookie中某个字段的值,用yaml中的内容
hrp convert add_case.har --to-pytest --output-dir ../testcases/project1 --profile ../profile/profile.yaml
- –profile …/profile/profile.yaml:使用
profile.yaml
中的header
信息替换生成的测试用例中整个header
# profile.yaml
headers:
token: "this header will be created or updated"
cookies:
Cookie1: "this cookie will be created or updated"
(2)覆盖header和cookie的内容,用yaml中的内容
hrp convert add_case.har --to-pytest --output-dir ../testcases/project1 --profile ../profile/profile_override.yaml
- –profile …/profile/profile_override.yaml: 只会替换pytest格式用例中header某个字段的值
# profile_override.yaml
override: true
headers:
accept-language: "this header will be created or updated"
cookies:
Cookie1: "this cookie will be created or updated"