Add a Go testing package

As I can see, currently there is no easy way to test maelstrom endpoints in Go code.
So maybe we can add a testing package maelstromtest similar to existing protocols testing packages like httptest, grpctest, httpmock.

The Stdin, Stdout, & Stderr are exported on the maelstrom.Node so you can wire in bytes.Buffer or a bytes.Reader for simple cases. You can do an io.Pipe as well if you want to handle multiple messages and the timing in between them.

There’s probably a better high-level abstraction that doesn’t use io.Reader & io.Writer though.

You can find examples of how Node is tested in node_test.go.

Thank you for your response, I think that current tests are mostly low-level protocol tests, but for application code, it will be easier to use a more abstract test library.
But not sure, do other devs have the same problem

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.