summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Zagorodny <vzagorodny@gitlab.com>2019-07-16 17:41:26 +0300
committerVictor Zagorodny <vzagorodny@gitlab.com>2019-07-17 13:41:28 +0300
commitdacd6284b695d5416765cfd08815f9297818707c (patch)
tree9fb721b5f279d40c540194f4bdc943ad3a3fddda
parent92af3cfaccdce585d4e6b44d3621e0043c78c08f (diff)
downloadgitlab-ce-vzagorodny-go-guide-use-cmp-diff-in-tests.tar.gz
Improve Testing section structure and wordingvzagorodny-go-guide-use-cmp-diff-in-tests
-rw-r--r--doc/development/go_guide/index.md14
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 {