https://github.com/kimuson13/gotestgen
Tool: generate Go test templates
https://github.com/kimuson13/gotestgen
go testing
Last synced: 5 months ago
JSON representation
Tool: generate Go test templates
- Host: GitHub
- URL: https://github.com/kimuson13/gotestgen
- Owner: kimuson13
- License: mit
- Created: 2022-02-09T02:30:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-13T11:49:00.000Z (over 4 years ago)
- Last Synced: 2024-06-21T03:18:39.829Z (about 2 years ago)
- Topics: go, testing
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gotestgen
## description
generate Go test templates
## usage
```go install github.com/kimuson13/gotestgen/cmd/gotestgen@latest```
after changing directory you want to generate test files and
```gotestgen ./...```
## options
### -p
add `t.Parallel()` into some test functions
### -g
select the place that test file is wrote
#### example
if you type `tree .`
```
$ tree .
.
├── hoge
│ └── hoge.go
├ go.mod
├ go.sum
└ main.go
```
```
$ cat hoge/hoge.go
package hoge
func Hoge() {
fmt.Println("Hoge")
}
func hoge() {
fmt.Println("hoge")
}
```
```
$ gotestgen -g=[hoge:hoge]
```
```
$ tree .
.
├── hoge
│ ├── hoge.go
│ └── hoge_test.go
├ go.mod
├ go.sum
└ main.go
```
```
$ cat hoge/hoge_test.go
package hoge_test
import "testing"
func TestHoge(t *testing.T) {
cases := map[string]struct {
}{
//write test cases below
}
for testName, tt := range cases {
tt := tt
t.Run(testName, func(t *testing.T) {
})
}
}
```