
Ask HN: Best resources to learn how to do integration testing in Go? - pawanrawal
Is there a good book or resource that I can use to understand how to test microservices? Does mocking make sense, how to test external services, how much to test them?<p>Also, any recommendations for libraries to use for Go?
======
sethammons
We have two layers of tests in the repo (unit and integration) and one in our
staging environment that tests the whole API from the he customer (black box)
perspective.

For our integration tests (we also call them acceptance tests), they are in an
internal acceptance package. We have scripts that manage starting and stopping
the docker containers of our dependant services and our service.

We developed a test harness atop "go test" that allows different suites of
tests to have pre and post suite set ups, with separate pre and post test
setups and built a framework atop that. However, that is overkill for many
projects.

Just have test helpers to make requests into your running and containerized
service and validate responses and output artifacts (logs, metrics, data
sinks).

If this is a missing space for a blog post or tutorial, maybe I could write
something up. It would have to be a month or two out before I could start it
in earnest.

~~~
hazz99
I'd definitely be interested in that blog post! I've been struggling with
integration tests for a while. Here are a few issues I've ran into this week:

\- Where do I put integration tests? In their own package, or beside unit
tests?

\- How do I automate the test environment? Should I use docker-compose? What
if I'm already using docker-compose to launch the application - should I use
Ansible instead?

\- Should I put the different testing commands in a Makefile, or just use the
builtin go test function?

Basically, I want to know the neatest, easiest way to configure a testing
environment, and the most idiomatic way to write/launch integration tests.

I'm not asking you to answer these, but I thought they could be useful for
that blog post :)

