2021-10-16 15:14:20 +08:00
2021-10-09 23:26:08 +08:00
2021-10-11 15:34:41 +08:00
2021-10-15 21:12:27 +08:00
2021-10-16 14:38:31 +08:00
2021-09-30 15:41:30 +08:00
2021-10-10 22:39:52 +08:00
2021-10-11 12:15:24 +08:00
2021-10-15 21:12:27 +08:00
2021-10-11 12:15:24 +08:00
2021-09-22 21:25:28 +08:00
2021-10-15 22:22:09 +08:00
2021-10-15 22:22:09 +08:00
init HttpBommer 🍰
2021-09-19 13:24:50 +08:00
2021-10-15 21:12:27 +08:00
2021-10-04 13:21:52 +08:00
2021-10-09 23:26:08 +08:00
2021-10-10 12:40:32 +08:00
2021-10-04 13:20:31 +08:00
2021-10-10 12:40:32 +08:00
2021-10-16 14:38:31 +08:00
2021-10-15 21:12:27 +08:00
2021-10-15 21:12:27 +08:00
2021-10-08 20:18:50 +08:00

HttpBoomer

Go Reference Github Actions codecov Go Report Card FOSSA Status

HttpBoomer = 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.

Key Features

flow chart

  • Full support for HTTP(S) requests, more protocols are also in the plan.
  • Testcases can be described in multiple formats, YAML/JSON/Golang, and they are interchangeable.
  • With HAR support, you can use Charles/Fiddler/Chrome/etc as a script recording generator.
  • 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 to create and call custom functions.
  • Inherit all powerful features of Boomer and locust, you can run load test without extra work.
  • Use it as a CLI tool or as a library are both supported.

Quick Start

Install

$ go get -u github.com/httprunner/httpboomer

Examples

This is an example of HttpBoomer testcase. You can find more in the examples directory.

import (
    "testing"

    "github.com/httprunner/httpboomer"
)

func TestCaseDemo(t *testing.T) {
    testcase := &httpboomer.TestCase{
        Config: httpboomer.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: []httpboomer.IStep{
            httpboomer.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": "HttpBoomer"}).                 // 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
            httpboomer.Step("post json data").
                POST("/post").
                WithJSON(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"),
        },
    }

    err := httpboomer.Run(t, testcase)
    if err != nil {
        t.Fatalf("run testcase error: %v", err)
    }
}
Description
HttpRunner 是一款开源的 API/UI 测试框架,简单易用,功能强大,具有丰富的插件化机制和高度的可扩展能力。
Readme Apache-2.0 57 MiB
Languages
Go 98.2%
HTML 0.6%
Shell 0.6%
Python 0.5%
Makefile 0.1%