mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 22:44:05 +08:00
refactor: rename to hrp
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v2
|
uses: codecov/codecov-action@v2
|
||||||
with:
|
with:
|
||||||
name: httpboomer # User defined upload name. Visible in Codecov UI
|
name: hrp(HttpRunner+) # User defined upload name. Visible in Codecov UI
|
||||||
token: ${{ secrets.CODECOV_TOKEN }} # Repository upload token
|
token: ${{ secrets.CODECOV_TOKEN }} # Repository upload token
|
||||||
file: ./cover.out # Path to coverage file to upload
|
file: ./cover.out # Path to coverage file to upload
|
||||||
flags: unittests # Flag upload to group coverage metrics
|
flags: unittests # Flag upload to group coverage metrics
|
||||||
|
|||||||
36
README.md
36
README.md
@@ -1,14 +1,14 @@
|
|||||||
# HttpBoomer
|
# HttpRunner+ (hrp)
|
||||||
|
|
||||||
[](https://pkg.go.dev/github.com/httprunner/httpboomer)
|
[](https://pkg.go.dev/github.com/httprunner/hrp)
|
||||||
[](https://github.com/httprunner/HttpBoomer/actions)
|
[](https://github.com/httprunner/hrp/actions)
|
||||||
[](https://codecov.io/gh/httprunner/HttpBoomer)
|
[](https://codecov.io/gh/httprunner/hrp)
|
||||||
[](https://goreportcard.com/report/github.com/httprunner/HttpBoomer)
|
[](https://goreportcard.com/report/github.com/httprunner/hrp)
|
||||||
[](https://app.fossa.com/reports/fb0e64a7-7dcf-48bb-8de9-8f0e016b903b)
|
[](https://app.fossa.com/reports/fb0e64a7-7dcf-48bb-8de9-8f0e016b903b)
|
||||||
|
|
||||||
> HttpBoomer = [HttpRunner] + [Boomer]
|
> hrp (HttpRunnerPlus) = [HttpRunner] + [Boomer]
|
||||||
|
|
||||||
HttpBoomer is a golang implementation of [HttpRunner]. Ideally, HttpBoomer will be fully compatible with HttpRunner, including testcase format and usage. What's more, HttpBoomer will integrate Boomer natively to be a better load generator for [locust].
|
`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
|
## Key Features
|
||||||
|
|
||||||
@@ -27,23 +27,23 @@ HttpBoomer is a golang implementation of [HttpRunner]. Ideally, HttpBoomer will
|
|||||||
### Install
|
### Install
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ go get -u github.com/httprunner/httpboomer
|
$ go get -u github.com/httprunner/hrp
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
This is an example of HttpBoomer testcase. You can find more in the [`examples`][examples] directory.
|
This is an example of `hrp` testcase. You can find more in the [`examples`][examples] directory.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCaseDemo(t *testing.T) {
|
func TestCaseDemo(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "demo with complex mechanisms",
|
Name: "demo with complex mechanisms",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Variables: map[string]interface{}{ // global level variables
|
Variables: map[string]interface{}{ // global level variables
|
||||||
@@ -54,8 +54,8 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
"varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function
|
"varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{ // step level variables
|
WithVariables(map[string]interface{}{ // step level variables
|
||||||
"n": 3, // inherit config level variables if not set in step level, a/varFoo1
|
"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
|
"b": 34.5, // override config level variable if existed, n/b/varFoo2
|
||||||
@@ -63,7 +63,7 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params
|
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). // request with headers
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers
|
||||||
Extract().
|
Extract().
|
||||||
WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath
|
WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath
|
||||||
Validate().
|
Validate().
|
||||||
@@ -72,7 +72,7 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
AssertLengthEqual("body.args.foo1", 5, "check args foo1"). // validate response body with jmespath
|
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
|
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
|
AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string
|
||||||
httpboomer.Step("post json data").
|
hrp.Step("post json data").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithJSON(map[string]interface{}{
|
WithJSON(map[string]interface{}{
|
||||||
"foo1": "$varFoo1", // reference former extracted variable
|
"foo1": "$varFoo1", // reference former extracted variable
|
||||||
@@ -85,7 +85,7 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
@@ -28,7 +28,7 @@ var demoTestCase = &TestCase{
|
|||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params
|
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). // request with headers
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers
|
||||||
Extract().
|
Extract().
|
||||||
WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath
|
WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath
|
||||||
Validate().
|
Validate().
|
||||||
|
|||||||
25
docs/cmd/hrp.md
Normal file
25
docs/cmd/hrp.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
## hrp
|
||||||
|
|
||||||
|
One-stop solution for HTTP(S) testing.
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
hrp(HttpRunnerPlus) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨
|
||||||
|
|
||||||
|
License: Apache-2.0
|
||||||
|
Github: https://github.com/httprunner/hrp
|
||||||
|
Copyright 2021 debugtalk
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for hrp
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [hrp boom](hrp_boom.md) - run load test with boomer
|
||||||
|
* [hrp har2case](hrp_har2case.md) - Convert HAR to json/yaml testcase files
|
||||||
|
* [hrp run](hrp_run.md) - run API test
|
||||||
|
|
||||||
|
###### Auto generated by spf13/cobra on 16-Oct-2021
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
## httpboomer boom
|
## hrp boom
|
||||||
|
|
||||||
run load test with boomer
|
run load test with boomer
|
||||||
|
|
||||||
@@ -7,15 +7,15 @@ run load test with boomer
|
|||||||
run yaml/json testcase files for load test
|
run yaml/json testcase files for load test
|
||||||
|
|
||||||
```
|
```
|
||||||
httpboomer boom [flags]
|
hrp boom [flags]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
$ httpboomer boom demo.json # run specified json testcase file
|
$ hrp boom demo.json # run specified json testcase file
|
||||||
$ httpboomer boom demo.yaml # run specified yaml testcase file
|
$ hrp boom demo.yaml # run specified yaml testcase file
|
||||||
$ httpboomer boom examples/ # run testcases in specified folder
|
$ hrp boom examples/ # run testcases in specified folder
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
@@ -35,6 +35,6 @@ httpboomer boom [flags]
|
|||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing.
|
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Oct-2021
|
###### Auto generated by spf13/cobra on 16-Oct-2021
|
||||||
23
docs/cmd/hrp_har2case.md
Normal file
23
docs/cmd/hrp_har2case.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
## hrp har2case
|
||||||
|
|
||||||
|
Convert HAR to json/yaml testcase files
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Convert HAR to json/yaml testcase files
|
||||||
|
|
||||||
|
```
|
||||||
|
hrp har2case path... [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for har2case
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
||||||
|
|
||||||
|
###### Auto generated by spf13/cobra on 16-Oct-2021
|
||||||
33
docs/cmd/hrp_run.md
Normal file
33
docs/cmd/hrp_run.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
## hrp run
|
||||||
|
|
||||||
|
run API test
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
run yaml/json testcase files for API test
|
||||||
|
|
||||||
|
```
|
||||||
|
hrp run path... [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
$ hrp run demo.json # run specified json testcase file
|
||||||
|
$ hrp run demo.yaml # run specified yaml testcase file
|
||||||
|
$ hrp run examples/ # run testcases in specified folder
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for run
|
||||||
|
-p, --proxy-url string set proxy url
|
||||||
|
-s, --silent disable logging request & response details
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
||||||
|
|
||||||
|
###### Auto generated by spf13/cobra on 16-Oct-2021
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
## httpboomer
|
|
||||||
|
|
||||||
One-stop solution for HTTP(S) testing.
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
HttpBoomer is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨
|
|
||||||
|
|
||||||
License: Apache-2.0
|
|
||||||
Github: https://github.com/httprunner/httpboomer
|
|
||||||
Copyright 2021 debugtalk
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for httpboomer
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [httpboomer boom](httpboomer_boom.md) - run load test with boomer
|
|
||||||
* [httpboomer har2case](httpboomer_har2case.md) - Convert HAR to json/yaml testcase files
|
|
||||||
* [httpboomer run](httpboomer_run.md) - run API test
|
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Oct-2021
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
## httpboomer har2case
|
|
||||||
|
|
||||||
Convert HAR to json/yaml testcase files
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Convert HAR to json/yaml testcase files
|
|
||||||
|
|
||||||
```
|
|
||||||
httpboomer har2case path... [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for har2case
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing.
|
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Oct-2021
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
## httpboomer run
|
|
||||||
|
|
||||||
run API test
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
run yaml/json testcase files for API test
|
|
||||||
|
|
||||||
```
|
|
||||||
httpboomer run path... [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
$ httpboomer run demo.json # run specified json testcase file
|
|
||||||
$ httpboomer run demo.yaml # run specified yaml testcase file
|
|
||||||
$ httpboomer run examples/ # run testcases in specified folder
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for run
|
|
||||||
-s, --silent Disable logging request & response details
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing.
|
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Oct-2021
|
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra/doc"
|
"github.com/spf13/cobra/doc"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer/httpboomer/cmd"
|
"github.com/httprunner/hrp/hrp/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// run this test to generate markdown docs
|
// run this test to generate markdown docs
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "User-Agent",
|
"name": "User-Agent",
|
||||||
"value": "HttpBoomer"
|
"value": "HttpRunnerPlus"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Accept-Encoding",
|
"name": "Accept-Encoding",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"foo2": "$varFoo2"
|
"foo2": "$varFoo2"
|
||||||
},
|
},
|
||||||
"headers": {
|
"headers": {
|
||||||
"User-Agent": "HttpBoomer"
|
"User-Agent": "HttpRunnerPlus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"variables": {
|
"variables": {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ teststeps:
|
|||||||
foo1: $varFoo1
|
foo1: $varFoo1
|
||||||
foo2: $varFoo2
|
foo2: $varFoo2
|
||||||
headers:
|
headers:
|
||||||
User-Agent: HttpBoomer
|
User-Agent: HttpRunnerPlus
|
||||||
variables:
|
variables:
|
||||||
b: 34.5
|
b: 34.5
|
||||||
"n": 3
|
"n": 3
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCaseDemo(t *testing.T) {
|
func TestCaseDemo(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "demo with complex mechanisms",
|
Name: "demo with complex mechanisms",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Variables: map[string]interface{}{ // global level variables
|
Variables: map[string]interface{}{ // global level variables
|
||||||
@@ -19,8 +19,8 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
"varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function
|
"varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{ // step level variables
|
WithVariables(map[string]interface{}{ // step level variables
|
||||||
"n": 3, // inherit config level variables if not set in step level, a/varFoo1
|
"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
|
"b": 34.5, // override config level variable if existed, n/b/varFoo2
|
||||||
@@ -28,7 +28,7 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params
|
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). // request with headers
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers
|
||||||
Extract().
|
Extract().
|
||||||
WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath
|
WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath
|
||||||
Validate().
|
Validate().
|
||||||
@@ -37,7 +37,7 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
AssertLengthEqual("body.args.foo1", 5, "check args foo1"). // validate response body with jmespath
|
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
|
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
|
AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string
|
||||||
httpboomer.Step("post json data").
|
hrp.Step("post json data").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithBody(map[string]interface{}{
|
WithBody(map[string]interface{}{
|
||||||
"foo1": "$varFoo1", // reference former extracted variable
|
"foo1": "$varFoo1", // reference former extracted variable
|
||||||
@@ -47,7 +47,7 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
AssertLengthEqual("body.json.foo1", 5, "check args foo1").
|
AssertLengthEqual("body.json.foo1", 5, "check args foo1").
|
||||||
AssertEqual("body.json.foo2", 12.3, "check args foo2"),
|
AssertEqual("body.json.foo2", 12.3, "check args foo2"),
|
||||||
httpboomer.Step("post form data").
|
hrp.Step("post form data").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithParams(map[string]interface{}{
|
WithParams(map[string]interface{}{
|
||||||
"foo1": "$varFoo1", // reference former extracted variable
|
"foo1": "$varFoo1", // reference former extracted variable
|
||||||
@@ -60,7 +60,7 @@ func TestCaseDemo(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,22 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// reference extracted variables for validation in the same step
|
// reference extracted variables for validation in the same step
|
||||||
func TestCaseExtractStepSingle(t *testing.T) {
|
func TestCaseExtractStepSingle(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with variables",
|
Name: "run request with variables",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Verify: false,
|
Verify: false,
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{
|
WithVariables(map[string]interface{}{
|
||||||
"var1": "bar1",
|
"var1": "bar1",
|
||||||
"agent": "HttpBoomer",
|
"agent": "HttpRunnerPlus",
|
||||||
"expectedStatusCode": 200,
|
"expectedStatusCode": 200,
|
||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
@@ -33,11 +33,11 @@ func TestCaseExtractStepSingle(t *testing.T) {
|
|||||||
AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type"). // assert with extracted variable from current step
|
AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type"). // assert with extracted variable from current step
|
||||||
AssertEqual("$varFoo1", "bar1", "check args foo1"). // assert with extracted variable from current step
|
AssertEqual("$varFoo1", "bar1", "check args foo1"). // assert with extracted variable from current step
|
||||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -45,17 +45,17 @@ func TestCaseExtractStepSingle(t *testing.T) {
|
|||||||
|
|
||||||
// reference extracted variables from previous step
|
// reference extracted variables from previous step
|
||||||
func TestCaseExtractStepAssociation(t *testing.T) {
|
func TestCaseExtractStepAssociation(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with variables",
|
Name: "run request with variables",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Verify: false,
|
Verify: false,
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{
|
WithVariables(map[string]interface{}{
|
||||||
"var1": "bar1",
|
"var1": "bar1",
|
||||||
"agent": "HttpBoomer",
|
"agent": "HttpRunnerPlus",
|
||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
||||||
@@ -70,10 +70,10 @@ func TestCaseExtractStepAssociation(t *testing.T) {
|
|||||||
AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type").
|
AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type").
|
||||||
AssertEqual("$varFoo1", "bar1", "check args foo1").
|
AssertEqual("$varFoo1", "bar1", "check args foo1").
|
||||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||||
httpboomer.Step("post json data").
|
hrp.Step("post json data").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", "$statusCode", "check status code"). // assert with extracted variable from previous step
|
AssertEqual("status_code", "$statusCode", "check status code"). // assert with extracted variable from previous step
|
||||||
@@ -82,7 +82,7 @@ func TestCaseExtractStepAssociation(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCaseCallFunction(t *testing.T) {
|
func TestCaseCallFunction(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with functions",
|
Name: "run request with functions",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Verify: false,
|
Verify: false,
|
||||||
@@ -18,20 +18,20 @@ func TestCaseCallFunction(t *testing.T) {
|
|||||||
"b": 3.45,
|
"b": 3.45,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
WithParams(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
Extract().
|
Extract().
|
||||||
WithJmesPath("body.args.foo1", "varFoo1").
|
WithJmesPath("body.args.foo1", "varFoo1").
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
AssertLengthEqual("body.args.foo1", 5, "check args foo1").
|
AssertLengthEqual("body.args.foo1", 5, "check args foo1").
|
||||||
AssertEqual("body.args.foo2", "12.3", "check args foo2"), // notice: request params value will be converted to string
|
AssertEqual("body.args.foo2", "12.3", "check args foo2"), // notice: request params value will be converted to string
|
||||||
httpboomer.Step("post json data with functions").
|
hrp.Step("post json data with functions").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
@@ -40,7 +40,7 @@ func TestCaseCallFunction(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,53 +3,53 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCaseBasicRequest(t *testing.T) {
|
func TestCaseBasicRequest(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "request methods testcase in hardcode",
|
Name: "request methods testcase in hardcode",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Verify: false,
|
Verify: false,
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
AssertEqual("headers.Connection", "keep-alive", "check header Connection").
|
AssertEqual("headers.Connection", "keep-alive", "check header Connection").
|
||||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||||
AssertEqual("body.args.foo2", "bar2", "check args foo2"),
|
AssertEqual("body.args.foo2", "bar2", "check args foo2"),
|
||||||
httpboomer.Step("post raw text").
|
hrp.Step("post raw text").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "text/plain"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "text/plain"}).
|
||||||
WithBody("This is expected to be sent back as part of response body.").
|
WithBody("This is expected to be sent back as part of response body.").
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
AssertEqual("body.data", "This is expected to be sent back as part of response body.", "check data"),
|
AssertEqual("body.data", "This is expected to be sent back as part of response body.", "check data"),
|
||||||
httpboomer.Step("post form data").
|
hrp.Step("post form data").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "application/x-www-form-urlencoded"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "application/x-www-form-urlencoded"}).
|
||||||
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
AssertEqual("body.form.foo1", "bar1", "check form foo1").
|
AssertEqual("body.form.foo1", "bar1", "check form foo1").
|
||||||
AssertEqual("body.form.foo2", "bar2", "check form foo2"),
|
AssertEqual("body.form.foo2", "bar2", "check form foo2"),
|
||||||
httpboomer.Step("post json data").
|
hrp.Step("post json data").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
AssertEqual("body.json.foo1", "bar1", "check json foo1").
|
AssertEqual("body.json.foo1", "bar1", "check json foo1").
|
||||||
AssertEqual("body.json.foo2", "bar2", "check json foo2"),
|
AssertEqual("body.json.foo2", "bar2", "check json foo2"),
|
||||||
httpboomer.Step("put request").
|
hrp.Step("put request").
|
||||||
PUT("/put").
|
PUT("/put").
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "text/plain"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "text/plain"}).
|
||||||
WithBody("This is expected to be sent back as part of response body.").
|
WithBody("This is expected to be sent back as part of response body.").
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
@@ -57,7 +57,7 @@ func TestCaseBasicRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCaseValidateStep(t *testing.T) {
|
func TestCaseValidateStep(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with validation",
|
Name: "run request with validation",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Verify: false,
|
Verify: false,
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{
|
WithVariables(map[string]interface{}{
|
||||||
"var1": "bar1",
|
"var1": "bar1",
|
||||||
"agent": "HttpBoomer",
|
"agent": "HttpRunnerPlus",
|
||||||
"expectedStatusCode": 200,
|
"expectedStatusCode": 200,
|
||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
@@ -31,11 +31,11 @@ func TestCaseValidateStep(t *testing.T) {
|
|||||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). // assert response header, with double quotes
|
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). // assert response header, with double quotes
|
||||||
AssertEqual("body.args.foo1", "bar1", "check args foo1"). // assert response json body with jmespath
|
AssertEqual("body.args.foo1", "bar1", "check args foo1"). // assert response json body with jmespath
|
||||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{
|
WithVariables(map[string]interface{}{
|
||||||
"var1": "bar1",
|
"var1": "bar1",
|
||||||
"agent": "HttpBoomer",
|
"agent": "HttpRunnerPlus",
|
||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
||||||
@@ -51,7 +51,7 @@ func TestCaseValidateStep(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,23 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCaseConfigVariables(t *testing.T) {
|
func TestCaseConfigVariables(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with variables",
|
Name: "run request with variables",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Variables: map[string]interface{}{
|
Variables: map[string]interface{}{
|
||||||
"var1": "bar1",
|
"var1": "bar1",
|
||||||
"agent": "HttpBoomer",
|
"agent": "HttpRunnerPlus",
|
||||||
"expectedStatusCode": 200,
|
"expectedStatusCode": 200,
|
||||||
},
|
},
|
||||||
Verify: false,
|
Verify: false,
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
||||||
WithHeaders(map[string]string{"User-Agent": "$agent"}).
|
WithHeaders(map[string]string{"User-Agent": "$agent"}).
|
||||||
@@ -29,28 +29,28 @@ func TestCaseConfigVariables(t *testing.T) {
|
|||||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCaseStepVariables(t *testing.T) {
|
func TestCaseStepVariables(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with variables",
|
Name: "run request with variables",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Verify: false,
|
Verify: false,
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{
|
WithVariables(map[string]interface{}{
|
||||||
"var1": "bar1",
|
"var1": "bar1",
|
||||||
"agent": "HttpBoomer",
|
"agent": "HttpRunnerPlus",
|
||||||
"expectedStatusCode": 200,
|
"expectedStatusCode": 200,
|
||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
@@ -62,30 +62,30 @@ func TestCaseStepVariables(t *testing.T) {
|
|||||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCaseOverrideConfigVariables(t *testing.T) {
|
func TestCaseOverrideConfigVariables(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with variables",
|
Name: "run request with variables",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Variables: map[string]interface{}{
|
Variables: map[string]interface{}{
|
||||||
"var1": "bar0",
|
"var1": "bar0",
|
||||||
"agent": "HttpBoomer",
|
"agent": "HttpRunnerPlus",
|
||||||
"expectedStatusCode": 200,
|
"expectedStatusCode": 200,
|
||||||
},
|
},
|
||||||
Verify: false,
|
Verify: false,
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{
|
WithVariables(map[string]interface{}{
|
||||||
"var1": "bar1", // override config variable
|
"var1": "bar1", // override config variable
|
||||||
"agent": "$agent", // reference config variable
|
"agent": "$agent", // reference config variable
|
||||||
@@ -100,19 +100,19 @@ func TestCaseOverrideConfigVariables(t *testing.T) {
|
|||||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCaseParseVariables(t *testing.T) {
|
func TestCaseParseVariables(t *testing.T) {
|
||||||
testcase := &httpboomer.TestCase{
|
testcase := &hrp.TestCase{
|
||||||
Config: httpboomer.TConfig{
|
Config: hrp.TConfig{
|
||||||
Name: "run request with functions",
|
Name: "run request with functions",
|
||||||
BaseURL: "https://postman-echo.com",
|
BaseURL: "https://postman-echo.com",
|
||||||
Verify: false,
|
Verify: false,
|
||||||
@@ -124,8 +124,8 @@ func TestCaseParseVariables(t *testing.T) {
|
|||||||
"varFoo2": "${max($a, $b)}", // 12.3
|
"varFoo2": "${max($a, $b)}", // 12.3
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TestSteps: []httpboomer.IStep{
|
TestSteps: []hrp.IStep{
|
||||||
httpboomer.Step("get with params").
|
hrp.Step("get with params").
|
||||||
WithVariables(map[string]interface{}{
|
WithVariables(map[string]interface{}{
|
||||||
"n": 3,
|
"n": 3,
|
||||||
"b": 34.5,
|
"b": 34.5,
|
||||||
@@ -133,16 +133,16 @@ func TestCaseParseVariables(t *testing.T) {
|
|||||||
}).
|
}).
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}).
|
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}).
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
Extract().
|
Extract().
|
||||||
WithJmesPath("body.args.foo1", "varFoo1").
|
WithJmesPath("body.args.foo1", "varFoo1").
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
AssertLengthEqual("body.args.foo1", 5, "check args foo1").
|
AssertLengthEqual("body.args.foo1", 5, "check args foo1").
|
||||||
AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string
|
AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string
|
||||||
httpboomer.Step("post json data with functions").
|
hrp.Step("post json data with functions").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
@@ -151,7 +151,7 @@ func TestCaseParseVariables(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := httpboomer.Run(t, testcase)
|
err := hrp.Run(t, testcase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("run testcase error: %v", err)
|
t.Fatalf("run testcase error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module github.com/httprunner/httpboomer
|
module github.com/httprunner/hrp
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ require (
|
|||||||
github.com/maja42/goval v1.2.1
|
github.com/maja42/goval v1.2.1
|
||||||
github.com/myzhan/boomer v1.6.0
|
github.com/myzhan/boomer v1.6.0
|
||||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/shirou/gopsutil v3.21.8+incompatible // indirect
|
github.com/shirou/gopsutil v3.21.8+incompatible // indirect
|
||||||
github.com/spf13/cobra v1.2.1
|
github.com/spf13/cobra v1.2.1
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# har2case
|
# har2case
|
||||||
|
|
||||||
Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner and HttpBoomer.
|
Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner and HttpRunner+.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewHAR(path string) *HAR {
|
func NewHAR(path string) *HAR {
|
||||||
@@ -49,13 +50,13 @@ func (h *HAR) GenYAML() (yamlPath string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HAR) makeTestCase() (*httpboomer.TCase, error) {
|
func (h *HAR) makeTestCase() (*hrp.TCase, error) {
|
||||||
teststeps, err := h.prepareTestSteps()
|
teststeps, err := h.prepareTestSteps()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
tCase := &httpboomer.TCase{
|
tCase := &hrp.TCase{
|
||||||
Config: *h.prepareConfig(),
|
Config: *h.prepareConfig(),
|
||||||
TestSteps: teststeps,
|
TestSteps: teststeps,
|
||||||
}
|
}
|
||||||
@@ -83,21 +84,21 @@ func (h *HAR) load() (*Har, error) {
|
|||||||
return har, nil
|
return har, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HAR) prepareConfig() *httpboomer.TConfig {
|
func (h *HAR) prepareConfig() *hrp.TConfig {
|
||||||
return &httpboomer.TConfig{
|
return &hrp.TConfig{
|
||||||
Name: "testcase description",
|
Name: "testcase description",
|
||||||
Variables: make(map[string]interface{}),
|
Variables: make(map[string]interface{}),
|
||||||
Verify: false,
|
Verify: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HAR) prepareTestSteps() ([]*httpboomer.TStep, error) {
|
func (h *HAR) prepareTestSteps() ([]*hrp.TStep, error) {
|
||||||
har, err := h.load()
|
har, err := h.load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var steps []*httpboomer.TStep
|
var steps []*hrp.TStep
|
||||||
for _, entry := range har.Log.Entries {
|
for _, entry := range har.Log.Entries {
|
||||||
step, err := h.prepareTestStep(&entry)
|
step, err := h.prepareTestStep(&entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -109,12 +110,12 @@ func (h *HAR) prepareTestSteps() ([]*httpboomer.TStep, error) {
|
|||||||
return steps, nil
|
return steps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HAR) prepareTestStep(entry *Entry) (*httpboomer.TStep, error) {
|
func (h *HAR) prepareTestStep(entry *Entry) (*hrp.TStep, error) {
|
||||||
log.Printf("[prepareTestStep] %v %v", entry.Request.Method, entry.Request.URL)
|
log.Printf("[prepareTestStep] %v %v", entry.Request.Method, entry.Request.URL)
|
||||||
tStep := &TStep{
|
tStep := &TStep{
|
||||||
TStep: httpboomer.TStep{
|
TStep: hrp.TStep{
|
||||||
Request: &httpboomer.TRequest{},
|
Request: &hrp.TRequest{},
|
||||||
Validators: make([]httpboomer.TValidator, 0),
|
Validators: make([]hrp.TValidator, 0),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := tStep.makeRequestMethod(entry); err != nil {
|
if err := tStep.makeRequestMethod(entry); err != nil {
|
||||||
@@ -142,11 +143,11 @@ func (h *HAR) prepareTestStep(entry *Entry) (*httpboomer.TStep, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TStep struct {
|
type TStep struct {
|
||||||
httpboomer.TStep
|
hrp.TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TStep) makeRequestMethod(entry *Entry) error {
|
func (s *TStep) makeRequestMethod(entry *Entry) error {
|
||||||
s.Request.Method = httpboomer.EnumHTTPMethod(entry.Request.Method)
|
s.Request.Method = hrp.EnumHTTPMethod(entry.Request.Method)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +225,7 @@ func (s *TStep) makeRequestBody(entry *Entry) error {
|
|||||||
|
|
||||||
func (s *TStep) makeValidate(entry *Entry) error {
|
func (s *TStep) makeValidate(entry *Entry) error {
|
||||||
// make validator for response status code
|
// make validator for response status code
|
||||||
s.Validators = append(s.Validators, httpboomer.TValidator{
|
s.Validators = append(s.Validators, hrp.TValidator{
|
||||||
Check: "status_code",
|
Check: "status_code",
|
||||||
Assert: "equals",
|
Assert: "equals",
|
||||||
Expect: entry.Response.Status,
|
Expect: entry.Response.Status,
|
||||||
@@ -235,7 +236,7 @@ func (s *TStep) makeValidate(entry *Entry) error {
|
|||||||
for _, header := range entry.Response.Headers {
|
for _, header := range entry.Response.Headers {
|
||||||
// assert Content-Type
|
// assert Content-Type
|
||||||
if strings.EqualFold(header.Name, "Content-Type") {
|
if strings.EqualFold(header.Name, "Content-Type") {
|
||||||
s.Validators = append(s.Validators, httpboomer.TValidator{
|
s.Validators = append(s.Validators, hrp.TValidator{
|
||||||
Check: "headers.Content-Type",
|
Check: "headers.Content-Type",
|
||||||
Assert: "equals",
|
Assert: "equals",
|
||||||
Expect: header.Value,
|
Expect: header.Value,
|
||||||
@@ -276,7 +277,7 @@ func (s *TStep) makeValidate(entry *Entry) error {
|
|||||||
case []interface{}:
|
case []interface{}:
|
||||||
continue
|
continue
|
||||||
default:
|
default:
|
||||||
s.Validators = append(s.Validators, httpboomer.TValidator{
|
s.Validators = append(s.Validators, hrp.TValidator{
|
||||||
Check: fmt.Sprintf("body.%s", key),
|
Check: fmt.Sprintf("body.%s", key),
|
||||||
Assert: "equals",
|
Assert: "equals",
|
||||||
Expect: v,
|
Expect: v,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func TestMakeTestCase(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make request headers
|
// make request headers
|
||||||
if !assert.Equal(t, "HttpBoomer", tCase.TestSteps[0].Request.Headers["User-Agent"]) {
|
if !assert.Equal(t, "HttpRunnerPlus", tCase.TestSteps[0].Request.Headers["User-Agent"]) {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if !assert.Equal(t, "postman-echo.com", tCase.TestSteps[0].Request.Headers["Host"]) {
|
if !assert.Equal(t, "postman-echo.com", tCase.TestSteps[0].Request.Headers["Host"]) {
|
||||||
|
|||||||
1
hrp/README.md
Normal file
1
hrp/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# HttpRunner+ cli
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// boomCmd represents the boom command
|
// boomCmd represents the boom command
|
||||||
@@ -13,16 +13,16 @@ var boomCmd = &cobra.Command{
|
|||||||
Use: "boom",
|
Use: "boom",
|
||||||
Short: "run load test with boomer",
|
Short: "run load test with boomer",
|
||||||
Long: `run yaml/json testcase files for load test`,
|
Long: `run yaml/json testcase files for load test`,
|
||||||
Example: ` $ httpboomer boom demo.json # run specified json testcase file
|
Example: ` $ hrp boom demo.json # run specified json testcase file
|
||||||
$ httpboomer boom demo.yaml # run specified yaml testcase file
|
$ hrp boom demo.yaml # run specified yaml testcase file
|
||||||
$ httpboomer boom examples/ # run testcases in specified folder`,
|
$ hrp boom examples/ # run testcases in specified folder`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var paths []httpboomer.ITestCase
|
var paths []hrp.ITestCase
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
paths = append(paths, &httpboomer.TestCasePath{Path: arg})
|
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
||||||
}
|
}
|
||||||
boomer := httpboomer.NewBoomer(masterHost, masterPort)
|
boomer := hrp.NewBoomer(masterHost, masterPort)
|
||||||
boomer.EnableCPUProfile(cpuProfile, cpuProfileDuration)
|
boomer.EnableCPUProfile(cpuProfile, cpuProfileDuration)
|
||||||
boomer.EnableMemoryProfile(memoryProfile, memoryProfileDuration)
|
boomer.EnableMemoryProfile(memoryProfile, memoryProfileDuration)
|
||||||
boomer.Run(paths...)
|
boomer.Run(paths...)
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer/har2case"
|
"github.com/httprunner/hrp/har2case"
|
||||||
)
|
)
|
||||||
|
|
||||||
// har2caseCmd represents the har2case command
|
// har2caseCmd represents the har2case command
|
||||||
@@ -6,19 +6,19 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RootCmd represents the base command when called without any subcommands
|
// RootCmd represents the base command when called without any subcommands
|
||||||
var RootCmd = &cobra.Command{
|
var RootCmd = &cobra.Command{
|
||||||
Use: "httpboomer",
|
Use: "hrp",
|
||||||
Short: "One-stop solution for HTTP(S) testing.",
|
Short: "One-stop solution for HTTP(S) testing.",
|
||||||
Long: `HttpBoomer is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨
|
Long: `hrp(HttpRunnerPlus) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨
|
||||||
|
|
||||||
License: Apache-2.0
|
License: Apache-2.0
|
||||||
Github: https://github.com/httprunner/httpboomer
|
Github: https://github.com/httprunner/hrp
|
||||||
Copyright 2021 debugtalk`,
|
Copyright 2021 debugtalk`,
|
||||||
Version: httpboomer.VERSION,
|
Version: hrp.VERSION,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer"
|
"github.com/httprunner/hrp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// runCmd represents the run command
|
// runCmd represents the run command
|
||||||
@@ -11,16 +11,16 @@ var runCmd = &cobra.Command{
|
|||||||
Use: "run path...",
|
Use: "run path...",
|
||||||
Short: "run API test",
|
Short: "run API test",
|
||||||
Long: `run yaml/json testcase files for API test`,
|
Long: `run yaml/json testcase files for API test`,
|
||||||
Example: ` $ httpboomer run demo.json # run specified json testcase file
|
Example: ` $ hrp run demo.json # run specified json testcase file
|
||||||
$ httpboomer run demo.yaml # run specified yaml testcase file
|
$ hrp run demo.yaml # run specified yaml testcase file
|
||||||
$ httpboomer run examples/ # run testcases in specified folder`,
|
$ hrp run examples/ # run testcases in specified folder`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
var paths []httpboomer.ITestCase
|
var paths []hrp.ITestCase
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
paths = append(paths, &httpboomer.TestCasePath{Path: arg})
|
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
||||||
}
|
}
|
||||||
runner := httpboomer.NewRunner().SetDebug(!silentFlag)
|
runner := hrp.NewRunner().SetDebug(!silentFlag)
|
||||||
if proxyUrl != "" {
|
if proxyUrl != "" {
|
||||||
runner.SetProxyUrl(proxyUrl)
|
runner.SetProxyUrl(proxyUrl)
|
||||||
}
|
}
|
||||||
7
hrp/main.go
Normal file
7
hrp/main.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/httprunner/hrp/hrp/cmd"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
cmd.Execute()
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
# httpboomer cli
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "github.com/httprunner/httpboomer/httpboomer/cmd"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
cmd.Execute()
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
type EnumHTTPMethod string
|
type EnumHTTPMethod string
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ type TValidator struct {
|
|||||||
|
|
||||||
type TStep struct {
|
type TStep struct {
|
||||||
Name string `json:"name" yaml:"name"`
|
Name string `json:"name" yaml:"name"`
|
||||||
|
Transaction string `json:"transaction,omitempty" yaml:"transaction,omitempty"`
|
||||||
Request *TRequest `json:"request,omitempty" yaml:"request,omitempty"`
|
Request *TRequest `json:"request,omitempty" yaml:"request,omitempty"`
|
||||||
TestCase *TestCase `json:"testcase,omitempty" yaml:"testcase,omitempty"`
|
TestCase *TestCase `json:"testcase,omitempty" yaml:"testcase,omitempty"`
|
||||||
Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"`
|
Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer/builtin"
|
"github.com/httprunner/hrp/builtin"
|
||||||
"github.com/maja42/goval"
|
"github.com/maja42/goval"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/imroc/req"
|
"github.com/imroc/req"
|
||||||
"github.com/jmespath/go-jmespath"
|
"github.com/jmespath/go-jmespath"
|
||||||
|
|
||||||
"github.com/httprunner/httpboomer/builtin"
|
"github.com/httprunner/hrp/builtin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewResponseObject(t *testing.T, resp *req.Resp) (*ResponseObject, error) {
|
func NewResponseObject(t *testing.T, resp *req.Resp) (*ResponseObject, error) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|||||||
10
step_test.go
10
step_test.go
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@@ -8,7 +8,7 @@ var (
|
|||||||
stepGET = Step("get with params").
|
stepGET = Step("get with params").
|
||||||
GET("/get").
|
GET("/get").
|
||||||
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||||
WithCookies(map[string]string{"user": "debugtalk"}).
|
WithCookies(map[string]string{"user": "debugtalk"}).
|
||||||
Validate().
|
Validate().
|
||||||
AssertEqual("status_code", 200, "check status code").
|
AssertEqual("status_code", 200, "check status code").
|
||||||
@@ -19,7 +19,7 @@ var (
|
|||||||
stepPOSTData = Step("post form data").
|
stepPOSTData = Step("post form data").
|
||||||
POST("/post").
|
POST("/post").
|
||||||
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "application/x-www-form-urlencoded"}).
|
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "application/x-www-form-urlencoded"}).
|
||||||
WithBody("a=1&b=2").
|
WithBody("a=1&b=2").
|
||||||
WithCookies(map[string]string{"user": "debugtalk"}).
|
WithCookies(map[string]string{"user": "debugtalk"}).
|
||||||
Validate().
|
Validate().
|
||||||
@@ -37,7 +37,7 @@ func TestRunRequestGetToStruct(t *testing.T) {
|
|||||||
if tStep.Request.Params["foo1"] != "bar1" || tStep.Request.Params["foo2"] != "bar2" {
|
if tStep.Request.Params["foo1"] != "bar1" || tStep.Request.Params["foo2"] != "bar2" {
|
||||||
t.Fatalf("tStep.Request.Params mismatch")
|
t.Fatalf("tStep.Request.Params mismatch")
|
||||||
}
|
}
|
||||||
if tStep.Request.Headers["User-Agent"] != "HttpBoomer" {
|
if tStep.Request.Headers["User-Agent"] != "HttpRunnerPlus" {
|
||||||
t.Fatalf("tStep.Request.Headers mismatch")
|
t.Fatalf("tStep.Request.Headers mismatch")
|
||||||
}
|
}
|
||||||
if tStep.Request.Cookies["user"] != "debugtalk" {
|
if tStep.Request.Cookies["user"] != "debugtalk" {
|
||||||
@@ -59,7 +59,7 @@ func TestRunRequestPostDataToStruct(t *testing.T) {
|
|||||||
if tStep.Request.Params["foo1"] != "bar1" || tStep.Request.Params["foo2"] != "bar2" {
|
if tStep.Request.Params["foo1"] != "bar1" || tStep.Request.Params["foo2"] != "bar2" {
|
||||||
t.Fatalf("tStep.Request.Params mismatch")
|
t.Fatalf("tStep.Request.Params mismatch")
|
||||||
}
|
}
|
||||||
if tStep.Request.Headers["User-Agent"] != "HttpBoomer" {
|
if tStep.Request.Headers["User-Agent"] != "HttpRunnerPlus" {
|
||||||
t.Fatalf("tStep.Request.Headers mismatch")
|
t.Fatalf("tStep.Request.Headers mismatch")
|
||||||
}
|
}
|
||||||
if tStep.Request.Cookies["user"] != "debugtalk" {
|
if tStep.Request.Cookies["user"] != "debugtalk" {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package httpboomer
|
package hrp
|
||||||
|
|
||||||
const VERSION = "v0.1.0"
|
const VERSION = "v0.1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user