github.com/elliotchance/tf now supports super easy HTTP testing by using the ServeHTTP function.
This means that you do not have to run the server and it's compatible with all HTTP libraries and frameworks but has all the functionality of the server itself.
The simplest example is to use the default muxer in the http package:
And now we can write some tests:
It is compatible with all HTTP frameworks because they must all expose a ServeHTTP which is the entry point for the request router/handler.
There are many more options for HTTPTest.
Some HTTP tests require multiple operations (such as CRUD operations), you can use MultiHTTPTest for this:
Each step will only proceed if the previous step was successful.