From 30f0e0fe3ba449b63d110fcd3688f82944991869 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 6 Dec 2021 21:21:40 +0800 Subject: [PATCH] change: remove mkdocs, move to httprunner/httprunner.github.io --- .github/workflows/deploy-mkdocs.yml | 25 --- .github/workflows/release.yml | 2 +- README.md | 270 +++++++++++++++++++++++++++ docs/CHANGELOG.md | 4 + docs/README.md | 275 +--------------------------- docs/boomer.md | 67 ------- docs/installation.md | 50 ----- docs/sponsors.md | 26 --- mkdocs.yml | 67 ------- 9 files changed, 283 insertions(+), 503 deletions(-) delete mode 100644 .github/workflows/deploy-mkdocs.yml create mode 100644 README.md delete mode 100644 docs/boomer.md delete mode 100644 docs/installation.md delete mode 100644 docs/sponsors.md delete mode 100644 mkdocs.yml diff --git a/.github/workflows/deploy-mkdocs.yml b/.github/workflows/deploy-mkdocs.yml deleted file mode 100644 index bc81558..0000000 --- a/.github/workflows/deploy-mkdocs.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Deploy docs to GitHub Pages - -on: - pull_request: - branches: [main] - types: [closed] - -jobs: - deploy: - name: Deploy docs to GitHub Pages - if: ${{ github.event.pull_request.merged }} # true - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Setup python3 env - uses: actions/setup-python@v2 - with: - python-version: 3.x - - name: Install mkdocs and material design - run: pip install mkdocs-material # including mkdocs - - name: Update hrp cli docs - run: go test docs/cmd/doc_test.go # update hrp cli docs - - name: Deploy docs to github pages - run: mkdocs gh-deploy --force diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26a2e0d..0bc75d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,4 +28,4 @@ jobs: project_path: "./hrp" # go build ./hrp/main.go binary_name: "hrp" ldflags: "-s -w" - extra_files: LICENSE docs/README.md docs/CHANGELOG.md + extra_files: LICENSE README.md docs/CHANGELOG.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..7370fe5 --- /dev/null +++ b/README.md @@ -0,0 +1,270 @@ +# hrp (HttpRunner+) + +[![Go Reference](https://pkg.go.dev/badge/github.com/httprunner/hrp.svg)](https://pkg.go.dev/github.com/httprunner/hrp) +[![Github Actions](https://github.com/httprunner/hrp/actions/workflows/unittest.yml/badge.svg)](https://github.com/httprunner/hrp/actions) +[![codecov](https://codecov.io/gh/httprunner/hrp/branch/main/graph/badge.svg?token=HPCQWCD7KO)](https://codecov.io/gh/httprunner/hrp) +[![Go Report Card](https://goreportcard.com/badge/github.com/httprunner/hrp)](https://goreportcard.com/report/github.com/httprunner/hrp) +[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B27856%2Fgithub.com%2Fhttprunner%2Fhrp.svg?type=shield)](https://app.fossa.com/reports/c2742455-c8ab-4b13-8fd7-4a35ba0b2840) + +`hrp` is a golang implementation of [HttpRunner]. Ideally, hrp will be fully compatible with HttpRunner, including testcase format and usage. What's more, hrp will integrate Boomer natively to be a better load generator for [locust]. + +## Key Features + +![flow chart](docs/assets/flow.jpg) + +- [x] Full support for HTTP(S) requests, more protocols are also in the plan. +- [x] Testcases can be described in multiple formats, `YAML`/`JSON`/`Golang`, and they are interchangeable. +- [x] With [`HAR`][HAR] support, you can use Charles/Fiddler/Chrome/etc as a script recording generator. +- [x] Supports `variables`/`extract`/`validate`/`hooks` mechanisms to create extremely complex test scenarios. +- [ ] Built-in integration of rich functions, and you can also use [`go plugin`][plugin] to create and call custom functions. +- [x] Inherit all powerful features of [`Boomer`][Boomer] and [`locust`][locust], you can run `load test` without extra work. +- [x] Use it as a `CLI tool` or as a `library` are both supported. + +See [CHANGELOG]. + +## Quick Start + +### use as CLI tool + +```bash +$ go get -u github.com/httprunner/hrp/hrp +``` + +Since installed, you will get a `hrp` command with multiple sub-commands. + +```text +$ hrp -h +hrp (HttpRunner+) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ + +License: Apache-2.0 +Github: https://github.com/httprunner/hrp +Copyright 2021 debugtalk + +Usage: + hrp [command] + +Available Commands: + boom run load test with boomer + completion generate the autocompletion script for the specified shell + har2case Convert HAR to json/yaml testcase files + help Help about any command + run run API test + +Flags: + -h, --help help for hrp + --log-json set log to json format + -l, --log-level string set log level (default "INFO") + -v, --version version for hrp + +Use "hrp [command] --help" for more information about a command. +``` + +You can use `hrp run` command to run HttpRunner JSON/YAML testcases. The following is an example running [examples/demo.json][demo.json] + +
+$ hrp run examples/demo.json + +```text +8:04PM INF Set log to pretty console +8:04PM INF Set log level to INFO +8:04PM INF [init] SetDebug debug=true +8:04PM INF load json testcase path=/Users/debugtalk/MyProjects/HttpRunner-dev/hrp/examples/demo.json +8:04PM INF call function success arguments=[5] funcName=gen_random_string output=B64R8 +8:04PM INF call function success arguments=[12.3,3.45] funcName=max output=12.3 +8:04PM INF run testcase start testcase="demo with complex mechanisms" +8:04PM INF call function success arguments=[12.3,34.5] funcName=max output=34.5 +8:04PM INF run step start step="get with params" +-------------------- request -------------------- +GET /get?foo1=B64R8&foo2=34.5 HTTP/1.1 +Host: postman-echo.com +User-Agent: HttpRunnerPlus + + +==================== response =================== +HTTP/1.1 200 OK +Content-Length: 304 +Connection: keep-alive +Content-Type: application/json; charset=utf-8 +Date: Thu, 11 Nov 2021 12:04:32 GMT +Etag: W/"130-LUQ0LVU7KVSZha0O3nQxqPlr5dw" +Set-Cookie: sails.sid=s%3Ag6vZXrHHzs-B7Q1bFrYQq83dUje_EkSu.06vsqbkZvIOJ6mb1It7c6i354e%2B0t91K4cG14YFjSX0; Path=/; HttpOnly +Vary: Accept-Encoding + +{"args":{"foo1":"B64R8","foo2":"34.5"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-618d06d0-7516144f65e561a8238adab5","user-agent":"HttpRunnerPlus","accept-encoding":"gzip"},"url":"https://postman-echo.com/get?foo1=B64R8&foo2=34.5"} +-------------------------------------------------- +8:04PM INF extract value from=body.args.foo1 value=B64R8 +8:04PM INF set variable value=B64R8 variable=varFoo1 +8:04PM INF validate status_code assertMethod=equals checkValue=200 expectValue=200 result=true +8:04PM INF validate headers."Content-Type" assertMethod=startswith checkValue="application/json; charset=utf-8" expectValue=application/json result=true +8:04PM INF validate body.args.foo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true +8:04PM INF validate $varFoo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true +8:04PM INF validate body.args.foo2 assertMethod=equals checkValue=34.5 expectValue=34.5 result=true +8:04PM INF run step end exportVars={"varFoo1":"B64R8"} step="get with params" success=true +8:04PM INF run step start step="post json data" +8:04PM INF call function success arguments=[12.3,3.45] funcName=max output=12.3 +-------------------- request -------------------- +POST /post HTTP/1.1 +Host: postman-echo.com +Content-Type: application/json; charset=UTF-8 + +{"foo1":"B64R8","foo2":12.3} +==================== response =================== +HTTP/1.1 200 OK +Content-Length: 424 +Connection: keep-alive +Content-Type: application/json; charset=utf-8 +Date: Thu, 11 Nov 2021 12:04:32 GMT +Etag: W/"1a8-1umvYElau4WkHR7VON+jKXozT2c" +Set-Cookie: sails.sid=s%3AeNnS5IE6TBePzx95OfuwyIweJy5aExb0.7MH6Vb42vbZ6OhNT2nhQGcAmHgqcFmtM8X03Qsoxa1k; Path=/; HttpOnly +Vary: Accept-Encoding + +{"args":{},"data":{"foo1":"B64R8","foo2":12.3},"files":{},"form":{},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-618d06d0-360475ad34903a97191978d7","content-length":"28","user-agent":"Go-http-client/1.1","content-type":"application/json; charset=UTF-8","accept-encoding":"gzip"},"json":{"foo1":"B64R8","foo2":12.3},"url":"https://postman-echo.com/post"} +-------------------------------------------------- +8:04PM INF validate status_code assertMethod=equals checkValue=200 expectValue=200 result=true +8:04PM INF validate body.json.foo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true +8:04PM INF validate body.json.foo2 assertMethod=equals checkValue=12.3 expectValue=12.3 result=true +8:04PM INF run step end exportVars=null step="post json data" success=true +8:04PM INF run step start step="post form data" +8:04PM INF call function success arguments=[12.3,3.45] funcName=max output=12.3 +-------------------- request -------------------- +POST /post HTTP/1.1 +Host: postman-echo.com +Content-Type: application/x-www-form-urlencoded; charset=UTF-8 + +foo1=B64R8&foo2=12.3 +==================== response =================== +HTTP/1.1 200 OK +Content-Length: 445 +Connection: keep-alive +Content-Type: application/json; charset=utf-8 +Date: Thu, 11 Nov 2021 12:04:32 GMT +Etag: W/"1bd-g/z+op+J2/U1DlrEv2g2VhZ0on4" +Set-Cookie: sails.sid=s%3ALfq9XEgKVT4dKQ8PnxUJ9-WSq4wI96Po.2P90TP9V2Pje3GNJ1hJmLcRRgcQy%2FDwBPF63Xdvdq4o; Path=/; HttpOnly +Vary: Accept-Encoding + +{"args":{},"data":"","files":{},"form":{"foo1":"B64R8","foo2":"12.3"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-618d06d0-56d250242bf05b7144edf2cb","content-length":"20","user-agent":"Go-http-client/1.1","content-type":"application/x-www-form-urlencoded; charset=UTF-8","accept-encoding":"gzip"},"json":{"foo1":"B64R8","foo2":"12.3"},"url":"https://postman-echo.com/post"} +-------------------------------------------------- +8:04PM INF validate status_code assertMethod=equals checkValue=200 expectValue=200 result=true +8:04PM INF validate body.form.foo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true +8:04PM INF validate body.form.foo2 assertMethod=equals checkValue=12.3 expectValue=12.3 result=true +8:04PM INF run step end exportVars=null step="post form data" success=true +8:04PM INF run testcase end testcase="demo with complex mechanisms" +``` +
+ +### use as library + +Beside using `hrp` as a CLI tool, you can also use it as golang library. + +```bash +$ go get -u github.com/httprunner/hrp +``` + +This is an example of `HttpRunner+` testcase. You can find more in the [`examples`][examples] directory. + + +
+demo + +```go +import ( + "testing" + + "github.com/httprunner/hrp" +) + +func TestCaseDemo(t *testing.T) { + demoTestCase := &hrp.TestCase{ + Config: hrp.TConfig{ + Name: "demo with complex mechanisms", + BaseURL: "https://postman-echo.com", + Variables: map[string]interface{}{ // global level variables + "n": 5, + "a": 12.3, + "b": 3.45, + "varFoo1": "${gen_random_string($n)}", + "varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function + }, + }, + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). + WithVariables(map[string]interface{}{ // step level variables + "n": 3, // inherit config level variables if not set in step level, a/varFoo1 + "b": 34.5, // override config level variable if existed, n/b/varFoo2 + "varFoo2": "${max($a, $b)}", // 34.5; override variable b and eval again + }). + GET("/get"). + WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers + Extract(). + WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath + Validate(). + AssertEqual("status_code", 200, "check response status code"). // validate response status code + AssertStartsWith("headers.\"Content-Type\"", "application/json", ""). // validate response header + AssertLengthEqual("body.args.foo1", 5, "check args foo1"). // validate response body with jmespath + AssertLengthEqual("$varFoo1", 5, "check args foo1"). // assert with extracted variable from current step + AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string + hrp.Step("post json data"). + POST("/post"). + WithBody(map[string]interface{}{ + "foo1": "$varFoo1", // reference former extracted variable + "foo2": "${max($a, $b)}", // 12.3; step level variables are independent, variable b is 3.45 here + }). + Validate(). + AssertEqual("status_code", 200, "check status code"). + AssertLengthEqual("body.json.foo1", 5, "check args foo1"). + AssertEqual("body.json.foo2", 12.3, "check args foo2"), + hrp.Step("post form data"). + POST("/post"). + WithHeaders(map[string]string{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}). + WithBody(map[string]interface{}{ + "foo1": "$varFoo1", // reference former extracted variable + "foo2": "${max($a, $b)}", // 12.3; step level variables are independent, variable b is 3.45 here + }). + Validate(). + AssertEqual("status_code", 200, "check status code"). + AssertLengthEqual("body.form.foo1", 5, "check args foo1"). + AssertEqual("body.form.foo2", "12.3", "check args foo2"), // form data will be converted to string + }, + } + + err := hrp.NewRunner(nil).Run(demoTestCase) // hrp.Run(demoTestCase) + if err != nil { + t.Fatalf("run testcase error: %v", err) + } +} +``` +
+ +## Sponsors + +Thank you to all our sponsors! ✨🍰✨ ([become a sponsor](sponsors.md)) + +### Gold Sponsor + +[霍格沃兹测试开发学社](https://ceshiren.com/) + +> [霍格沃兹测试开发学社](http://qrcode.testing-studio.com/f?from=httprunner&url=https://ceshiren.com)是业界领先的测试开发技术高端教育品牌,隶属于[测吧(北京)科技有限公司](http://qrcode.testing-studio.com/f?from=httprunner&url=https://www.testing-studio.com) 。学院课程由一线大厂测试经理与资深测试开发专家参与研发,实战驱动。课程涵盖 web/app 自动化测试、接口测试、性能测试、安全测试、持续集成/持续交付/DevOps,测试左移&右移、精准测试、测试平台开发、测试管理等内容,帮助测试工程师实现测试开发技术转型。通过优秀的学社制度(奖学金、内推返学费、行业竞赛等多种方式)来实现学员、学社及用人企业的三方共赢。 + +> [进入测试开发技术能力测评!](http://qrcode.testing-studio.com/f?from=httprunner&url=https://ceshiren.com/t/topic/14940) + +### Open Source Sponsor + +[Sentry](https://sentry.io/_/open-source/) + +## Subscribe + +关注 HttpRunner 的微信公众号,第一时间获得最新资讯。 + +HttpRunner + +[HttpRunner]: https://github.com/httprunner/httprunner +[Boomer]: https://github.com/myzhan/boomer +[locust]: https://github.com/locustio/locust +[jmespath]: https://jmespath.org/ +[allure]: https://docs.qameta.io/allure/ +[HAR]: http://httparchive.org/ +[plugin]: https://pkg.go.dev/plugin +[demo.json]: https://github.com/httprunner/hrp/blob/main/examples/demo.json +[examples]: https://github.com/httprunner/hrp/blob/main/examples/ +[CHANGELOG]: docs/CHANGELOG.md \ No newline at end of file diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d40e676..44dbb94 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## v0.2.2 (2021-12-06) + +- change: remove mkdocs, move to [repo](https://github.com/httprunner/httprunner.github.io) + ## v0.2.1 (2021-12-02) - feat: push load testing metrics to Prometheus Pushgateway diff --git a/docs/README.md b/docs/README.md index abb48c7..d244ed9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,267 +1,8 @@ -# hrp (HttpRunner+) - -[![Go Reference](https://pkg.go.dev/badge/github.com/httprunner/hrp.svg)](https://pkg.go.dev/github.com/httprunner/hrp) -[![Github Actions](https://github.com/httprunner/hrp/actions/workflows/unittest.yml/badge.svg)](https://github.com/httprunner/hrp/actions) -[![codecov](https://codecov.io/gh/httprunner/hrp/branch/main/graph/badge.svg?token=HPCQWCD7KO)](https://codecov.io/gh/httprunner/hrp) -[![Go Report Card](https://goreportcard.com/badge/github.com/httprunner/hrp)](https://goreportcard.com/report/github.com/httprunner/hrp) -[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B27856%2Fgithub.com%2Fhttprunner%2Fhrp.svg?type=shield)](https://app.fossa.com/reports/c2742455-c8ab-4b13-8fd7-4a35ba0b2840) - -`hrp` is a golang implementation of [HttpRunner]. Ideally, hrp will be fully compatible with HttpRunner, including testcase format and usage. What's more, hrp will integrate Boomer natively to be a better load generator for [locust]. - -## Key Features - -![flow chart](assets/flow.jpg) - -- [x] Full support for HTTP(S) requests, more protocols are also in the plan. -- [x] Testcases can be described in multiple formats, `YAML`/`JSON`/`Golang`, and they are interchangeable. -- [x] With [`HAR`][HAR] support, you can use Charles/Fiddler/Chrome/etc as a script recording generator. -- [x] Supports `variables`/`extract`/`validate`/`hooks` mechanisms to create extremely complex test scenarios. -- [ ] Built-in integration of rich functions, and you can also use [`go plugin`][plugin] to create and call custom functions. -- [x] Inherit all powerful features of [`Boomer`][Boomer] and [`locust`][locust], you can run `load test` without extra work. -- [x] Use it as a `CLI tool` or as a `library` are both supported. - -## Quick Start - -### use as CLI tool - -```bash -$ go get -u github.com/httprunner/hrp/hrp -``` - -Since installed, you will get a `hrp` command with multiple sub-commands. - -```text -$ hrp -h -hrp (HttpRunner+) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ - -License: Apache-2.0 -Github: https://github.com/httprunner/hrp -Copyright 2021 debugtalk - -Usage: - hrp [command] - -Available Commands: - boom run load test with boomer - completion generate the autocompletion script for the specified shell - har2case Convert HAR to json/yaml testcase files - help Help about any command - run run API test - -Flags: - -h, --help help for hrp - --log-json set log to json format - -l, --log-level string set log level (default "INFO") - -v, --version version for hrp - -Use "hrp [command] --help" for more information about a command. -``` - -You can use `hrp run` command to run HttpRunner JSON/YAML testcases. The following is an example running [examples/demo.json][demo.json] - -
-$ hrp run examples/demo.json - -```text -8:04PM INF Set log to pretty console -8:04PM INF Set log level to INFO -8:04PM INF [init] SetDebug debug=true -8:04PM INF load json testcase path=/Users/debugtalk/MyProjects/HttpRunner-dev/hrp/examples/demo.json -8:04PM INF call function success arguments=[5] funcName=gen_random_string output=B64R8 -8:04PM INF call function success arguments=[12.3,3.45] funcName=max output=12.3 -8:04PM INF run testcase start testcase="demo with complex mechanisms" -8:04PM INF call function success arguments=[12.3,34.5] funcName=max output=34.5 -8:04PM INF run step start step="get with params" --------------------- request -------------------- -GET /get?foo1=B64R8&foo2=34.5 HTTP/1.1 -Host: postman-echo.com -User-Agent: HttpRunnerPlus - - -==================== response =================== -HTTP/1.1 200 OK -Content-Length: 304 -Connection: keep-alive -Content-Type: application/json; charset=utf-8 -Date: Thu, 11 Nov 2021 12:04:32 GMT -Etag: W/"130-LUQ0LVU7KVSZha0O3nQxqPlr5dw" -Set-Cookie: sails.sid=s%3Ag6vZXrHHzs-B7Q1bFrYQq83dUje_EkSu.06vsqbkZvIOJ6mb1It7c6i354e%2B0t91K4cG14YFjSX0; Path=/; HttpOnly -Vary: Accept-Encoding - -{"args":{"foo1":"B64R8","foo2":"34.5"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-618d06d0-7516144f65e561a8238adab5","user-agent":"HttpRunnerPlus","accept-encoding":"gzip"},"url":"https://postman-echo.com/get?foo1=B64R8&foo2=34.5"} --------------------------------------------------- -8:04PM INF extract value from=body.args.foo1 value=B64R8 -8:04PM INF set variable value=B64R8 variable=varFoo1 -8:04PM INF validate status_code assertMethod=equals checkValue=200 expectValue=200 result=true -8:04PM INF validate headers."Content-Type" assertMethod=startswith checkValue="application/json; charset=utf-8" expectValue=application/json result=true -8:04PM INF validate body.args.foo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true -8:04PM INF validate $varFoo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true -8:04PM INF validate body.args.foo2 assertMethod=equals checkValue=34.5 expectValue=34.5 result=true -8:04PM INF run step end exportVars={"varFoo1":"B64R8"} step="get with params" success=true -8:04PM INF run step start step="post json data" -8:04PM INF call function success arguments=[12.3,3.45] funcName=max output=12.3 --------------------- request -------------------- -POST /post HTTP/1.1 -Host: postman-echo.com -Content-Type: application/json; charset=UTF-8 - -{"foo1":"B64R8","foo2":12.3} -==================== response =================== -HTTP/1.1 200 OK -Content-Length: 424 -Connection: keep-alive -Content-Type: application/json; charset=utf-8 -Date: Thu, 11 Nov 2021 12:04:32 GMT -Etag: W/"1a8-1umvYElau4WkHR7VON+jKXozT2c" -Set-Cookie: sails.sid=s%3AeNnS5IE6TBePzx95OfuwyIweJy5aExb0.7MH6Vb42vbZ6OhNT2nhQGcAmHgqcFmtM8X03Qsoxa1k; Path=/; HttpOnly -Vary: Accept-Encoding - -{"args":{},"data":{"foo1":"B64R8","foo2":12.3},"files":{},"form":{},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-618d06d0-360475ad34903a97191978d7","content-length":"28","user-agent":"Go-http-client/1.1","content-type":"application/json; charset=UTF-8","accept-encoding":"gzip"},"json":{"foo1":"B64R8","foo2":12.3},"url":"https://postman-echo.com/post"} --------------------------------------------------- -8:04PM INF validate status_code assertMethod=equals checkValue=200 expectValue=200 result=true -8:04PM INF validate body.json.foo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true -8:04PM INF validate body.json.foo2 assertMethod=equals checkValue=12.3 expectValue=12.3 result=true -8:04PM INF run step end exportVars=null step="post json data" success=true -8:04PM INF run step start step="post form data" -8:04PM INF call function success arguments=[12.3,3.45] funcName=max output=12.3 --------------------- request -------------------- -POST /post HTTP/1.1 -Host: postman-echo.com -Content-Type: application/x-www-form-urlencoded; charset=UTF-8 - -foo1=B64R8&foo2=12.3 -==================== response =================== -HTTP/1.1 200 OK -Content-Length: 445 -Connection: keep-alive -Content-Type: application/json; charset=utf-8 -Date: Thu, 11 Nov 2021 12:04:32 GMT -Etag: W/"1bd-g/z+op+J2/U1DlrEv2g2VhZ0on4" -Set-Cookie: sails.sid=s%3ALfq9XEgKVT4dKQ8PnxUJ9-WSq4wI96Po.2P90TP9V2Pje3GNJ1hJmLcRRgcQy%2FDwBPF63Xdvdq4o; Path=/; HttpOnly -Vary: Accept-Encoding - -{"args":{},"data":"","files":{},"form":{"foo1":"B64R8","foo2":"12.3"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-618d06d0-56d250242bf05b7144edf2cb","content-length":"20","user-agent":"Go-http-client/1.1","content-type":"application/x-www-form-urlencoded; charset=UTF-8","accept-encoding":"gzip"},"json":{"foo1":"B64R8","foo2":"12.3"},"url":"https://postman-echo.com/post"} --------------------------------------------------- -8:04PM INF validate status_code assertMethod=equals checkValue=200 expectValue=200 result=true -8:04PM INF validate body.form.foo1 assertMethod=length_equals checkValue=B64R8 expectValue=5 result=true -8:04PM INF validate body.form.foo2 assertMethod=equals checkValue=12.3 expectValue=12.3 result=true -8:04PM INF run step end exportVars=null step="post form data" success=true -8:04PM INF run testcase end testcase="demo with complex mechanisms" -``` -
- -### use as library - -Beside using `hrp` as a CLI tool, you can also use it as golang library. - -```bash -$ go get -u github.com/httprunner/hrp -``` - -This is an example of `HttpRunner+` testcase. You can find more in the [`examples`][examples] directory. - - -
-demo - -```go -import ( - "testing" - - "github.com/httprunner/hrp" -) - -func TestCaseDemo(t *testing.T) { - demoTestCase := &hrp.TestCase{ - Config: hrp.TConfig{ - Name: "demo with complex mechanisms", - BaseURL: "https://postman-echo.com", - Variables: map[string]interface{}{ // global level variables - "n": 5, - "a": 12.3, - "b": 3.45, - "varFoo1": "${gen_random_string($n)}", - "varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function - }, - }, - TestSteps: []hrp.IStep{ - hrp.Step("get with params"). - WithVariables(map[string]interface{}{ // step level variables - "n": 3, // inherit config level variables if not set in step level, a/varFoo1 - "b": 34.5, // override config level variable if existed, n/b/varFoo2 - "varFoo2": "${max($a, $b)}", // 34.5; override variable b and eval again - }). - GET("/get"). - WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params - WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers - Extract(). - WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath - Validate(). - AssertEqual("status_code", 200, "check response status code"). // validate response status code - AssertStartsWith("headers.\"Content-Type\"", "application/json", ""). // validate response header - AssertLengthEqual("body.args.foo1", 5, "check args foo1"). // validate response body with jmespath - AssertLengthEqual("$varFoo1", 5, "check args foo1"). // assert with extracted variable from current step - AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string - hrp.Step("post json data"). - POST("/post"). - WithBody(map[string]interface{}{ - "foo1": "$varFoo1", // reference former extracted variable - "foo2": "${max($a, $b)}", // 12.3; step level variables are independent, variable b is 3.45 here - }). - Validate(). - AssertEqual("status_code", 200, "check status code"). - AssertLengthEqual("body.json.foo1", 5, "check args foo1"). - AssertEqual("body.json.foo2", 12.3, "check args foo2"), - hrp.Step("post form data"). - POST("/post"). - WithHeaders(map[string]string{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}). - WithBody(map[string]interface{}{ - "foo1": "$varFoo1", // reference former extracted variable - "foo2": "${max($a, $b)}", // 12.3; step level variables are independent, variable b is 3.45 here - }). - Validate(). - AssertEqual("status_code", 200, "check status code"). - AssertLengthEqual("body.form.foo1", 5, "check args foo1"). - AssertEqual("body.form.foo2", "12.3", "check args foo2"), // form data will be converted to string - }, - } - - err := hrp.NewRunner(nil).Run(demoTestCase) // hrp.Run(demoTestCase) - if err != nil { - t.Fatalf("run testcase error: %v", err) - } -} -``` -
- -## Sponsors - -Thank you to all our sponsors! ✨🍰✨ ([become a sponsor](sponsors.md)) - -### Gold Sponsor - -[霍格沃兹测试开发学社](https://ceshiren.com/) - -> [霍格沃兹测试开发学社](http://qrcode.testing-studio.com/f?from=httprunner&url=https://ceshiren.com)是业界领先的测试开发技术高端教育品牌,隶属于[测吧(北京)科技有限公司](http://qrcode.testing-studio.com/f?from=httprunner&url=https://www.testing-studio.com) 。学院课程由一线大厂测试经理与资深测试开发专家参与研发,实战驱动。课程涵盖 web/app 自动化测试、接口测试、性能测试、安全测试、持续集成/持续交付/DevOps,测试左移&右移、精准测试、测试平台开发、测试管理等内容,帮助测试工程师实现测试开发技术转型。通过优秀的学社制度(奖学金、内推返学费、行业竞赛等多种方式)来实现学员、学社及用人企业的三方共赢。 - -> [进入测试开发技术能力测评!](http://qrcode.testing-studio.com/f?from=httprunner&url=https://ceshiren.com/t/topic/14940) - -### Open Source Sponsor - -[Sentry](https://sentry.io/_/open-source/) - -## Subscribe - -关注 HttpRunner 的微信公众号,第一时间获得最新资讯。 - -HttpRunner - -[HttpRunner]: https://github.com/httprunner/httprunner -[Boomer]: https://github.com/myzhan/boomer -[locust]: https://github.com/locustio/locust -[jmespath]: https://jmespath.org/ -[allure]: https://docs.qameta.io/allure/ -[HAR]: http://httparchive.org/ -[plugin]: https://pkg.go.dev/plugin -[demo.json]: https://github.com/httprunner/hrp/blob/main/examples/demo.json -[examples]: https://github.com/httprunner/hrp/blob/main/examples/ +# Links + +- Homepage: https://httprunner.com +- Docs + - English: https://httprunner.com/docs + - 中文: https://httprunner.com/zh/docs + - [hrp command help](cmd/hrp.md) +- Blog: https://httprunner.com/blog diff --git a/docs/boomer.md b/docs/boomer.md deleted file mode 100644 index bbfa9f1..0000000 --- a/docs/boomer.md +++ /dev/null @@ -1,67 +0,0 @@ -# Load Test - -## Run load test - -`HttpRunner+` supports running load test without extra work. You can use `hrp boom` command to run YAML/JSON testcases in load testing mode. - -By default, hrp will print load testing results in console output, refreshed every 3 seconds. - -``` -$ hrp boom examples/demo.json --spawn-count 10 --spawn-rate 1 -6:09PM INF Set log to pretty console -6:09PM INF Set log level to INFO -6:09PM INF Set log level to WARN -2021/12/02 18:09:48 Spawning 10 clients immediately -Current time: 2021/12/02 18:09:51, Users: 10, Total RPS: 20, Total Fail Ratio: 0.0% -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ -| TYPE | NAME | # REQUESTS | # FAILS | MEDIAN | AVERAGE | MIN | MAX | CONTENT SIZE | # REQS/SEC | # FAILS/SEC | -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ -| request-GET | get with params | 10 | 0 | 2400 | 2423.00 | 2422 | 2424 | 300 | 10 | 0 | -| request-POST | post json data | 10 | 0 | 310 | 304.50 | 301 | 307 | 420 | 10 | 0 | -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ - -Current time: 2021/12/02 18:09:54, Users: 10, Total RPS: 16, Total Fail Ratio: 0.0% -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ -| TYPE | NAME | # REQUESTS | # FAILS | MEDIAN | AVERAGE | MIN | MAX | CONTENT SIZE | # REQS/SEC | # FAILS/SEC | -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ -| request-GET | get with params | 18 | 0 | 1200 | 1157.39 | 1083 | 1367 | 300 | 9 | 0 | -| request-POST | post json data | 10 | 0 | 290 | 290.20 | 287 | 293 | 420 | 10 | 0 | -| request-POST | post form data | 20 | 0 | 310 | 300.00 | 287 | 311 | 441 | 10 | 0 | -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ - -Current time: 2021/12/02 18:09:57, Users: 10, Total RPS: 17, Total Fail Ratio: 0.0% -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ -| TYPE | NAME | # REQUESTS | # FAILS | MEDIAN | AVERAGE | MIN | MAX | CONTENT SIZE | # REQS/SEC | # FAILS/SEC | -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ -| request-GET | get with params | 12 | 0 | 1100 | 1153.92 | 1081 | 1464 | 300 | 6 | 0 | -| request-POST | post json data | 20 | 0 | 270 | 279.70 | 269 | 337 | 420 | 6 | 0 | -| request-POST | post form data | 20 | 0 | 270 | 272.85 | 269 | 279 | 441 | 10 | 0 | -+--------------+-----------------+------------+---------+--------+---------+------+------+--------------+------------+-------------+ -``` - -If you want to disable console output, you can add a `--disable-console-output` flag. - -``` -$ hrp boom examples/demo.json --spawn-count 10 --spawn-rate 1 --disable-console-output -``` - -You can reference this [doc](cmd/hrp_boom.md) for all command arguments. - -## Report metrics to Prometheus Pushgateway - -Besides printing load testing results in console, you can also push metrics to [Prometheus Pushgateway][pushgateway_github], and then you can configure pretty graphs on [Grafana][Grafana]. - -``` -$ hrp boom examples/demo.json --spawn-count 10 --spawn-rate 1 --prometheus-gateway http://127.0.0.1:9091 -``` - -You can deploy the Pushgateway using the [prom/pushgateway][pushgateway_docker] Docker image at ease. - -``` -$ docker pull prom/pushgateway -$ docker run -d -p 9091:9091 prom/pushgateway -``` - -[pushgateway_github]: https://github.com/prometheus/pushgateway -[pushgateway_docker]: https://hub.docker.com/r/prom/pushgateway -[Grafana]: https://grafana.com/ diff --git a/docs/installation.md b/docs/installation.md deleted file mode 100644 index abbbe20..0000000 --- a/docs/installation.md +++ /dev/null @@ -1,50 +0,0 @@ -# Installation - -`HttpRunner+` is developed with Golang, it supports Go `1.13+` and most operating systems. Combination of Go `1.13/1.14/1.15/1.16/1.17` and `macOS/Linux/Windows` are tested continuously on [GitHub-Actions][github-actions]. - -## install as CLI tool - -```bash -$ go get -u github.com/httprunner/hrp/hrp -``` - -Since installed, you will get a `hrp` command with multiple sub-commands. - -```text -$ hrp -h -hrp (HttpRunner+) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ - -License: Apache-2.0 -Github: https://github.com/httprunner/hrp -Copyright 2021 debugtalk - -Usage: - hrp [command] - -Available Commands: - boom run load test with boomer - completion generate the autocompletion script for the specified shell - har2case Convert HAR to json/yaml testcase files - help Help about any command - run run API test - -Flags: - -h, --help help for hrp - --log-json set log to json format - -l, --log-level string set log level (default "INFO") - -v, --version version for hrp - -Use "hrp [command] --help" for more information about a command. -``` - -## install as library - -Beside using `hrp` as a CLI tool, you can also use it as golang library. - -```bash -$ go get -u github.com/httprunner/hrp -``` - -Then you can import `github.com/httprunner/hrp` and write testcases in Golang. - -[github-actions]: https://github.com/httprunner/hrp/actions diff --git a/docs/sponsors.md b/docs/sponsors.md deleted file mode 100644 index 0589e27..0000000 --- a/docs/sponsors.md +++ /dev/null @@ -1,26 +0,0 @@ -# 赞助商 - -感谢各位对 HttpRunner 的赞助支持! - -## 金牌赞助商(Gold Sponsor) - -[霍格沃兹测试开发学社](https://ceshiren.com/) - -> [霍格沃兹测试开发学社](http://qrcode.testing-studio.com/f?from=httprunner&url=https://ceshiren.com)是业界领先的测试开发技术高端教育品牌,隶属于[测吧(北京)科技有限公司](http://qrcode.testing-studio.com/f?from=httprunner&url=https://www.testing-studio.com) 。学院课程由一线大厂测试经理与资深测试开发专家参与研发,实战驱动。课程涵盖 web/app 自动化测试、接口测试、性能测试、安全测试、持续集成/持续交付/DevOps,测试左移&右移、精准测试、测试平台开发、测试管理等内容,帮助测试工程师实现测试开发技术转型。通过优秀的学社制度(奖学金、内推返学费、行业竞赛等多种方式)来实现学员、学社及用人企业的三方共赢。 - -> [进入测试开发技术能力测评!](http://qrcode.testing-studio.com/f?from=httprunner&url=https://ceshiren.com/t/topic/14940) - -### 开源服务赞助商(Open Source Sponsor) - -[Sentry](https://sentry.io/_/open-source/) - -HttpRunner is in Sentry Sponsored plan. - -## 成为赞助商 - -如果你所在的公司或个人也想对 HttpRunner 进行赞助,可参考如下方案,具体可联系[项目作者](mailto:debugtalk@gmail.com)。 - -| 等级 | 金牌赞助商
(Gold Sponsor) | 银牌赞助商
(Silver Sponsor)| 个人赞赏 | -|:---:|:---:|:---:|:---:| -| 金额 | ¥20000/年 | ¥8000/年 | 任意 | -| 权益 | 公司 logo(大)和链接展示在 README.md
200 字的宣传文案 | 公司 logo(中)和链接展示在 README.md
80 字的宣传文案| 个人 ID 和链接展示在 sponsors.md | diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index 2f510c2..0000000 --- a/mkdocs.yml +++ /dev/null @@ -1,67 +0,0 @@ -# install mkdocs and material design -# $ pip install mkdocs-material - -# usage -# $ mkdocs serve # build docs and preview -# $ mkdocs gh-deploy # Deploy your documentation to GitHub Pages - -# Project information -site_name: HttpRunner+ Docs -site_description: HttpRunner+ User Documentation -site_author: 'debugtalk' - -# Repository -repo_name: HttpRunner -repo_url: https://github.com/httprunner/hrp -edit_uri: "" - -# Copyright -copyright: 'Copyright © 2021 debugtalk' - -# Configuration -theme: - name: 'material' - language: 'zh' - palette: - primary: 'indigo' - accent: 'indigo' - font: - text: 'Roboto' - code: 'Roboto Mono' - -# Extensions -markdown_extensions: - - admonition - - codehilite: - guess_lang: false - - toc: - permalink: true - - def_list - - pymdownx.tasklist: - custom_checkbox: true - -# extra -extra: - search: - language: 'jp' - social: - - icon: material/library - link: https://debugtalk.com - - icon: fontawesome/brands/github-alt - link: 'https://github.com/httprunner' - analytics: - provider: google - property: G-N2DPN3VP7K - -# index pages -nav: - - README: README.md - - Installation: installation.md - - CLI Tools: - - hrp: cmd/hrp.md - - hrp_run: cmd/hrp_run.md - - hrp_har2case: cmd/hrp_har2case.md - - hrp_boom: cmd/hrp_boom.md - - Load Test: boomer.md - - Sponsors: sponsors.md - - Release History: CHANGELOG.md