jzs 6 years ago

What is your opinion about using https://golang.org/pkg/net/http/httptest/#Server for end to end tests? Assuming you're testing a webserver of course.

  • pasxizeis 6 years ago

    httptest solves the problem of spinning up a new server for use in tests.

    However, there are cases where you already have a server (ie. your golang program) and you want to end-to-end test the whole binary (ie. execute the binary with the given arguments and test it).

    httptest is a good fit when you need a mock server in your tests. spawn is a good fit when you want to test your actual server binary.