https://github.com/ras0q/gotests-template
My template for https://github.com/cweill/gotests
https://github.com/ras0q/gotests-template
gotests
Last synced: 12 months ago
JSON representation
My template for https://github.com/cweill/gotests
- Host: GitHub
- URL: https://github.com/ras0q/gotests-template
- Owner: ras0q
- Created: 2021-11-15T04:49:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-30T02:53:36.000Z (about 2 years ago)
- Last Synced: 2025-04-09T21:51:28.494Z (about 1 year ago)
- Topics: gotests
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gotests-template
My template for [cweill/gotests](https://github.com/cweill/gotests)
## Usage (VSCode)
Add gotests settings to ./vscode/settings.json
```txt
{
...,
"go.generateTestsFlags": [
"-template_dir",
"./path/to/ras0q/gotests-template/templates" // Or templates2
],
...
}
```
## Contents
### templates
[example_templates_test.go](./example_templates_test.go)
### templates2
[example_templates2_test.go](./example_templates2_test.go)
- TDD
- Parallel test
- Use `map[string]struct`(map key is testname)
- Use [google/go-cmp](https://github.com/google/go-cmp)
### map-gomock-gocmp-errors-setupFields
[example_map-errors-gomock-gocmp_test.go](./example_map-errors-gomock-gocmp_test.go)
- manage subtest names as map keys
- initialize receiver fields with `*gomock.Controller`
- can change to parallel test with a `-parallel` flag
- use following packages
- standard `errors` package
- `gomock`:
- `go-cmp`: