From b33dca4e87d3e06c42c9c44d1c7e588e46f21b4e Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Tue, 31 May 2022 18:11:18 -0400 Subject: [PATCH] wip --- docs/2_development/2_tech-stack/go.md | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/docs/2_development/2_tech-stack/go.md b/docs/2_development/2_tech-stack/go.md index 7a82028..6520b11 100644 --- a/docs/2_development/2_tech-stack/go.md +++ b/docs/2_development/2_tech-stack/go.md @@ -335,3 +335,49 @@ jobs: Make sure to pin the linter version (`version: v1.45`) since the same linters can behave differently from a version to another. ::: + +## Testing + +### Testing philosophy + +Here are a few key points to remember when writing tests: + +- your **production code must be testable**. Adjust it as needed. +- all your **tests must be event driven** and not time driven +- your **unit tests must be blazing fast** +- **never export testing code** across package boundaries +- run your unit and integration tests in **parallel** +- have a **good testing depth**: you need to assert enough affected elements +- **keep your tests dumb** and feel free to repeat code + +### Libraries to use + +- [github.com/stretchr/testify](https://github.com/stretchr/testify) for assertions +- [github.com/golang/gomock](https://github.com/golang/gomock) for mocking (see the [Mocking](#Mocking) section) + +### `assert.*` vs `require.*` + + +### Asserting errors + +- `assert.ErrorIs` + `assert.EqualError` + + +### 'Table' tests + +### Subtests + +### Parallel tests + +- Network servers, listen on port `:0`. +- Race detector + +### Unit tests + +### Integration tests + +### End to end tests + +### Fuzz tests + +### Continuous integration