diff options
-rw-r--r-- | doc/development/go_guide/index.md | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/doc/development/go_guide/index.md b/doc/development/go_guide/index.md index cc46f8c32ee..f827d240bf6 100644 --- a/doc/development/go_guide/index.md +++ b/doc/development/go_guide/index.md @@ -129,6 +129,8 @@ deploy a new pod, migrating the data automatically. ## Testing +### Testing frameworks + We should not use any specific library or framework for testing, as the [standard library](https://golang.org/pkg/) provides already everything to get started. If there is a need for more sophisticated testing tools, the following @@ -138,11 +140,19 @@ library or framework: - [Testify](https://github.com/stretchr/testify) - [httpexpect](https://github.com/gavv/httpexpect) +### Subtests + Use [subtests](https://blog.golang.org/subtests) whenever possible to improve code readability and test output. -When comparing expected and actual values in tests, use [testify/require.Equal](https://godoc.org/github.com/stretchr/testify/require#Equal) -and its name-likes for better results readability when it comes to comparing structs or large portions of text or JSON: +### Better output in tests + +When comparing expected and actual values in tests, use +[testify/require.Equal](https://godoc.org/github.com/stretchr/testify/require#Equal), +[testify/require.EqualError](https://godoc.org/github.com/stretchr/testify/require#EqualError), +[testify/require.EqualValues](https://godoc.org/github.com/stretchr/testify/require#EqualValues), +and others to improve readability when comparing structs, errors, +large portions of text, or JSON documents: ```go type TestData struct { |