Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Fargher <proglottis@gmail.com>2020-10-06 03:24:25 +0300
committerJames Fargher <proglottis@gmail.com>2020-10-29 00:10:54 +0300
commite09cb9c683ff72c1276f38870afb766d63226980 (patch)
tree4ede6e363dd76f415606de44d1bce9eb8ba579c3 /STYLE.md
parent1ee6cc62c052accbfff7b1ac568ec3c0ca8238da (diff)
Introduce test name style guide with example
Diffstat (limited to 'STYLE.md')
-rw-r--r--STYLE.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/STYLE.md b/STYLE.md
index f3b884899..8230c8f9d 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -170,6 +170,24 @@ A type should be declared before its first use.
## Tests
+### Naming
+
+Prefer to name tests in the same style as [examples](https://golang.org/pkg/testing/#hdr-Examples).
+
+To declare a test for the package, a function F, a type T and method M on type T are:
+```
+func TestF() { ... }
+func TestT() { ... }
+func TestT_M() { ... }
+```
+
+A suffix may be appended to distinguish between test cases. The suffix must start with a lower-case letter.
+```
+func TestF_suffix() { ... }
+func TestT_suffix() { ... }
+func TestT_M_suffix() { ... }
+```
+
### Table-driven tests
We like table-driven tests ([Table-driven tests using subtests](https://blog.golang.org/subtests#TOC_4.), [Cheney blog post], [Golang wiki]).