针对api服务,http、gRPC的自动化测试框架
- 无需进行程序开发,只需要编写配置文件
- 可以指定testcase之间的依赖关系
- 无依赖关系的testcase可以并发执行,执行速度更快
- 使用XPath提取变量,书写方便
- 支持从文件中导入变量,支持从response中提取变量
从上面的链接获取对应操作系统和cpu架构的bin文件
make build
或
go install github.com/vearne/autotest@latest
autotest test --config-file=${CONFIG_FILE}
autotest run --config-file=${CONFIG_FILE} --env-file=${ENV_FILE}
autotest extract --xpath=${XPATH} --json=${JSON}
cd ./docker-compose
docker compose up -d
curl -X POST 'http://localhost:8080/api/books' \
--header 'Content-Type: application/json' \
--data '{"title": "book3_title", "author": "book3_author"}'
curl -X DELETE 'http://localhost:8080/api/books/1'
curl -X PUT 'localhost:8080/api/books/3' \
--header 'Content-Type: application/json' \
--data '{"title": "book3_title", "author": "book3_author-2"}'
curl 'http://localhost:8080/api/books'
autotest run -c=./config_files/autotest.yml -e=./config_files/.env.dev
获取书本列表中,书的title
autotest extract -x "//title" -j '[
{
"id": 2,
"title": "Effective Go",
"author": "The Go Authors"
},
{
"id": 3,
"title": "book3_title",
"author": "book3_author-2"
}
]'
- 1) 支持使用脚本语言Lua判断HTTP response是否符合预期
- 2) 输出report到文件中
- 3) 支持对gRPC协议的API服务进行自动化测试