Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By steinfletcherMITIn 1 marketplace
Write, fix and review Go tests for HTTP handlers using apitest's request builders, response assertions and JSONPath matching. Mocks outbound HTTP calls and can render a sequence diagram of each test, including mocked calls and database queries.
Trending plugins
7-day copy clicks
Claude loads one when your task matches it, or you run it by name.
1 marketplace, most starred first
go-testing, golang, http-testing, api-testing, http-mocks, jsonpath, sequence-diagrams, http ·
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
A simple and extensible behavioural testing library for Go HTTP services. Tests are written the way a client uses the API: build a request, send it to the handler, and assert on the response. External HTTP calls can be mocked, and every test can render a sequence diagram of what happened.
In behavioural tests the internal structure of the app is not known by the tests. Data is input to the system and the outputs are expected to meet certain conditions.
http.Handler, or against a running servertesting, Ginkgo and custom assertion librariesThe API is stable. The library is maintained and issues are addressed; feature requests are considered.
Join the conversation at #apitest on https://gophers.slack.com.
Logo by @egonelbre
This README covers the whole library. The same material with more narrative is at https://apitest.dev, and the API reference is on pkg.go.dev.
This repository includes an Agent Skill that teaches coding agents how to write apitest tests, including the mistakes that are easy to make with mocks and JSONPath. In Claude Code, add the repository as a plugin marketplace and install the plugin:
claude plugin marketplace add steinfletcher/apitest
claude plugin install apitest@apitest
Inside a session, /plugin marketplace add steinfletcher/apitest followed by /plugin install apitest@apitest does the
same. To use the skill without the plugin, or with another agent that supports Agent Skills, copy
skills/apitest into the agent's skills directory, such as .claude/skills/apitest in your project.
The documentation is also available as Markdown for agents, at apitest.dev/llms-full.txt.
go get github.com/steinfletcher/apitest
func TestGetUser(t *testing.T) {
apitest.New().
Handler(handler).
Get("/user/1234").
Expect(t).
Status(http.StatusOK).
Body(`{"id": "1234", "name": "Tate"}`).
End()
}
Handler takes any http.Handler, so a http.ServeMux, a gin engine, an echo instance and so on all work. Everything
before Expect(t) describes the request; everything after it describes the expected response. End() runs the test.
When the expected body is valid JSON it is compared structurally, so key order and whitespace do not matter.

Get, Post, Put, Patch and Delete set the method and URL. Each has an f variant that formats the URL, and
Method covers anything else.
apitest.Handler(handler).Getf("/user/%s", id)
apitest.Handler(handler).Method(http.MethodOptions).URL("/user")
A ready-made *http.Request can be used instead of the builder.
req := httptest.NewRequest(http.MethodGet, "/user/1234", nil)
apitest.Handler(handler).
HttpRequest(req).
Expect(t).
Status(http.StatusOK).
End()
apitest.Handler(handler).
Get("/hello").
Header("Authorization", "Bearer token").
Headers(map[string]string{"X-Request-Id": "12345"}).
ContentType("application/json").
Expect(t).
Status(http.StatusOK).
End()
Query, QueryParams and QueryCollection can be combined. QueryCollection sets repeated parameters, so
map[string][]string{"a": {"b", "c", "d"}} is encoded as a=b&a=c&a=d. A query string written in the URL, as in
Get("/hello?page=2"), is kept, and parameters from the builder methods are appended to it.
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub steinfletcher/apitest --plugin apitestPlugins from other owners that cover similar ground