diff options
author | James Fargher <proglottis@gmail.com> | 2020-10-06 03:24:25 +0300 |
---|---|---|
committer | James Fargher <proglottis@gmail.com> | 2020-10-29 00:10:54 +0300 |
commit | e09cb9c683ff72c1276f38870afb766d63226980 (patch) | |
tree | 4ede6e363dd76f415606de44d1bce9eb8ba579c3 /STYLE.md | |
parent | 1ee6cc62c052accbfff7b1ac568ec3c0ca8238da (diff) |
Introduce test name style guide with example
Diffstat (limited to 'STYLE.md')
-rw-r--r-- | STYLE.md | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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]). |