A command line http test tool. Maintain the case via git and pure text

httptest

A command line http test tool Maintain the api test cases via git and pure text

We want to test the APIs via http requests and assert the responses, postman & newman are easy for this.

But when you got more than maybe 50+ cases, the exported json file shared with your team is huge, maybe more than 10000 lines, it's hard to maintain in the future.

So, here is the httptest

  • all in text(.toml/.yaml/.json)
  • easy to create/modify/copy and delete
  • maintained by git
  • run fast

note: not ready for production

Screenshots

Features

  • Define:

  • Assert:

    • assert status/statusCode/contentLength/contentType/body
    • assert latency
    • assert numeric support _in/_not_in/_lt/_lte/_gt/_gte
    • assert string support _contains/_not_contains/_startswith/_endswith
    • assert response json body, the path syntax is jmespath examples/json.toml
    • assert response headers examples/header.toml
    • assert response has redirected examples/redirect.toml
    • assert response proto/protoMajor/protoMinor
  • Cli and Config:

    • exit code != 0 if got any fail assertions
    • verbose mode: ./httptest run -v examples/get.toml or export HTTPTEST_DEBUG = true
    • quiet mode: -q/--quiet to silent the print, for check $? only
    • show run result with stats
    • configfile: ./httptest run -c examples/config/dev.toml examples/get.toml
    • configfile: debug=true/false to trigger debug print
    • configfile: render=true/false to use go_template render the env
    • configfile: failFast=true/false, will exit if got one fail case while running
    • configfile: timeout=1000, will set request timeout to 1000ms, fail if exceed
    • support run cases in order, ./httptest run -c examples/config/order.toml

Examples

simplest

[request]
method = "get"
url = "http://httpbin.org/get"

[assert]
status = "OK"
statusCode = 200

full normal assertions: asserts.toml / asserts.json / asserts.yaml | assert.prop | assert.ini

[request]
method = "get"
url = "http://httpbin.org/get"
[request.header]
hello = "world"

[assert]
# status
status = "ok"
statusCode = 200
statusCode_in = [400, 500]
statusCode_not_in = [200, 400]
statusCode_lt = 100
statusCode_lte = 100
statusCode_gt = 500
statusCode_gte = 500

# content-length
contentLength = 18
contentLength_lt = 1
contentLength_lte = 1
contentLength_gt = 180
contentLength_gte = 180

# content-type
contentType = "abc"

# body
body = "HTTPBIN is awesome"
body_contains = "awesome2"
body_not_contains = "awesome"
body_startswith = "A"
body_endswith = "a"
body_not_startswith = "{"
body_not_endswith = "}"

# latency
latency_lt = 0
latency_lte = 0
latency_gt = 100
latency_gte = 100

json assertions

[request]
method = "post"
url = "http://httpbin.org/post"
body = """
{
    "hello": "world",
    "array": [1, 2, 3, 4]
}
"""
[request.header]
Content-Type = "application/json"


[assert]
status = "ok"
statusCode = 200
contentLength_gt = 180
contentType = "application/json"

[[assert.json]]
path = "headers.Host"
value =  "httpbin.org"

[[assert.json]]
# path = "headers.\"Accept-Encoding\""
path = 'headers."Accept-Encoding"'
value =  "gzip"

[[assert.json]]
path = 'json.array[0]'
value =  1

[[assert.json]]
path = 'json.hello'
value =  "world"

[[assert.json]]
path = '*.hello'
value =  ["world"]

[[assert.json]]
path = "length(json.array)"
value = 4

with template render, ./httptest run examples/use_template.toml -c examples/config/dev.toml -v

title = "http method post, use template"
description = "http method post"

[request]
method = "post"
url = "{{.host}}/post"
body = """
{
    "hello": "{{.name}}",
    "world": {{if .debug}}"in debug mode"{{else}}"not debug mode"{{end}},
    "array": "{{range $i, $a := .array}} {{$i}}{{$a}} {{end}}"
}
"""
[request.header]
Content-Type = "{{.content_type}}"


[assert]
status = "ok"
statusCode = 200
contentLength_gt = 180
contentType = "{{.content_type}}"

TODO

  • sub-command: bootstrap create the raw template, like example.toml.tpl
  • sub-command: generate x generate a case, from tpl
  • error: dns / connection reset/timeout and so on
  • how to test: long-live / file download / static file / websocket / keep-alive
  • run in order glob, the pattern is based on the binary root dir
  • support request body type, msgpack/zip.....
  • display: file / line number to show which case fail
  • set timeout each case
  • case scope config, render=true, priority higher than global config
  • feature: ssl / https
  • feature: retry
  • feature: repeat
  • feature: data share between cases
  • how to run in parallel
  • multiple cases in one file, like ginkgo?

Dependency

Inspired by

