Skip to content

pinzolo/tagt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tagt: Friend of table driven tests

tagt is test helper that prints tags with original error message.

Usage

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
	}
}

About

tagt is test helper that adds tags to error message.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages