https://github.com/pinzolo/tagt
tagt is test helper that adds tags to error message.
https://github.com/pinzolo/tagt
golang testing
Last synced: 7 months ago
JSON representation
tagt is test helper that adds tags to error message.
- Host: GitHub
- URL: https://github.com/pinzolo/tagt
- Owner: pinzolo
- License: mit
- Created: 2018-07-11T06:20:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-11T22:32:07.000Z (over 7 years ago)
- Last Synced: 2024-10-23T14:15:59.644Z (12 months ago)
- Topics: golang, testing
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tagt: Friend of table driven tests
tagt is test helper that prints tags with original error message.## Usage
```go
testdata := []struct{
id int
exists bool
tag string
}{
{1, true, "valid user"},
{9, false, "unknown user"},
}
for _, data := range testdata {
tt := tagt.New(t, data.tag)
user := repo.FindByID(data.id)
if d.exists && user == nil {
t.Errorf("user should be found by id is %d", data.id)
// => user should be found by id is 1
tt.Errorf("user should be found by id is %d", data.id)
// => [valid user] user should be found by id is 1
} else if !d.exists && user != nil {
t.Errorf("user should not be found by id is %d", data.id)
// => user should not be found by id is 9
tt.Errorf("user should not be found by id is %d", data.id)
// => [unknown user] user should not be found by id is 9
}
}
```