HttpRunner 项目使用教程
1. 项目的目录结构及介绍
HttpRunner 项目的目录结构如下:
httprunner/
├── docs/
├── examples/
├── hrps/
├── scripts/
├── .gitignore
├── Dockerfile
├── LICENSE
├── Makefile
├── README.en.md
├── README.md
├── go.mod
├── go.sum
├── poetry.lock
├── pyproject.toml
目录介绍
- docs/: 包含项目的文档文件。
- examples/: 包含示例测试用例。
- hrps/: 包含核心的测试引擎代码。
- scripts/: 包含一些辅助脚本。
- .gitignore: Git 忽略文件配置。
- Dockerfile: Docker 镜像构建文件。
- LICENSE: 项目许可证文件。
- Makefile: 用于构建和测试的 Makefile。
- README.en.md: 英文版的项目介绍文档。
- README.md: 中文版的项目介绍文档。
- go.mod: Go 模块文件。
- go.sum: Go 模块依赖校验文件。
- poetry.lock: Python 依赖锁定文件。
- pyproject.toml: Python 项目配置文件。
2. 项目的启动文件介绍
HttpRunner 项目的启动文件是 hrp
命令行工具。可以通过以下命令启动:
hrp [command]
可用命令
- adb: 简单的 Android 设备管理工具。
- boom: 使用 Boomer 运行负载测试。
- build: 构建测试插件。
- completion: 生成自动补全脚本。
- convert: 将多种源格式转换为 HttpRunner JSON/YAML/gotest/pytest 用例。
- help: 帮助信息。
- ios: 简单的 iOS 设备管理工具。
- pytest: 使用 pytest 运行 API 测试。
- run: 使用 Go 引擎运行 API 测试。
3. 项目的配置文件介绍
HttpRunner 项目的配置文件主要是 pyproject.toml
和 go.mod
。
pyproject.toml
pyproject.toml
是 Python 项目的配置文件,包含项目的基本信息和依赖管理。
[tool.poetry]
name = "httprunner"
version = "3.x.x"
description = "HttpRunner is an open-source API testing tool."
authors = ["debugtalk <debugtalk@example.com>"]
license = "Apache-2.0"
[tool.poetry.dependencies]
python = "^3.6"
requests = "^2.25.1"
PyYAML = "^5.4.1"
...
[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
...
go.mod
go.mod
是 Go 模块文件,定义了项目的 Go 依赖。
module github.com/httprunner/httprunner
go 1.16
require (
github.com/stretchr/testify v1.7.0
...
)
通过这些配置文件,可以管理和构建 HttpRunner 项目。