Execute a go test from the command line as follows:
$ go test websocket-server_test.go websocket-server.go
ok command-line-arguments 0.048s
It will give us the response ok, which means the test compiled and executed successfully.
Let’s see how it looks when a Go test fails. Change the expected output in the assert statement to something else. In the following hello has been changed to hi:
...
assert.Equal(t, "hi", message.Message, "they should be equal")
...
Execute the test again by running the go test command:
$ go test websocket-server_test.go websocket-server.go
It will give us the failure response along with the error trace as shown in the following screenshot: