wstest alternatives and similar packages
Based on the "Testing Frameworks" category.
Alternatively, view wstest alternatives based on common mentions on social networks and blogs.
-
dockertest
Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work. -
gnomock
Test your code without writing mocks with ephemeral Docker containers ๐ฆ Setup popular services with just a couple lines of code โฑ๏ธ No bash, no yaml, only code ๐ป -
embedded-postgres
Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test -
gotest.tools
A collection of packages to augment the go testing package and support common patterns. -
go-testdeep
Extremely flexible golang deep comparison, extends the go testing package, tests HTTP APIs and provides tests suite -
testza
Full-featured test framework for Go! Assertions, fuzzing, input testing, output capturing, and much more! ๐ -
jsonassert
A Go test assertion library for verifying that two representations of JSON are semantically equal -
GoSpec
Testing framework for Go. Allows writing self-documenting tests/specifications, and executes them concurrently and safely isolated. [UNMAINTAINED] -
assert
:exclamation:Basic Assertion Library used along side native go testing, with building blocks for custom assertions -
Gont
DISCONTINUED. A Go testing framework for distributed applications [GET https://api.github.com/repos/cunicu/gont: 404 - Not Found // See: https://docs.github.com/rest/repos/repos#get-a-repository] -
fluentassert
DISCONTINUED. Extensible, type-safe, fluent assertion Go library. Do NOT use it (sic!). -
gogiven
gogiven - BDD testing framework for go that generates readable output directly from source code
SaaSHub - Software Alternatives and Reviews
Do you think we are missing an alternative of wstest or a related project?
Popular Comparisons
README
wstest
A websocket client for unit-testing a websocket server
The gorilla organization provides full featured websocket implementation that the standard library lacks.
The standard library provides a httptest.ResponseRecorder struct that test
an http.Handler without ListenAndServe, but is helpless when the connection is being hijacked
by an http upgrader. As for testing websockets, it has the httptest.NewServer that actually
listens on a socket on an arbitrary port.
This package provides a NewDialer function to test just the http.Handler that upgrades
the connection to a websocket session. It runs the handler function in a goroutine
without listening on any port. The returned websocket.Dialer then can be used to dial and communicate
with the given handler.
Get
go get -u github.com/posener/wstest
Examples
See the [example test](./example_test.go).
An example how to modify a test function from using
httptest.Server to use wstest.NewDialer function.
func TestHandler(t *testing.T) {
var err error
h := &myHandler{}
- s := httptest.NewServer(h)
- defer s.Close()
- d := websocket.Dialer{}
+ d := wstest.NewDialer(h)
- c, resp, err := d.Dial("ws://" + s.Listener.Addr().String() + "/ws", nil)
+ c, resp, err := d.Dial("ws://" + "whatever" + "/ws", nil)
if err != nil {
t.Fatal(err)
}
if got, want := resp.StatusCode, http.StatusSwitchingProtocols; got != want {
t.Errorf("resp.StatusCode = %q, want %q", got, want)
}
err = c.WriteJSON("test")
if err != nil {
t.Fatal(err)
}
}