Ask HN: Best resources to learn how to do integration testing in Go?
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?
Also, any recommendations for libraries to use for Go?
2 comments
[ 2.6 ms ] story [ 17.1 ms ] threadFor 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.
- 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 :)