Owner
wklken
Pythonista/Gopher/Vimer.
wklken
Comments
  • run in order

    run in order

    -c config.yaml
    

    set the patterns, by glob syntax

    order:
        - case*.yaml
        - stage2*.yaml
        - stagex.yaml
    

    then the run order

    • patterns hit the config
    • the rest of non-hit
  •  run in parallel

    run in parallel

    make it with the run in order config?

    order:
       - xxxxx
           - parallel = true
    
    

    or?

    can we define it globally?

    parallel=true [run all in parallel => need a worker pool]
    
  • new feature 2022-12

    new feature 2022-12

    • feat(assert/regexp): support assert body_regexp/body_not_regexp
    • feat(assert/body_icontains): support body_icontains in assertion
    • feat(cookie_exists): support cookie_exists to check if name in cookie
    • feat(assert.header_exists): add assert header_exists; fix bug of stats merge
    • add .goreleaser.yml
  • fix(assert): json assertion type not match / repsonse body length=0 EOF

    fix(assert): json assertion type not match / repsonse body length=0 EOF

    Bugfix:

    1. response body length=0, application/json will cause json decode EOF
    2. assert header output with a \n
    3. assert json, both number but type not the same(int64(1) != float64(1)), cast to same type then assert
  • v1.0.0

    v1.0.0

    1. format
    2. show the line number if fail
    3. support case timeout
    4. support retry
    5. run in parallel
    6. support assert.error_contains for http fail
    7. support application/msgpack for request
    8. support decode msgpack and assert as json
    9. support assert xml via xpath
    10. support assert html via xpath
    11. support assert yaml/toml via jmespath, assert as json
    12. add progress bar
    13. support assert cookie
    14. add request support disable_redirect
  • support config like workflow

    support config like workflow

    github actions

    jobs:
       xxxx:
         steps:
           - name: xxxxx
             run: xxxx
           - name: xxxx
             run: xxxx
    

    like the order in config file, but more powerful

A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

Nov 22, 2021
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Dec 31, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Feb 5, 2022
A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem
A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem

COMMIT CLI A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem. And yes, it is bui

Feb 9, 2022
An open-source GitLab command line tool bringing GitLab's cool features to your command line
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Dec 30, 2022
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purposeā€”to prompt for a value to be included in another command line. readval prints

Dec 22, 2021
textnote is a command line tool for quickly creating and managing daily plain text notes.

textnote is a command line tool for quickly creating and managing daily plain text notes. It is designed for ease of use to encourage the practice of daily, organized note taking. textnote intentionally facilitates only the management (creation, opening, organizing, and consolidated archiving) of notes, following the philosophy that notes are best written in a text editor and not via a CLI.

Jan 2, 2023
A command-line tool and library for generating regular expressions from user-provided test cases
A command-line tool and library for generating regular expressions from user-provided test cases

Table of Contents What does this tool do? Do I still need to learn to write regexes then? Current features How to install? 4.1 The command-line tool 4

Jan 9, 2023
Go-test-app - Test application to verify environment deployment and reachability over HTTP

Test app Test application to verify environment deployment and reachability over

May 23, 2022
Pure Go command line prompt with history, kill-ring, and tab completion

Prompt Prompt is a command line prompt editor with history, kill-ring, and tab completion. It was inspired by linenoise and derivatives which eschew u

Nov 20, 2021
tfacon is a CLI tool for connecting Test Management Platforms and Test Failure Analysis Classifier.

Test Failure Classifier Connector Description tfacon is a CLI tool for connecting Test Management Platforms and Test Failure Analysis Classifier. Test

Jun 23, 2022
Contextual information about your git projects, right on the command-line
Contextual information about your git projects, right on the command-line

gitty gitty is a smart little CLI helper for git projects, that shows you all the relevant issues, pull requests and changes at a quick glance. It cur

Jan 8, 2023
A command-line driven git server

GitGo GitGo is split into three parts: The API server The GIT server The CLI client We need a couple of certificates before setting up the application

Dec 14, 2021
Oct 1, 2022
Jan 27, 2022
:mag: Search the Go packages via command-line

GoSearch Search the Go packages for pkg.go.dev via command-line. It supports all search options in Search Help. Installation go get github.com/mingram

Jun 23, 2022
A set of Go scripts to monitor YAGPDB status via the command-line.
A set of Go scripts to monitor YAGPDB status via the command-line.

A set of Go scripts to monitor YAGPDB status by making GET requests to the YAGPDB status endpoint.

Apr 20, 2022
colorStyle is a library of styles for command-line text.
colorStyle is a library of styles for command-line text.

colorStyle ColorStyle is a library of styles for command-line text. Used to modify the style of text for standard output to the terminal interface, yo

Nov 12, 2022
Easily manage your work via command line

Wo Easily manage your work via command line Introduction Wo, is cli that provides it easy to manage your workspace. Wo provides to manipulating workfl

Dec 11, 2021